diff --git "a/pgsql-performance.200509" "b/pgsql-performance.200509" new file mode 100644--- /dev/null +++ "b/pgsql-performance.200509" @@ -0,0 +1,48295 @@ +From pgsql-performance-owner@postgresql.org Thu Sep 1 07:50:26 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C7B77D88A6 + for ; + Thu, 1 Sep 2005 07:50:24 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 74884-03 + for ; + Thu, 1 Sep 2005 10:50:20 +0000 (GMT) +Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) + by svr1.postgresql.org (Postfix) with ESMTP id 08E30D6D83 + for ; + Thu, 1 Sep 2005 07:50:19 -0300 (ADT) +Received: from mainbox.archonet.com + (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) + by smtp.metronet.co.uk (MetroNet Mail) with ESMTP + id 6C7B240C3B0; Thu, 1 Sep 2005 11:50:15 +0100 (BST) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mainbox.archonet.com (Postfix) with ESMTP id 519EE15F1C; + Thu, 1 Sep 2005 11:46:50 +0100 (BST) +Received: from mainbox.archonet.com ([127.0.0.1]) + by localhost (mainbox [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 26846-10; Thu, 1 Sep 2005 11:46:46 +0100 (BST) +Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP id 7FF7715F27; + Thu, 1 Sep 2005 11:45:23 +0100 (BST) +Message-ID: <4316DBC5.8060504@archonet.com> +Date: Thu, 01 Sep 2005 11:45:25 +0100 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Morgan Kita +Cc: pgsql-performance@postgresql.org +Subject: Re: Big question on insert performance/using COPY FROM +References: <08B420FF5BF7BC42A064212C2EB768801C10BE@neutron.verseon.com> +In-Reply-To: <08B420FF5BF7BC42A064212C2EB768801C10BE@neutron.verseon.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.057 required=5 tests=[AWL=0.007, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/1 +X-Sequence-Number: 14309 + +Morgan Kita wrote: +> Hi, +> +> I am currently trying to speed up the insertion of bulk loads to my +> database. I have fiddled with all of the parameters that I have seen +> suggested(aka checkpoint_segments, checkpoint_timeout, +> maintinence_work_mem, and shared buffers) with no success. I even +> turned off fysnc with no effect so I am pretty sure the biggest +> problem is that the DB is CPU limited at the moment because of the +> rather weak machine that postmaster is running on(Athlon 2400+ xp +> with 512 RAM) + +Don't be pretty sure, be abolutely sure. What do your various +system-load figures show? Windows has a system performance monitoring +tool that can show CPU/Memory/Disk IO, and *nix tools have vmstat or iostat. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Thu Sep 1 10:23:13 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F29DDD89FA + for ; + Thu, 1 Sep 2005 10:23:12 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 10334-01 + for ; + Thu, 1 Sep 2005 13:23:11 +0000 (GMT) +Received: from thor.netera.se (thor.netera.se [85.112.172.11]) + by svr1.postgresql.org (Postfix) with ESMTP id BA974D8959 + for ; + Thu, 1 Sep 2005 10:23:09 -0300 (ADT) +Received: from [192.168.2.240] (1-1-1-41a.o.sth.bostream.se [81.26.246.14]) + by thor.netera.se (Postfix) with ESMTP id 27E9A13AC01C + for ; + Thu, 1 Sep 2005 15:23:13 +0200 (CEST) +Message-ID: <43170151.90408@relevanttraffic.se> +Date: Thu, 01 Sep 2005 15:25:37 +0200 +From: Ulrich Wisser +Organization: Relevant Traffic AB +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: Need for speed 3 +Content-Type: text/plain; charset=UTF-8; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.001 required=5 tests=[AWL=0.001] +X-Spam-Level: +X-Archive-Number: 200509/3 +X-Sequence-Number: 14311 + +Hi again, + +first I want to say ***THANK YOU*** for everyone who kindly shared their +thoughts on my hardware problems. I really appreciate it. I started to +look for a new server and I am quite sure we'll get a serious hardware +"update". As suggested by some people I would like now to look closer at +possible algorithmic improvements. + +My application basically imports Apache log files into a Postgres +database. Every row in the log file gets imported in one of three (raw +data) tables. My columns are exactly as in the log file. The import is +run approx. every five minutes. We import about two million rows a month. + +Between 30 and 50 users are using the reporting at the same time. + +Because reporting became so slow, I did create a reporting table. In +that table data is aggregated by dropping time (date is preserved), ip, +referer, user-agent. And although it breaks normalization some data from +a master table is copied, so no joins are needed anymore. + +After every import the data from the current day is deleted from the +reporting table and recalculated from the raw data table. + + +Is this description understandable? If so + +What do you think of this approach? Are there better ways to do it? Is +there some literature you recommend reading? + +TIA + +Ulrich + + +From pgsql-performance-owner@postgresql.org Thu Sep 1 10:28:00 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1EA3AD8A11 + for ; + Thu, 1 Sep 2005 10:27:59 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 06451-08 + for ; + Thu, 1 Sep 2005 13:27:55 +0000 (GMT) +Received: from smtpauth08.mail.atl.earthlink.net + (smtpauth08.mail.atl.earthlink.net [209.86.89.68]) + by svr1.postgresql.org (Postfix) with ESMTP id AD35FD8A07 + for ; + Thu, 1 Sep 2005 10:27:53 -0300 (ADT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=m/5GD6EFs6b73pG8JL8gXve1VWDjQr/P8ncbuAIG3FlfjqDJoujs7cFxdRtAyHpZ; + h=Received:Message-Id:X-Mailer:Date:To:From:Subject:In-Reply-To:References:Mime-Version:Content-Type:X-ELNK-Trace:X-Originating-IP; +Received: from [24.41.3.216] (helo=RJP-01.earthlink.net) + by smtpauth08.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1EAp6j-00027Q-GR; Thu, 01 Sep 2005 09:27:57 -0400 +Message-Id: <6.2.3.4.0.20050901085555.0207ae30@pop.earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 6.2.3.4 +Date: Thu, 01 Sep 2005 09:27:49 -0400 +To: Ernst Einstein , + pgsql-performance@postgresql.org +From: Ron +Subject: Re: Poor performance on HP Package Cluster +In-Reply-To: <1125584167.6683.21.camel@Thor.decoit.lan> +References: <1125584167.6683.21.camel@Thor.decoit.lan> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bcad14bfdfa34cef0e84e5ba05683dc4a6350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 24.41.3.216 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.391 required=5 tests=[AWL=0.017, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200509/4 +X-Sequence-Number: 14312 + +Your HD raw IO rate seems fine, so the problem is not likely to be +with the HDs. + +That consistent ~10x increase in how long it takes to do an import or +a select is noteworthy. + +This "smells" like an interconnect problem. Was the Celeron locally +connected to the HDs while the new Xeons are network +connected? Getting 10's or even 100's of MBps throughput out of +local storage is much easier than it is to do over a network. 1GbE +is required if you want HDs to push 72.72MBps over a network, and not +even one 10GbE line will allow you to match local buffered IO of +1885.34MBps. What size are those network connects (Server A <-> +storage, Server B <-> storage, Server A <-> Server B)? + +Ron Peacetree + + +At 10:16 AM 9/1/2005, Ernst Einstein wrote: + +>I've set up a Package Cluster ( Fail-Over Cluster ) on our two HP +>DL380 G4 with MSA Storage G2.( Xeon 3,4Ghz, 6GB Ram, 2x 36GB@15rpm- +>Raid1). The system is running under Suse Linux Enterprise Server. +> +>My problem is, that the performance is very low. On our old Server ( +>Celeron 2Ghz with 2 GB of Ram ) an import of our Data takes about 10 +>minutes. ( 1,1GB data ). One of the DL380 it takes more than 90 minutes... +>Selects response time have also been increased. Celeron 3 sec, Xeon 30-40sec. +> +>I'm trying to fix the problem for two day's now, googled a lot, but +>i don't know what to do. +> +>Top says, my CPU spends ~50% time with wait io. +> +>top - 14:07:34 up 22 min, 3 users, load average: 1.09, 1.04, 0.78 +>Tasks: 74 total, 3 running, 71 sleeping, 0 stopped, 0 zombie +>Cpu(s): 50.0% us, 5.0% sy, 0.0% ni, 0.0% id, 45.0% wa, 0.0% hi, 0.0% si +>Mem: 6050356k total, 982004k used, 5068352k free, 60300k buffers +>Swap: 2097136k total, 0k used, 2097136k free, 786200k cached +> +> PID USER PR NI VIRT RES SHR S %CPU +> %MEM TIME+COMMAND +> 9939 postgres 18 0 254m 143m 140m +> R 49.3 2.4 8:35.43 postgres:postgres plate [local] +> INSERT +> 9938 postgres 16 0 13720 1440 1120 +> S 4.9 0.0 0:59.08 psql -d plate -f +> dump.sql +>10738 root 15 0 3988 1120 840 +>R 4.9 0.0 0:00.05 top -d +>0.2 +> 1 root 16 0 640 264 216 +> S 0.0 0.0 0:05.03 +> init[3] +> 2 root 34 19 0 0 0 +> S 0.0 0.0 0:00.00 [ksoftirqd/0] +> +>vmstat 1: +> +>ClusterNode2 root $ vmstat 1 +>procs -----------memory---------- ---swap-- -----io---- --system------cpu---- +> r b swpd free buff cache si so bi bo +> in cs us sy id wa +> 1 0 0 5032012 60888 821008 0 0 216 6938 1952 5049 +> 40 8 15 37 +> 0 1 0 5031392 60892 821632 0 0 0 8152 +> 2126 5725 45 6 0 49 +> 0 1 0 5030896 60900 822144 0 0 0 8124 +> 2052 5731 46 6 0 47 +> 0 1 0 5030400 60908 822768 0 0 0 8144 +> 2124 5717 44 7 0 50 +> 1 0 0 5029904 60924 823272 0 0 0 8304 +> 2062 5763 43 7 0 49 +> +>I've read (2004), that Xeon may have problems with content switching +>- is the problem still existing? Can I do something to minimize the +>problem? +> +> +>postgresql.conf: +> +>shared_buffers = 28672 +>effective_cache_size = 400000 +>random_page_cost = 2 +> +> +>shmall & shmmax are set to 268435456 +> +>hdparm: +> +>ClusterNode2 root $ hdparm -tT /dev/cciss/c0d0p1 +> +>/dev/cciss/c0d0p1: +>Timing buffer-cache reads: 3772 MB in 2.00 seconds = 1885.34 MB/sec +>Timing buffered disk reads: 150 MB in 2.06 seconds = 72.72 MB/sec + + + + +From pgsql-performance-owner@postgresql.org Thu Sep 1 10:52:34 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 07147D8A22 + for ; + Thu, 1 Sep 2005 10:42:44 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 13483-06 + for ; + Thu, 1 Sep 2005 13:42:42 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 3C451D8A28 + for ; + Thu, 1 Sep 2005 10:42:40 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Subject: Re: Need for speed 3 +Date: Thu, 1 Sep 2005 09:42:41 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3417DD24C@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Need for speed 3 +Thread-Index: AcWu+KZmG29WV/YZQL+pM8YOxUvDPgAAadzw +From: "Merlin Moncure" +To: "Ulrich Wisser" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.056 required=5 tests=[AWL=0.006, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/5 +X-Sequence-Number: 14313 + + +Ulrich wrote: +> Hi again, +>=20 +> first I want to say ***THANK YOU*** for everyone who kindly shared +their +> thoughts on my hardware problems. I really appreciate it. I started to +> look for a new server and I am quite sure we'll get a serious hardware +> "update". As suggested by some people I would like now to look closer +at +> possible algorithmic improvements. +>=20 +> My application basically imports Apache log files into a Postgres +> database. Every row in the log file gets imported in one of three (raw +> data) tables. My columns are exactly as in the log file. The import is +> run approx. every five minutes. We import about two million rows a +month. +>=20 +> Between 30 and 50 users are using the reporting at the same time. +>=20 +> Because reporting became so slow, I did create a reporting table. In +> that table data is aggregated by dropping time (date is preserved), +ip, +> referer, user-agent. And although it breaks normalization some data +from +> a master table is copied, so no joins are needed anymore. +>=20 +> After every import the data from the current day is deleted from the +> reporting table and recalculated from the raw data table. +>=20 + +schemas would be helpful. You may be able to tweak the import table a +bit and how it moves over to the data tables. + +Just a thought: have you considered having apache logs write to a +process that immediately makes insert query(s) to postgresql?=20 + +You could write small C program which executes advanced query interface +call to the server. + +Merlin + +From pgsql-performance-owner@postgresql.org Thu Sep 1 11:03:59 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 731B7D70AA + for ; + Thu, 1 Sep 2005 11:03:58 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 16829-08 + for ; + Thu, 1 Sep 2005 14:03:53 +0000 (GMT) +Received: from thor.netera.se (thor.netera.se [85.112.172.11]) + by svr1.postgresql.org (Postfix) with ESMTP id 83262D7954 + for ; + Thu, 1 Sep 2005 11:03:51 -0300 (ADT) +Received: from [192.168.2.240] (1-1-1-41a.o.sth.bostream.se [81.26.246.14]) + by thor.netera.se (Postfix) with ESMTP id 486A513AC01C; + Thu, 1 Sep 2005 16:03:55 +0200 (CEST) +Message-ID: <43170ADA.2080002@relevanttraffic.se> +Date: Thu, 01 Sep 2005 16:06:18 +0200 +From: Ulrich Wisser +Organization: Relevant Traffic AB +User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Merlin Moncure +Cc: pgsql-performance@postgresql.org +Subject: Re: Need for speed 3 +References: <6EE64EF3AB31D5448D0007DD34EEB3417DD24C@Herge.rcsinc.local> +In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB3417DD24C@Herge.rcsinc.local> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.001 required=5 tests=[AWL=0.001] +X-Spam-Level: +X-Archive-Number: 200509/6 +X-Sequence-Number: 14314 + +Hi Merlin, + +> schemas would be helpful. + +right now I would like to know if my approach to the problem makes +sense. Or if I should rework the whole procedure of import and aggregate. + +> Just a thought: have you considered having apache logs write to a +> process that immediately makes insert query(s) to postgresql? + +Yes we have considered that, but dismissed the idea very soon. We need +Apache to be as responsive as possible. It's a two server setup with +load balancer and failover. Serving about ones thousand domains and +counting. It needs to be as failsafe as possible and under no +circumstances can any request be lost. (The click counting is core +business and relates directly to our income.) +That said it seemed quite save to let Apache write logfiles. And import +them later. By that a database downtime wouldn't be mission critical. + + +> You could write small C program which executes advanced query interface +> call to the server. + +How would that improve performance? + +Ulrich + +From pgsql-performance-owner@postgresql.org Thu Sep 1 09:16:54 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 671A7D8965 + for ; + Thu, 1 Sep 2005 09:16:53 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 96593-01 + for ; + Thu, 1 Sep 2005 12:16:51 +0000 (GMT) +Received: from mail.gmx.net (imap.gmx.net [213.165.64.20]) + by svr1.postgresql.org (Postfix) with SMTP id 1B6D6D8959 + for ; + Thu, 1 Sep 2005 09:16:48 -0300 (ADT) +Received: (qmail invoked by alias); 01 Sep 2005 12:16:52 -0000 +Received: from bitz57.bitz.briteline.de (EHLO Thor.decoit.lan) [195.90.9.57] + by mail.gmx.net (mp020) with SMTP; 01 Sep 2005 14:16:52 +0200 +X-Authenticated: #1246422 +Subject: Poor performance on HP Package Cluster +From: Ernst Einstein +To: pgsql-performance@postgresql.org +Content-Type: text/plain +Date: Thu, 01 Sep 2005 16:16:07 +0200 +Message-Id: <1125584167.6683.21.camel@Thor.decoit.lan> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 +Content-Transfer-Encoding: 7bit +X-Y-GMX-Trusted: 0 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/2 +X-Sequence-Number: 14310 + +Hi! + +I've set up a Package Cluster ( Fail-Over Cluster ) on our two HP DL380 +G4 with MSA Storrage G2.( Xeon 3,4Ghz, 6GB Ram, 2x 36GB@15rpm- Raid1) +The system is running under Suse Linux Enterprise Server. + +My problem is, that the performance is very low. On our old Server +( Celeron 2Ghz with 2 GB of Ram ) an import of our Data takes about 10 +minutes. ( 1,1GB data ) +One of the DL380 it takes more than 90 minutes... +Selects response time have also been increased. Celeron 3 sec, Xeon +30-40sec. + + I'm trying to fix the problem for two day's now, googled a lot, but i +don't know what to do. + +Top says, my CPU spends ~50% time with wait io. + +top - 14:07:34 up 22 min, 3 users, load average: 1.09, 1.04, 0.78 +Tasks: 74 total, 3 running, 71 sleeping, 0 stopped, 0 zombie +Cpu(s): 50.0% us, 5.0% sy, 0.0% ni, 0.0% id, 45.0% wa, 0.0% hi, +0.0% si +Mem: 6050356k total, 982004k used, 5068352k free, 60300k buffers +Swap: 2097136k total, 0k used, 2097136k free, 786200k cached + + PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ +COMMAND + 9939 postgres 18 0 254m 143m 140m R 49.3 2.4 8:35.43 postgres: +postgres plate [local] INSERT + 9938 postgres 16 0 13720 1440 1120 S 4.9 0.0 0:59.08 psql -d +plate -f dump.sql +10738 root 15 0 3988 1120 840 R 4.9 0.0 0:00.05 top -d +0.2 + 1 root 16 0 640 264 216 S 0.0 0.0 0:05.03 init +[3] + 2 root 34 19 0 0 0 S 0.0 0.0 0:00.00 +[ksoftirqd/0] + +vmstat 1: + +ClusterNode2 root $ vmstat 1 +procs -----------memory---------- ---swap-- -----io---- --system-- +----cpu---- + r b swpd free buff cache si so bi bo in cs us sy +id wa + 1 0 0 5032012 60888 821008 0 0 216 6938 1952 5049 40 +8 15 37 + 0 1 0 5031392 60892 821632 0 0 0 8152 2126 5725 45 +6 0 49 + 0 1 0 5030896 60900 822144 0 0 0 8124 2052 5731 46 +6 0 47 + 0 1 0 5030400 60908 822768 0 0 0 8144 2124 5717 44 +7 0 50 + 1 0 0 5029904 60924 823272 0 0 0 8304 2062 5763 43 +7 0 49 + +I've read (2004), that Xeon may have problems with content switching - +is the problem still existing? Can I do something to minimize the +problem? + + +postgresql.conf: + +shared_buffers = 28672 +effective_cache_size = 400000 +random_page_cost = 2 + + +shmall & shmmax are set to 268435456 + +hdparm: + +ClusterNode2 root $ hdparm -tT /dev/cciss/c0d0p1 + +/dev/cciss/c0d0p1: +Timing buffer-cache reads: 3772 MB in 2.00 seconds = 1885.34 MB/sec +Timing buffered disk reads: 150 MB in 2.06 seconds = 72.72 MB/sec + +greetings Ernst + + + + + +From pgsql-performance-owner@postgresql.org Thu Sep 1 12:30:57 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5203CD83A0 + for ; + Thu, 1 Sep 2005 12:28:40 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 46453-06 + for ; + Thu, 1 Sep 2005 15:28:36 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 54712D7CCA + for ; + Thu, 1 Sep 2005 12:28:34 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Subject: Re: Need for speed 3 +Date: Thu, 1 Sep 2005 11:28:33 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3417DD255@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Need for speed 3 +Thread-Index: AcWu/f6UDe6QwuHSTme5HcXL4EfRFgACNlcQ +From: "Merlin Moncure" +To: "Ulrich Wisser" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.056 required=5 tests=[AWL=0.006, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/7 +X-Sequence-Number: 14315 + +> Hi Merlin, +> > Just a thought: have you considered having apache logs write to a +> > process that immediately makes insert query(s) to postgresql? +>=20 +> Yes we have considered that, but dismissed the idea very soon. We need +> Apache to be as responsive as possible. It's a two server setup with +> load balancer and failover. Serving about ones thousand domains and +> counting. It needs to be as failsafe as possible and under no +> circumstances can any request be lost. (The click counting is core +> business and relates directly to our income.) +> That said it seemed quite save to let Apache write logfiles. And +import +> them later. By that a database downtime wouldn't be mission critical. + +hm. well, it may be possible to do this in a fast and safe way but I +understand your reservations here, but I'm going to spout off my opinion +anyways :). + +If you are not doing this the following point is moot. But take into +consideration you could set a very low transaction time out (like .25 +seconds) and siphon log entries off to a text file if your database +server gets in trouble. 2 million hits a month is not very high even if +your traffic is bursty (there are approx 2.5 million seconds in a +month). + +With a direct linked log file you get up to date stats always and spare +yourself the dump/load song and dance which is always a headache :(. +Also, however you are doing your billing, it will be easier to manage it +if everything is extracted from pg and not some conglomeration of log +files, *if* you can put 100% faith in your database. When it comes to +pg now, I'm a believer. + +> > You could write small C program which executes advanced query +interface +> > call to the server. +>=20 +> How would that improve performance? + +The functions I'm talking about are PQexecParams and PQexecPrepared. +The query string does not need to be encoded or decoded and is very +light on server resources and is very low latency. Using them you could +get prob. 5000 inserts/sec on a cheap server if you have some type of +write caching in place with low cpu load. =20 + +Merlin + + + +From pgsql-performance-owner@postgresql.org Thu Sep 1 14:38:06 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 83306D83C7 + for ; + Thu, 1 Sep 2005 13:38:17 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 64180-01 + for ; + Thu, 1 Sep 2005 16:38:14 +0000 (GMT) +Received: from mail.mi8.com (d01gw04.mi8.com [63.240.6.44]) + by svr1.postgresql.org (Postfix) with ESMTP id 9FD4CD7D01 + for ; + Thu, 1 Sep 2005 13:38:12 -0300 (ADT) +Received: from 172.16.1.118 by mail.mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D4)); Thu, 01 Sep 2005 12:37:56 -0400 +X-Server-Uuid: C8FB4D43-1108-484A-A898-3CBCC7906230 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.174]) by + d01smtp03.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Thu, 1 Sep + 2005 12:37:55 -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 ; Thu, 1 Sep + 2005 12:37:55 -0500 +User-Agent: Microsoft-Entourage/11.1.0.040913 +Date: Thu, 01 Sep 2005 09:37:53 -0700 +Subject: Re: Need for speed 3 +From: "Luke Lonergan" +To: "Ulrich Wisser" , + pgsql-performance@postgresql.org +Cc: "Nicholas E. Wakefield" , + "Barry Klawans" , + "Daria Hutchinson" +Message-ID: +In-Reply-To: <43170151.90408@relevanttraffic.se> +MIME-Version: 1.0 +X-OriginalArrivalTime: 01 Sep 2005 16:37:55.0800 (UTC) + FILETIME=[8145C580:01C5AF13] +X-WSS-ID: 6F09F1EE3P01057575-02-01 +Content-Type: text/plain; + charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.575 required=5 tests=[AWL=-0.006, + FORGED_RCVD_HELO=0.05, RCVD_NUMERIC_HELO=1.531] +X-Spam-Level: * +X-Archive-Number: 200509/8 +X-Sequence-Number: 14316 + +Ulrich, + +On 9/1/05 6:25 AM, "Ulrich Wisser" wrote: + +> My application basically imports Apache log files into a Postgres +> database. Every row in the log file gets imported in one of three (raw +> data) tables. My columns are exactly as in the log file. The import is +> run approx. every five minutes. We import about two million rows a month. + +Bizgres Clickstream does this job using an ETL (extract transform and load) +process to transform the weblogs into an optimized schema for reporting. + +> After every import the data from the current day is deleted from the +> reporting table and recalculated from the raw data table. + +This is something the optimized ETL in Bizgres Clickstream also does well. + +> What do you think of this approach? Are there better ways to do it? Is +> there some literature you recommend reading? + +I recommend the Bizgres Clickstream docs, you can get it from Bizgres CVS, +and there will shortly be a live html link on the website. + +Bizgres is free - it also improves COPY performance by almost 2x, among +other enhancements. + +- Luke + + + +From pgsql-performance-owner@postgresql.org Tue Sep 6 01:06:52 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 89A41D7954 + for ; + Thu, 1 Sep 2005 14:30:50 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 74166-04 + for ; + Thu, 1 Sep 2005 17:30:47 +0000 (GMT) +Received: from knimail01.KineticNetworks.com + (h-67-103-46-99.snfccasy.covad.net [67.103.46.99]) + by svr1.postgresql.org (Postfix) with ESMTP id 5E583D6E2A + for ; + Thu, 1 Sep 2005 14:30:45 -0300 (ADT) +X-MimeOLE: Produced By Microsoft Exchange V6.0.6556.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: Need for speed 3 +Date: Thu, 1 Sep 2005 10:30:43 -0700 +Message-ID: + <14C909669B6CE74381F7BC95A85A0C7F4AD1B1@knimail01.kineticnetworks.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Need for speed 3 +Thread-Index: AcWvE5JTtogy/BANTW28oI3GexzpJQAAv9tA +From: "Nicholas E. Wakefield" +To: "Ulrich Wisser" , + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.085 required=5 tests=[AWL=0.035, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/79 +X-Sequence-Number: 14387 + +Ulrich, + +Luke cc'd me on his reply and you definitely should have a look at +Bizgres Clickstream. Even if the whole stack doesn't match you needs, +though it sounds like it would. The clickstream focused TELL and BizGres +enhancements could make your life a little easier. + +Basically the stack components that you might want to look at first are: + +BizGres flavor of PostGreSQL - Enhanced for business intelligence and +data warehousing - The www.bizgres.com website can speak to this in more +detail. +Clickstream Data Model - Pageview fact table surrounded by various +dimensions and 2 core staging tables for the cleansed weblog data. +ETL Platform - Contains a weblog sessionizer, cleanser and ETL +transformations, which can handle 2-3 million hits without any trouble. +With native support for the COPY command, for even greater performance. +JasperReports - For pixel perfect reporting. + +Sorry for sounding like I'm in marketing or sales, however I'm not. + +Couple of key features that might interest you, considering your email. +The weblog parsing component allows for relatively complex cleansing, +allowing for less data to be written to the DB and therefore increasing +throughput. In addition, if you run every 5 minutes there would be no +need to truncate the days data and reload, the ETL knows how to connect +the data from before. The copy enhancement to postgresql found in +bizgres, makes a noticeable improvement when loading data. +The schema is basically + +Dimension tables Session, Known Party (If cookies are logged), Page, IP +Address, Date, Time, Referrer, Referrer Page. +Fact tables: Pageview, Hit Subset (Not everyone wants all hits). + +Staging Tables: Hits (Cleansed hits or just pageviews without surrogate +keys), Session (Session data gathered while parsing the log). + +Regards + +Nick + + +-----Original Message----- +From: Luke Lonergan [mailto:llonergan@greenplum.com]=20 +Sent: Thursday, September 01, 2005 9:38 AM +To: Ulrich Wisser; pgsql-performance@postgresql.org +Cc: Nicholas E. Wakefield; Barry Klawans; Daria Hutchinson +Subject: Re: [PERFORM] Need for speed 3 + +Ulrich, + +On 9/1/05 6:25 AM, "Ulrich Wisser" +wrote: + +> My application basically imports Apache log files into a Postgres=20 +> database. Every row in the log file gets imported in one of three (raw +> data) tables. My columns are exactly as in the log file. The import is + +> run approx. every five minutes. We import about two million rows a +month. + +Bizgres Clickstream does this job using an ETL (extract transform and +load) process to transform the weblogs into an optimized schema for +reporting. +=20 +> After every import the data from the current day is deleted from the=20 +> reporting table and recalculated from the raw data table. + +This is something the optimized ETL in Bizgres Clickstream also does +well. +=20 +> What do you think of this approach? Are there better ways to do it? Is + +> there some literature you recommend reading? + +I recommend the Bizgres Clickstream docs, you can get it from Bizgres +CVS, and there will shortly be a live html link on the website. + +Bizgres is free - it also improves COPY performance by almost 2x, among +other enhancements. + +- Luke=20 + + + + +From pgsql-performance-owner@postgresql.org Thu Sep 1 14:43:14 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3358ED6E2A + for ; + Thu, 1 Sep 2005 14:42:40 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 75632-08 + for ; + Thu, 1 Sep 2005 17:42:34 +0000 (GMT) +Received: from newman.lshift.net (host226.lshift.net [195.172.218.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 8E44AD846F + for ; + Thu, 1 Sep 2005 14:42:32 -0300 (ADT) +Received: (qmail 29773 invoked by uid 1004); 1 Sep 2005 17:42:32 -0000 +Received: from 10.224.189.77 by newman (envelope-from , + uid 64011) with qmail-scanner-1.24 (clamdscan: 0.80/627. + Clear:RC:1(10.224.189.77):. + Processed in 0.014316 secs); 01 Sep 2005 17:42:32 -0000 +Received: from ponder.lshift.net (HELO localhost) ([10.224.189.77]) + (envelope-sender ) + by newman.lshift.net (qmail-ldap-1.03) with AES256-SHA encrypted SMTP + for ; 1 Sep 2005 17:42:31 -0000 +Date: Thu, 1 Sep 2005 18:42:31 +0100 +From: Matthew Sackman +To: pgsql-performance@postgresql.org +Subject: Massive performance issues +Message-ID: <20050901174231.GE23970@pongo.lshift.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.374 required=5 tests=[DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200509/9 +X-Sequence-Number: 14317 + +Hi, + +I'm having performance issues with a table consisting of 2,043,133 rows. The +schema is: + +\d address + Table "public.address" + Column | Type | Modifiers +----------------------+------------------------+----------- + postcode_top | character varying(2) | not null + postcode_middle | character varying(4) | not null + postcode_bottom | character varying(7) | not null + postcode | character varying(10) | not null + property_type | character varying(15) | not null + sale_type | character varying(10) | not null + flat_extra | character varying(100) | not null + number | character varying(100) | not null + street | character varying(100) | not null + locality_1 | character varying(100) | not null + locality_2 | character varying(100) | not null + city | character varying(100) | not null + county | character varying(100) | not null +Indexes: + "address_city_index" btree (city) + "address_county_index" btree (county) + "address_locality_1_index" btree (locality_1) + "address_locality_2_index" btree (locality_2) + "address_pc_bottom_index" btree (postcode_bottom) + "address_pc_middle_index" btree (postcode_middle) + "address_pc_top_index" btree (postcode_top) + "address_pc_top_middle_bottom_index" btree (postcode_top, + postcode_middle, postcode_bottom) + "address_pc_top_middle_index" btree (postcode_top, postcode_middle) + "address_postcode_index" btree (postcode) + "address_property_type_index" btree (property_type) + "address_street_index" btree (street) + "street_prefix" btree (lower("substring"((street)::text, 1, 1))) + +This is with postgresql 7.4 running on linux 2.6.11 with a 3GHz P4 and a +SATA harddrive. + +Queries such as: + +select locality_2 from address where locality_2 = 'Manchester'; + +are taking 14 seconds to complete, and this is only 2 years worth of +data - we will have up to 15 years (so over 15 million rows). + +Interestingly, doing: +explain select locality_2 from address where locality_2 = 'Manchester'; +gives + QUERY PLAN +---------------------------------------------------------------- + Seq Scan on address (cost=0.00..80677.16 rows=27923 width=12) + Filter: ((locality_2)::text = 'Manchester'::text) + +but: +explain select locality_1 from address where locality_1 = 'Manchester'; +gives + QUERY PLAN +---------------------------------------------------------------- + Index Scan using address_locality_1_index on address +(cost=0.00..69882.18 rows=17708 width=13) + Index Cond: ((locality_1)::text = 'Manchester'::text) + +Sadly, using the index makes things worse, the query taking 17 seconds. + +locality_1 has 16650 distinct values and locality_2 has 1156 distinct +values. + +Whilst the locality_2 query is in progress, both the disk and the CPU +are maxed out with the disk constantly reading at 60MB/s and the CPU +rarely dropping under 100% load. + +With the locality_1 query in progress, the CPU is maxed out but the disk +is reading at just 3MB/s. + +Obviously, to me, this is a problem, I need these queries to be under a +second to complete. Is this unreasonable? What can I do to make this "go +faster"? I've considered normalising the table but I can't work out +whether the slowness is in dereferencing the pointers from the index +into the table or in scanning the index in the first place. And +normalising the table is going to cause much pain when inserting values +and I'm not entirely sure if I see why normalising it should cause a +massive performance improvement. + +I need to get to the stage where I can run queries such as: +select street, locality_1, locality_2, city from address +where (city = 'Nottingham' or locality_2 = 'Nottingham' + or locality_1 = 'Nottingham') + and upper(substring(street from 1 for 1)) = 'A' +group by street, locality_1, locality_2, city +order by street +limit 20 offset 0 + +and have the results very quickly. + +Any help most gratefully received (even if it's to say that I should be +posting to a different mailing list!). + +Many thanks, + +Matthew + + +From pgsql-performance-owner@postgresql.org Thu Sep 1 15:48:39 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id ECDC2D84AB + for ; + Thu, 1 Sep 2005 15:04:57 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 83213-01 + for ; + Thu, 1 Sep 2005 18:04:56 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 922F9D715F + for ; + Thu, 1 Sep 2005 15:04:54 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Subject: Re: Massive performance issues +Date: Thu, 1 Sep 2005 14:04:54 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3417DD259@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Massive performance issues +Thread-Index: AcWvHZzpxj+UFy59Sj+XUoD/j4kC+wAAPKuw +From: "Merlin Moncure" +To: "Matthew Sackman" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.056 required=5 tests=[AWL=0.006, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/11 +X-Sequence-Number: 14319 + +> Table "public.address" +> Column | Type | Modifiers +> ----------------------+------------------------+----------- +> postcode_top | character varying(2) | not null +> postcode_middle | character varying(4) | not null +> postcode_bottom | character varying(7) | not null + + +consider making above fields char(x) not varchar(x) for small but +important savings. + +> postcode | character varying(10) | not null +> property_type | character varying(15) | not null +> sale_type | character varying(10) | not null +> flat_extra | character varying(100) | not null +> number | character varying(100) | not null +> street | character varying(100) | not null +> locality_1 | character varying(100) | not null +> locality_2 | character varying(100) | not null +> city | character varying(100) | not null +> county | character varying(100) | not null +> Indexes: +> "address_city_index" btree (city) +> "address_county_index" btree (county) +> "address_locality_1_index" btree (locality_1) +> "address_locality_2_index" btree (locality_2) +> "address_pc_bottom_index" btree (postcode_bottom) +> "address_pc_middle_index" btree (postcode_middle) +> "address_pc_top_index" btree (postcode_top) +> "address_pc_top_middle_bottom_index" btree (postcode_top, +> postcode_middle, postcode_bottom) +> "address_pc_top_middle_index" btree (postcode_top, +postcode_middle) +> "address_postcode_index" btree (postcode) +> "address_property_type_index" btree (property_type) +> "address_street_index" btree (street) +> "street_prefix" btree (lower("substring"((street)::text, 1, 1))) +>=20 +> Obviously, to me, this is a problem, I need these queries to be under +a +> second to complete. Is this unreasonable? What can I do to make this +"go +> faster"? I've considered normalising the table but I can't work out +> whether the slowness is in dereferencing the pointers from the index +> into the table or in scanning the index in the first place. And +> normalising the table is going to cause much pain when inserting +values +> and I'm not entirely sure if I see why normalising it should cause a +> massive performance improvement. + +http://www.dbdebunk.com :) + +> I need to get to the stage where I can run queries such as: +> select street, locality_1, locality_2, city from address +> where (city =3D 'Nottingham' or locality_2 =3D 'Nottingham' +> or locality_1 =3D 'Nottingham') +> and upper(substring(street from 1 for 1)) =3D 'A' +> group by street, locality_1, locality_2, city +> order by street +> limit 20 offset 0 +>=20 +> and have the results very quickly. +>=20 +> Any help most gratefully received (even if it's to say that I should +be +> posting to a different mailing list!). + +this is correct list. did you run vacuum/analyze, etc? +Please post vacuum analyze times. + +Merlin + +From pgsql-performance-owner@postgresql.org Thu Sep 1 15:34:54 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4A217D862A + for ; + Thu, 1 Sep 2005 15:10:51 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81215-05 + for ; + Thu, 1 Sep 2005 18:10:34 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id C909DD86F9 + for ; + Thu, 1 Sep 2005 15:10:31 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Subject: Re: Massive performance issues +Date: Thu, 1 Sep 2005 14:10:31 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3417DD25A@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Massive performance issues +Thread-Index: AcWvHZzpxj+UFy59Sj+XUoD/j4kC+wAAkCNA +From: "Merlin Moncure" +To: "Matthew Sackman" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.056 required=5 tests=[AWL=0.006, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/10 +X-Sequence-Number: 14318 + +> I'm having performance issues with a table consisting of 2,043,133 +rows. +> The +> schema is: + +> locality_1 has 16650 distinct values and locality_2 has 1156 distinct +> values. + +Just so you know I have a 2GHz p4 workstation with similar size (2M +rows), several keys, and can find and fetch 2k rows based on 20k unique +value key in about 60 ms. (.06 seconds). + +Merlin + +From pgsql-performance-owner@postgresql.org Thu Sep 1 16:54:40 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 41A17D8836 + for ; + Thu, 1 Sep 2005 15:40:26 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 89701-04 + for ; + Thu, 1 Sep 2005 18:40:23 +0000 (GMT) +Received: from svctag-ckgvz71.mailserver.wazagua.com (unknown + [209.34.245.244]) + by svr1.postgresql.org (Postfix) with ESMTP id 3F6B2D877A + for ; + Thu, 1 Sep 2005 15:40:22 -0300 (ADT) +Received: from jfradkin ([66.15.127.235]) by + svctag-ckgvz71.mailserver.wazagua.com with Microsoft + SMTPSVC(6.0.3790.1830); Thu, 1 Sep 2005 14:40:30 -0400 +From: "Joel Fradkin" +To: "'Merlin Moncure'" , + "'Matthew Sackman'" +Cc: +Subject: Re: Massive performance issues +Date: Thu, 1 Sep 2005 14:42:51 -0400 +Message-ID: <003901c5af24$f5cd8ee0$797ba8c0@jfradkin> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB3417DD25A@Herge.rcsinc.local> +X-OriginalArrivalTime: 01 Sep 2005 18:40:30.0406 (UTC) + FILETIME=[A0F59660:01C5AF24] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=2.908 required=5 tests=[AWL=-0.168, + MSGID_DOLLARS=3.076] +X-Spam-Level: ** +X-Archive-Number: 200509/15 +X-Sequence-Number: 14323 + +Any chance it's a vacuum thing? +Or configuration (out of the box it needs adjusting)? + +Joel Fradkin + + + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Merlin Moncure +Sent: Thursday, September 01, 2005 2:11 PM +To: Matthew Sackman +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Massive performance issues + +> I'm having performance issues with a table consisting of 2,043,133 +rows. +> The +> schema is: + +> locality_1 has 16650 distinct values and locality_2 has 1156 distinct +> values. + +Just so you know I have a 2GHz p4 workstation with similar size (2M +rows), several keys, and can find and fetch 2k rows based on 20k unique +value key in about 60 ms. (.06 seconds). + +Merlin + +---------------------------(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 Sep 1 16:51:08 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 45253D7D3B + for ; + Thu, 1 Sep 2005 15:47:24 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 90090-05 + for ; + Thu, 1 Sep 2005 18:47:07 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 08854D76D5 + for ; + Thu, 1 Sep 2005 15:47:06 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j81Il6Br005179; + Thu, 1 Sep 2005 14:47:06 -0400 (EDT) +To: Matthew Sackman +Cc: pgsql-performance@postgresql.org +Subject: Re: Massive performance issues +In-reply-to: <20050901174231.GE23970@pongo.lshift.net> +References: <20050901174231.GE23970@pongo.lshift.net> +Comments: In-reply-to Matthew Sackman + message dated "Thu, 01 Sep 2005 18:42:31 +0100" +Date: Thu, 01 Sep 2005 14:47:06 -0400 +Message-ID: <5178.1125600426@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/14 +X-Sequence-Number: 14322 + +Matthew Sackman writes: +> Obviously, to me, this is a problem, I need these queries to be under a +> second to complete. Is this unreasonable? + +Yes. Pulling twenty thousand rows at random from a table isn't free. +You were pretty vague about your disk hardware, which makes me think +you didn't spend a lot of money on it ... and on low-ball hardware, +that sort of random access speed just isn't gonna happen. + +If the queries you need are very consistent, you might be able to get +some mileage out of CLUSTERing by the relevant index ... but the number +of indexes you've created makes me think that's not so ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Sep 1 16:43:33 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 360A9D6FA7 + for ; + Thu, 1 Sep 2005 15:52:49 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91318-06 + for ; + Thu, 1 Sep 2005 18:52:32 +0000 (GMT) +Received: from newman.lshift.net (host226.lshift.net [195.172.218.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 72C0AD86EB + for ; + Thu, 1 Sep 2005 15:52:30 -0300 (ADT) +Received: (qmail 2963 invoked by uid 1004); 1 Sep 2005 18:52:31 -0000 +Received: from 10.224.189.77 by newman (envelope-from , + uid 64011) with qmail-scanner-1.24 (clamdscan: 0.80/627. + Clear:RC:1(10.224.189.77):. + Processed in 0.01388 secs); 01 Sep 2005 18:52:31 -0000 +Received: from ponder.lshift.net (HELO localhost) ([10.224.189.77]) + (envelope-sender ) + by newman.lshift.net (qmail-ldap-1.03) with AES256-SHA encrypted SMTP + for ; 1 Sep 2005 18:52:31 -0000 +Date: Thu, 1 Sep 2005 19:52:31 +0100 +From: Matthew Sackman +To: pgsql-performance@postgresql.org +Subject: Re: Massive performance issues +Message-ID: <20050901185231.GA7131@pongo.lshift.net> +Mail-Followup-To: pgsql-performance@postgresql.org +References: <6EE64EF3AB31D5448D0007DD34EEB3417DD259@Herge.rcsinc.local> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB3417DD259@Herge.rcsinc.local> +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.093 required=5 tests=[AWL=0.093] +X-Spam-Level: +X-Archive-Number: 200509/13 +X-Sequence-Number: 14321 + +On Thu, Sep 01, 2005 at 02:04:54PM -0400, Merlin Moncure wrote: +> > Any help most gratefully received (even if it's to say that I should +> be +> > posting to a different mailing list!). +> +> this is correct list. did you run vacuum/analyze, etc? +> Please post vacuum analyze times. + +2005-09-01 19:47:08 LOG: statement: vacuum full analyze address; +2005-09-01 19:48:44 LOG: duration: 96182.777 ms + +2005-09-01 19:50:20 LOG: statement: vacuum analyze address; +2005-09-01 19:51:48 LOG: duration: 87675.268 ms + +I run them regularly, pretty much after every bulk import. + +Matthew + +From pgsql-performance-owner@postgresql.org Thu Sep 1 16:27:31 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8088BD8746 + for ; + Thu, 1 Sep 2005 16:08:13 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 96622-01 + for ; + Thu, 1 Sep 2005 19:08:09 +0000 (GMT) +Received: from newman.lshift.net (host226.lshift.net [195.172.218.226]) + by svr1.postgresql.org (Postfix) with ESMTP id A8FD0D86FD + for ; + Thu, 1 Sep 2005 16:08:07 -0300 (ADT) +Received: (qmail 3976 invoked by uid 1004); 1 Sep 2005 19:08:09 -0000 +Received: from 10.224.189.77 by newman (envelope-from , + uid 64011) with qmail-scanner-1.24 (clamdscan: 0.80/627. + Clear:RC:1(10.224.189.77):. + Processed in 0.013879 secs); 01 Sep 2005 19:08:09 -0000 +Received: from ponder.lshift.net (HELO localhost) ([10.224.189.77]) + (envelope-sender ) + by newman.lshift.net (qmail-ldap-1.03) with AES256-SHA encrypted SMTP + for ; 1 Sep 2005 19:08:08 -0000 +Date: Thu, 1 Sep 2005 20:08:08 +0100 +From: Matthew Sackman +To: pgsql-performance@postgresql.org +Subject: Re: Massive performance issues +Message-ID: <20050901190808.GB7131@pongo.lshift.net> +Mail-Followup-To: pgsql-performance@postgresql.org +References: <20050901174231.GE23970@pongo.lshift.net> + <5178.1125600426@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <5178.1125600426@sss.pgh.pa.us> +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.249 required=5 tests=[AWL=-0.125, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200509/12 +X-Sequence-Number: 14320 + +On Thu, Sep 01, 2005 at 02:47:06PM -0400, Tom Lane wrote: +> Matthew Sackman writes: +> > Obviously, to me, this is a problem, I need these queries to be under a +> > second to complete. Is this unreasonable? +> +> Yes. Pulling twenty thousand rows at random from a table isn't free. + +I appreciate that. But I'm surprised by how un-free it seems to be. +And it seems others here have performance I need on similar hardware. + +> You were pretty vague about your disk hardware, which makes me think +> you didn't spend a lot of money on it ... and on low-ball hardware, +> that sort of random access speed just isn't gonna happen. + +Well, this is a development box. But the live box wouldn't be much more +than RAID 1 on SCSI 10ks so that should only be a halving of seek time, +not the 1000 times reduction I'm after! + +In fact, now I think about it, I have been testing on a 2.4 kernel on a +dual HT 3GHz Xeon with SCSI RAID array and the performance is only +marginally better. + +> If the queries you need are very consistent, you might be able to get +> some mileage out of CLUSTERing by the relevant index ... but the number +> of indexes you've created makes me think that's not so ... + +No, the queries, whilst in just three distinct forms, will effectively +be for fairly random values. + +Matthew + +From pgsql-performance-owner@postgresql.org Thu Sep 1 17:17:57 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1C4D8D868E + for ; + Thu, 1 Sep 2005 16:33:05 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 00735-05 + for ; + Thu, 1 Sep 2005 19:33:02 +0000 (GMT) +Received: from mx1.surnet.cl (mx1.surnet.cl [216.155.73.180]) + by svr1.postgresql.org (Postfix) with ESMTP id 7B35ED86D7 + for ; + Thu, 1 Sep 2005 16:33:00 -0300 (ADT) +Received: from unknown (HELO cluster.surnet.cl) (216.155.73.164) + by mx1.surnet.cl with ESMTP; 01 Sep 2005 15:32:58 -0400 +X-IronPort-AV: i="3.96,162,1122868800"; d="scan'208"; a="3341636:sNHT29855088" +Received: from alvh.no-ip.org (216.155.78.140) by cluster.surnet.cl (7.0.043) + (authenticated as alvherre@surnet.cl) + id 42B3EF6000ACC361; Thu, 1 Sep 2005 15:32:58 -0400 +Received: by alvh.no-ip.org (Postfix, from userid 1000) + id 6740FC30B1B; Thu, 1 Sep 2005 15:33:31 -0400 (CLT) +Date: Thu, 1 Sep 2005 15:33:31 -0400 +From: Alvaro Herrera +To: Merlin Moncure +Cc: Matthew Sackman , + pgsql-performance@postgresql.org +Subject: Re: Massive performance issues +Message-ID: <20050901193331.GA31313@surnet.cl> +Mail-Followup-To: Merlin Moncure , + Matthew Sackman , + pgsql-performance@postgresql.org +References: <6EE64EF3AB31D5448D0007DD34EEB3417DD259@Herge.rcsinc.local> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB3417DD259@Herge.rcsinc.local> +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=2.255 required=5 tests=[AWL=-0.521, + DNS_FROM_RFC_ABUSE=0.374, DNS_FROM_RFC_POST=1.376, + RCVD_IN_NJABL_PROXY=1.026] +X-Spam-Level: ** +X-Archive-Number: 200509/20 +X-Sequence-Number: 14328 + +On Thu, Sep 01, 2005 at 02:04:54PM -0400, Merlin Moncure wrote: +> > Table "public.address" +> > Column | Type | Modifiers +> > ----------------------+------------------------+----------- +> > postcode_top | character varying(2) | not null +> > postcode_middle | character varying(4) | not null +> > postcode_bottom | character varying(7) | not null +> +> consider making above fields char(x) not varchar(x) for small but +> important savings. + +Huh, hang on -- AFAIK there's no saving at all by doing that. Quite the +opposite really, because with char(x) you store the padding blanks, +which are omitted with varchar(x), so less I/O (not necessarily a +measurable amount, mind you, maybe even zero because of padding issues.) + +-- +Alvaro Herrera -- Valdivia, Chile Architect, www.EnterpriseDB.com +You liked Linux a lot when he was just the gawky kid from down the block +mowing your lawn or shoveling the snow. But now that he wants to date +your daughter, you're not so sure he measures up. (Larry Greenemeier) + +From pgsql-performance-owner@postgresql.org Thu Sep 1 17:07:48 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 37D52D85B3 + for ; + Thu, 1 Sep 2005 16:46:11 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 03939-02 + for ; + Thu, 1 Sep 2005 19:46:09 +0000 (GMT) +Received: from smtpauth08.mail.atl.earthlink.net + (smtpauth08.mail.atl.earthlink.net [209.86.89.68]) + by svr1.postgresql.org (Postfix) with ESMTP id B865FD83AD + for ; + Thu, 1 Sep 2005 16:46:06 -0300 (ADT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=R2BV1L7V7a23X+jy21Ns8nTxVacNEUYHjyQTnvqMOi4ZcjqTa1TzmP3sAITyulZf; + h=Received:Message-Id:X-Mailer:Date:To:From:Subject:In-Reply-To:References:Mime-Version:Content-Type:X-ELNK-Trace:X-Originating-IP; +Received: from [24.41.3.216] (helo=RJP-01.earthlink.net) + by smtpauth08.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1EAv0h-0000G7-D1; Thu, 01 Sep 2005 15:46:07 -0400 +Message-Id: <6.2.3.4.0.20050901145054.021b1678@pop.earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 6.2.3.4 +Date: Thu, 01 Sep 2005 15:43:01 -0400 +To: Matthew Sackman , + pgsql-performance@postgresql.org +From: Ron +Subject: Re: Massive performance issues +In-Reply-To: <20050901174231.GE23970@pongo.lshift.net> +References: <20050901174231.GE23970@pongo.lshift.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bccd5b6ade15c41f5e5ba15d3b0e3f4924350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 24.41.3.216 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.386 required=5 tests=[AWL=0.012, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200509/18 +X-Sequence-Number: 14326 + +This should be able to run _very_ fast. + +At 01:42 PM 9/1/2005, Matthew Sackman wrote: +>Hi, +> +>I'm having performance issues with a table consisting of 2,043,133 rows. The +>schema is: +> +>\d address +> Table "public.address" +> Column | Type | Modifiers +>----------------------+------------------------+----------- +> postcode_top | character varying(2) | not null +> postcode_middle | character varying(4) | not null +> postcode_bottom | character varying(7) | not null +> postcode | character varying(10) | not null +> property_type | character varying(15) | not null +> sale_type | character varying(10) | not null +> flat_extra | character varying(100) | not null +> number | character varying(100) | not null +> street | character varying(100) | not null +> locality_1 | character varying(100) | not null +> locality_2 | character varying(100) | not null +> city | character varying(100) | not null +> county | character varying(100) | not null +>Indexes: +> "address_city_index" btree (city) +> "address_county_index" btree (county) +> "address_locality_1_index" btree (locality_1) +> "address_locality_2_index" btree (locality_2) +> "address_pc_bottom_index" btree (postcode_bottom) +> "address_pc_middle_index" btree (postcode_middle) +> "address_pc_top_index" btree (postcode_top) +> "address_pc_top_middle_bottom_index" btree (postcode_top, +> postcode_middle, postcode_bottom) +> "address_pc_top_middle_index" btree (postcode_top, postcode_middle) +> "address_postcode_index" btree (postcode) +> "address_property_type_index" btree (property_type) +> "address_street_index" btree (street) +> "street_prefix" btree (lower("substring"((street)::text, 1, 1))) + +IOW, each row takes ~1KB on HD. First suggestion: format your HD to +use 8KB pages with 1KB segments. That'll out each row down on HD as +an atomic unit. 8KB pages also "play nice" with pg. + +At 1KB per row, this table takes up ~2.1GB and should fit into RAM +fairly easily on a decently configured DB server (my _laptop_ has 2GB +of RAM after all...) + +Since you are using ~2.1GB for 2 years worth of data, 15 years worth +should take no more than 2.1GB*7.5= 15.75GB. + +If you replace some of those 100 char fields with integers for code +numbers and have an auxiliary table for each of those fields mapping +the code numbers to the associated 100 char string, you should be +able to shrink a row considerably. Your target is to have each row +take <= 512B. Once a row fits into one 512B sector on HD, there's a +no point in making it smaller unless you can shrink it enough to fit +2 rows into one sector (<= 256B). Once two rows fit into one sector, +there's no point shrinking a row unless you can make 3 rows fit into +a sector. Etc. + +Assuming each 100 char (eg 100B) field can be replaced with a 4B int, +each row could be as small as 76B. That makes 85B per row the goal +as it would allow you to fit 6 rows per 512B HD sector. So in the +best case your table will be 12x smaller in terms of real HD space. + +Fitting one (or more) row(s) into one sector will cut down the real +space used on HD for the table to ~7.88GB (or 1.32GB in the best +case). Any such streamlining will make it faster to load, make the +working set that needs to be RAM for best performance smaller, etc, etc. + + +>This is with postgresql 7.4 running on linux 2.6.11 with a 3GHz P4 +>and a SATA harddrive. + +Upgrade pg to 8.0.3 and make sure you have enough RAM for your real +day to day load. Frankly, RAM is so cheap ($75-$150/GB), I'd just +upgrade the machine to 4GB as a matter of course. P4's have PAE, so +if your mainboard can hold it, put more than 4GB of RAM in if you +find you need it. + +Since you are describing your workload as being predominantly reads, +you can get away with far less HD capability as long as you crank up +RAM high enough to hold the working set of the DB. The indications +from the OP are that you may very well be able to hold the entire DB +in RAM. That's a big win whenever you can achieve it. + +After these steps, there may still be performance issues that need +attention, but the DBMS should be _much_ faster. + +Ron Peacetree + + + +From pgsql-performance-owner@postgresql.org Thu Sep 1 17:02:45 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5F251D8698 + for ; + Thu, 1 Sep 2005 16:51:42 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 01224-07 + for ; + Thu, 1 Sep 2005 19:51:36 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id E667ED85B3 + for ; + Thu, 1 Sep 2005 16:51:34 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Subject: Re: Massive performance issues +Date: Thu, 1 Sep 2005 15:51:35 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3417DD25F@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Massive performance issues +Thread-Index: AcWvK/ZlPEutYfphRDu64DiSlazd3wAAjfdw +From: "Merlin Moncure" +To: "Alvaro Herrera" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.056 required=5 tests=[AWL=0.006, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/17 +X-Sequence-Number: 14325 + +> -----Original Message----- +> From: Alvaro Herrera [mailto:alvherre@alvh.no-ip.org] +> Sent: Thursday, September 01, 2005 3:34 PM +> To: Merlin Moncure +> Cc: Matthew Sackman; pgsql-performance@postgresql.org +> Subject: Re: [PERFORM] Massive performance issues +>=20 +> On Thu, Sep 01, 2005 at 02:04:54PM -0400, Merlin Moncure wrote: +> > > Table "public.address" +> > > Column | Type | Modifiers +> > > ----------------------+------------------------+----------- +> > > postcode_top | character varying(2) | not null +> > > postcode_middle | character varying(4) | not null +> > > postcode_bottom | character varying(7) | not null +> > +> > consider making above fields char(x) not varchar(x) for small but +> > important savings. +>=20 +> Huh, hang on -- AFAIK there's no saving at all by doing that. Quite +the +> opposite really, because with char(x) you store the padding blanks, +> which are omitted with varchar(x), so less I/O (not necessarily a +> measurable amount, mind you, maybe even zero because of padding +issues.) + +You are right, all this time I thought there was a 4 byte penalty for +storing varchar type and not in char :(. So there is no reason at all +to use the char type? + +Merlin + + +From pgsql-performance-owner@postgresql.org Thu Sep 1 16:57:06 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 098A2D76D5 + for ; + Thu, 1 Sep 2005 16:53:18 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 01821-10 + for ; + Thu, 1 Sep 2005 19:53:15 +0000 (GMT) +Received: from mx1.surnet.cl (mx1.surnet.cl [216.155.73.180]) + by svr1.postgresql.org (Postfix) with ESMTP id 4D06DD868E + for ; + Thu, 1 Sep 2005 16:53:13 -0300 (ADT) +Received: from unknown (HELO cluster.surnet.cl) (216.155.73.164) + by mx1.surnet.cl with ESMTP; 01 Sep 2005 15:53:14 -0400 +X-IronPort-AV: i="3.96,162,1122868800"; + d="scan'208"; a="3347051:sNHT175076136" +Received: from alvh.no-ip.org (216.155.78.140) by cluster.surnet.cl (7.0.043) + (authenticated as alvherre@surnet.cl) + id 42B3EF6000ACCE81; Thu, 1 Sep 2005 15:53:14 -0400 +Received: by alvh.no-ip.org (Postfix, from userid 1000) + id C7267C30B1B; Thu, 1 Sep 2005 15:53:47 -0400 (CLT) +Date: Thu, 1 Sep 2005 15:53:47 -0400 +From: Alvaro Herrera +To: Merlin Moncure +Cc: pgsql-performance@postgresql.org +Subject: Re: Massive performance issues +Message-ID: <20050901195347.GA31519@surnet.cl> +Mail-Followup-To: Merlin Moncure , + pgsql-performance@postgresql.org +References: <6EE64EF3AB31D5448D0007DD34EEB3417DD25F@Herge.rcsinc.local> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB3417DD25F@Herge.rcsinc.local> +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=2.26 required=5 tests=[AWL=-0.516, + DNS_FROM_RFC_ABUSE=0.374, DNS_FROM_RFC_POST=1.376, + RCVD_IN_NJABL_PROXY=1.026] +X-Spam-Level: ** +X-Archive-Number: 200509/16 +X-Sequence-Number: 14324 + +On Thu, Sep 01, 2005 at 03:51:35PM -0400, Merlin Moncure wrote: + +> > Huh, hang on -- AFAIK there's no saving at all by doing that. Quite +> > the opposite really, because with char(x) you store the padding +> > blanks, which are omitted with varchar(x), so less I/O (not +> > necessarily a measurable amount, mind you, maybe even zero because +> > of padding issues.) +> +> You are right, all this time I thought there was a 4 byte penalty for +> storing varchar type and not in char :(. So there is no reason at all +> to use the char type? + +Other than SQL conformance, apparently not. + +-- +Alvaro Herrera -- Valdivia, Chile Architect, www.EnterpriseDB.com +Bob [Floyd] used to say that he was planning to get a Ph.D. by the "green +stamp method," namely by saving envelopes addressed to him as 'Dr. Floyd'. +After collecting 500 such letters, he mused, a university somewhere in +Arizona would probably grant him a degree. (Don Knuth) + +From pgsql-performance-owner@postgresql.org Thu Sep 1 17:10:06 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E8A23D868E + for ; + Thu, 1 Sep 2005 17:09:42 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 10169-01 + for ; + Thu, 1 Sep 2005 20:09:35 +0000 (GMT) +Received: from cassarossa.samfundet.no (cassarossa.samfundet.no + [129.241.93.19]) + by svr1.postgresql.org (Postfix) with ESMTP id D13EED87F1 + for ; + Thu, 1 Sep 2005 17:09:33 -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 1EAvNL-0001Os-Mq + for pgsql-performance@postgresql.org; Thu, 01 Sep 2005 22:09:33 +0200 +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1EAvNK-0006Od-00 + for ; Thu, 01 Sep 2005 22:09:30 +0200 +Date: Thu, 1 Sep 2005 22:09:30 +0200 +From: "Steinar H. Gunderson" +To: pgsql-performance@postgresql.org +Subject: Re: Massive performance issues +Message-ID: <20050901200930.GA23339@uio.no> +Mail-Followup-To: pgsql-performance@postgresql.org +References: <20050901174231.GE23970@pongo.lshift.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Disposition: inline +In-Reply-To: <20050901174231.GE23970@pongo.lshift.net> +X-Operating-System: Linux 2.6.11.8 on a i686 +X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.015 required=5 tests=[AWL=0.015] +X-Spam-Level: +X-Archive-Number: 200509/19 +X-Sequence-Number: 14327 + +On Thu, Sep 01, 2005 at 06:42:31PM +0100, Matthew Sackman wrote: +> flat_extra | character varying(100) | not null +> number | character varying(100) | not null +> street | character varying(100) | not null +> locality_1 | character varying(100) | not null +> locality_2 | character varying(100) | not null +> city | character varying(100) | not null +> county | character varying(100) | not null + +Having these fixed probably won't give you any noticeable improvements; +unless there's something natural about your data setting 100 as a hard limit, +you could just as well drop these. + +> "address_city_index" btree (city) +> "address_county_index" btree (county) +> "address_locality_1_index" btree (locality_1) +> "address_locality_2_index" btree (locality_2) +> "address_pc_bottom_index" btree (postcode_bottom) +> "address_pc_middle_index" btree (postcode_middle) +> "address_pc_top_index" btree (postcode_top) +> "address_pc_top_middle_bottom_index" btree (postcode_top, +> postcode_middle, postcode_bottom) +> "address_pc_top_middle_index" btree (postcode_top, postcode_middle) +> "address_postcode_index" btree (postcode) +> "address_property_type_index" btree (property_type) +> "address_street_index" btree (street) +> "street_prefix" btree (lower("substring"((street)::text, 1, 1))) + +Wow, that's quite a lof of indexes... but your problem isn't reported as +being in insert/update/delete. + +> This is with postgresql 7.4 running on linux 2.6.11 with a 3GHz P4 and a +> SATA harddrive. + +8.0 or 8.1 might help you some -- better (and more!) disks will probably help +a _lot_. + +> Queries such as: +> +> select locality_2 from address where locality_2 = 'Manchester'; +> +> are taking 14 seconds to complete, and this is only 2 years worth of +> data - we will have up to 15 years (so over 15 million rows). + +As Tom pointed out; you're effectively doing random searches here, and using +CLUSTER might help. Normalizing your data to get smaller rows (and avoid +possibly costly string comparisons if your strcoll() is slow) will probably +also help. + +> I need to get to the stage where I can run queries such as: +> select street, locality_1, locality_2, city from address +> where (city = 'Nottingham' or locality_2 = 'Nottingham' +> or locality_1 = 'Nottingham') +> and upper(substring(street from 1 for 1)) = 'A' +> group by street, locality_1, locality_2, city +> order by street +> limit 20 offset 0 + +This might be a lot quicker than pulling all the records like in your example +queries... + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-performance-owner@postgresql.org Thu Sep 1 17:24:48 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1640CD87EA + for ; + Thu, 1 Sep 2005 17:24:42 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 13140-04 + for ; + Thu, 1 Sep 2005 20:24:39 +0000 (GMT) +Received: from mail.mi8.com (d01gw02.mi8.com [63.240.6.46]) + by svr1.postgresql.org (Postfix) with ESMTP id 652F9D7C10 + for ; + Thu, 1 Sep 2005 17:24:37 -0300 (ADT) +Received: from 172.16.1.118 by mail.mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D2)); Thu, 01 Sep 2005 16:24:33 -0400 +X-Server-Uuid: 7829E76E-BB9E-4995-8473-3C0929DF7DD1 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.174]) by + d01smtp03.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Thu, 1 Sep + 2005 16:24:33 -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 ; Thu, 1 Sep + 2005 16:24:32 -0500 +User-Agent: Microsoft-Entourage/11.1.0.040913 +Date: Thu, 01 Sep 2005 13:24:30 -0700 +Subject: Re: Poor performance on HP Package Cluster +From: "Luke Lonergan" +To: "Ernst Einstein" , + pgsql-performance@postgresql.org +Message-ID: +In-Reply-To: <1125584167.6683.21.camel@Thor.decoit.lan> +MIME-Version: 1.0 +X-OriginalArrivalTime: 01 Sep 2005 20:24:33.0374 (UTC) + FILETIME=[2A0EE7E0:01C5AF33] +X-WSS-ID: 6F09BC0B34S1240271-01-01 +Content-Type: text/plain; + charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.574 required=5 tests=[AWL=-0.007, + FORGED_RCVD_HELO=0.05, RCVD_NUMERIC_HELO=1.531] +X-Spam-Level: * +X-Archive-Number: 200509/21 +X-Sequence-Number: 14329 + +Are you using the built-in HP SmartArray RAID/SCSI controllers? If so, that +could be your problem, they are known to have terrible and variable +performance with Linux. + +The only good fix is to add a simple SCSI controller to your system (HP +sells them) and stay away from hardware RAID. + +- Luke + + +On 9/1/05 7:16 AM, "Ernst Einstein" wrote: + +> Hi! +> +> I've set up a Package Cluster ( Fail-Over Cluster ) on our two HP DL380 +> G4 with MSA Storrage G2.( Xeon 3,4Ghz, 6GB Ram, 2x 36GB@15rpm- Raid1) +> The system is running under Suse Linux Enterprise Server. +> +> My problem is, that the performance is very low. On our old Server +> ( Celeron 2Ghz with 2 GB of Ram ) an import of our Data takes about 10 +> minutes. ( 1,1GB data ) +> One of the DL380 it takes more than 90 minutes... +> Selects response time have also been increased. Celeron 3 sec, Xeon +> 30-40sec. +> +> I'm trying to fix the problem for two day's now, googled a lot, but i +> don't know what to do. +> +> Top says, my CPU spends ~50% time with wait io. +> +> top - 14:07:34 up 22 min, 3 users, load average: 1.09, 1.04, 0.78 +> Tasks: 74 total, 3 running, 71 sleeping, 0 stopped, 0 zombie +> Cpu(s): 50.0% us, 5.0% sy, 0.0% ni, 0.0% id, 45.0% wa, 0.0% hi, +> 0.0% si +> Mem: 6050356k total, 982004k used, 5068352k free, 60300k buffers +> Swap: 2097136k total, 0k used, 2097136k free, 786200k cached +> +> PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ +> COMMAND +> 9939 postgres 18 0 254m 143m 140m R 49.3 2.4 8:35.43 postgres: +> postgres plate [local] INSERT +> 9938 postgres 16 0 13720 1440 1120 S 4.9 0.0 0:59.08 psql -d +> plate -f dump.sql +> 10738 root 15 0 3988 1120 840 R 4.9 0.0 0:00.05 top -d +> 0.2 +> 1 root 16 0 640 264 216 S 0.0 0.0 0:05.03 init +> [3] +> 2 root 34 19 0 0 0 S 0.0 0.0 0:00.00 +> [ksoftirqd/0] +> +> vmstat 1: +> +> ClusterNode2 root $ vmstat 1 +> procs -----------memory---------- ---swap-- -----io---- --system-- +> ----cpu---- +> r b swpd free buff cache si so bi bo in cs us sy +> id wa +> 1 0 0 5032012 60888 821008 0 0 216 6938 1952 5049 40 +> 8 15 37 +> 0 1 0 5031392 60892 821632 0 0 0 8152 2126 5725 45 +> 6 0 49 +> 0 1 0 5030896 60900 822144 0 0 0 8124 2052 5731 46 +> 6 0 47 +> 0 1 0 5030400 60908 822768 0 0 0 8144 2124 5717 44 +> 7 0 50 +> 1 0 0 5029904 60924 823272 0 0 0 8304 2062 5763 43 +> 7 0 49 +> +> I've read (2004), that Xeon may have problems with content switching - +> is the problem still existing? Can I do something to minimize the +> problem? +> +> +> postgresql.conf: +> +> shared_buffers = 28672 +> effective_cache_size = 400000 +> random_page_cost = 2 +> +> +> shmall & shmmax are set to 268435456 +> +> hdparm: +> +> ClusterNode2 root $ hdparm -tT /dev/cciss/c0d0p1 +> +> /dev/cciss/c0d0p1: +> Timing buffer-cache reads: 3772 MB in 2.00 seconds = 1885.34 MB/sec +> Timing buffered disk reads: 150 MB in 2.06 seconds = 72.72 MB/sec +> +> greetings Ernst +> +> +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: Don't 'kill -9' the postmaster +> + + + +From pgsql-performance-owner@postgresql.org Thu Sep 1 17:28:47 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C2C31D87EA + for ; + Thu, 1 Sep 2005 17:25:33 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 13142-06 + for ; + Thu, 1 Sep 2005 20:25:29 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id E7B6ED8534 + for ; + Thu, 1 Sep 2005 17:25:28 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j81KPTj7006093; + Thu, 1 Sep 2005 16:25:29 -0400 (EDT) +To: Ron +Cc: Matthew Sackman , + pgsql-performance@postgresql.org +Subject: Re: Massive performance issues +In-reply-to: <6.2.3.4.0.20050901145054.021b1678@pop.earthlink.net> +References: <20050901174231.GE23970@pongo.lshift.net> + <6.2.3.4.0.20050901145054.021b1678@pop.earthlink.net> +Comments: In-reply-to Ron + message dated "Thu, 01 Sep 2005 15:43:01 -0400" +Date: Thu, 01 Sep 2005 16:25:29 -0400 +Message-ID: <6092.1125606329@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/22 +X-Sequence-Number: 14330 + +Ron writes: +> ... Your target is to have each row take <= 512B. + +Ron, are you assuming that the varchar fields are blank-padded or +something? I think it's highly unlikely that he's got more than a +couple hundred bytes per row right now --- at least if the data is +what it sounds like. + +The upthread comment about strcoll() set off some alarm bells in my head. +If the database wasn't initdb'd in C locale already, try making it so. +Also, use a single-byte encoding if you can (LatinX is fine, Unicode not). + +> Upgrade pg to 8.0.3 and make sure you have enough RAM for your real +> day to day load. + +Newer PG definitely better. Some attention to the configuration +parameters might also be called for. I fear though that these things +are probably just chipping at the margins ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Sep 1 17:39:33 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7EC7DD889D + for ; + Thu, 1 Sep 2005 17:39:31 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 14336-09 + for ; + Thu, 1 Sep 2005 20:39:28 +0000 (GMT) +Received: from dd01.profihoster.net (dd01.profihoster.net [84.233.130.40]) + by svr1.postgresql.org (Postfix) with ESMTP id EF00FD8622 + for ; + Thu, 1 Sep 2005 17:39:26 -0300 (ADT) +Received: from [192.168.54.33] (I95a4.i.pppool.de [85.73.149.164]) + by dd01.profihoster.net (Postfix) with ESMTP id 58C882380EF; + Thu, 1 Sep 2005 22:38:18 +0200 (CEST) +Message-ID: <431766F1.6080501@laliluna.de> +Date: Thu, 01 Sep 2005 22:39:13 +0200 +From: Sebastian Hennebrueder +User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) +X-Accept-Language: de-DE, de, en-us, en +MIME-Version: 1.0 +To: Matthew Sackman +Cc: pgsql-performance@postgresql.org +Subject: Re: Massive performance issues +References: <20050901174231.GE23970@pongo.lshift.net> +In-Reply-To: <20050901174231.GE23970@pongo.lshift.net> +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/23 +X-Sequence-Number: 14331 + +Matthew Sackman schrieb: + +>Hi, +> +>I'm having performance issues with a table consisting of 2,043,133 rows. The +>schema is: +> +>\d address +> Table "public.address" +> Column | Type | Modifiers +>----------------------+------------------------+----------- +> postcode_top | character varying(2) | not null +> postcode_middle | character varying(4) | not null +> postcode_bottom | character varying(7) | not null +> postcode | character varying(10) | not null +> property_type | character varying(15) | not null +> sale_type | character varying(10) | not null +> flat_extra | character varying(100) | not null +> number | character varying(100) | not null +> street | character varying(100) | not null +> locality_1 | character varying(100) | not null +> locality_2 | character varying(100) | not null +> city | character varying(100) | not null +> county | character varying(100) | not null +>Indexes: +> "address_city_index" btree (city) +> "address_county_index" btree (county) +> "address_locality_1_index" btree (locality_1) +> "address_locality_2_index" btree (locality_2) +> "address_pc_bottom_index" btree (postcode_bottom) +> "address_pc_middle_index" btree (postcode_middle) +> "address_pc_top_index" btree (postcode_top) +> "address_pc_top_middle_bottom_index" btree (postcode_top, +> postcode_middle, postcode_bottom) +> "address_pc_top_middle_index" btree (postcode_top, postcode_middle) +> "address_postcode_index" btree (postcode) +> "address_property_type_index" btree (property_type) +> "address_street_index" btree (street) +> "street_prefix" btree (lower("substring"((street)::text, 1, 1))) +> +>This is with postgresql 7.4 running on linux 2.6.11 with a 3GHz P4 and a +>SATA harddrive. +> +>Queries such as: +> +>select locality_2 from address where locality_2 = 'Manchester'; +> +>are taking 14 seconds to complete, and this is only 2 years worth of +>data - we will have up to 15 years (so over 15 million rows). +> +>Interestingly, doing: +>explain select locality_2 from address where locality_2 = 'Manchester'; +>gives +> QUERY PLAN +>---------------------------------------------------------------- +> Seq Scan on address (cost=0.00..80677.16 rows=27923 width=12) +> Filter: ((locality_2)::text = 'Manchester'::text) +> +>but: +>explain select locality_1 from address where locality_1 = 'Manchester'; +>gives +> QUERY PLAN +>---------------------------------------------------------------- +> Index Scan using address_locality_1_index on address +>(cost=0.00..69882.18 rows=17708 width=13) +> Index Cond: ((locality_1)::text = 'Manchester'::text) +> +>Sadly, using the index makes things worse, the query taking 17 seconds. +> +>locality_1 has 16650 distinct values and locality_2 has 1156 distinct +>values. +> +>Whilst the locality_2 query is in progress, both the disk and the CPU +>are maxed out with the disk constantly reading at 60MB/s and the CPU +>rarely dropping under 100% load. +> +>With the locality_1 query in progress, the CPU is maxed out but the disk +>is reading at just 3MB/s. +> +>Obviously, to me, this is a problem, I need these queries to be under a +>second to complete. Is this unreasonable? What can I do to make this "go +>faster"? I've considered normalising the table but I can't work out +>whether the slowness is in dereferencing the pointers from the index +>into the table or in scanning the index in the first place. And +>normalising the table is going to cause much pain when inserting values +>and I'm not entirely sure if I see why normalising it should cause a +>massive performance improvement. +> +> +> +Just an idea: When you do not want to adapt your application to use a +normalized database you may push the data into normalized table using +triggers. +Example: +Add a table city with column id, name +and add a column city_id to your main table. +In this case you have redundant data in your main table (locality_1 and +city_id) but you could make queries to the city table when searching for +'Man%' + +-- +Best Regards / Viele Gr��e + +Sebastian Hennebrueder + +---- + +http://www.laliluna.de + +Tutorials for JSP, JavaServer Faces, Struts, Hibernate and EJB + +Get support, education and consulting for these technologies. + + +From pgsql-performance-owner@postgresql.org Thu Sep 1 17:55:16 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CBF4BD88FF + for ; + Thu, 1 Sep 2005 17:54:40 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18524-10 + for ; + Thu, 1 Sep 2005 20:54:39 +0000 (GMT) +Received: from olive.qinip.net (olive.qinip.net [62.100.30.40]) + by svr1.postgresql.org (Postfix) with ESMTP id D53A6D88A6 + for ; + Thu, 1 Sep 2005 17:54:38 -0300 (ADT) +Received: from [10.0.0.2] (h8441139206.dsl.speedlinq.nl [84.41.139.206]) + by olive.qinip.net (Postfix) with ESMTP + id 4AB47180CD; Thu, 1 Sep 2005 22:54:36 +0200 (MEST) +Message-ID: <43176A95.70506@tweakers.net> +Date: Thu, 01 Sep 2005 22:54:45 +0200 +From: Arjen van der Meijden +User-Agent: Mozilla Thunderbird 1.0RC1 (Windows/20041201) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Matthew Sackman +Cc: pgsql-performance@postgresql.org +Subject: Re: Massive performance issues +References: <20050901174231.GE23970@pongo.lshift.net> +In-Reply-To: <20050901174231.GE23970@pongo.lshift.net> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/24 +X-Sequence-Number: 14332 + +On 1-9-2005 19:42, Matthew Sackman wrote: +> Obviously, to me, this is a problem, I need these queries to be under a +> second to complete. Is this unreasonable? What can I do to make this "go +> faster"? I've considered normalising the table but I can't work out +> whether the slowness is in dereferencing the pointers from the index +> into the table or in scanning the index in the first place. And +> normalising the table is going to cause much pain when inserting values +> and I'm not entirely sure if I see why normalising it should cause a +> massive performance improvement. + +In this case, I think normalising will give a major decrease in on-disk +table-size of this large table and the indexes you have. If that's the +case, that in itself will speed-up all i/o-bound queries quite a bit. + +locality_1, _2, city and county can probably be normalised away without +much problem, but going from varchar's to integers will probably safe +you quite a bit of (disk)space. + +But since it won't change the selectivity of indexes, so you won't get +more index-scans instead of sequential scans, I suppose. +I think its not that hard to create a normalized set of tables from this + data-set (using insert into tablename select distinct ... from address +and such, insert into address_new (..., city) select ... (select cityid +from cities where city = address.city) from address) +So its at least relatively easy to figure out the performance +improvement from normalizing the dataset a bit. + +If you want to improve your hardware, have a look at the Western Digital +Raptor-series SATA disks, they are fast scsi-like SATA drives. You may +also have a look at the amount of memory available, to allow caching +this (entire) table. + +Best regards, + +Arjen + +From pgsql-performance-owner@postgresql.org Thu Sep 1 18:05:41 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A8B33D857B + for ; + Thu, 1 Sep 2005 18:05:40 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 23228-01 + for ; + Thu, 1 Sep 2005 21:05:38 +0000 (GMT) +Received: from smtpauth03.mail.atl.earthlink.net + (smtpauth03.mail.atl.earthlink.net [209.86.89.63]) + by svr1.postgresql.org (Postfix) with ESMTP id D9CA8D8572 + for ; + Thu, 1 Sep 2005 18:05:37 -0300 (ADT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=SvVFwdW6lq8/d01mZ0MpuWGV0NSXIlx/IDaQuZ59QdWVr0ZmCjptZmjL2zNILkeM; + h=Received:Message-Id:X-Mailer:Date:To:From:Subject:In-Reply-To:References:Mime-Version:Content-Type:X-ELNK-Trace:X-Originating-IP; +Received: from [24.41.3.216] (helo=RJP-01.earthlink.net) + by smtpauth03.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1EAwFf-0000YI-2D; Thu, 01 Sep 2005 17:05:39 -0400 +Message-Id: <6.2.3.4.0.20050901163955.021b3708@pop.earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 6.2.3.4 +Date: Thu, 01 Sep 2005 17:05:33 -0400 +To: Tom Lane , pgsql-performance@postgresql.org +From: Ron +Subject: Re: Massive performance issues +In-Reply-To: <6092.1125606329@sss.pgh.pa.us> +References: <20050901174231.GE23970@pongo.lshift.net> + <6.2.3.4.0.20050901145054.021b1678@pop.earthlink.net> + <6092.1125606329@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bcea9eab727269858dfa2188a6bdcfde63350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 24.41.3.216 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.382 required=5 tests=[AWL=0.008, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200509/25 +X-Sequence-Number: 14333 + +At 04:25 PM 9/1/2005, Tom Lane wrote: +>Ron writes: +> > ... Your target is to have each row take <= 512B. +> +>Ron, are you assuming that the varchar fields are blank-padded or +>something? I think it's highly unlikely that he's got more than a +>couple hundred bytes per row right now --- at least if the data is +>what it sounds like. + +As it stands, each row will take 55B - 748B and each field is +variable in size up to the maximums given in the OP's schema. Since +pg uses an underlying OS FS, and not a native one, there will be +extra FS overhead no matter what we do, particularly to accommodate +such flexibility... The goal is to minimize overhead and maximize +regularity in layout. The recipe I know for HD IO speed is in +keeping the data small, regular, and as simple as possible. + +Even better, if the table(s) can be made RAM resident, then searches, +even random ones, can be very fast. He wants a 1000x performance +improvement. Going from disk resident to RAM resident should help +greatly in attaining that goal. + +In addition, by replacing as many variable sized text strings as +possible with ints, the actual compare functions he used as examples +should run faster as well. + + +>The upthread comment about strcoll() set off some alarm bells in my +>head. If the database wasn't initdb'd in C locale already, try +>making it so. Also, use a single-byte encoding if you can (LatinX +>is fine, Unicode not). + +Good thoughts I hadn't had. + + +> > Upgrade pg to 8.0.3 and make sure you have enough RAM for your real +> > day to day load. +> +>Newer PG definitely better. Some attention to the configuration +>parameters might also be called for. I fear though that these +>things are probably just chipping at the margins ... + +I don't expect 8.0.3 to be a major performance improvement. I do +expect it to be a major _maintenance_ improvement for both him and +those of us trying to help him ;-) + +The performance difference between not having the working set of the +DB fit into RAM during ordinary operation vs having it be so (or +better, having the whole DB fit into RAM during ordinary operation) +has been considerably more effective than "chipping at the margins" +IME. Especially so if the HD IO subsystem is wimpy. + +Ron Peacetree + + + +From pgsql-performance-owner@postgresql.org Thu Sep 1 18:06:53 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C79B0D881A + for ; + Thu, 1 Sep 2005 18:06:28 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 21357-08 + for ; + Thu, 1 Sep 2005 21:06:26 +0000 (GMT) +Received: from newman.lshift.net (host226.lshift.net [195.172.218.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 76F21D8873 + for ; + Thu, 1 Sep 2005 18:06:24 -0300 (ADT) +Received: (qmail 13058 invoked by uid 1004); 1 Sep 2005 21:06:26 -0000 +Received: from 10.224.189.77 by newman (envelope-from , + uid 64011) with qmail-scanner-1.24 (clamdscan: 0.80/627. + Clear:RC:1(10.224.189.77):. + Processed in 0.014259 secs); 01 Sep 2005 21:06:26 -0000 +Received: from ponder.lshift.net (HELO localhost) ([10.224.189.77]) + (envelope-sender ) + by newman.lshift.net (qmail-ldap-1.03) with AES256-SHA encrypted SMTP + for ; 1 Sep 2005 21:06:26 -0000 +Date: Thu, 1 Sep 2005 22:06:26 +0100 +From: Matthew Sackman +To: pgsql-performance@postgresql.org +Subject: Re: Massive performance issues +Message-ID: <20050901210626.GC7131@pongo.lshift.net> +Mail-Followup-To: pgsql-performance@postgresql.org +References: <20050901174231.GE23970@pongo.lshift.net> + <20050901200930.GA23339@uio.no> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20050901200930.GA23339@uio.no> +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.249 required=5 tests=[AWL=-0.125, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200509/26 +X-Sequence-Number: 14334 + +On Thu, Sep 01, 2005 at 10:09:30PM +0200, Steinar H. Gunderson wrote: +> > "address_city_index" btree (city) +> > "address_county_index" btree (county) +> > "address_locality_1_index" btree (locality_1) +> > "address_locality_2_index" btree (locality_2) +> > "address_pc_bottom_index" btree (postcode_bottom) +> > "address_pc_middle_index" btree (postcode_middle) +> > "address_pc_top_index" btree (postcode_top) +> > "address_pc_top_middle_bottom_index" btree (postcode_top, +> > postcode_middle, postcode_bottom) +> > "address_pc_top_middle_index" btree (postcode_top, postcode_middle) +> > "address_postcode_index" btree (postcode) +> > "address_property_type_index" btree (property_type) +> > "address_street_index" btree (street) +> > "street_prefix" btree (lower("substring"((street)::text, 1, 1))) +> +> Wow, that's quite a lof of indexes... but your problem isn't reported as +> being in insert/update/delete. + +Hah, well now that you mention it. Basically, 100,000 rows come in in a +bulk import every month and the only way I can get it to complete in any +sane time frame at all is to drop the indexes, do the import and then +recreate the indexes. But that's something that I'm OK with - the +imports don't have to be that fast and whilst important, it's not *the* +critical path. Selection from the database is, hence the indexes. + +> > This is with postgresql 7.4 running on linux 2.6.11 with a 3GHz P4 and a +> > SATA harddrive. +> +> 8.0 or 8.1 might help you some -- better (and more!) disks will probably help +> a _lot_. + +Ok, I did try 8.0 when I started this and found that the server bind +parameters (both via DBD::Pg (with pg_prepare_server => 1) and via JDBC +(various versions I tried)) failed - the parameters were clearly not +being substituted. This was Postgresql 8.0 from Debian unstable. That +was a couple of weeks ago and I've not been back to check whether its +been fixed. Anyway, because of these problems I dropped back to 7.4. + +> > Queries such as: +> > +> > select locality_2 from address where locality_2 = 'Manchester'; +> > +> > are taking 14 seconds to complete, and this is only 2 years worth of +> > data - we will have up to 15 years (so over 15 million rows). +> +> As Tom pointed out; you're effectively doing random searches here, and using +> CLUSTER might help. Normalizing your data to get smaller rows (and avoid +> possibly costly string comparisons if your strcoll() is slow) will probably +> also help. + +Ok, so you're saying that joining the address table into an address_city +table (the obvious normalization) will help here? + +The locale settings in postgresql.conf all have en_GB and a \l shows +encoding of LATIN1. So I don't think I've set anything to UTF8 or such +like. + +> > I need to get to the stage where I can run queries such as: +> > select street, locality_1, locality_2, city from address +> > where (city = 'Nottingham' or locality_2 = 'Nottingham' +> > or locality_1 = 'Nottingham') +> > and upper(substring(street from 1 for 1)) = 'A' +> > group by street, locality_1, locality_2, city +> > order by street +> > limit 20 offset 0 +> +> This might be a lot quicker than pulling all the records like in your example +> queries... + +Yes, that certainly does seem to be the case - around 4 seconds. But I +need it to be 10 times faster (or thereabouts) otherwise I have big +problems! + +Many thanks for all the advice so far. + +Matthew + + +From pgsql-performance-owner@postgresql.org Thu Sep 1 18:14:01 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A1D59D8836 + for ; + Thu, 1 Sep 2005 18:14:00 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 23374-03 + for ; + Thu, 1 Sep 2005 21:13:58 +0000 (GMT) +Received: from newman.lshift.net (host226.lshift.net [195.172.218.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 1588FD8805 + for ; + Thu, 1 Sep 2005 18:13:57 -0300 (ADT) +Received: (qmail 13590 invoked by uid 1004); 1 Sep 2005 21:13:59 -0000 +Received: from 10.224.189.77 by newman (envelope-from , + uid 64011) with qmail-scanner-1.24 (clamdscan: 0.80/627. + Clear:RC:1(10.224.189.77):. + Processed in 0.014165 secs); 01 Sep 2005 21:13:59 -0000 +Received: from ponder.lshift.net (HELO localhost) ([10.224.189.77]) + (envelope-sender ) + by newman.lshift.net (qmail-ldap-1.03) with AES256-SHA encrypted SMTP + for ; 1 Sep 2005 21:13:59 -0000 +Date: Thu, 1 Sep 2005 22:13:59 +0100 +From: Matthew Sackman +To: pgsql-performance@postgresql.org +Subject: Re: Massive performance issues +Message-ID: <20050901211359.GD7131@pongo.lshift.net> +Mail-Followup-To: pgsql-performance@postgresql.org +References: <20050901174231.GE23970@pongo.lshift.net> + <43176A95.70506@tweakers.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <43176A95.70506@tweakers.net> +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.267 required=5 tests=[AWL=-0.107, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200509/27 +X-Sequence-Number: 14335 + +On Thu, Sep 01, 2005 at 10:54:45PM +0200, Arjen van der Meijden wrote: +> On 1-9-2005 19:42, Matthew Sackman wrote: +> >Obviously, to me, this is a problem, I need these queries to be under a +> >second to complete. Is this unreasonable? What can I do to make this "go +> >faster"? I've considered normalising the table but I can't work out +> >whether the slowness is in dereferencing the pointers from the index +> >into the table or in scanning the index in the first place. And +> >normalising the table is going to cause much pain when inserting values +> >and I'm not entirely sure if I see why normalising it should cause a +> >massive performance improvement. +> +> In this case, I think normalising will give a major decrease in on-disk +> table-size of this large table and the indexes you have. If that's the +> case, that in itself will speed-up all i/o-bound queries quite a bit. + +Well that's the thing - on the queries where it decides to use the index +it only reads at around 3MB/s and the CPU is maxed out, whereas when it +doesn't use the index, the disk is being read at 60MB/s. So when it +decides to use an index, I don't seem to be IO bound at all. Or at least +that's the way it seems to me. + +> locality_1, _2, city and county can probably be normalised away without +> much problem, but going from varchar's to integers will probably safe +> you quite a bit of (disk)space. + +Sure, that's what I've been considering today. + +> But since it won't change the selectivity of indexes, so you won't get +> more index-scans instead of sequential scans, I suppose. +> I think its not that hard to create a normalized set of tables from this +> data-set (using insert into tablename select distinct ... from address +> and such, insert into address_new (..., city) select ... (select cityid +> from cities where city = address.city) from address) +> So its at least relatively easy to figure out the performance +> improvement from normalizing the dataset a bit. + +Yeah, the initial creation isn't too painful but when adding rows into +the address table it gets more painful. However, as I've said elsewhere, +the import isn't the critical path so I can cope with that pain, +possibly coding around it in a stored proceedure and triggers as +suggested. + +> If you want to improve your hardware, have a look at the Western Digital +> Raptor-series SATA disks, they are fast scsi-like SATA drives. You may +> also have a look at the amount of memory available, to allow caching +> this (entire) table. + +Well I've got 1GB of RAM, but from analysis of its use, a fair amount +isn't being used. About 50% is actually in use by applications and about +half of the rest is cache and the rest isn't being used. Has this to do +with the max_fsm_pages and max_fsm_relations settings? I've pretty much +not touched the configuration and it's the standard Debian package. + +Matthew + +From pgsql-performance-owner@postgresql.org Thu Sep 1 18:30:44 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3D889D868E + for ; + Thu, 1 Sep 2005 18:27:11 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25148-08 + for ; + Thu, 1 Sep 2005 21:27:06 +0000 (GMT) +Received: from smtp104.sbc.mail.mud.yahoo.com (smtp104.sbc.mail.mud.yahoo.com + [68.142.198.203]) + by svr1.postgresql.org (Postfix) with SMTP id A9543D6FA7 + for ; + Thu, 1 Sep 2005 18:27:02 -0300 (ADT) +Received: (qmail 16706 invoked from network); 1 Sep 2005 21:26:54 -0000 +Received: from unknown (HELO discord.dyndns.org) + (jeffroe996@sbcglobal.net@69.227.49.205 with plain) + by smtp104.sbc.mail.mud.yahoo.com with SMTP; 1 Sep 2005 21:26:53 -0000 +Received: from localhost (localhost.localdomain [127.0.0.1]) + by discord.dyndns.org (8.13.4/8.13.4) with ESMTP id j81LQl1Z013177; + Thu, 1 Sep 2005 14:26:47 -0700 +Date: Thu, 1 Sep 2005 14:26:47 -0700 (PDT) +From: Jeff Frost +X-X-Sender: jeff@discord.dyndns.org +To: Matthew Sackman +Cc: pgsql-performance@postgresql.org +Subject: Re: Massive performance issues +In-Reply-To: <20050901211359.GD7131@pongo.lshift.net> +Message-ID: +References: <20050901174231.GE23970@pongo.lshift.net> + <43176A95.70506@tweakers.net> + <20050901211359.GD7131@pongo.lshift.net> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.026 required=5 tests=[AWL=0.026] +X-Spam-Level: +X-Archive-Number: 200509/28 +X-Sequence-Number: 14336 + +> Well I've got 1GB of RAM, but from analysis of its use, a fair amount +> isn't being used. About 50% is actually in use by applications and about +> half of the rest is cache and the rest isn't being used. Has this to do +> with the max_fsm_pages and max_fsm_relations settings? I've pretty much +> not touched the configuration and it's the standard Debian package. + +Matt, have a look at the annotated postgresql.conf for 7.x here: + +http://www.varlena.com/varlena/GeneralBits/Tidbits/annotated_conf_e.html + +If you have the default settings, you're likely hampering yourself quite a +bit. You probably care about shared_buffers, sort_mem, +vacuum_mem, max_fsm_pages, effective_cache_size + +Also, you may want to read the PostgreSQL 8.0 Performance Checklist. Even +though it's for 8.0, it'll give you good ideas on what to change in 7.4. You +can find it here: http://www.powerpostgresql.com/PerfList/ + +-- +Jeff Frost, Owner +Frost Consulting, LLC http://www.frostconsultingllc.com/ +Phone: 650-780-7908 FAX: 650-649-1954 + +From pgsql-performance-owner@postgresql.org Thu Sep 1 18:53:15 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E31A0D881A + for ; + Thu, 1 Sep 2005 18:52:49 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 33241-08 + for ; + Thu, 1 Sep 2005 21:52:47 +0000 (GMT) +Received: from cassarossa.samfundet.no (cassarossa.samfundet.no + [129.241.93.19]) + by svr1.postgresql.org (Postfix) with ESMTP id B7172D8792 + for ; + Thu, 1 Sep 2005 18:52:45 -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 1EAwzG-0003DY-AG + for pgsql-performance@postgresql.org; Thu, 01 Sep 2005 23:52:47 +0200 +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1EAwzF-0001Ji-00 + for ; Thu, 01 Sep 2005 23:52:45 +0200 +Date: Thu, 1 Sep 2005 23:52:45 +0200 +From: "Steinar H. Gunderson" +To: pgsql-performance@postgresql.org +Subject: Re: Massive performance issues +Message-ID: <20050901215245.GA4242@uio.no> +Mail-Followup-To: pgsql-performance@postgresql.org +References: <20050901174231.GE23970@pongo.lshift.net> + <43176A95.70506@tweakers.net> + <20050901211359.GD7131@pongo.lshift.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Disposition: inline +In-Reply-To: <20050901211359.GD7131@pongo.lshift.net> +X-Operating-System: Linux 2.6.11.8 on a i686 +X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.014 required=5 tests=[AWL=0.014] +X-Spam-Level: +X-Archive-Number: 200509/29 +X-Sequence-Number: 14337 + +On Thu, Sep 01, 2005 at 10:13:59PM +0100, Matthew Sackman wrote: +> Well that's the thing - on the queries where it decides to use the index +> it only reads at around 3MB/s and the CPU is maxed out, whereas when it +> doesn't use the index, the disk is being read at 60MB/s. So when it +> decides to use an index, I don't seem to be IO bound at all. Or at least +> that's the way it seems to me. + +You are I/O bound; your disk is doing lots and lots of seeks. The SATA +interface is not the bottleneck; the disk's ability to rotate and move its +heads is. + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-performance-owner@postgresql.org Thu Sep 1 19:01:44 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D108ED88E8 + for ; + Thu, 1 Sep 2005 19:00:11 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 33593-09 + for ; + Thu, 1 Sep 2005 22:00:07 +0000 (GMT) +Received: from newman.lshift.net (host226.lshift.net [195.172.218.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 76A64D8912 + for ; + Thu, 1 Sep 2005 19:00:05 -0300 (ADT) +Received: (qmail 16630 invoked by uid 1004); 1 Sep 2005 22:00:08 -0000 +Received: from 10.224.189.77 by newman (envelope-from , + uid 64011) with qmail-scanner-1.24 (clamdscan: 0.80/627. + Clear:RC:1(10.224.189.77):. + Processed in 0.013884 secs); 01 Sep 2005 22:00:08 -0000 +Received: from ponder.lshift.net (HELO localhost) ([10.224.189.77]) + (envelope-sender ) + by newman.lshift.net (qmail-ldap-1.03) with AES256-SHA encrypted SMTP + for ; 1 Sep 2005 22:00:07 -0000 +Date: Thu, 1 Sep 2005 23:00:07 +0100 +From: Matthew Sackman +To: pgsql-performance@postgresql.org +Subject: Re: Massive performance issues +Message-ID: <20050901220007.GE7131@pongo.lshift.net> +Mail-Followup-To: pgsql-performance@postgresql.org +References: <20050901174231.GE23970@pongo.lshift.net> + <43176A95.70506@tweakers.net> + <20050901211359.GD7131@pongo.lshift.net> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.262 required=5 tests=[AWL=-0.112, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200509/30 +X-Sequence-Number: 14338 + +On Thu, Sep 01, 2005 at 02:26:47PM -0700, Jeff Frost wrote: +> >Well I've got 1GB of RAM, but from analysis of its use, a fair amount +> >isn't being used. About 50% is actually in use by applications and about +> >half of the rest is cache and the rest isn't being used. Has this to do +> >with the max_fsm_pages and max_fsm_relations settings? I've pretty much +> >not touched the configuration and it's the standard Debian package. +> +> Matt, have a look at the annotated postgresql.conf for 7.x here: +> +> http://www.varlena.com/varlena/GeneralBits/Tidbits/annotated_conf_e.html +> +> If you have the default settings, you're likely hampering yourself quite a +> bit. You probably care about shared_buffers, sort_mem, +> vacuum_mem, max_fsm_pages, effective_cache_size + +That's a useful resource, thanks for the pointer. I'll work through that +tomorrow. + +> Also, you may want to read the PostgreSQL 8.0 Performance Checklist. Even +> though it's for 8.0, it'll give you good ideas on what to change in 7.4. +> You can find it here: http://www.powerpostgresql.com/PerfList/ + +Thanks, another good resource. I'll work through that too. + +Matthew + +From pgsql-performance-owner@postgresql.org Thu Sep 1 19:25:58 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 42398D8917 + for ; + Thu, 1 Sep 2005 19:01:58 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37957-02 + for ; + Thu, 1 Sep 2005 22:01:56 +0000 (GMT) +Received: from newman.lshift.net (host226.lshift.net [195.172.218.226]) + by svr1.postgresql.org (Postfix) with ESMTP id EF9C0D8915 + for ; + Thu, 1 Sep 2005 19:01:55 -0300 (ADT) +Received: (qmail 16724 invoked by uid 1004); 1 Sep 2005 22:01:58 -0000 +Received: from 10.224.189.77 by newman (envelope-from , + uid 64011) with qmail-scanner-1.24 (clamdscan: 0.80/627. + Clear:RC:1(10.224.189.77):. + Processed in 0.013894 secs); 01 Sep 2005 22:01:58 -0000 +Received: from ponder.lshift.net (HELO localhost) ([10.224.189.77]) + (envelope-sender ) + by newman.lshift.net (qmail-ldap-1.03) with AES256-SHA encrypted SMTP + for ; 1 Sep 2005 22:01:58 -0000 +Date: Thu, 1 Sep 2005 23:01:58 +0100 +From: Matthew Sackman +To: pgsql-performance@postgresql.org +Subject: Re: Massive performance issues +Message-ID: <20050901220158.GF7131@pongo.lshift.net> +Mail-Followup-To: pgsql-performance@postgresql.org +References: <20050901174231.GE23970@pongo.lshift.net> + <43176A95.70506@tweakers.net> + <20050901211359.GD7131@pongo.lshift.net> + <20050901215245.GA4242@uio.no> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20050901215245.GA4242@uio.no> +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.272 required=5 tests=[AWL=-0.102, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200509/32 +X-Sequence-Number: 14340 + +On Thu, Sep 01, 2005 at 11:52:45PM +0200, Steinar H. Gunderson wrote: +> On Thu, Sep 01, 2005 at 10:13:59PM +0100, Matthew Sackman wrote: +> > Well that's the thing - on the queries where it decides to use the index +> > it only reads at around 3MB/s and the CPU is maxed out, whereas when it +> > doesn't use the index, the disk is being read at 60MB/s. So when it +> > decides to use an index, I don't seem to be IO bound at all. Or at least +> > that's the way it seems to me. +> +> You are I/O bound; your disk is doing lots and lots of seeks. The SATA +> interface is not the bottleneck; the disk's ability to rotate and move its +> heads is. + +Ahh of course (/me hits head against wall). Because I've /seen/ it read +at 60MB/s I was assuming that if it wasn't reading that fast then I'm +not IO bound but of course, it's not reading sequentially. That all +makes sense. Been a long day etc... ;-) + +Matthew + +From pgsql-performance-owner@postgresql.org Thu Sep 1 19:15:30 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 65F76D888B + for ; + Thu, 1 Sep 2005 19:05:50 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37740-04 + for ; + Thu, 1 Sep 2005 22:05:47 +0000 (GMT) +Received: from smtpauth06.mail.atl.earthlink.net + (smtpauth06.mail.atl.earthlink.net [209.86.89.66]) + by svr1.postgresql.org (Postfix) with ESMTP id 0B8ADD8835 + for ; + Thu, 1 Sep 2005 19:05:46 -0300 (ADT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=ihXb6KovYqG7kvViXMbRpxhl/dU9HGtosbLhAc1B2DEXAVX/zWkvIWDodL5O2062; + h=Received:Message-Id:X-Mailer:Date:To:From:Subject:In-Reply-To:References:Mime-Version:Content-Type:X-ELNK-Trace:X-Originating-IP; +Received: from [24.41.3.216] (helo=RJP-01.earthlink.net) + by smtpauth06.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1EAxBr-0001HI-Qb; Thu, 01 Sep 2005 18:05:47 -0400 +Message-Id: <6.2.3.4.0.20050901173454.021c5730@pop.earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 6.2.3.4 +Date: Thu, 01 Sep 2005 18:05:43 -0400 +To: Matthew Sackman , + pgsql-performance@postgresql.org +From: Ron +Subject: Re: Massive performance issues +In-Reply-To: <20050901210626.GC7131@pongo.lshift.net> +References: <20050901174231.GE23970@pongo.lshift.net> + <20050901200930.GA23339@uio.no> + <20050901210626.GC7131@pongo.lshift.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bccae8c97a0bf3bb18921bc4c43e82e000350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 24.41.3.216 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.379 required=5 tests=[AWL=0.005, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200509/31 +X-Sequence-Number: 14339 + +At 05:06 PM 9/1/2005, Matthew Sackman wrote: +>On Thu, Sep 01, 2005 at 10:09:30PM +0200, Steinar H. Gunderson wrote: +> > > "address_city_index" btree (city) +> > > "address_county_index" btree (county) +> > > "address_locality_1_index" btree (locality_1) +> > > "address_locality_2_index" btree (locality_2) +> > > "address_pc_bottom_index" btree (postcode_bottom) +> > > "address_pc_middle_index" btree (postcode_middle) +> > > "address_pc_top_index" btree (postcode_top) +> > > "address_pc_top_middle_bottom_index" btree (postcode_top, +> > > postcode_middle, postcode_bottom) +> > > "address_pc_top_middle_index" btree (postcode_top, postcode_middle) +> > > "address_postcode_index" btree (postcode) +> > > "address_property_type_index" btree (property_type) +> > > "address_street_index" btree (street) +> > > "street_prefix" btree (lower("substring"((street)::text, 1, 1))) +> > +> > Wow, that's quite a lof of indexes... but your problem isn't reported as +> > being in insert/update/delete. +> +>Hah, well now that you mention it. Basically, 100,000 rows come in in a +>bulk import every month and the only way I can get it to complete in any +>sane time frame at all is to drop the indexes, do the import and then +>recreate the indexes. But that's something that I'm OK with - + +FTR, this "drop the indexes, do , recreate the indexes" is +Industry Standard Practice for bulk +inserts/updates/deletes. Regardless of DB product used. + + +> - the imports don't have to be that fast and whilst important, +> it's not *the* +>critical path. Selection from the database is, hence the indexes. + +A DB _without_ indexes that fits into RAM during ordinary operation +may actually be faster than a DB _with_ indexes that does +not. Fitting the entire DB into RAM during ordinary operation if at +all possible should be the first priority with a small data mine-like +application such as you've described. + +Also normalization is _not_ always a good thing for data mining like +apps. Having most or everything you need in one place in a compact +and regular format is usually more effective for data mines than "Nth +Order Normal Form" optimization to the degree usually found in +textbooks using OLTP-like examples. + +Indexes are a complication used as a performance enhancing technique +because without them the DB is not performing well enough. IME, it's +usually better to get as much performance as one can from other +aspects of design and _then_ start adding complications. Including +indexes. Even if you fit the whole DB in RAM, you are very likely to +need some indexes; but profile your performance first and then add +indexes as needed rather than just adding them willy nilly early in +the design process. + +You said you had 1GB of RAM on the machine now. That clearly is +inadequate to your desired performance given what you said about the +DB. Crank that box to 4GB and tighten up your data structures. Then +see where you are. + + +> > > This is with postgresql 7.4 running on linux 2.6.11 with a 3GHz P4 and a +> > > SATA harddrive. +> > +> > 8.0 or 8.1 might help you some -- better (and more!) disks will +> probably help +> > a _lot_. +> +>Ok, I did try 8.0 when I started this and found that the server bind +>parameters (both via DBD::Pg (with pg_prepare_server => 1) and via JDBC +>(various versions I tried)) failed - the parameters were clearly not +>being substituted. This was Postgresql 8.0 from Debian unstable. That +>was a couple of weeks ago and I've not been back to check whether its +>been fixed. Anyway, because of these problems I dropped back to 7.4. + +Since I assume you are not going to run anything with the string +"unstable" in its name in production (?!), why not try a decent +production ready distro like SUSE 9.x and see how pg 8.0.3 runs on a +OS more representative of what you are likely (or at least what is +safe...) to run in production? + + +> > > Queries such as: +> > > +> > > select locality_2 from address where locality_2 = 'Manchester'; +> > > +> > > are taking 14 seconds to complete, and this is only 2 years worth of +> > > data - we will have up to 15 years (so over 15 million rows). +> > +> > As Tom pointed out; you're effectively doing random searches +> here, and using +> > CLUSTER might help. Normalizing your data to get smaller rows (and avoid +> > possibly costly string comparisons if your strcoll() is slow) will probably +> > also help. +> +>Ok, so you're saying that joining the address table into an address_city +>table (the obvious normalization) will help here? +> +>The locale settings in postgresql.conf all have en_GB and a \l shows +>encoding of LATIN1. So I don't think I've set anything to UTF8 or such +>like. +> +> > > I need to get to the stage where I can run queries such as: +> > > select street, locality_1, locality_2, city from address +> > > where (city = 'Nottingham' or locality_2 = 'Nottingham' +> > > or locality_1 = 'Nottingham') +> > > and upper(substring(street from 1 for 1)) = 'A' +> > > group by street, locality_1, locality_2, city +> > > order by street +> > > limit 20 offset 0 +> > +> > This might be a lot quicker than pulling all the records like in +> your example +> > queries... +> +>Yes, that certainly does seem to be the case - around 4 seconds. But I +>need it to be 10 times faster (or thereabouts) otherwise I have big +>problems! + +*beats drum* Get it in RAM, Get it in RAM, ... + +Ron Peacetree + + + +From pgsql-performance-owner@postgresql.org Thu Sep 1 19:26:48 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 844A3D88BF + for ; + Thu, 1 Sep 2005 19:22:40 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 39199-06 + for ; + Thu, 1 Sep 2005 22:22:38 +0000 (GMT) +Received: from newman.lshift.net (host226.lshift.net [195.172.218.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 0573BD88A6 + for ; + Thu, 1 Sep 2005 19:22:37 -0300 (ADT) +Received: (qmail 18584 invoked by uid 1004); 1 Sep 2005 22:22:39 -0000 +Received: from 10.224.189.77 by newman (envelope-from , + uid 64011) with qmail-scanner-1.24 (clamdscan: 0.80/627. + Clear:RC:1(10.224.189.77):. + Processed in 0.014316 secs); 01 Sep 2005 22:22:39 -0000 +Received: from ponder.lshift.net (HELO localhost) ([10.224.189.77]) + (envelope-sender ) + by newman.lshift.net (qmail-ldap-1.03) with AES256-SHA encrypted SMTP + for ; 1 Sep 2005 22:22:39 -0000 +Date: Thu, 1 Sep 2005 23:22:39 +0100 +From: Matthew Sackman +To: pgsql-performance@postgresql.org +Subject: Re: Massive performance issues +Message-ID: <20050901222239.GG7131@pongo.lshift.net> +Mail-Followup-To: pgsql-performance@postgresql.org +References: <20050901174231.GE23970@pongo.lshift.net> + <20050901200930.GA23339@uio.no> + <20050901210626.GC7131@pongo.lshift.net> + <6.2.3.4.0.20050901173454.021c5730@pop.earthlink.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <6.2.3.4.0.20050901173454.021c5730@pop.earthlink.net> +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.273 required=5 tests=[AWL=-0.101, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200509/33 +X-Sequence-Number: 14341 + +On Thu, Sep 01, 2005 at 06:05:43PM -0400, Ron wrote: +> > Selection from the database is, hence the indexes. +> +> A DB _without_ indexes that fits into RAM during ordinary operation +> may actually be faster than a DB _with_ indexes that does +> not. Fitting the entire DB into RAM during ordinary operation if at +> all possible should be the first priority with a small data mine-like +> application such as you've described. + +That makes sense. + +> Also normalization is _not_ always a good thing for data mining like +> apps. Having most or everything you need in one place in a compact +> and regular format is usually more effective for data mines than "Nth +> Order Normal Form" optimization to the degree usually found in +> textbooks using OLTP-like examples. + +Sure. + +> >Ok, I did try 8.0 when I started this and found that the server bind +> >parameters (both via DBD::Pg (with pg_prepare_server => 1) and via JDBC +> >(various versions I tried)) failed - the parameters were clearly not +> >being substituted. This was Postgresql 8.0 from Debian unstable. That +> >was a couple of weeks ago and I've not been back to check whether its +> >been fixed. Anyway, because of these problems I dropped back to 7.4. +> +> Since I assume you are not going to run anything with the string +> "unstable" in its name in production (?!), why not try a decent +> production ready distro like SUSE 9.x and see how pg 8.0.3 runs on a +> OS more representative of what you are likely (or at least what is +> safe...) to run in production? + +Well, you see, as ever, it's a bit complicated. The company I'm doing +the development for has been subcontracted to do it and the contractor was +contracted by the actual "client". So there are two companies involved +in addition to the "client". Sadly, the "client" actually has dictated +things like "it will be deployed on FreeBSD and thou shall not argue". +At this point in time, I actually have very little information about the +specification of the boxen that'll be running this application. This is +something I'm hoping to solve very soon. The worst part of it is that +I'm not going have direct (ssh) access to the box and all configuration +changes will most likely have to be relayed through techies at the +"client" so fine tuning this is going to be a veritable nightmare. + +> >> > I need to get to the stage where I can run queries such as: +> >> > select street, locality_1, locality_2, city from address +> >> > where (city = 'Nottingham' or locality_2 = 'Nottingham' +> >> > or locality_1 = 'Nottingham') +> >> > and upper(substring(street from 1 for 1)) = 'A' +> >> > group by street, locality_1, locality_2, city +> >> > order by street +> >> > limit 20 offset 0 +> >> +> >> This might be a lot quicker than pulling all the records like in +> >your example +> >> queries... +> > +> >Yes, that certainly does seem to be the case - around 4 seconds. But I +> >need it to be 10 times faster (or thereabouts) otherwise I have big +> >problems! +> +> *beats drum* Get it in RAM, Get it in RAM, ... + +Ok, but I currently have 2 million rows. When this launches in a couple +of weeks, it'll launch with 5 million+ and then gain > a million a year. +I think the upshot of this all is 4GB RAM as a minimum and judicious use +of normalization so as to avoid more expensive string comparisons and +reduce table size is my immediate plan (along with proper configuration +of pg). + +Matthew + +From pgsql-performance-owner@postgresql.org Thu Sep 1 19:40:37 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8B89DD881E + for ; + Thu, 1 Sep 2005 19:34:44 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 43322-06 + for ; + Thu, 1 Sep 2005 22:34:43 +0000 (GMT) +Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) + by svr1.postgresql.org (Postfix) with ESMTP id DF480D8803 + for ; + Thu, 1 Sep 2005 19:34:41 -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 j81MYah3027983 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); + Thu, 1 Sep 2005 16:34:39 -0600 (MDT) + (envelope-from mfuhr@winnie.fuhr.org) +Received: from winnie.fuhr.org (localhost [127.0.0.1]) + by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j81MYahK044249; + Thu, 1 Sep 2005 16:34:36 -0600 (MDT) + (envelope-from mfuhr@winnie.fuhr.org) +Received: (from mfuhr@localhost) + by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j81MYa5K044248; + Thu, 1 Sep 2005 16:34:36 -0600 (MDT) (envelope-from mfuhr) +Date: Thu, 1 Sep 2005 16:34:36 -0600 +From: Michael Fuhr +To: Matthew Sackman +Cc: pgsql-performance@postgresql.org +Subject: Re: Massive performance issues +Message-ID: <20050901223436.GA44175@winnie.fuhr.org> +References: <20050901174231.GE23970@pongo.lshift.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20050901174231.GE23970@pongo.lshift.net> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.005 required=5 tests=[AWL=0.005] +X-Spam-Level: +X-Archive-Number: 200509/34 +X-Sequence-Number: 14342 + +On Thu, Sep 01, 2005 at 06:42:31PM +0100, Matthew Sackman wrote: +> +> "address_pc_top_index" btree (postcode_top) +> "address_pc_top_middle_bottom_index" btree (postcode_top, +> postcode_middle, postcode_bottom) +> "address_pc_top_middle_index" btree (postcode_top, postcode_middle) + +This doesn't address the query performance problem, but isn't only +one of these indexes necessary? The second one, on all three +columns, because searches involving only postcode_top or only +postcode_top and postcode_middle could use it, making the indexes +on only those columns superfluous. Or am I missing something? + +-- +Michael Fuhr + +From pgsql-performance-owner@postgresql.org Thu Sep 1 20:03:03 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5D64DD88D2 + for ; + Thu, 1 Sep 2005 20:03:02 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 49141-07 + for ; + Thu, 1 Sep 2005 23:02:51 +0000 (GMT) +Received: from crestone.coronasolutions.com (crestone.coronasolutions.com + [66.45.104.24]) + by svr1.postgresql.org (Postfix) with ESMTP id 57F86D8792 + for ; + Thu, 1 Sep 2005 20:02:50 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by crestone.coronasolutions.com (Postfix) with ESMTP id 76CE2644FE5 + for ; + Thu, 1 Sep 2005 17:02:52 -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 01839-01 for ; + Thu, 1 Sep 2005 17:02:50 -0600 (MDT) +Received: from [192.168.1.12] (c-24-9-24-35.hsd1.co.comcast.net [24.9.24.35]) + (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by crestone.coronasolutions.com (Postfix) with ESMTP id 696CD644514 + for ; + Thu, 1 Sep 2005 17:02:50 -0600 (MDT) +Mime-Version: 1.0 (Apple Message framework v733) +In-Reply-To: +References: +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <494FEEA8-7309-436B-BC49-CB37CE52697B@drivefaster.net> +Content-Transfer-Encoding: 7bit +From: Dan Harris +Subject: Re: Poor performance on HP Package Cluster +Date: Thu, 1 Sep 2005 17:02:49 -0600 +To: pgsql-performance@postgresql.org +X-Mailer: Apple Mail (2.733) +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at drivefaster.net +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/35 +X-Sequence-Number: 14343 + +Do you have any sources for that information? I am running dual +SmartArray 6402's in my DL585 and haven't noticed anything poor about +their performance. + +On Sep 1, 2005, at 2:24 PM, Luke Lonergan wrote: + +> Are you using the built-in HP SmartArray RAID/SCSI controllers? If +> so, that +> could be your problem, they are known to have terrible and variable +> performance with Linux. + +From pgsql-performance-owner@postgresql.org Thu Sep 1 20:09:09 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DF9E2D881E + for ; + Thu, 1 Sep 2005 20:09:07 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 50263-08 + for ; + Thu, 1 Sep 2005 23:09:03 +0000 (GMT) +Received: from pharmaline.de (mail.pharmaline.de [62.153.135.34]) + by svr1.postgresql.org (Postfix) with ESMTP id 3827BD83AD + for ; + Thu, 1 Sep 2005 20:09:01 -0300 (ADT) +Received: from [192.168.2.21] (62.153.135.40) by pharmaline.de with ESMTP + (Eudora Internet Mail Server 3.2.6) for + ; Fri, 2 Sep 2005 01:09:03 +0200 +Mime-Version: 1.0 (Apple Message framework v734) +Content-Transfer-Encoding: 7bit +Message-Id: <08E57775-5E88-42B0-926D-21CAFB21CF24@pharmaline.de> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +To: pgsql-performance@postgresql.org +From: Guido Neitzer +Subject: Prepared statement not using index +Date: Fri, 2 Sep 2005 01:09:03 +0200 +X-Mailer: Apple Mail (2.734) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/36 +X-Sequence-Number: 14344 + +Hi. + +I have an interesting problem with the JDBC drivers. When I use a +select like this: + +"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)> + +the existing index on the plz column is not used. + +When I the same select with a concrete value, the index IS used. + +I use PostgreSQL 8.0.3 on Mac OS X and the JDBC driver 8.0-312 JDBC 3. + +After a lot of other things, I tried using a 7.4 driver and with +this, the index is used in both cases. + +Why can this happen? Is there a setting I might have not seen? +Something I do wrong? + +cug + +From pgsql-performance-owner@postgresql.org Thu Sep 1 20:09:46 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5CB5DD893E + for ; + Thu, 1 Sep 2005 20:09:44 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 50912-06 + for ; + Thu, 1 Sep 2005 23:09:38 +0000 (GMT) +Received: from smtpauth01.mail.atl.earthlink.net + (smtpauth01.mail.atl.earthlink.net [209.86.89.61]) + by svr1.postgresql.org (Postfix) with ESMTP id F019CD8921 + for ; + Thu, 1 Sep 2005 20:09:35 -0300 (ADT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=SaDRLVdv9mYqlvk2ZXYT3ZMaskU8HnqjH+6qcpYdIdJi4ZAVnBGubIRkYWN/lNDR; + h=Received:Message-Id:X-Mailer:Date:To:From:Subject:In-Reply-To:References:Mime-Version:Content-Type:X-ELNK-Trace:X-Originating-IP; +Received: from [24.41.3.216] (helo=RJP-01.earthlink.net) + by smtpauth01.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1EAyBd-00054U-Kl; Thu, 01 Sep 2005 19:09:37 -0400 +Message-Id: <6.2.3.4.0.20050901184427.05ecb4a8@pop.earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 6.2.3.4 +Date: Thu, 01 Sep 2005 19:09:32 -0400 +To: Matthew Sackman , + pgsql-performance@postgresql.org +From: Ron +Subject: Re: Massive performance issues +In-Reply-To: <20050901222239.GG7131@pongo.lshift.net> +References: <20050901174231.GE23970@pongo.lshift.net> + <20050901200930.GA23339@uio.no> + <20050901210626.GC7131@pongo.lshift.net> + <6.2.3.4.0.20050901173454.021c5730@pop.earthlink.net> + <20050901222239.GG7131@pongo.lshift.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bc396aa5b1d465d3407bf79d57c1a94566350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 24.41.3.216 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.375 required=5 tests=[AWL=0.001, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200509/37 +X-Sequence-Number: 14345 + +At 06:22 PM 9/1/2005, Matthew Sackman wrote: +>On Thu, Sep 01, 2005 at 06:05:43PM -0400, Ron wrote: +> > +> > Since I assume you are not going to run anything with the string +> > "unstable" in its name in production (?!), why not try a decent +> > production ready distro like SUSE 9.x and see how pg 8.0.3 runs on a +> > OS more representative of what you are likely (or at least what is +> > safe...) to run in production? +> +>Well, you see, as ever, it's a bit complicated. The company I'm doing +>the development for has been subcontracted to do it and the contractor was +>contracted by the actual "client". So there are two companies involved +>in addition to the "client". Sadly, the "client" actually has dictated +>things like "it will be deployed on FreeBSD and thou shall not argue". + +At least get them to promise they will use a release the BSD folks +mark "stable"! + + +>At this point in time, I actually have very little information about the +>specification of the boxen that'll be running this application. This is +>something I'm hoping to solve very soon. The worst part of it is that +>I'm not going have direct (ssh) access to the box and all configuration +>changes will most likely have to be relayed through techies at the +>"client" so fine tuning this is going to be a veritable nightmare. + +IME, what you have actually just said is "It will not be possible to +safely fine tune the DB unless or until I have direct access; and/or +someone who does have direct access is correctly trained." + +Ick. + + +> > >> > I need to get to the stage where I can run queries such as: +> > >> > select street, locality_1, locality_2, city from address +> > >> > where (city = 'Nottingham' or locality_2 = 'Nottingham' +> > >> > or locality_1 = 'Nottingham') +> > >> > and upper(substring(street from 1 for 1)) = 'A' +> > >> > group by street, locality_1, locality_2, city +> > >> > order by street +> > >> > limit 20 offset 0 +> > >> +> > >> This might be a lot quicker than pulling all the records like in +> > >your example +> > >> queries... +> > > +> > >Yes, that certainly does seem to be the case - around 4 seconds. But I +> > >need it to be 10 times faster (or thereabouts) otherwise I have big +> > >problems! +> > +> > *beats drum* Get it in RAM, Get it in RAM, ... +> +>Ok, but I currently have 2 million rows. When this launches in a couple +>of weeks, it'll launch with 5 million+ and then gain > a million a year. + +At my previously mentioned optimum of 85B per row, 2M rows is +170MB. 5M rows is 425MB. Assuming the gain of 1M rows per year, +that's +85MB per year for this table. + +Up to 2GB DIMMs are currently standard, and 4GB DIMMs are just in the +process of being introduced. Mainboards with anything from 4 to 16 +DIMM slots are widely available. + +IOW, given the description you've provided this DB should _always_ +fit in RAM. Size the production system such that the entire DB fits +into RAM during ordinary operation with an extra 1GB of RAM initially +tossed on as a safety measure and the client will be upgrading the HW +because it's obsolete before they run out of room in RAM. + + +>I think the upshot of this all is 4GB RAM as a minimum and judicious use +>of normalization so as to avoid more expensive string comparisons and +>reduce table size is my immediate plan (along with proper configuration +>of pg). + +My suggestion is only slightly different. Reduce table size(s) and +up the RAM to the point where the whole DB fits comfortably in RAM. + +You've got the rare opportunity to build a practical Memory Resident +Database. It should run like a banshee when you're done. I'd love +to see the benches on the final product. + +Ron Peacetree + + + +From pgsql-performance-owner@postgresql.org Thu Sep 1 20:23:50 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 69250D8433 + for ; + Thu, 1 Sep 2005 20:23:49 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 55773-04 + for ; + Thu, 1 Sep 2005 23:23:47 +0000 (GMT) +Received: from smtp3.adl2.internode.on.net (smtp3.adl2.internode.on.net + [203.16.214.203]) + by svr1.postgresql.org (Postfix) with ESMTP id AA197D83AD + for ; + Thu, 1 Sep 2005 20:23:45 -0300 (ADT) +Received: from pluto.mirrabooka.com (ppp188-133.static.internode.on.net + [150.101.188.133]) + by smtp3.adl2.internode.on.net (8.12.9/8.12.6) with ESMTP id + j81NNiIE055604 for ; + Fri, 2 Sep 2005 08:53:48 +0930 (CST) + (envelope-from alison@mirrabooka.com) +Received: by pluto.mirrabooka.com (Postfix, from userid 506) + id 6CFDE2B123; Fri, 2 Sep 2005 09:23:44 +1000 (EST) +Date: Fri, 02 Sep 2005 09:23:44 +1000 +To: pgsql-performance@postgresql.org +Subject: Re: lots of updates on small table +Message-ID: <43178D80.nail2T711S8W7@pluto.mirrabooka.com> +References: <42D5F34E.nail9QE1195IE@pluto.mirrabooka.com> + <20050714162114.GA19778@alvh.no-ip.org> + <42D6F854.nail3K81VIICH@pluto.mirrabooka.com> + <5893.1121385447@sss.pgh.pa.us> + <42D71EC1.nail8BK11QC2Q@pluto.mirrabooka.com> +In-Reply-To: <42D71EC1.nail8BK11QC2Q@pluto.mirrabooka.com> +User-Agent: nail 11.6 9/7/04 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +From: alison@mirrabooka.com (Alison Winters) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 required=5 tests=[AWL=-0.000, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/38 +X-Sequence-Number: 14346 + +Just to dig up an old thread from last month: + +In case anyone was wondering we finally got a free day to put in the new +version of the software, and it's greatly improved the performance. The +solutions we employed were as follows: + +- recompile everything with ecpg -t for auto-commit +- vacuum run by cron every 15 minutes +- vacuum full analyze AND a reindex of the table in question run by cron + once per day + +I also went through and double-checked everywhere where we opened a +cursor to make sure it was always closed when we were done. + +This seems to have fixed up the endlessly growing indexes and slower and +slower updates. Thanks to everyone who helped out. + +Alison + + +From pgsql-performance-owner@postgresql.org Thu Sep 1 22:04:13 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 81475D6EA2 + for ; + Thu, 1 Sep 2005 22:04:12 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 79006-03 + for ; + Fri, 2 Sep 2005 01:04:11 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.196]) + by svr1.postgresql.org (Postfix) with ESMTP id 87F36D87DD + for ; + Thu, 1 Sep 2005 22:04:07 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id 36so492731wra + for ; + Thu, 01 Sep 2005 18:04: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:mime-version:content-type; + b=GOAqiId6YKwhllWqR8g9liw6rrhE3UqemTHEq4GwJQv4g/D6zCp8v8fPP73DmB8sSTdqKbKMX6CUo0WI3dLm1+R9wVgDm5d4yZTJIMzBU2KBFHghzMYUSvc4AbUDRP/LulUcrlNwELUtYzYDeudTKu8QzE+ci6M2/9x2lY6fu1U= +Received: by 10.54.53.7 with SMTP id b7mr185103wra; + Thu, 01 Sep 2005 18:04:11 -0700 (PDT) +Received: by 10.54.125.9 with HTTP; Thu, 1 Sep 2005 18:04:10 -0700 (PDT) +Message-ID: <3aa4c10905090118046e81b107@mail.gmail.com> +Date: Thu, 1 Sep 2005 22:04:10 -0300 +From: Ricardo Humphreys +To: pgsql-performance@postgresql.org +Subject: Avoid using swap in a cluster +Mime-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_2437_33099889.1125623050865" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.529 required=5 tests=[HTML_20_30=0.504, + HTML_MESSAGE=0.001, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200509/39 +X-Sequence-Number: 14347 + +------=_Part_2437_33099889.1125623050865 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Hi all. + In a cluster, is there any way to use the main memory of the other nodes= +=20 +instead of the swap? If I have a query with many sub-queries and a lot of= +=20 +data, I can easily fill all the memory in a node. The point is: is there an= +y=20 +way to continue using the main memory from other nodes in the same query=20 +instead of the swap? + Thank you, +Ricardo. + +------=_Part_2437_33099889.1125623050865 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +
Hi all.
+
 
+
In a cluster, is there any way to use the main memory of the other nod= +es instead of the swap? If I have a query with many sub-queries and a lot o= +f data, I can easily fill all the memory in a node. The point is: is there = +any way to continue using the main memory from other nodes in the same quer= +y instead of the swap? +
+
 
+
Thank you,
+
Ricardo.
 
+ +------=_Part_2437_33099889.1125623050865-- + +From pgsql-performance-owner@postgresql.org Fri Sep 2 00:20:22 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CE286D6FD0 + for ; + Fri, 2 Sep 2005 00:20:10 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 19945-10 + for ; + Fri, 2 Sep 2005 03:20:05 +0000 (GMT) +Received: from linda-2.paradise.net.nz (bm-2a.paradise.net.nz [202.0.58.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 9ABE4D6DF4 + for ; + Fri, 2 Sep 2005 00:20:01 -0300 (ADT) +Received: from smtp-1.paradise.net.nz (smtp-1a.paradise.net.nz [202.0.32.194]) + by linda-2.paradise.net.nz (Paradise.net.nz) + with ESMTP id <0IM60080G6L7FY@linda-2.paradise.net.nz> for + pgsql-performance@postgresql.org; Fri, 02 Sep 2005 15:19:56 +1200 (NZST) +Received: from [192.168.1.11] (218-101-45-29.paradise.net.nz [218.101.45.29]) + by smtp-1.paradise.net.nz (Postfix) with ESMTP id 746BE82A15; Fri, + 02 Sep 2005 15:19:55 +1200 (NZST) +Date: Fri, 02 Sep 2005 15:19:53 +1200 +From: Mark Kirkwood +Subject: Re: Massive performance issues +In-reply-to: <20050901174231.GE23970@pongo.lshift.net> +To: Matthew Sackman +Cc: pgsql-performance@postgresql.org +Message-id: <4317C4D9.9070106@paradise.net.nz> +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=ISO-8859-1 +Content-transfer-encoding: 7bit +X-Accept-Language: en-us, en +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050726) +References: <20050901174231.GE23970@pongo.lshift.net> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.14 required=5 tests=[AWL=0.140] +X-Spam-Level: +X-Archive-Number: 200509/40 +X-Sequence-Number: 14348 + +It would be good to see EXPLAIN ANALYZE output for the three queries +below (the real vs. estimated row counts being of interest). + +The number of pages in your address table might be interesting to know too. + +regards + +Mark + +Matthew Sackman wrote (with a fair bit of snippage): +> explain select locality_2 from address where locality_2 = 'Manchester'; +> gives +> QUERY PLAN +> ---------------------------------------------------------------- +> Seq Scan on address (cost=0.00..80677.16 rows=27923 width=12) +> Filter: ((locality_2)::text = 'Manchester'::text) +> +> +> explain select locality_1 from address where locality_1 = 'Manchester'; +> gives +> QUERY PLAN +> ---------------------------------------------------------------- +> Index Scan using address_locality_1_index on address +> (cost=0.00..69882.18 rows=17708 width=13) +> Index Cond: ((locality_1)::text = 'Manchester'::text) +> + > +> select street, locality_1, locality_2, city from address +> where (city = 'Nottingham' or locality_2 = 'Nottingham' +> or locality_1 = 'Nottingham') +> and upper(substring(street from 1 for 1)) = 'A' +> group by street, locality_1, locality_2, city +> order by street +> limit 20 offset 0 +> + +From pgsql-performance-owner@postgresql.org Fri Sep 2 01:17:52 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 11F41D7093 + for ; + Fri, 2 Sep 2005 01:17:51 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91524-02 + for ; + Fri, 2 Sep 2005 04:17:47 +0000 (GMT) +Received: from spark.hss.co.in (spark.hss.co.in [203.145.155.21]) + by svr1.postgresql.org (Postfix) with ESMTP id A0F6BD6E64 + for ; + Fri, 2 Sep 2005 01:17:40 -0300 (ADT) +Received: from ultra.hss.co.in (ultra [192.168.100.5]) + by spark.hss.co.in (8.12.10/8.12.10) with ESMTP id j824CM3q025206 + for ; + Fri, 2 Sep 2005 09:42:23 +0530 (IST) +Received: from sandesh.hss.hns.com (localhost [127.0.0.1]) + by ultra.hss.co.in (8.10.0/8.10.0) with ESMTP id j824ITV05058 + for ; + Fri, 2 Sep 2005 09:48:31 +0530 (IST) +Subject: Update is more affected( taking more time) than Select ( if Auto + vacuum is not running) +To: pgsql-performance@postgresql.org +X-Mailer: Lotus Notes Release 6.5 September 26, 2003 +Message-ID: + +From: Hemant Pandey +Date: Fri, 2 Sep 2005 09:21:51 +0530 +X-MIMETrack: Serialize by Router on Sandesh/HSS(Release 6.0|September 26, + 2002) at 02/09/2005 09:47:28 AM +MIME-Version: 1.0 +Content-type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.406 required=5 tests=[AWL=-0.058, + ROUND_THE_WORLD_LOCAL=0.464] +X-Spam-Level: +X-Archive-Number: 200509/41 +X-Sequence-Number: 14349 + + + + + +Hi All, + I have an ODBC application( using postgres database) which has three +different operations. Each operation is having combination of SELECT and +UPDATE. + +For example: +Operation A: 6 Fetch + 1 Update +Operation B: 9 Fetch +Operation C: 5 Fetch + 3 Update ( Tables has 140 records) + +I have run these operations while Auto Vacumm is running and observed the +time taken in thse operations. I found that Operation C is taking highest +time and A is the lowest. +So i inferrred that, UPDATE takes more time. + +Now i run these operations again, without running Auto Vacuum. I observed +that, time taken for operation A & B is almost same but time for Operation +C is increasing. + +I am not able to analyze, why only for operation C, time is increasing?? +Does auto vacuum affects more on UPDATE. + + +Please help me to understand these things. + +Thanks in advance. + +Hemant + +*********************** FSS-Unclassified *********************** +"DISCLAIMER: This message is proprietary to Flextronics Software +Systems Limited (FSS) and is intended solely for the use of the +individual to whom it is addressed. It may contain privileged or +confidential information and should not be circulated or used for +any purpose other than for what it is intended. If you have received +this message in error, please notify the originator immediately. +If you are not the intended recipient, you are notified that you are +strictly prohibited from using, copying, altering, or disclosing +the contents of this message. FSS accepts no responsibility for +loss or damage arising from the use of the information transmitted +by this email including damage from virus." + + +From pgsql-performance-owner@postgresql.org Fri Sep 2 01:24:39 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E0A57D7045 + for ; + Fri, 2 Sep 2005 01:24:38 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91524-06 + for ; + Fri, 2 Sep 2005 04:24:36 +0000 (GMT) +Received: from linda-2.paradise.net.nz (bm-2a.paradise.net.nz [202.0.58.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 97F7AD7039 + for ; + Fri, 2 Sep 2005 01:24:35 -0300 (ADT) +Received: from smtp-2.paradise.net.nz (smtp-2a.paradise.net.nz [202.0.32.195]) + by linda-2.paradise.net.nz (Paradise.net.nz) + with ESMTP id <0IM6009GJ9KY4Z@linda-2.paradise.net.nz> for + pgsql-performance@postgresql.org; Fri, 02 Sep 2005 16:24:34 +1200 (NZST) +Received: from [192.168.1.11] (218-101-45-29.paradise.net.nz [218.101.45.29]) + by smtp-2.paradise.net.nz (Postfix) with ESMTP id 883C39E21D; Fri, + 02 Sep 2005 16:24:34 +1200 (NZST) +Date: Fri, 02 Sep 2005 16:24:32 +1200 +From: Mark Kirkwood +Subject: Re: Massive performance issues +In-reply-to: <20050901174231.GE23970@pongo.lshift.net> +To: Matthew Sackman +Cc: pgsql-performance@postgresql.org +Message-id: <4317D400.2080809@paradise.net.nz> +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=ISO-8859-1 +Content-transfer-encoding: 7bit +X-Accept-Language: en-us, en +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050726) +References: <20050901174231.GE23970@pongo.lshift.net> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.137 required=5 tests=[AWL=0.137] +X-Spam-Level: +X-Archive-Number: 200509/42 +X-Sequence-Number: 14350 + +Matthew Sackman wrote: + +> I need to get to the stage where I can run queries such as: + > +> select street, locality_1, locality_2, city from address +> where (city = 'Nottingham' or locality_2 = 'Nottingham' +> or locality_1 = 'Nottingham') +> and upper(substring(street from 1 for 1)) = 'A' +> group by street, locality_1, locality_2, city +> order by street +> limit 20 offset 0 +> +> and have the results very quickly. +> + +This sort of query will be handled nicely in 8.1 - it has bitmap and/or +processing to make use of multiple indexes. Note that 8.1 is in beta now. + +Cheers + +Mark + + +From pgsql-performance-owner@postgresql.org Fri Sep 2 01:54:51 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E9C1BD6D8A + for ; + Fri, 2 Sep 2005 01:54:50 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 56598-07 + for ; + Fri, 2 Sep 2005 04:54:48 +0000 (GMT) +Received: from mail.mi8.com (d01gw04.mi8.com [63.240.6.44]) + by svr1.postgresql.org (Postfix) with ESMTP id 29BF4D6FF6 + for ; + Fri, 2 Sep 2005 01:54:47 -0300 (ADT) +Received: from 172.16.1.110 by mail.mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D4)); Fri, 02 Sep 2005 00:54:36 -0400 +X-Server-Uuid: C8FB4D43-1108-484A-A898-3CBCC7906230 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.174]) by + D01SMTP01.Mi8.com with Microsoft SMTPSVC(6.0.3790.211); Fri, 2 Sep 2005 + 00:54:36 -0400 +Received: from 24.5.173.15 ([24.5.173.15]) 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 ; Fri, 2 Sep + 2005 00:54:35 -0500 +User-Agent: Microsoft-Entourage/11.1.0.040913 +Date: Thu, 01 Sep 2005 21:54:34 -0700 +Subject: Re: Poor performance on HP Package Cluster +From: "Luke Lonergan" +To: "Dan Harris" , + pgsql-performance@postgresql.org +Message-ID: +In-Reply-To: <494FEEA8-7309-436B-BC49-CB37CE52697B@drivefaster.net> +MIME-Version: 1.0 +X-OriginalArrivalTime: 02 Sep 2005 04:54:36.0674 (UTC) + FILETIME=[6B0BE620:01C5AF7A] +X-WSS-ID: 6F0904863P01577610-01-01 +Content-Type: text/plain; + charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.588 required=5 tests=[AWL=0.007, + FORGED_RCVD_HELO=0.05, RCVD_NUMERIC_HELO=1.531] +X-Spam-Level: * +X-Archive-Number: 200509/43 +X-Sequence-Number: 14351 + +Dan, + +On 9/1/05 4:02 PM, "Dan Harris" wrote: + +> Do you have any sources for that information? I am running dual +> SmartArray 6402's in my DL585 and haven't noticed anything poor about +> their performance. + +I've previously posted comprehensive results using the 5i and 6xxx series +smart arrays using software RAID, HW RAID on 3 different kernels, alongside +LSI and Adaptec SCSI controllers, and an Adaptec 24xx HW RAID adapter. +Results with bonnie++ and simple sequential read/write with dd. + +I'll post them again here for reference in the next message. Yes, the +performance of the SmartArray controllers under Linux was abysmal, even when +run by the labs at HP. + +- Luke + + + +From pgsql-performance-owner@postgresql.org Fri Sep 2 02:11:24 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E2EC1D6D8A + for ; + Fri, 2 Sep 2005 02:11:22 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 98792-08 + for ; + Fri, 2 Sep 2005 05:11:17 +0000 (GMT) +Received: from smtp111.mail.sc5.yahoo.com (smtp111.mail.sc5.yahoo.com + [66.163.170.9]) + by svr1.postgresql.org (Postfix) with SMTP id 0E0C2D70E2 + for ; + Fri, 2 Sep 2005 02:11:16 -0300 (ADT) +Received: (qmail 35904 invoked from network); 2 Sep 2005 05:11:15 -0000 +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.de; + h=Received:Message-ID:Date:From:Reply-To:Organization:User-Agent:X-Accept-Language:MIME-Version:To:Content-Type:Content-Transfer-Encoding; + b=SZQLa+6EnuNltkuAtPZ+px8+RfNAAMktQ7fiqum9gEfxnzebF/CiCfwDyhS1by3Fqjuf7ZW65epGx7NhhnCCw41doCSMAGOILyolwXI02MTOymV00YQ6UaptjQcz9kO2/m6TfaIQ22AsjjJEQt3u30lsSrS1qfYfY/QadLzvouM= + ; +Received: from unknown (HELO ?192.168.2.161?) (falkmilan@84.56.234.93 with + plain) + by smtp111.mail.sc5.yahoo.com with SMTP; 2 Sep 2005 05:11:15 -0000 +Message-ID: <4317DF42.5080702@yahoo.de> +Date: Fri, 02 Sep 2005 07:12:34 +0200 +From: "apoc9009@yahoo.de" +Reply-To: apoc9009@yahoo.de +Organization: apoc9009@yahoo.de +User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance list +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.7 required=5 tests=[AWL=-0.760, + DNS_FROM_RFC_ABUSE=0.374, FROM_ENDS_IN_NUMS=0.516, MISSING_SUBJECT=1.57] +X-Spam-Level: * +X-Archive-Number: 200509/44 +X-Sequence-Number: 14352 + +unsubscribe-digest + + + + + +___________________________________________________________ +Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier anmelden: http://mail.yahoo.de + +From pgsql-performance-owner@postgresql.org Fri Sep 2 06:23:53 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7D8D2D7839 + for ; + Fri, 2 Sep 2005 06:23:52 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 94231-05 + for ; + Fri, 2 Sep 2005 09:23:49 +0000 (GMT) +Received: from mailserv.pune.wibhu.com (unknown [210.212.168.94]) + by svr1.postgresql.org (Postfix) with ESMTP id C51A8D77E5 + for ; + Fri, 2 Sep 2005 06:23:45 -0300 (ADT) +Received: from Akshay ([192.168.1.131]) + by mailserv.pune.wibhu.com (8.12.8/8.12.5) with ESMTP id j829Ivs0024658; + Fri, 2 Sep 2005 14:49:03 +0530 +From: "Akshay Mathur" +To: "'Ron'" +Cc: +Subject: Re: Massive performance issues +Date: Fri, 2 Sep 2005 14:53:58 +0530 +Message-ID: <002901c5afa0$0dcddab0$8301a8c0@pune.wibhu.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.2180 +Importance: Normal +In-Reply-To: <6.2.3.4.0.20050901163955.021b3708@pop.earthlink.net> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.095 required=5 tests=[AWL=0.095] +X-Spam-Level: +X-Archive-Number: 200509/45 +X-Sequence-Number: 14353 + +Ron, + +Can you give me some pointers to make the tables RAM resident. If one +does so, is the program accessing the data need to change. Does pgsql +take care to write the data to disk? + +Regards, + +akshay + +--------------------------------------- +Akshay Mathur +SMTS, Product Verification +AirTight Networks, Inc. (www.airtightnetworks.net) +O: +91 20 2588 1555 ext 205 +F: +91 20 2588 1445 + + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Ron +Sent: Friday, September 02, 2005 2:36 AM +To: Tom Lane; pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Massive performance issues + +Even better, if the table(s) can be made RAM resident, then searches, +even random ones, can be very fast. He wants a 1000x performance +improvement. Going from disk resident to RAM resident should help +greatly in attaining that goal. + + + + + +From pgsql-performance-owner@postgresql.org Fri Sep 2 06:45:25 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7D0A8D7696 + for ; + Fri, 2 Sep 2005 06:45:24 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 45892-01 + for ; + Fri, 2 Sep 2005 09:45:23 +0000 (GMT) +Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) + by svr1.postgresql.org (Postfix) with ESMTP id C012FD7672 + for ; + Fri, 2 Sep 2005 06:45:22 -0300 (ADT) +Received: from mainbox.archonet.com + (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) + by smtp.metronet.co.uk (MetroNet Mail) with ESMTP + id D82BE40BEEE; Fri, 2 Sep 2005 10:45:18 +0100 (BST) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mainbox.archonet.com (Postfix) with ESMTP id 724BA15F1D; + Fri, 2 Sep 2005 10:43:02 +0100 (BST) +Received: from mainbox.archonet.com ([127.0.0.1]) + by localhost (mainbox [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 26140-10; Fri, 2 Sep 2005 10:42:59 +0100 (BST) +Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP id AFA7115F1C; + Fri, 2 Sep 2005 10:42:59 +0100 (BST) +Message-ID: <43181EA3.3010302@archonet.com> +Date: Fri, 02 Sep 2005 10:42:59 +0100 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Ricardo Humphreys +Cc: pgsql-performance@postgresql.org +Subject: Re: Avoid using swap in a cluster +References: <3aa4c10905090118046e81b107@mail.gmail.com> +In-Reply-To: <3aa4c10905090118046e81b107@mail.gmail.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.057 required=5 tests=[AWL=0.007, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/46 +X-Sequence-Number: 14354 + +Ricardo Humphreys wrote: +> Hi all. +> In a cluster, is there any way to use the main memory of the other nodes +> instead of the swap? If I have a query with many sub-queries and a lot of +> data, I can easily fill all the memory in a node. The point is: is there any +> way to continue using the main memory from other nodes in the same query +> instead of the swap? + +I don't know of any clustered version of PG that can spread queries over +multiple machines. Can I ask what you are using? + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Fri Sep 2 07:00:29 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1D8AED7907 + for ; + Fri, 2 Sep 2005 07:00:27 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 26037-10 + for ; + Fri, 2 Sep 2005 10:00:25 +0000 (GMT) +Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) + by svr1.postgresql.org (Postfix) with ESMTP id E8DCAD78F9 + for ; + Fri, 2 Sep 2005 07:00:22 -0300 (ADT) +Received: from mainbox.archonet.com + (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) + by smtp.metronet.co.uk (MetroNet Mail) with ESMTP + id 29993412E02; Fri, 2 Sep 2005 11:00:18 +0100 (BST) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mainbox.archonet.com (Postfix) with ESMTP id 6A3AB15F1F; + Fri, 2 Sep 2005 10:55:31 +0100 (BST) +Received: from mainbox.archonet.com ([127.0.0.1]) + by localhost (mainbox [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 26359-10; Fri, 2 Sep 2005 10:55:26 +0100 (BST) +Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP id 7D37E15F1C; + Fri, 2 Sep 2005 10:48:11 +0100 (BST) +Message-ID: <43181FDB.7070106@archonet.com> +Date: Fri, 02 Sep 2005 10:48:11 +0100 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Hemant Pandey +Cc: pgsql-performance@postgresql.org +Subject: Re: Update is more affected( taking more time) than Select +References: + +In-Reply-To: + +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.057 required=5 tests=[AWL=0.007, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/47 +X-Sequence-Number: 14355 + +Hemant Pandey wrote: +> Operation A: 6 Fetch + 1 Update +> Operation B: 9 Fetch +> Operation C: 5 Fetch + 3 Update ( Tables has 140 records) +> +> I have run these operations while Auto Vacumm is running and observed the +> time taken in thse operations. I found that Operation C is taking highest +> time and A is the lowest. +> So i inferrred that, UPDATE takes more time. +> +> Now i run these operations again, without running Auto Vacuum. I observed +> that, time taken for operation A & B is almost same but time for Operation +> C is increasing. +> +> I am not able to analyze, why only for operation C, time is increasing?? +> Does auto vacuum affects more on UPDATE. + +Depends on what is happening. Without vacuuming (automatic or manual) a +table will tend to have "holes" since an update with MVCC is basically a +delete and an insert. + +Since you say the table has only 140 records, almost any operation will +tend to scan rather than use an index. However, if you issue lots of +updates you will end up with many "holes" which have to be scanned past. +PG won't know they are there because its statistics will be out of date +unless you have analysed that table recently. So - everything will start +to get slower. + +So - for a small, rapidly updated table make sure you vacuum a lot +(perhaps as often as once a minute). Or, run autovacuum and let it cope. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Fri Sep 2 07:20:38 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B4491D77C7 + for ; + Fri, 2 Sep 2005 07:20:36 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 19964-03 + for ; + Fri, 2 Sep 2005 10:20:32 +0000 (GMT) +Received: from mail1.fluidhosting.com (mail1.fluidhosting.com [204.14.90.61]) + by svr1.postgresql.org (Postfix) with SMTP id 2ABC1D6DAC + for ; + Fri, 2 Sep 2005 07:20:29 -0300 (ADT) +Received: (qmail 82015 invoked by uid 399); 2 Sep 2005 10:20:30 -0000 +Received: from 194-185-112-82.f5.ngi.it (HELO ?10.20.20.4?) (194.185.112.82) + by mail1.fluidhosting.com with SMTP; 2 Sep 2005 10:20:30 -0000 +Message-ID: <43182789.4070307@beccati.com> +Date: Fri, 02 Sep 2005 12:20:57 +0200 +From: Matteo Beccati +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: ORDER BY and LIMIT not propagated on inherited tables / UNIONs +Content-Type: multipart/mixed; boundary="------------050903020502070400020804" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 required=5 tests=[AWL=-0.050, + MIME_SUSPECT_NAME=0.1] +X-Spam-Level: +X-Archive-Number: 200509/48 +X-Sequence-Number: 14356 + +This is a multi-part message in MIME format. +--------------050903020502070400020804 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Hi, + +I'm using inherited tables to partition some data which can grow very +large. Recently I discovered that a simple query that on a regular table +would use an index was instead using seq scans (70s vs a guessed 2s). +The well known query is: + +SELECT foo FROM bar ORDER BY foo DESC LIMIT 1 + +(The same applies for SELECT MIN(foo) FROM bar using 8.1) + + +The query plan generated when running the query on a table which has +inheritance forces the planner to choose a seq_scan for each table. +Wouldn't be a good thing to also promote ORDER BYs and LIMITs to each +subscan (like WHERE does)? + +I needed a quick solution, so I wrote a function which looks each +inherited table separately and my problem is partially solved, but I +think that a (hopefully) little change in the optimizer could be advisable. + +Attached are some EXPLAIN ANALYZE outputs of my suggestion. + + +Best regards +-- +Matteo Beccati +http://phpadsnew.com +http://phppgads.com + +--------------050903020502070400020804 +Content-Type: plain/text; + name="order_limit_inheritance.txt" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline; + filename="order_limit_inheritance.txt" + +EXPLAIN ANALYZE SELECT t_stamp FROM gw_stats.stats ORDER BY t_stamp DESC LIMIT 1; + +---------------------------------------------------------------------------------------------------------------------------------------------------- + Limit (cost=169880.85..169880.85 rows=1 width=8) (actual time=53540.270..53540.276 rows=1 loops=1) + -> Sort (cost=169880.85..173008.45 rows=1251039 width=8) (actual time=53540.257..53540.257 rows=1 loops=1) + Sort Key: gw_stats.stats.t_stamp + -> Result (cost=0.00..32110.39 rows=1251039 width=8) (actual time=0.071..39441.375 rows=1250266 loops=1) + -> Append (cost=0.00..32110.39 rows=1251039 width=8) (actual time=0.059..24631.103 rows=1250266 loops=1) + -> Seq Scan on stats (cost=0.00..13.20 rows=320 width=8) (actual time=0.006..0.006 rows=0 loops=1) + -> Seq Scan on stats_200506 stats (cost=0.00..9541.20 rows=372020 width=8) (actual time=0.036..2530.075 rows=371769 loops=1) + -> Seq Scan on stats_200507 stats (cost=0.00..9472.74 rows=369374 width=8) (actual time=0.035..3278.674 rows=369179 loops=1) + -> Seq Scan on stats_200508 stats (cost=0.00..6023.53 rows=234753 width=8) (actual time=0.032..1661.003 rows=234808 loops=1) + -> Seq Scan on stats_200509 stats (cost=0.00..365.77 rows=14177 width=8) (actual time=0.010..91.709 rows=14274 loops=1) + -> Seq Scan on stats_200501 stats (cost=0.00..1.30 rows=30 width=8) (actual time=0.011..0.204 rows=30 loops=1) + -> Seq Scan on stats_200502 stats (cost=0.00..117.81 rows=4581 width=8) (actual time=0.037..31.678 rows=4581 loops=1) + -> Seq Scan on stats_200503 stats (cost=0.00..333.05 rows=12905 width=8) (actual time=0.035..84.913 rows=12905 loops=1) + -> Seq Scan on stats_200504 stats (cost=0.00..805.40 rows=31140 width=8) (actual time=0.039..277.561 rows=31140 loops=1) + -> Seq Scan on stats_200505 stats (cost=0.00..5436.39 rows=211739 width=8) (actual time=0.040..1549.011 rows=211580 loops=1) + Total runtime: 53556.986 ms +---------------------------------------------------------------------------------------------------------------------------------------------------- + + +Which is roughly equivalent to: + +EXPLAIN ANALYZE + SELECT t_stamp FROM ONLY gw_stats.stats UNION ALL + SELECT t_stamp FROM gw_stats.stats_200501 UNION ALL + SELECT t_stamp FROM gw_stats.stats_200502 UNION ALL + SELECT t_stamp FROM gw_stats.stats_200503 UNION ALL + SELECT t_stamp FROM gw_stats.stats_200504 UNION ALL + SELECT t_stamp FROM gw_stats.stats_200505 UNION ALL + SELECT t_stamp FROM gw_stats.stats_200506 UNION ALL + SELECT t_stamp FROM gw_stats.stats_200507 UNION ALL + SELECT t_stamp FROM gw_stats.stats_200508 UNION ALL + SELECT t_stamp FROM gw_stats.stats_200509 + ORDER BY t_stamp DESC LIMIT 1; + +---------------------------------------------------------------------------------------------------------------------------------------------- + Limit (cost=182178.14..182178.14 rows=1 width=8) (actual time=58783.069..58783.075 rows=1 loops=1) + -> Sort (cost=182178.14..185302.26 rows=1249647 width=8) (actual time=58783.051..58783.051 rows=1 loops=1) + Sort Key: t_stamp + -> Append (cost=0.00..44570.94 rows=1249647 width=8) (actual time=0.058..44601.547 rows=1248877 loops=1) + -> Subquery Scan "*SELECT* 1" (cost=0.00..16.40 rows=320 width=8) (actual time=0.017..0.017 rows=0 loops=1) + -> Seq Scan on stats (cost=0.00..13.20 rows=320 width=8) (actual time=0.006..0.006 rows=0 loops=1) + -> Subquery Scan "*SELECT* 2" (cost=0.00..1.60 rows=30 width=8) (actual time=0.024..0.533 rows=30 loops=1) + -> Seq Scan on stats_200501 (cost=0.00..1.30 rows=30 width=8) (actual time=0.013..0.204 rows=30 loops=1) + -> Subquery Scan "*SELECT* 3" (cost=0.00..163.62 rows=4581 width=8) (actual time=0.068..81.795 rows=4581 loops=1) + -> Seq Scan on stats_200502 (cost=0.00..117.81 rows=4581 width=8) (actual time=0.057..31.186 rows=4581 loops=1) + -> Subquery Scan "*SELECT* 4" (cost=0.00..462.10 rows=12905 width=8) (actual time=0.046..230.967 rows=12905 loops=1) + -> Seq Scan on stats_200503 (cost=0.00..333.05 rows=12905 width=8) (actual time=0.033..87.605 rows=12905 loops=1) + -> Subquery Scan "*SELECT* 5" (cost=0.00..1116.80 rows=31140 width=8) (actual time=0.051..553.689 rows=31140 loops=1) + -> Seq Scan on stats_200504 (cost=0.00..805.40 rows=31140 width=8) (actual time=0.037..197.642 rows=31140 loops=1) + -> Subquery Scan "*SELECT* 6" (cost=0.00..7553.78 rows=211739 width=8) (actual time=0.063..4753.960 rows=211580 loops=1) + -> Seq Scan on stats_200505 (cost=0.00..5436.39 rows=211739 width=8) (actual time=0.035..2133.092 rows=211580 loops=1) + -> Subquery Scan "*SELECT* 7" (cost=0.00..13261.40 rows=372020 width=8) (actual time=0.043..7178.521 rows=371769 loops=1) + -> Seq Scan on stats_200506 (cost=0.00..9541.20 rows=372020 width=8) (actual time=0.031..2632.163 rows=371769 loops=1) + -> Subquery Scan "*SELECT* 8" (cost=0.00..13166.48 rows=369374 width=8) (actual time=0.049..8289.331 rows=369179 loops=1) + -> Seq Scan on stats_200507 (cost=0.00..9472.74 rows=369374 width=8) (actual time=0.035..3171.864 rows=369179 loops=1) + -> Subquery Scan "*SELECT* 9" (cost=0.00..8371.06 rows=234753 width=8) (actual time=0.049..7465.002 rows=234808 loops=1) + -> Seq Scan on stats_200508 (cost=0.00..6023.53 rows=234753 width=8) (actual time=0.037..2555.151 rows=234808 loops=1) + -> Subquery Scan "*SELECT* 10" (cost=0.00..457.70 rows=12785 width=8) (actual time=0.044..267.321 rows=12885 loops=1) + -> Seq Scan on stats_200509 (cost=0.00..329.85 rows=12785 width=8) (actual time=0.032..118.810 rows=12885 loops=1) + Total runtime: 58798.373 ms +---------------------------------------------------------------------------------------------------------------------------------------------- + + +And would instead better perform if translated to: + +EXPLAIN ANALYZE + (SELECT t_stamp FROM ONLY gw_stats.stats ORDER BY t_stamp DESC LIMIT 1) UNION ALL + (SELECT t_stamp FROM gw_stats.stats_200501 ORDER BY t_stamp DESC LIMIT 1) UNION ALL + (SELECT t_stamp FROM gw_stats.stats_200502 ORDER BY t_stamp DESC LIMIT 1) UNION ALL + (SELECT t_stamp FROM gw_stats.stats_200503 ORDER BY t_stamp DESC LIMIT 1) UNION ALL + (SELECT t_stamp FROM gw_stats.stats_200504 ORDER BY t_stamp DESC LIMIT 1) UNION ALL + (SELECT t_stamp FROM gw_stats.stats_200505 ORDER BY t_stamp DESC LIMIT 1) UNION ALL + (SELECT t_stamp FROM gw_stats.stats_200506 ORDER BY t_stamp DESC LIMIT 1) UNION ALL + (SELECT t_stamp FROM gw_stats.stats_200507 ORDER BY t_stamp DESC LIMIT 1) UNION ALL + (SELECT t_stamp FROM gw_stats.stats_200508 ORDER BY t_stamp DESC LIMIT 1) UNION ALL + (SELECT t_stamp FROM gw_stats.stats_200509 ORDER BY t_stamp DESC LIMIT 1) + ORDER BY t_stamp DESC LIMIT 1; +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Limit (cost=27.22..27.22 rows=1 width=8) (actual time=1.408..1.413 rows=1 loops=1) + -> Sort (cost=27.22..27.24 rows=10 width=8) (actual time=1.395..1.395 rows=1 loops=1) + Sort Key: t_stamp + -> Append (cost=26.52..27.05 rows=10 width=8) (actual time=0.158..1.319 rows=9 loops=1) + -> Subquery Scan "*SELECT* 1" (cost=26.52..26.53 rows=1 width=8) (actual time=0.041..0.041 rows=0 loops=1) + -> Limit (cost=26.52..26.52 rows=1 width=8) (actual time=0.030..0.030 rows=0 loops=1) + -> Sort (cost=26.52..27.32 rows=320 width=8) (actual time=0.020..0.020 rows=0 loops=1) + Sort Key: t_stamp + -> Seq Scan on stats (cost=0.00..13.20 rows=320 width=8) (actual time=0.007..0.007 rows=0 loops=1) + -> Subquery Scan "*SELECT* 2" (cost=0.00..0.14 rows=1 width=8) (actual time=0.101..0.118 rows=1 loops=1) + -> Limit (cost=0.00..0.13 rows=1 width=8) (actual time=0.090..0.095 rows=1 loops=1) + -> Index Scan Backward using stats_200501_t_stamp_uc_id_key on stats_200501 (cost=0.00..3.77 rows=30 width=8) (actual time=0.078..0.078 rows=1 loops=1) + -> Subquery Scan "*SELECT* 3" (cost=0.00..0.05 rows=1 width=8) (actual time=0.095..0.111 rows=1 loops=1) + -> Limit (cost=0.00..0.04 rows=1 width=8) (actual time=0.084..0.090 rows=1 loops=1) + -> Index Scan Backward using stats_200502_t_stamp_uc_id_key on stats_200502 (cost=0.00..173.89 rows=4581 width=8) (actual time=0.073..0.073 rows=1 loops=1) + -> Subquery Scan "*SELECT* 4" (cost=0.00..0.05 rows=1 width=8) (actual time=0.093..0.110 rows=1 loops=1) + -> Limit (cost=0.00..0.04 rows=1 width=8) (actual time=0.082..0.088 rows=1 loops=1) + -> Index Scan Backward using stats_200503_t_stamp_uc_id_key on stats_200503 (cost=0.00..487.20 rows=12905 width=8) (actual time=0.070..0.070 rows=1 loops=1) + -> Subquery Scan "*SELECT* 5" (cost=0.00..0.05 rows=1 width=8) (actual time=0.096..0.111 rows=1 loops=1) + -> Limit (cost=0.00..0.04 rows=1 width=8) (actual time=0.084..0.089 rows=1 loops=1) + -> Index Scan Backward using stats_200504_t_stamp_uc_id_key on stats_200504 (cost=0.00..1174.66 rows=31140 width=8) (actual time=0.072..0.072 rows=1 loops=1) + -> Subquery Scan "*SELECT* 6" (cost=0.00..0.05 rows=1 width=8) (actual time=0.110..0.127 rows=1 loops=1) + -> Limit (cost=0.00..0.04 rows=1 width=8) (actual time=0.098..0.103 rows=1 loops=1) + -> Index Scan Backward using stats_200505_t_stamp_uc_id_key on stats_200505 (cost=0.00..8081.03 rows=211739 width=8) (actual time=0.087..0.087 rows=1 loops=1) + -> Subquery Scan "*SELECT* 7" (cost=0.00..0.05 rows=1 width=8) (actual time=0.135..0.150 rows=1 loops=1) + -> Limit (cost=0.00..0.04 rows=1 width=8) (actual time=0.123..0.128 rows=1 loops=1) + -> Index Scan Backward using stats_200506_t_stamp_uc_id_key on stats_200506 (cost=0.00..14449.91 rows=372020 width=8) (actual time=0.112..0.112 rows=1 loops=1) + -> Subquery Scan "*SELECT* 8" (cost=0.00..0.05 rows=1 width=8) (actual time=0.115..0.131 rows=1 loops=1) + -> Limit (cost=0.00..0.04 rows=1 width=8) (actual time=0.104..0.109 rows=1 loops=1) + -> Index Scan Backward using stats_200507_t_stamp_uc_id_key on stats_200507 (cost=0.00..14346.43 rows=369374 width=8) (actual time=0.092..0.092 rows=1 loops=1) + -> Subquery Scan "*SELECT* 9" (cost=0.00..0.05 rows=1 width=8) (actual time=0.116..0.132 rows=1 loops=1) + -> Limit (cost=0.00..0.04 rows=1 width=8) (actual time=0.104..0.110 rows=1 loops=1) + -> Index Scan Backward using stats_200508_t_stamp_uc_id_key on stats_200508 (cost=0.00..9124.53 rows=234753 width=8) (actual time=0.093..0.093 rows=1 loops=1) + -> Subquery Scan "*SELECT* 10" (cost=0.00..0.05 rows=1 width=8) (actual time=0.111..0.128 rows=1 loops=1) + -> Limit (cost=0.00..0.04 rows=1 width=8) (actual time=0.100..0.105 rows=1 loops=1) + -> Index Scan Backward using stats_200509_t_stamp_uc_id_key on stats_200509 (cost=0.00..555.95 rows=14177 width=8) (actual time=0.088..0.088 rows=1 loops=1) + Total runtime: 1.663 ms +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + +--------------050903020502070400020804-- + +From pgsql-performance-owner@postgresql.org Fri Sep 2 08:18:27 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EABC3D7839 + for ; + Fri, 2 Sep 2005 08:18:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 67579-01 + for ; + Fri, 2 Sep 2005 11:18:24 +0000 (GMT) +Received: from mail.advfn.com (mail.advfn.com [212.161.99.149]) + by svr1.postgresql.org (Postfix) with ESMTP id C0171D77EF + for ; + Fri, 2 Sep 2005 08:18:22 -0300 (ADT) +Received: from [192.168.0.155] (gw.advfn.com [213.86.19.101]) + by mail.advfn.com (Postfix) with ESMTP id 759553E215; + Fri, 2 Sep 2005 11:18:24 +0000 (GMT) +In-Reply-To: <43181EA3.3010302@archonet.com> +References: <3aa4c10905090118046e81b107@mail.gmail.com> + <43181EA3.3010302@archonet.com> +Mime-Version: 1.0 (Apple Message framework v734) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <1C0688FA-8D0D-4862-B416-C2574FD284BC@advfn.com> +Cc: Ricardo Humphreys , + pgsql-performance@postgresql.org +Content-Transfer-Encoding: 7bit +From: Alex Stapleton +Subject: Re: Avoid using swap in a cluster +Date: Fri, 2 Sep 2005 12:18:22 +0100 +To: Richard Huxton +X-Mailer: Apple Mail (2.734) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=-0.053 required=5 tests=[AWL=-0.053] +X-Spam-Level: +X-Archive-Number: 200509/49 +X-Sequence-Number: 14357 + + +On 2 Sep 2005, at 10:42, Richard Huxton wrote: + +> Ricardo Humphreys wrote: +> +>> Hi all. +>> In a cluster, is there any way to use the main memory of the +>> other nodes instead of the swap? If I have a query with many sub- +>> queries and a lot of data, I can easily fill all the memory in a +>> node. The point is: is there any way to continue using the main +>> memory from other nodes in the same query instead of the swap? +>> +> +> I don't know of any clustered version of PG that can spread queries +> over multiple machines. Can I ask what you are using? + +IIRC GreenPlums DeepGreen MPP (Version 2) can do it. It does cost +money though, but it is a very nice product. + +> -- +> Richard Huxton +> Archonet Ltd +> +> ---------------------------(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 Fri Sep 2 08:43:11 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E0B6DD6E86 + for ; + Fri, 2 Sep 2005 08:43:10 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 09350-06 + for ; + Fri, 2 Sep 2005 11:43:09 +0000 (GMT) +Received: from mail.androme.com (mail.androme.com [62.58.96.145]) + by svr1.postgresql.org (Postfix) with ESMTP id C40BED72F7 + for ; + Fri, 2 Sep 2005 08:43:07 -0300 (ADT) +Received: from [127.0.0.1] ([192.168.10.56]) + by mail.androme.com (8.12.10/8.12.10) with ESMTP id j82Bh5xx024069 + for ; Fri, 2 Sep 2005 13:43:08 +0200 +Message-ID: <43183AC9.1060704@andromeiberica.com> +Date: Fri, 02 Sep 2005 13:43:05 +0200 +From: Arnau +Reply-To: arnaulist@andromeiberica.com +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: Advise about how to delete entries +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/50 +X-Sequence-Number: 14358 + +Hi all, + + I have the following table: + +espsm_asme=# \d statistics_sasme + Table "public.statistics_sasme" + Column | Type | + Modifiers +--------------------------+--------------------------+-------------------------------------------------------------- + statistic_id | numeric(10,0) | not null default +nextval('STATISTICS_OPERATOR_ID_SEQ'::text) + input_message_id | character varying(50) | + timestamp_in | timestamp with time zone | + telecom_operator_id | numeric(4,0) | + enduser_number | character varying(15) | not null + telephone_number | character varying(15) | not null + application_id | numeric(10,0) | + customer_id | numeric(10,0) | + customer_app_config_id | numeric(10,0) | + customer_app_contents_id | numeric(10,0) | + message | character varying(160) | + message_type_id | numeric(4,0) | +Indexes: + "pk_stsasme_statistic_id" primary key, btree (statistic_id) +Triggers: + "RI_ConstraintTrigger_17328735" AFTER INSERT OR UPDATE ON +statistics_sasme FROM telecom_operators NOT DEFERRABLE INITIALLY +IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE +"RI_FKey_check_ins"('fk_stsasme_telecom_operator_id', +'statistics_sasme', 'telecom_operators', 'UNSPECIFIED', +'telecom_operator_id', 'telecom_operator_id') + "RI_ConstraintTrigger_17328738" AFTER INSERT OR UPDATE ON +statistics_sasme FROM applications NOT DEFERRABLE INITIALLY IMMEDIATE +FOR EACH ROW EXECUTE PROCEDURE +"RI_FKey_check_ins"('fk_stsasme_application_id', 'statistics_sasme', +'applications', 'UNSPECIFIED', 'application_id', 'application_id') + "RI_ConstraintTrigger_17328741" AFTER INSERT OR UPDATE ON +statistics_sasme FROM customers NOT DEFERRABLE INITIALLY IMMEDIATE FOR +EACH ROW EXECUTE PROCEDURE "RI_FKey_check_ins"('fk_stsasme_customer_id', +'statistics_sasme', 'customers', 'UNSPECIFIED', 'customer_id', +'customer_id') + + +That contains about 7.000.000 entries and I have to remove 33.000 +entries. I have created an sql file with all the delete sentences, e.g.: + + "DELETE FROM statistics_sasme WHERE statistic_id = 9832;" + +then I do \i delete_items.sql. Remove a single entry takes more than 10 +seconds. What would you do to speed it up? + +Thank you very much + + +From pgsql-performance-owner@postgresql.org Fri Sep 2 09:35:37 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 346CED7839 + for ; + Fri, 2 Sep 2005 09:35:36 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 68470-05 + for ; + Fri, 2 Sep 2005 12:35:34 +0000 (GMT) +Received: from cmailm2.svr.pol.co.uk (cmailm2.svr.pol.co.uk [195.92.193.210]) + by svr1.postgresql.org (Postfix) with ESMTP id 6E8A2D781C + for ; + Fri, 2 Sep 2005 09:35:33 -0300 (ADT) +Received: from modem-2769.lemur.dialup.pol.co.uk ([217.135.138.209] + helo=192.168.0.102) by cmailm2.svr.pol.co.uk with esmtp (Exim 4.41) + id 1EBAlc-0001DK-E3; Fri, 02 Sep 2005 13:35:36 +0100 +Subject: Re: ORDER BY and LIMIT not propagated on inherited +From: Simon Riggs +To: Matteo Beccati +Cc: pgsql-performance@postgresql.org +In-Reply-To: <43182789.4070307@beccati.com> +References: <43182789.4070307@beccati.com> +Content-Type: text/plain +Organization: 2nd Quadrant +Date: Fri, 02 Sep 2005 13:35:32 +0100 +Message-Id: <1125664532.3956.278.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-3) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.052 required=5 tests=[AWL=0.002, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/51 +X-Sequence-Number: 14359 + +On Fri, 2005-09-02 at 12:20 +0200, Matteo Beccati wrote: + +> I'm using inherited tables to partition some data which can grow very +> large. Recently I discovered that a simple query that on a regular table +> would use an index was instead using seq scans (70s vs a guessed 2s). +> The well known query is: +> +> SELECT foo FROM bar ORDER BY foo DESC LIMIT 1 +> +> (The same applies for SELECT MIN(foo) FROM bar using 8.1) +> +> +> The query plan generated when running the query on a table which has +> inheritance forces the planner to choose a seq_scan for each table. +> Wouldn't be a good thing to also promote ORDER BYs and LIMITs to each +> subscan (like WHERE does)? + +The tuple_fraction implied by LIMIT is already passed through to each +child table when using an inherited table structure. This would then be +taken into account when plans are made for each child table. I don't +think the situation you observe occurs as a result of query planning. + +Do your child tables have indexes on them? Indexes are not inherited +onto child tables, so it is possible that there is no index for the +planner to elect to use. + +Best Regards, Simon Riggs + + + + +From pgsql-performance-owner@postgresql.org Fri Sep 2 09:54:18 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 149ECD7A07 + for ; + Fri, 2 Sep 2005 09:54:17 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 51156-02 + for ; + Fri, 2 Sep 2005 12:54:14 +0000 (GMT) +Received: from mail1.fluidhosting.com (mail1.fluidhosting.com [204.14.90.61]) + by svr1.postgresql.org (Postfix) with SMTP id F082BD7989 + for ; + Fri, 2 Sep 2005 09:54:13 -0300 (ADT) +Received: (qmail 36674 invoked by uid 399); 2 Sep 2005 12:54:17 -0000 +Received: from 194-185-112-82.f5.ngi.it (HELO ?10.20.20.4?) (194.185.112.82) + by mail1.fluidhosting.com with SMTP; 2 Sep 2005 12:54:17 -0000 +Message-ID: <43184B8F.2090505@beccati.com> +Date: Fri, 02 Sep 2005 14:54:39 +0200 +From: Matteo Beccati +User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Simon Riggs +Cc: pgsql-performance@postgresql.org +Subject: Re: ORDER BY and LIMIT not propagated on inherited +References: <43182789.4070307@beccati.com> + <1125664532.3956.278.camel@localhost.localdomain> +In-Reply-To: <1125664532.3956.278.camel@localhost.localdomain> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.008 required=5 tests=[AWL=0.008] +X-Spam-Level: +X-Archive-Number: 200509/52 +X-Sequence-Number: 14360 + +Simon Riggs wrote: +>>The query plan generated when running the query on a table which has +>>inheritance forces the planner to choose a seq_scan for each table. +>>Wouldn't be a good thing to also promote ORDER BYs and LIMITs to each +>>subscan (like WHERE does)? +> +> The tuple_fraction implied by LIMIT is already passed through to each +> child table when using an inherited table structure. This would then be +> taken into account when plans are made for each child table. I don't +> think the situation you observe occurs as a result of query planning. +> +> Do your child tables have indexes on them? Indexes are not inherited +> onto child tables, so it is possible that there is no index for the +> planner to elect to use. + +In this cases the tuple_fraction is useless if the planner doesn't know +that a ORDER BY on each child table is requested. In fact the sort is +applied after all the rows are appended. The correct strategy IMHO would +be applying the order by and limit for each child table (which results +in an index scan, if possible), appending, then finally sorting a bunch +of rows, and limiting again. + +Every table has indexes, as you can see in the third attacheed EXPLAIN +ANALYZE output. + + +Best regards +-- +Matteo Beccati +http://phpadsnew.com +http://phppgads.com + +From pgsql-performance-owner@postgresql.org Fri Sep 2 10:36:16 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7C5C7D7255 + for ; + Fri, 2 Sep 2005 10:36:15 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 29761-08 + for ; + Fri, 2 Sep 2005 13:36:14 +0000 (GMT) +Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) + by svr1.postgresql.org (Postfix) with ESMTP id 6601DD7A3C + for ; + Fri, 2 Sep 2005 10:36:11 -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 j82DaBx1029074 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); + Fri, 2 Sep 2005 07:36:14 -0600 (MDT) + (envelope-from mfuhr@winnie.fuhr.org) +Received: from winnie.fuhr.org (localhost [127.0.0.1]) + by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j82DaBD7065410; + Fri, 2 Sep 2005 07:36:11 -0600 (MDT) + (envelope-from mfuhr@winnie.fuhr.org) +Received: (from mfuhr@localhost) + by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j82DaAh7065409; + Fri, 2 Sep 2005 07:36:10 -0600 (MDT) (envelope-from mfuhr) +Date: Fri, 2 Sep 2005 07:36:10 -0600 +From: Michael Fuhr +To: Arnau +Cc: pgsql-performance@postgresql.org +Subject: Re: Advise about how to delete entries +Message-ID: <20050902133610.GB65294@winnie.fuhr.org> +References: <43183AC9.1060704@andromeiberica.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <43183AC9.1060704@andromeiberica.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.005 required=5 tests=[AWL=0.005] +X-Spam-Level: +X-Archive-Number: 200509/53 +X-Sequence-Number: 14361 + +On Fri, Sep 02, 2005 at 01:43:05PM +0200, Arnau wrote: +> +> statistic_id | numeric(10,0) | not null default +> nextval('STATISTICS_OPERATOR_ID_SEQ'::text) + +Any reason this column is numeric instead of integer or bigint? + +> That contains about 7.000.000 entries and I have to remove 33.000 +> entries. I have created an sql file with all the delete sentences, e.g.: +> +> "DELETE FROM statistics_sasme WHERE statistic_id = 9832;" +> +> then I do \i delete_items.sql. Remove a single entry takes more than 10 +> seconds. What would you do to speed it up? + +The referential integrity triggers might be slowing down the delete. +Do you have indexes on all foreign key columns that refer to this +table? Do all foreign key columns that refer to statistic_id have +the same type as statistic_id (numeric)? What's the output "EXPLAIN +ANALYZE DELETE ..."? Do you vacuum and analyze the tables regularly? +What version of PostgreSQL are you using? + +-- +Michael Fuhr + +From pgsql-performance-owner@postgresql.org Fri Sep 2 11:53:20 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D83E4D70BC + for ; + Fri, 2 Sep 2005 11:41:02 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 89356-05 + for ; + Fri, 2 Sep 2005 14:41:01 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id DC78CD70A7 + for ; + Fri, 2 Sep 2005 11:41:00 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j82EesXI014075; + Fri, 2 Sep 2005 10:40:54 -0400 (EDT) +To: Matteo Beccati +Cc: Simon Riggs , + pgsql-performance@postgresql.org +Subject: Re: ORDER BY and LIMIT not propagated on inherited +In-reply-to: <43184B8F.2090505@beccati.com> +References: <43182789.4070307@beccati.com> + <1125664532.3956.278.camel@localhost.localdomain> + <43184B8F.2090505@beccati.com> +Comments: In-reply-to Matteo Beccati + message dated "Fri, 02 Sep 2005 14:54:39 +0200" +Date: Fri, 02 Sep 2005 10:40:54 -0400 +Message-ID: <14074.1125672054@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/54 +X-Sequence-Number: 14362 + +Matteo Beccati writes: +> The correct strategy IMHO would +> be applying the order by and limit for each child table (which results +> in an index scan, if possible), appending, then finally sorting a bunch +> of rows, and limiting again. + +This would be a win in some cases, and in many others a loss (ie, wasted +sort steps). The hard part is determining when to apply it. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Sep 2 12:00:40 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8FD1DD899F + for ; + Fri, 2 Sep 2005 12:00:33 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 15277-08 + for ; + Fri, 2 Sep 2005 15:00:29 +0000 (GMT) +Received: from mail1.fluidhosting.com (mail1.fluidhosting.com [204.14.90.61]) + by svr1.postgresql.org (Postfix) with SMTP id C1D4BD7769 + for ; + Fri, 2 Sep 2005 12:00:27 -0300 (ADT) +Received: (qmail 3994 invoked by uid 399); 2 Sep 2005 15:00:27 -0000 +Received: from 194-185-112-82.f5.ngi.it (HELO ?10.20.20.4?) (194.185.112.82) + by mail1.fluidhosting.com with SMTP; 2 Sep 2005 15:00:27 -0000 +Message-ID: <43186922.4060703@beccati.com> +Date: Fri, 02 Sep 2005 17:00:50 +0200 +From: Matteo Beccati +User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: Simon Riggs , + pgsql-performance@postgresql.org +Subject: Re: ORDER BY and LIMIT not propagated on inherited +References: <43182789.4070307@beccati.com> + <1125664532.3956.278.camel@localhost.localdomain> + <43184B8F.2090505@beccati.com> <14074.1125672054@sss.pgh.pa.us> +In-Reply-To: <14074.1125672054@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 required=5 tests=[AWL=0.007] +X-Spam-Level: +X-Archive-Number: 200509/55 +X-Sequence-Number: 14363 + +Hi, + +>>The correct strategy IMHO would +>>be applying the order by and limit for each child table (which results +>>in an index scan, if possible), appending, then finally sorting a bunch +>>of rows, and limiting again. +> +> This would be a win in some cases, and in many others a loss (ie, wasted +> sort steps). The hard part is determining when to apply it. + +I don't actually know how many smaller separate sorts compare to a +single big sort, but I guess the difference wouldn't be so big if the +LIMIT is low. Add to this that you don't need to append the whole +rowsets, but just smaller ones. + + +Best regards +-- +Matteo Beccati +http://phpadsnew.com +http://phppgads.com + +From pgsql-performance-owner@postgresql.org Fri Sep 2 12:10:51 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8ADDDD84C4 + for ; + Fri, 2 Sep 2005 12:09:27 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37165-10 + for ; + Fri, 2 Sep 2005 15:09:24 +0000 (GMT) +Received: from smtp1.asco.de (smtp1.asco.de [217.13.70.154]) + by svr1.postgresql.org (Postfix) with ESMTP id 408BFD7B6A + for ; + Fri, 2 Sep 2005 12:09:20 -0300 (ADT) +Received: from [192.168.1.72] (pitr.asco.de [192.168.1.72]) + (envelope-sender: ) + (authenticated j_schicke CRAM-MD5 bits=0) + by smtp1.asco.de (8.13.4/8.13.4/Debian-3) with ESMTP id j82F9I3v017896 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) + for ; Fri, 2 Sep 2005 17:09:18 +0200 +Date: Fri, 02 Sep 2005 17:09:18 +0200 +From: Jens-Wolfhard Schicke +Reply-To: Jens-Wolfhard Schicke +Cc: pgsql-performance@postgresql.org +Subject: Re: ORDER BY and LIMIT not propagated on inherited +Message-ID: <6A72374A62C8721E4E414937@[192.168.1.72]> +In-Reply-To: <43186922.4060703@beccati.com> +References: <43182789.4070307@beccati.com> + <1125664532.3956.278.camel@localhost.localdomain> + <43184B8F.2090505@beccati.com> <14074.1125672054@sss.pgh.pa.us> + <43186922.4060703@beccati.com> +X-Mailer: Mulberry/3.1.6 (Linux/x86) +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: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.172 required=5 tests=[AWL=0.172] +X-Spam-Level: +X-Archive-Number: 200509/56 +X-Sequence-Number: 14364 + +>>> The correct strategy IMHO would +>>> be applying the order by and limit for each child table (which results +>>> in an index scan, if possible), appending, then finally sorting a bunch +>>> of rows, and limiting again. +>> +>> This would be a win in some cases, and in many others a loss (ie, wasted +>> sort steps). The hard part is determining when to apply it. +> +> I don't actually know how many smaller separate sorts compare to a single +> big sort, but I guess the difference wouldn't be so big if the LIMIT is +> low. Add to this that you don't need to append the whole rowsets, but +> just smaller ones. + +I think if you have a bunch of sorted thingies, you'd perform exactly one=20 +merge step and be done, should be possible to do that in O(child_tables *=20 +rows)... + +Mit freundlichem Gru=DF +Jens Schicke +--=20 +Jens Schicke j.schicke@asco.de +asco GmbH http://www.asco.de +Mittelweg 7 Tel 0531/3906-127 +38106 Braunschweig Fax 0531/3906-400 + +From pgsql-performance-owner@postgresql.org Fri Sep 2 13:12:33 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B404DD7A95 + for ; + Fri, 2 Sep 2005 13:12:32 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 07838-10 + for ; + Fri, 2 Sep 2005 16:12:31 +0000 (GMT) +Received: from fdd00lnhub.fds.com (external.fds.com [208.15.90.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A08A6D7A90 + for ; + Fri, 2 Sep 2005 13:12:29 -0300 (ADT) +Subject: Poor SQL performance +To: pgsql-performance@postgresql.org +X-Mailer: Lotus Notes Release 6.5 September 18, 2003 +Message-ID: + +From: Patrick Hatcher +Date: Fri, 2 Sep 2005 09:12:04 -0700 +X-MIMETrack: Serialize by Router on FDD00LNHUB/FSG/SVR/FDD(Release 6.5.2|June + 01, 2004) at 09/02/2005 12:12:31 PM +MIME-Version: 1.0 +Content-type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.178 required=5 tests=[AWL=0.178] +X-Spam-Level: +X-Archive-Number: 200509/57 +X-Sequence-Number: 14365 + + + + + +Hey there folks. I'm at a loss as to how to increase the speed of this +query. It's something I need to run each day, but can't at the rate this +runs. Tables are updated 1/day and is vacuum analyzed after each load. + +select ddw_tran_key, r.price_type_id, t.price_type_id +from +cdm.cdm_ddw_tran_item_header h JOIN cdm.cdm_ddw_tran_item t +on t.appl_xref=h.appl_xref +JOIN +mdc_upc u ON +u.upc = t.item_upc +JOIN +mdc_price_history r +ON +r. upc_id = u.keyp_upc and date(r.site_timestamp) = h.first_order_date +where +cal_date = '2005-08-31' +and +h.appl_id= 'MCOM' +and tran_typ_id='S' +limit 1000 + + +My explain is just horrendous: + + QUERY +PLAN +-------------------------------------------------------------------------------------------------------------------------------------------------- + Limit (cost=288251.71..342657.36 rows=258 width=14) + -> Merge Join (cost=288251.71..342657.36 rows=258 width=14) + Merge Cond: (("outer".appl_xref)::text = "inner"."?column6?") + Join Filter: (date("inner".site_timestamp) = +"outer".first_order_date) + -> Index Scan using cdm_ddw_tran_item_header_pkey on +cdm_ddw_tran_item_header h (cost=0.00..51188.91 rows=789900 width=21) + Filter: ((appl_id)::text = 'MCOM'::text) + -> Sort (cost=288251.71..288604.31 rows=141038 width=39) + Sort Key: (t.appl_xref)::text + -> Hash Join (cost=29708.54..276188.93 rows=141038 +width=39) + Hash Cond: ("outer".upc_id = "inner".keyp_upc) + -> Seq Scan on mdc_price_history r +(cost=0.00..189831.09 rows=11047709 width=16) + -> Hash (cost=29698.81..29698.81 rows=3892 width=31) + -> Nested Loop (cost=0.00..29698.81 rows=3892 +width=31) + -> Index Scan using +cdm_ddw_tran_item_cal_date on cdm_ddw_tran_item t (cost=0.00..14046.49 +rows=3891 width=35) + Index Cond: (cal_date = +'2005-08-31'::date) + Filter: (tran_typ_id = 'S'::bpchar) + -> Index Scan using mdcupcidx on mdc_upc +u (cost=0.00..4.01 rows=1 width=12) + Index Cond: (u.upc = +"outer".item_upc) +(18 rows) + + + +What I found is that I remove change the line: +r.upc_id = u.keyp_upc and date(r.site_timestamp) = h.first_order_date + +To +r.upc_id = u.keyp_upc + +My query plan drops to: + QUERY +PLAN +----------------------------------------------------------------------------------------------------------------------------------------------- + Limit (cost=33327.39..37227.51 rows=1000 width=14) + -> Hash Join (cost=33327.39..279027.01 rows=62998 width=14) + Hash Cond: ("outer".upc_id = "inner".keyp_upc) + -> Seq Scan on mdc_price_history r (cost=0.00..189831.09 +rows=11047709 width=8) + -> Hash (cost=33323.05..33323.05 rows=1738 width=14) + -> Nested Loop (cost=0.00..33323.05 rows=1738 width=14) + -> Nested Loop (cost=0.00..26335.62 rows=1737 +width=18) + -> Index Scan using cdm_ddw_tran_item_cal_date +on cdm_ddw_tran_item t (cost=0.00..14046.49 rows=3891 width=35) + Index Cond: (cal_date = +'2005-08-31'::date) + Filter: (tran_typ_id = 'S'::bpchar) + -> Index Scan using +cdm_ddw_tran_item_header_pkey on cdm_ddw_tran_item_header h +(cost=0.00..3.15 rows=1 width=17) + Index Cond: (("outer".appl_xref)::text = +(h.appl_xref)::text) + Filter: ((appl_id)::text = 'MCOM'::text) + -> Index Scan using mdcupcidx on mdc_upc u +(cost=0.00..4.01 rows=1 width=12) + Index Cond: (u.upc = "outer".item_upc) +(15 rows) + + + + +Unfortunately, I need this criteria since it contains the first date of the +order and is used to pull the correct price. +Any suggestions? +TIA +Patrick + + + + + +From pgsql-performance-owner@postgresql.org Fri Sep 2 13:47:35 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0ECE8D7B37 + for ; + Fri, 2 Sep 2005 13:47:34 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 12319-01 + for ; + Fri, 2 Sep 2005 16:47:29 +0000 (GMT) +Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 37A59D7A95 + for ; + Fri, 2 Sep 2005 13:47:26 -0300 (ADT) +Received: (qmail 28381 invoked from network); 2 Sep 2005 18:47:54 +0200 +Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) + by boutiquenumerique.com with SMTP; 2 Sep 2005 18:47:54 +0200 +To: arnaulist@andromeiberica.com, pgsql-performance@postgresql.org +Subject: Re: Advise about how to delete entries +References: <43183AC9.1060704@andromeiberica.com> +Message-ID: +Date: Fri, 02 Sep 2005 18:47:21 +0200 +From: PFC +Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= +Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +In-Reply-To: <43183AC9.1060704@andromeiberica.com> +User-Agent: Opera M2/8.0 (Linux, build 1095) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/58 +X-Sequence-Number: 14366 + + +> "DELETE FROM statistics_sasme WHERE statistic_id = 9832;" + + As Michael said, why use a NUMERIC when a bigint is faster and better for +your use case, as you only need an integer and not a fixed precision +decimal ? + + Also if you use postgres < 8, the index will not be used if you search on +a type different from the column type. So, if your key is a bigint, you +should do WHERE statistic_id = 9832::bigint. + + For mass deletes like this, you should use one of the following, which +will be faster : + + DELETE FROM ... WHERE ID IN (list of values) + Don't put the 30000 values in the same query, but rather do 300 queries +with 100 values in each. + + COPY FROM a file with all the ID's to delete, into a temporary table, and +do a joined delete to your main table (thus, only one query). + + EXPLAIN DELETE is your friend. + +From pgsql-performance-owner@postgresql.org Fri Sep 2 13:54:55 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BE613D7A77 + for ; + Fri, 2 Sep 2005 13:48:57 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 85655-03 + for ; + Fri, 2 Sep 2005 16:48:53 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 69CD9D7989 + for ; + Fri, 2 Sep 2005 13:48:53 -0300 (ADT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 8021254; Fri, 02 Sep 2005 09:51:12 -0700 +From: Josh Berkus +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: Massive performance issues +Date: Fri, 2 Sep 2005 09:50:01 -0700 +User-Agent: KMail/1.8 +Cc: Matthew Sackman +References: <20050901174231.GE23970@pongo.lshift.net> + <5178.1125600426@sss.pgh.pa.us> + <20050901190808.GB7131@pongo.lshift.net> +In-Reply-To: <20050901190808.GB7131@pongo.lshift.net> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +Message-Id: <200509020950.01600.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.011 required=5 tests=[AWL=0.011] +X-Spam-Level: +X-Archive-Number: 200509/59 +X-Sequence-Number: 14367 + +Matthew, + +> Well, this is a development box. But the live box wouldn't be much more +> than RAID 1 on SCSI 10ks so that should only be a halving of seek time, +> not the 1000 times reduction I'm after! + +If you're looking for 1000 times reduction, I think you're going to need=20 +*considerably* beefier hardware. You'd pretty much have to count on the=20 +whole DB being in RAM, and a CPU being always available for incoming querie= +s. + +> In fact, now I think about it, I have been testing on a 2.4 kernel on a +> dual HT 3GHz Xeon with SCSI RAID array and the performance is only +> marginally better. + +Yes, but HT sucks for databases, so you're probably bottlenecking yourself = +on=20 +CPU on that machine. =20 + +However, if this is the query you really want to optimize for: + +select street, locality_1, locality_2, city from address=20 +where (city =3D 'Nottingham' or locality_2 =3D 'Nottingham' +=A0 =A0 =A0 =A0or locality_1 =3D 'Nottingham') +=A0 and upper(substring(street from 1 for 1)) =3D 'A'=20 +group by street, locality_1, locality_2, city +order by street +limit 20 offset 0 + +=2E.. then this is the query you should test on. Although I will say that= + your=20 +denormalized schema is actually hurting you siginificantly with the above=20 +type of query; indexes aren't going to be possible for it. + +=2D-=20 +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Fri Sep 2 14:55:16 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5CE77D8A0D + for ; + Fri, 2 Sep 2005 14:55:15 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 24894-04 + for ; + Fri, 2 Sep 2005 17:55:12 +0000 (GMT) +Received: from cmailg1.svr.pol.co.uk (cmailg1.svr.pol.co.uk [195.92.195.171]) + by svr1.postgresql.org (Postfix) with ESMTP id AC216D8A0B + for ; + Fri, 2 Sep 2005 14:55:07 -0300 (ADT) +Received: from modem-1141.leopard.dialup.pol.co.uk ([217.135.148.117] + helo=192.168.0.102) by cmailg1.svr.pol.co.uk with esmtp (Exim 4.41) + id 1EBFkp-0006vt-65; Fri, 02 Sep 2005 18:55:07 +0100 +Subject: Re: ORDER BY and LIMIT not propagated on inherited +From: Simon Riggs +To: Matteo Beccati +Cc: pgsql-performance@postgresql.org +In-Reply-To: <43182789.4070307@beccati.com> +References: <43182789.4070307@beccati.com> +Content-Type: text/plain +Organization: 2nd Quadrant +Date: Fri, 02 Sep 2005 18:54:56 +0100 +Message-Id: <1125683697.3956.310.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-3) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.052 required=5 tests=[AWL=0.002, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/60 +X-Sequence-Number: 14368 + +On Fri, 2005-09-02 at 12:20 +0200, Matteo Beccati wrote: +> I'm using inherited tables to partition some data which can grow very +> large. Recently I discovered that a simple query that on a regular table +> would use an index was instead using seq scans (70s vs a guessed 2s). +> The well known query is: +> +> SELECT foo FROM bar ORDER BY foo DESC LIMIT 1 +> +> (The same applies for SELECT MIN(foo) FROM bar using 8.1) +> + +Returning to Matteo's original query, what we are saying is that the new +optimization for MIN/MAX queries doesn't work with inherited tables. + +It could do, by running optimize_minmax_aggregates() for each query that +gets planned to see if a better plan exists for each child table. + +I think that's a TODO item. + +Optimizing ORDER BY and LIMIT down looks like it would be harder to do +in the general case, even if Matteo's simple transform looks good. I'm +not sure it's a very common query type though... + +Best Regards, Simon Riggs + + +From pgsql-performance-owner@postgresql.org Fri Sep 2 15:00:55 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 132C6D783A + for ; + Fri, 2 Sep 2005 15:00:55 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 32384-03 + for ; + Fri, 2 Sep 2005 18:00:50 +0000 (GMT) +Received: from mail.travelamericas.com (unknown [206.130.134.147]) + by svr1.postgresql.org (Postfix) with SMTP id E1032D76CC + for ; + Fri, 2 Sep 2005 15:00:48 -0300 (ADT) +Received: (qmail 13806 invoked from network); 2 Sep 2005 18:00:48 -0000 +Received: from unknown (HELO ?10.0.0.253?) (10.0.0.253) + by verkiel.travelamericas.com with SMTP; 2 Sep 2005 18:00:48 -0000 +Message-ID: <4318934E.7070404@travelamericas.com> +Date: Fri, 02 Sep 2005 11:00:46 -0700 +From: Chris Travers +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Akshay Mathur +Cc: 'Ron' , pgsql-performance@postgresql.org +Subject: Re: Massive performance issues +References: <002901c5afa0$0dcddab0$8301a8c0@pune.wibhu.com> +In-Reply-To: <002901c5afa0$0dcddab0$8301a8c0@pune.wibhu.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.026 required=5 tests=[AWL=0.026] +X-Spam-Level: +X-Archive-Number: 200509/61 +X-Sequence-Number: 14369 + +Akshay Mathur wrote: + +>Ron, +> +>Can you give me some pointers to make the tables RAM resident. If one +>does so, is the program accessing the data need to change. Does pgsql +>take care to write the data to disk? +> +> +> +PostgreSQL tried to intelligently cache information and then will also +use the OS disk cache as a secondary cache. So a sufficiently small and +frequently accessed table will be resident in RAM. + +The simplest way to affect this calculus is to put more RAM in the +machine. There are hacks I can think of to create RAM caches of +specific tables, but I don't want to take responsibility for anyone +trying these and running into trouble. + +Best Wishes, +Chris Travers +Metatron Technology Consulting + +From pgsql-performance-owner@postgresql.org Fri Sep 2 15:34:05 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D65F2D7A64 + for ; + Fri, 2 Sep 2005 15:34:04 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 87443-06 + for ; + Fri, 2 Sep 2005 18:34:00 +0000 (GMT) +Received: from mail1.fluidhosting.com (mail1.fluidhosting.com [204.14.90.61]) + by svr1.postgresql.org (Postfix) with SMTP id 27E8BD6E05 + for ; + Fri, 2 Sep 2005 15:33:58 -0300 (ADT) +Received: (qmail 6947 invoked by uid 399); 2 Sep 2005 18:33:57 -0000 +Received: from 81-174-7-77.f5.ngi.it (HELO ?127.0.0.1?) (81.174.7.77) + by mail1.fluidhosting.com with SMTP; 2 Sep 2005 18:33:57 -0000 +Message-ID: <43189B0F.2000904@beccati.com> +Date: Fri, 02 Sep 2005 20:33:51 +0200 +From: Matteo Beccati +User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Simon Riggs +Cc: pgsql-performance@postgresql.org +Subject: Re: ORDER BY and LIMIT not propagated on inherited +References: <43182789.4070307@beccati.com> + <1125683697.3956.310.camel@localhost.localdomain> +In-Reply-To: <1125683697.3956.310.camel@localhost.localdomain> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/62 +X-Sequence-Number: 14370 + +Simon Riggs wrote: +> Returning to Matteo's original query, what we are saying is that the new +> optimization for MIN/MAX queries doesn't work with inherited tables. +> +> It could do, by running optimize_minmax_aggregates() for each query that +> gets planned to see if a better plan exists for each child table. +> +> I think that's a TODO item. + +Great. Of course I'm using ORDER BY ... LIMIT as a workaround to get the +index scan on pre-8.1, and because I'm used to it insted of the +previously not optimized MIN/MAX aggregates. + +> Optimizing ORDER BY and LIMIT down looks like it would be harder to do +> in the general case, even if Matteo's simple transform looks good. I'm +> not sure it's a very common query type though... + +If I can find some time, I'll try to write some hacks... I just need to +find out where to start ;) + + +Best regards +-- +Matteo Beccati +http://phpadsnew.com/ +http://phppgads.com/ + +From pgsql-performance-owner@postgresql.org Fri Sep 2 17:10:43 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A4A1CD85D3 + for ; + Fri, 2 Sep 2005 17:08:56 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 52436-01 + for ; + Fri, 2 Sep 2005 20:08:54 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.207]) + by svr1.postgresql.org (Postfix) with ESMTP id 81B70D85A7 + for ; + Fri, 2 Sep 2005 17:08:53 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id i23so123185wra + for ; + Fri, 02 Sep 2005 13:08:53 -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=UJzkGG0P3WX6kH7cgRTpY2f4uIu5CWcQoMGYZdlzJNIqYozHfa1ZPDicHOUX9uvrzO6cEvOn386f9hvIhp6s6C0kjfojFBuv3NeC7rOUjcXCYc/wE0XRTqapHlYqAS2GHI6uYpTNw46/OCWTUZcPziH3ScRKZo7g+2L+9oFuC9E= +Received: by 10.54.38.51 with SMTP id l51mr2323107wrl; + Fri, 02 Sep 2005 13:08:53 -0700 (PDT) +Received: by 10.54.32.2 with HTTP; Fri, 2 Sep 2005 13:08:53 -0700 (PDT) +Message-ID: +Date: Sat, 3 Sep 2005 01:38:53 +0530 +From: Ramesh kumar +Reply-To: mbrameshkumar@gmail.com +To: Matteo Beccati +Subject: Re: ORDER BY and LIMIT not propagated on inherited +Cc: Simon Riggs , + pgsql-performance@postgresql.org +In-Reply-To: <43189B0F.2000904@beccati.com> +Mime-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_99_32768915.1125691733300" +References: <43182789.4070307@beccati.com> + <1125683697.3956.310.camel@localhost.localdomain> + <43189B0F.2000904@beccati.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.239 required=5 tests=[AWL=0.159, HTML_30_40=0.056, + HTML_MESSAGE=0.001, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200509/63 +X-Sequence-Number: 14371 + +------=_Part_99_32768915.1125691733300 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Hi all +I have got lot of information from ur group. +Now i want to relieve from this group. +I kindly request all of you. +Plz unsubcribe me. +Thankz a lot +Ramesh + + On 9/3/05, Matteo Beccati wrote:=20 +>=20 +> Simon Riggs wrote: +> > Returning to Matteo's original query, what we are saying is that the ne= +w +> > optimization for MIN/MAX queries doesn't work with inherited tables. +> > +> > It could do, by running optimize_minmax_aggregates() for each query tha= +t +> > gets planned to see if a better plan exists for each child table. +> > +> > I think that's a TODO item. +>=20 +> Great. Of course I'm using ORDER BY ... LIMIT as a workaround to get the +> index scan on pre-8.1, and because I'm used to it insted of the +> previously not optimized MIN/MAX aggregates. +>=20 +> > Optimizing ORDER BY and LIMIT down looks like it would be harder to do +> > in the general case, even if Matteo's simple transform looks good. I'm +> > not sure it's a very common query type though... +>=20 +> If I can find some time, I'll try to write some hacks... I just need to +> find out where to start ;) +>=20 +>=20 +> Best regards +> -- +> Matteo Beccati +> http://phpadsnew.com/ +> http://phppgads.com/ +>=20 +> ---------------------------(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 +>=20 + + + +--=20 +urs + +RameshKumar.M + +------=_Part_99_32768915.1125691733300 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +
Hi all
+
I have got lot of information from ur group.
+
Now i want to relieve from this group.
+
I kindly request all of you.
+
Plz unsubcribe me.
+
Thankz a lot
+
Ramesh

 
+
On 9/3/05, M= +atteo Beccati <php@beccati.com> wrote: +
Simon Riggs wrote:
> Retur= +ning to Matteo's original query, what we are saying is that the new
>= + optimization for MIN/MAX queries doesn't work with inherited tables. +
>
> It could do, by running optimize_minmax_aggregates() for e= +ach query that
> gets planned to see if a better plan exists for each= + child table.
>
> I think that's a TODO item.

Great. Of = +course I'm using ORDER BY ... LIMIT as a workaround to get the +
index scan on pre-8.1, and because I'm used to it insted of the
prev= +iously not optimized MIN/MAX aggregates.

> Optimizing ORDER BY an= +d LIMIT down looks like it would be harder to do
> in the general cas= +e, even if Matteo's simple transform looks good. I'm +
> not sure it's a very common query type though...

If I can f= +ind some time, I'll try to write some hacks... I just need to
find out w= +here to start ;)


Best regards
--
Matteo Beccati
+http://phpadsnew.com/
http://phppga= +ds.com/

---------------------------(end of broadcast)-----------= +----------------
TIP 1: if posting/reading through Usenet, please send a= +n appropriate +
      subscribe-nomail command to majordomo@postgresql.org so that y= +our
      message can get through to the m= +ailing list cleanly


+
--
urs

RameshKumar.M=20 + +------=_Part_99_32768915.1125691733300-- + +From pgsql-performance-owner@postgresql.org Tue Sep 6 00:49:57 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CA72ED791E + for ; + Fri, 2 Sep 2005 19:56:08 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 96834-06 + for ; + Fri, 2 Sep 2005 22:56:05 +0000 (GMT) +Received: from r163ip.btv.lv (r163ip.btv.lv [217.198.224.163]) + by svr1.postgresql.org (Postfix) with ESMTP id 26DC0D8A5C + for ; + Fri, 2 Sep 2005 19:56:02 -0300 (ADT) +Received: from p4 (pIV.homenet [192.168.88.4]) + by r163ip.btv.lv (8.12.9/8.12.6) with ESMTP id j82Mu2p6004594 + for ; + Sat, 3 Sep 2005 01:56:04 +0300 (EEST) + (envelope-from postgres@bilteks.com) +From: "Alexander Kirpa" +To: pgsql-performance@postgresql.org +Date: Sat, 3 Sep 2005 01:56:03 +0300 +MIME-Version: 1.0 +Content-type: text/plain; charset=US-ASCII +Content-transfer-encoding: 7BIT +Subject: Re: Poor SQL performance +Message-ID: <431902B3.24869.16B01310@localhost> +X-mailer: Pegasus Mail for Win32 (v3.12c) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/74 +X-Sequence-Number: 14382 + +Place +'and date(r.site_timestamp) = h.first_order_date' +after WHERE + +Best regards, + Alexander Kirpa + + +From pgsql-performance-owner@postgresql.org Fri Sep 2 22:37:29 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D95BAD829B + for ; + Fri, 2 Sep 2005 22:37:28 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 26113-08 + for ; + Sat, 3 Sep 2005 01:37:26 +0000 (GMT) +Received: from linda-5.paradise.net.nz (bm-5a.paradise.net.nz [202.0.58.24]) + by svr1.postgresql.org (Postfix) with ESMTP id D9915D7A08 + for ; + Fri, 2 Sep 2005 22:37:25 -0300 (ADT) +Received: from smtp-2.paradise.net.nz (smtp-2a.paradise.net.nz [202.0.32.195]) + by linda-5.paradise.net.nz (Paradise.net.nz) + with ESMTP id <0IM700AWDWIFPU@linda-5.paradise.net.nz> for + pgsql-performance@postgresql.org; Sat, 03 Sep 2005 13:37:28 +1200 (NZST) +Received: from [192.168.1.11] (218-101-14-90.paradise.net.nz [218.101.14.90]) + by smtp-2.paradise.net.nz (Postfix) with ESMTP id E12529ED88; Sat, + 03 Sep 2005 13:22:02 +1200 (NZST) +Date: Sat, 03 Sep 2005 13:22:01 +1200 +From: Mark Kirkwood +Subject: Re: Massive performance issues +In-reply-to: <4317D400.2080809@paradise.net.nz> +To: Matthew Sackman +Cc: pgsql-performance@postgresql.org +Message-id: <4318FAB9.4060800@paradise.net.nz> +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=ISO-8859-1 +Content-transfer-encoding: 7bit +X-Accept-Language: en-us, en +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050726) +References: <20050901174231.GE23970@pongo.lshift.net> + <4317D400.2080809@paradise.net.nz> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.135 required=5 tests=[AWL=0.135] +X-Spam-Level: +X-Archive-Number: 200509/64 +X-Sequence-Number: 14372 + +Mark Kirkwood wrote: +> Matthew Sackman wrote: +> +>> I need to get to the stage where I can run queries such as: +> +> > +> +>> select street, locality_1, locality_2, city from address where (city = +>> 'Nottingham' or locality_2 = 'Nottingham' +>> or locality_1 = 'Nottingham') +>> and upper(substring(street from 1 for 1)) = 'A' group by street, +>> locality_1, locality_2, city +>> order by street +>> limit 20 offset 0 +>> +>> and have the results very quickly. +>> +> +> This sort of query will be handled nicely in 8.1 - it has bitmap and/or +> processing to make use of multiple indexes. Note that 8.1 is in beta now. +> + +As others have commented, you will probably need better hardware to +achieve a factor of 1000 improvement, However I think using 8.1 could by +itself give you a factor or 10->100 improvement. + +e.g. Using your schema and generating synthetic data: + + +EXPLAIN +SELECT street, locality_1, locality_2, city +FROM address +WHERE (city = '500TH CITY' + OR locality_2 = '50TH LOCALITY' + OR locality_1 = '500TH LOCALITY') + AND upper(substring(street from 1 for 1)) = 'A' +GROUP BY street, locality_1, locality_2, city +ORDER BY street +LIMIT 20 OFFSET 0 + + QUERY PLAN + +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Limit (cost=59559.04..59559.09 rows=20 width=125) + -> Sort (cost=59559.04..59559.09 rows=21 width=125) + Sort Key: street + -> HashAggregate (cost=59558.37..59558.58 rows=21 width=125) + -> Bitmap Heap Scan on address (cost=323.19..59556.35 +rows=202 width=125) + Recheck Cond: (((city)::text = '500TH CITY'::text) +OR ((locality_2)::text = '50TH LOCALITY'::text) OR ((locality_1)::text = +'500TH LOCALITY'::text)) + Filter: (upper("substring"((street)::text, 1, 1)) += 'A'::text) + -> BitmapOr (cost=323.19..323.19 rows=40625 width=0) + -> Bitmap Index Scan on address_city_index + (cost=0.00..15.85 rows=1958 width=0) + Index Cond: ((city)::text = '500TH +CITY'::text) + -> Bitmap Index Scan on +address_locality_2_index (cost=0.00..143.00 rows=18000 width=0) + Index Cond: ((locality_2)::text = +'50TH LOCALITY'::text) + -> Bitmap Index Scan on +address_locality_1_index (cost=0.00..164.33 rows=20667 width=0) + Index Cond: ((locality_1)::text = +'500TH LOCALITY'::text) +(14 rows) + + +This takes 0.5s -> 2s to execute (depending on the frequencies generated +for the two localities). + +So we are a factor of 10 better already, on modest HW (2xPIII 1Ghz 2G +running FreeBSD 5.4). + +To go better than this you could try a specific summary table: + + +CREATE TABLE address_summary AS +SELECT street, + locality_1, + locality_2, + city, + upper(substring(street from 1 for 1)) AS cut_street +FROM address +GROUP BY street, locality_1, locality_2, city +; + +CREATE INDEX address_summary_city_index ON address_summary(city); +CREATE INDEX address_summary_locality_1_index ON +address_summary(locality_1); +CREATE INDEX address_summary_locality_2_index ON +address_summary(locality_2); +CREATE INDEX address_summary_street_index ON address_summary(street); +CREATE INDEX street_summary_prefix ON address_summary(cut_street); + + +And the query can be rewritten as: + +EXPLAIN +SELECT street, locality_1, locality_2, city +FROM address_summary +WHERE (city = '500TH CITY' + OR locality_2 = '50TH LOCALITY' + OR locality_1 = '500TH LOCALITY') + AND cut_street = 'A' +ORDER BY street +LIMIT 20 OFFSET 0 + + QUERY PLAN + +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Limit (cost=0.00..2006.05 rows=20 width=125) + -> Index Scan using address_summary_street_index on address_summary + (cost=0.00..109028.81 rows=1087 width=125) + Filter: ((((city)::text = '500TH CITY'::text) OR +((locality_2)::text = '50TH LOCALITY'::text) OR ((locality_1)::text = +'500TH LOCALITY'::text)) AND (cut_street = 'A'::text)) +(3 rows) + + +This takes 0.02s - so getting close to the factor of 1000 (a modern +machine with 3-5 times the memory access speed will get you there easily). + +The effectiveness of the summary table will depend on the how much the +GROUP BY reduces the cardinality (not much in this synthetic case), so +you will probably get better improvement with the real data! + +Cheers + +Mark + +From pgsql-performance-owner@postgresql.org Sat Sep 3 18:02:31 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 86E0CD8B2D + for ; + Sat, 3 Sep 2005 18:02:30 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 99919-07 + for ; + Sat, 3 Sep 2005 21:02:27 +0000 (GMT) +Received: from web35508.mail.mud.yahoo.com (web35508.mail.mud.yahoo.com + [66.163.179.132]) + by svr1.postgresql.org (Postfix) with SMTP id 48177D8B22 + for ; + Sat, 3 Sep 2005 18:02:25 -0300 (ADT) +Received: (qmail 75396 invoked by uid 60001); 3 Sep 2005 21:02:27 -0000 +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com.br; + h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; + b=RHKvjUQeNSMjDAfse3Nuz3Mertsz2XRutzsKdbwLGVVYvfYGnGaYVEXa3psZgWm/dUPh27nazfMQKf3mdLqldEZ2UnYZWX1VgiMs6lPrXAwvUnZl1vYtnm/0y1ySsEEPLWabiGtC5sml3sVqO9lTwf52vshpvA78qgCOAcP6GD4= + ; +Message-ID: <20050903210227.75394.qmail@web35508.mail.mud.yahoo.com> +Received: from [201.34.168.229] by web35508.mail.mud.yahoo.com via HTTP; + Sat, 03 Sep 2005 21:02:27 GMT +Date: Sat, 3 Sep 2005 21:02:27 +0000 (GMT) +From: Carlos Benkendorf +Subject: Improving performance of a query +To: pgsql-performance@postgresql.org +MIME-Version: 1.0 +Content-Type: multipart/alternative; boundary="0-381588866-1125781347=:75377" +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.702 required=5 tests=[AWL=-0.177, + DNS_FROM_RFC_ABUSE=0.374, HTML_20_30=0.504, HTML_MESSAGE=0.001] +X-Spam-Level: +X-Archive-Number: 200509/65 +X-Sequence-Number: 14373 + +--0-381588866-1125781347=:75377 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit + +Hi, + +Is there a way to improve the performance of the following query? + +SELECT * FROM SSIRRA where +(YEAR = 2004 and CUSTOMER = 0000000004 and CODE = 00 and PART >= 00) or +(YEAR = 2004 and CUSTOMER = 0000000004 and CODE > 00) or +(YEAR = 2004 and CUSTOMER > 0000000004) or +(YEAR > 2004) + +Thanks in advance! + +Benkendorf + + +__________________________________________________ +Converse com seus amigos em tempo real com o Yahoo! Messenger +http://br.download.yahoo.com/messenger/ +--0-381588866-1125781347=:75377 +Content-Type: text/html; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit + +
Hi,
+
 
+
Is there a way to improve the performance of the following query?
+
 
+
SELECT * FROM SSIRRA where
(YEAR = 2004 and CUSTOMER = 0000000004 and CODE = 00 and PART >= 00) or
(YEAR = 2004 and CUSTOMER = 0000000004 and CODE > 00) or
(YEAR = 2004 and CUSTOMER > 0000000004) or
(YEAR > 2004)
+
 
+
Thanks in advance!
+
 
+
Benkendorf

__________________________________________________
Converse com seus amigos em tempo real com o Yahoo! Messenger
http://br.download.yahoo.com/messenger/ +--0-381588866-1125781347=:75377-- + +From pgsql-performance-owner@postgresql.org Sat Sep 3 19:11:09 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 13358D8B0E + for ; + Sat, 3 Sep 2005 19:11:08 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 95203-01 + for ; + Sat, 3 Sep 2005 22:11:04 +0000 (GMT) +Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) + by svr1.postgresql.org (Postfix) with ESMTP id A6784D796E + for ; + Sat, 3 Sep 2005 19:11:02 -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 j83MB1JU030943 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); + Sat, 3 Sep 2005 16:11:03 -0600 (MDT) + (envelope-from mfuhr@winnie.fuhr.org) +Received: from winnie.fuhr.org (localhost [127.0.0.1]) + by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j83MB0mC003125; + Sat, 3 Sep 2005 16:11:00 -0600 (MDT) + (envelope-from mfuhr@winnie.fuhr.org) +Received: (from mfuhr@localhost) + by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j83MB0sD003124; + Sat, 3 Sep 2005 16:11:00 -0600 (MDT) (envelope-from mfuhr) +Date: Sat, 3 Sep 2005 16:11:00 -0600 +From: Michael Fuhr +To: Carlos Benkendorf +Cc: pgsql-performance@postgresql.org +Subject: Re: Improving performance of a query +Message-ID: <20050903221100.GA2985@winnie.fuhr.org> +References: <20050903210227.75394.qmail@web35508.mail.mud.yahoo.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20050903210227.75394.qmail@web35508.mail.mud.yahoo.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.005 required=5 tests=[AWL=0.005] +X-Spam-Level: +X-Archive-Number: 200509/66 +X-Sequence-Number: 14374 + +On Sat, Sep 03, 2005 at 09:02:27PM +0000, Carlos Benkendorf wrote: +> Is there a way to improve the performance of the following query? +> +> SELECT * FROM SSIRRA where +> (YEAR = 2004 and CUSTOMER = 0000000004 and CODE = 00 and PART >= 00) or +> (YEAR = 2004 and CUSTOMER = 0000000004 and CODE > 00) or +> (YEAR = 2004 and CUSTOMER > 0000000004) or +> (YEAR > 2004) + +Could you post the EXPLAIN ANALYZE output of the query? It might +also be useful to see the EXPLAIN ANALYZE output for each of those +WHERE conditions individually. Also, what are the table and index +definitions? How many rows are in the table? What version of +PostgreSQL are you using? Do you vacuum and analyze regularly? + +In simple tests in 8.0.3 with random data -- which almost certainly +has a different distribution than yours -- I see about a 10% +improvement with a multi-column index on (year, customer, code, +part) over using single-column indexes on each of those columns. +Various multi-column indexes on two or three of the columns gave +worse performance than single-column indexes. Your results will +probably vary, however. + +In my tests, 8.1beta1 with its bitmap scans was about 20-25% faster +than 8.0.3 with single-column indexes and about 35% faster with a +four-column index. 8.1beta1's use of a four-column index was about +45% faster than 8.0.3's use of single-column indexes. Don't trust +these numbers too much, though -- I simply inserted 20,000 random +records into a table and ran the above query. + +-- +Michael Fuhr + +From pgsql-performance-owner@postgresql.org Sun Sep 4 03:16:13 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 11C1AD7887 + for ; + Sun, 4 Sep 2005 03:16:12 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 87329-09 + for ; + Sun, 4 Sep 2005 06:16:10 +0000 (GMT) +Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.207]) + by svr1.postgresql.org (Postfix) with ESMTP id 57457D7882 + for ; + Sun, 4 Sep 2005 03:16:09 -0300 (ADT) +Received: by xproxy.gmail.com with SMTP id i31so634343wxd + for ; + Sat, 03 Sep 2005 23:16:10 -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:mime-version:content-type:content-transfer-encoding:content-disposition; + b=PpAzFMRUsZSTlfoSn8FoOOZ3OMUxFExzi9OohlEVOezZ/MQbr2J3lp+2w8ZieAKUnaC/krPhxxrerHqbKIym/ktu9gDzVtKWzBz2tanO0AU8VnRWybOWvjiGF+097OyuakpCy12yluhVeoFwtDFmhkKlvX+2Wul8pDKpASssuxQ= +Received: by 10.70.63.9 with SMTP id l9mr41746wxa; + Sat, 03 Sep 2005 23:16:10 -0700 (PDT) +Received: by 10.70.115.1 with HTTP; Sat, 3 Sep 2005 23:16:10 -0700 (PDT) +Message-ID: <72e966b00509032316166ff0cf@mail.gmail.com> +Date: Sun, 4 Sep 2005 00:16:10 -0600 +From: Jan Peterson +Reply-To: jan.l.peterson@gmail.com +To: pgsql-performance@postgresql.org +Subject: poor VACUUM performance on large tables +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.024 required=5 tests=[RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200509/67 +X-Sequence-Number: 14375 + +Hello, + +We have been experiencing poor performance of VACUUM in our production +database. Relevant details of our implementation are as follows: + +1. We have a database that grows to about 100GB. +2. The database is a mixture of large and small tables. +3. Bulk data (stored primarily in pg_largeobject, but also in various +TOAST tables) comprises about 45% of our data. +4. Some of our small tables are very active, with several hundred +updates per hour. +5. We have a "rolling delete" function that purges older data on a +periodic basis to keep our maximum database size at or near 100GB. + +Everything works great until our rolling delete kicks in. Of course, +we are doing periodic VACUUMS on all tables, with frequent VACUUMs on +the more active tables. The problem arises when we start deleting the +bulk data and have to VACUUM pg_largeobject and our other larger +tables. We have seen VACUUM run for several hours (even tens of +hours). During this VACUUM process, our smaller tables accumulate +dead rows (we assume because of the transactional nature of the +VACUUM) at a very rapid rate. Statistics are also skewed during this +process and we have observed the planner choosing sequential scans on +tables where it is obvious that an index scan would be more efficient. + +We're looking for ways to improve the performance of VACUUM. We are +already experimenting with Hannu Krosing's patch for VACUUM, but it's +not really helping (we are still faced with doing a database wide +VACUUM about once every three weeks or so as we approach the +transaction id rollover point... this VACUUM has been measured at 28 +hours in an active environment). + +Other things we're trying are partitioning tables (rotating the table +that updates happen to and using a view to combine the sub-tables for +querying). Unfortunately, we are unable to partition the +pg_largeobject table, and that table alone can take up 40+% of our +database storage. We're also looking at somehow storing our large +objects externally (as files in the local file system) and +implementing a mechanism similar to Oracle's bfile functionality. Of +course, we can't afford to give up the transactional security of being +able to roll back if a particular update doesn't succeed. + +Does anyone have any suggestions to offer on good ways to proceed +given our constraints? Thanks in advance for any help you can +provide. + + -jan- +--=20 +Jan L. Peterson + + +From pgsql-performance-owner@postgresql.org Sun Sep 4 11:58:04 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 08C3FD730B + for ; + Sun, 4 Sep 2005 11:58:03 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 35006-09 + for ; + Sun, 4 Sep 2005 14:58:00 +0000 (GMT) +Received: from window.monsterlabs.com (window.monsterlabs.com + [216.183.105.176]) + by svr1.postgresql.org (Postfix) with SMTP id 831EDD72D1 + for ; + Sun, 4 Sep 2005 11:57:58 -0300 (ADT) +Received: (qmail 30747 invoked from network); 4 Sep 2005 14:57:38 -0000 +Received: from dsl092-071-205.bos1.dsl.speakeasy.net (HELO ?66.92.71.205?) + (66.92.71.205) by 0 with SMTP; 4 Sep 2005 14:57:38 -0000 +In-Reply-To: <72e966b00509032316166ff0cf@mail.gmail.com> +References: <72e966b00509032316166ff0cf@mail.gmail.com> +Mime-Version: 1.0 (Apple Message framework v734) +Content-Type: text/plain; charset=WINDOWS-1252; delsp=yes; format=flowed +Message-Id: +Cc: pgsql-performance@postgresql.org +Content-Transfer-Encoding: quoted-printable +From: "Thomas F. O'Connell" +Subject: Re: poor VACUUM performance on large tables +Date: Sun, 4 Sep 2005 09:58:01 -0500 +To: jan.l.peterson@gmail.com +X-Mailer: Apple Mail (2.734) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/69 +X-Sequence-Number: 14377 + + +On Sep 4, 2005, at 1:16 AM, Jan Peterson wrote: + +> Hello, +> +> We have been experiencing poor performance of VACUUM in our production +> database. Relevant details of our implementation are as follows: +> +> 1. We have a database that grows to about 100GB. +> 2. The database is a mixture of large and small tables. +> 3. Bulk data (stored primarily in pg_largeobject, but also in various +> TOAST tables) comprises about 45% of our data. +> 4. Some of our small tables are very active, with several hundred +> updates per hour. +> 5. We have a "rolling delete" function that purges older data on a +> periodic basis to keep our maximum database size at or near 100GB. +> +> Everything works great until our rolling delete kicks in. Of course, +> we are doing periodic VACUUMS on all tables, with frequent VACUUMs on +> the more active tables. The problem arises when we start deleting the +> bulk data and have to VACUUM pg_largeobject and our other larger +> tables. We have seen VACUUM run for several hours (even tens of +> hours). During this VACUUM process, our smaller tables accumulate +> dead rows (we assume because of the transactional nature of the +> VACUUM) at a very rapid rate. Statistics are also skewed during this +> process and we have observed the planner choosing sequential scans on +> tables where it is obvious that an index scan would be more efficient. +> +> We're looking for ways to improve the performance of VACUUM. We are +> already experimenting with Hannu Krosing's patch for VACUUM, but it's +> not really helping (we are still faced with doing a database wide +> VACUUM about once every three weeks or so as we approach the +> transaction id rollover point... this VACUUM has been measured at 28 +> hours in an active environment). +> +> Other things we're trying are partitioning tables (rotating the table +> that updates happen to and using a view to combine the sub-tables for +> querying). Unfortunately, we are unable to partition the +> pg_largeobject table, and that table alone can take up 40+% of our +> database storage. We're also looking at somehow storing our large +> objects externally (as files in the local file system) and +> implementing a mechanism similar to Oracle's bfile functionality. Of +> course, we can't afford to give up the transactional security of being +> able to roll back if a particular update doesn't succeed. +> +> Does anyone have any suggestions to offer on good ways to proceed +> given our constraints? Thanks in advance for any help you can +> provide. +> +> -jan- + +Do you have your Free Space Map settings configured appropriately? =20 +See section 16.4.3.2 of the docs: + +http://www.postgresql.org/docs/8.0/static/runtime-config.html#RUNTIME-=20= + +CONFIG-RESOURCE + +You'll want to run a VACUUM VERBOSE and note the numbers at the end, =20 +which describe how many pages are used and how many are needed. =20 +max_fsm_pages should be set according to that, and you can set =20 +max_fsm_relations based on it, too, although typically one knows =20 +roughly how many relations are in a database. + +http://www.postgresql.org/docs/8.0/static/sql-vacuum.html + +Finally, have you experimented with pg_autovacuum, which is located =20 +in contrib in the source tarballs (and is integrated into the backend =20= + +in 8.1 beta and beyond)? You don't really say how often you're =20 +running VACUUM, and it might be that you're not vacuuming often enough. + +-- +Thomas F. O'Connell +Co-Founder, Information Architect +Sitening, LLC + +Strategic Open Source: Open Your i=99 + +http://www.sitening.com/ +110 30th Avenue North, Suite 6 +Nashville, TN 37203-6320 +615-469-5150 +615-469-5151 (fax)= + +From pgsql-performance-owner@postgresql.org Sun Sep 4 11:38:31 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1A2C6D723A + for ; + Sun, 4 Sep 2005 11:38:30 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 04780-03 + for ; + Sun, 4 Sep 2005 14:38:27 +0000 (GMT) +Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) + by svr1.postgresql.org (Postfix) with SMTP id EB261D70BA + for ; + Sun, 4 Sep 2005 11:38:25 -0300 (ADT) +Received: (qmail invoked by alias); 04 Sep 2005 14:38:29 -0000 +Received: from dyndsl-085-016-001-021.ewe-ip-backbone.de (EHLO + Dellerium.party.net) [85.16.1.21] + by mail.gmx.net (mp021) with SMTP; 04 Sep 2005 16:38:29 +0200 +X-Authenticated: #1246422 +Subject: Re: Poor performance on HP Package Cluster +From: Ernst Einstein +To: Luke Lonergan +Cc: Dan Harris , + pgsql-performance@postgresql.org +In-Reply-To: +References: +Content-Type: multipart/alternative; boundary="=-HDg5Hv9ESi1ADrEMAlEc" +Date: Sun, 04 Sep 2005 17:47:55 +0200 +Message-Id: <1125848875.6873.10.camel@Dellerium.party.net> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 +X-Y-GMX-Trusted: 0 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.087 required=5 tests=[HTML_40_50=0.086, + HTML_MESSAGE=0.001] +X-Spam-Level: +X-Archive-Number: 200509/68 +X-Sequence-Number: 14376 + + +--=-HDg5Hv9ESi1ADrEMAlEc +Content-Type: text/plain +Content-Transfer-Encoding: 7bit + +Hi ! + +Sorry, for my late answer. I was unavailable for a few days... + +Yes, I'm using the build-in HP Smart Array Controller. Both, the +internal disks, and the external storrage are using the controller. + +Can you send me your test results? I'm interested in it. + +I've done some testing now. I've imported the data again and tuned the +DB like I was told in some performance howtos. Now, the database has a +good performance - until it has to read from the disks. + +Greetings Ernst + + +Am Donnerstag, den 01.09.2005, 21:54 -0700 schrieb Luke Lonergan: + +> Dan, +> +> On 9/1/05 4:02 PM, "Dan Harris" wrote: +> +> > Do you have any sources for that information? I am running dual +> > SmartArray 6402's in my DL585 and haven't noticed anything poor about +> > their performance. +> +> I've previously posted comprehensive results using the 5i and 6xxx series +> smart arrays using software RAID, HW RAID on 3 different kernels, alongside +> LSI and Adaptec SCSI controllers, and an Adaptec 24xx HW RAID adapter. +> Results with bonnie++ and simple sequential read/write with dd. +> +> I'll post them again here for reference in the next message. Yes, the +> performance of the SmartArray controllers under Linux was abysmal, even when +> run by the labs at HP. +> +> - Luke +> +> +> +> ---------------------------(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 +> + +-- +Ernst Einstein + +--=-HDg5Hv9ESi1ADrEMAlEc +Content-Type: text/html; charset=utf-8 +Content-Transfer-Encoding: 7bit + + + + + + + + +Hi !
+
+Sorry, for my late answer. I was unavailable for a few days...
+
+Yes, I'm using the build-in HP Smart Array Controller. Both, the internal disks, and the external storrage are using the controller.
+
+Can you send me your test results? I'm interested in it.
+
+I've done some testing now. I've imported the data again and tuned the DB like I was told in some performance howtos. Now, the database has a good performance - until it has to read from the disks.
+
+Greetings Ernst
+
+
+Am Donnerstag, den 01.09.2005, 21:54 -0700 schrieb Luke Lonergan: +

+
+Dan,
+
+On 9/1/05 4:02 PM, "Dan Harris" <fbsd@drivefaster.net> wrote:
+
+> Do you have any sources for that information?  I am running dual
+> SmartArray 6402's in my DL585 and haven't noticed anything poor about
+> their performance.
+
+I've previously posted comprehensive results using the 5i and 6xxx series
+smart arrays using software RAID, HW RAID on 3 different kernels, alongside
+LSI and Adaptec SCSI controllers, and an Adaptec 24xx HW RAID adapter.
+Results with bonnie++ and simple sequential read/write with dd.
+
+I'll post them again here for reference in the next message.  Yes, the
+performance of the SmartArray controllers under Linux was abysmal, even when
+run by the labs at HP.
+
+- Luke
+
+
+
+---------------------------(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
+
+
+
+ + + + +
+--
+Ernst Einstein <Crusader@gmx.ch> +
+ + + +--=-HDg5Hv9ESi1ADrEMAlEc-- + + +From pgsql-performance-owner@postgresql.org Sun Sep 4 14:20:16 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 356DFD8411 + for ; + Sun, 4 Sep 2005 14:20:14 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 80840-06 + for ; + Sun, 4 Sep 2005 17:20:07 +0000 (GMT) +Received: from mail.Mi8.com (d01gw01.mi8.com [63.240.6.47]) + by svr1.postgresql.org (Postfix) with ESMTP id CA355D7D16 + for ; + Sun, 4 Sep 2005 14:20:03 -0300 (ADT) +Received: from 172.16.1.110 by mail.Mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D1)); Sun, 04 Sep 2005 13:19:55 -0400 +X-Server-Uuid: 241911D6-425B-44B9-A073-E3FE0F8FC774 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.174]) by + D01SMTP01.Mi8.com with Microsoft SMTPSVC(6.0.3790.211); Sun, 4 Sep 2005 + 13:19:55 -0400 +Received: from 24.5.173.15 ([24.5.173.15]) 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 ; Sun, 4 Sep + 2005 13:19:54 -0500 +User-Agent: Microsoft-Entourage/11.1.0.040913 +Date: Sun, 04 Sep 2005 10:19:53 -0700 +Subject: Re: Poor performance on HP Package Cluster +From: "Luke Lonergan" +To: "Ernst Einstein" +Cc: "Dan Harris" , + pgsql-performance@postgresql.org +Message-ID: +In-Reply-To: <1125848875.6873.10.camel@Dellerium.party.net> +MIME-Version: 1.0 +X-OriginalArrivalTime: 04 Sep 2005 17:19:55.0150 (UTC) + FILETIME=[DE2952E0:01C5B174] +X-WSS-ID: 6F05F3310TK3908504-01-01 +Content-Type: multipart/alternative; + boundary=B_3208673994_10704975 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.84 required=5 tests=[AWL=-0.246, + FORGED_RCVD_HELO=0.05, HTML_20_30=0.504, HTML_MESSAGE=0.001, + RCVD_NUMERIC_HELO=1.531] +X-Spam-Level: * +X-Archive-Number: 200509/70 +X-Sequence-Number: 14378 + +> 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_3208673994_10704975 +Content-Type: text/plain; + charset=iso-8859-1 +Content-Transfer-Encoding: quoted-printable + +Sure =AD I posted the excel spreadsheet to the list right after my message, +but I think it blocks attachments. I=B9ll send it to you now privately. + +I recommend switching to software RAID 10 or 5 using simple SCSI U320 +adapter(s) from LSI or Adaptec, which you can buy from HP if you must. + +Cheers, + +- Luke=20 + + +On 9/4/05 8:47 AM, "Ernst Einstein" wrote: + +> Hi ! +>=20 +> Sorry, for my late answer. I was unavailable for a few days... +>=20 +> Yes, I'm using the build-in HP Smart Array Controller. Both, the internal +> disks, and the external storrage are using the controller. +>=20 +> Can you send me your test results? I'm interested in it. +>=20 +> I've done some testing now. I've imported the data again and tuned the DB= + like +> I was told in some performance howtos. Now, the database has a good +> performance - until it has to read from the disks. +>=20 +> Greetings Ernst +>=20 +>=20 +> Am Donnerstag, den 01.09.2005, 21:54 -0700 schrieb Luke Lonergan: +>>=20 +>> Dan, +>>=20 +>> On 9/1/05 4:02 PM, "Dan Harris" wrote: +>>=20 +>>> > Do you have any sources for that information? I am running dual +>>> > SmartArray 6402's in my DL585 and haven't noticed anything poor about +>>> > their performance. +>>=20 +>> I've previously posted comprehensive results using the 5i and 6xxx serie= +s +>> smart arrays using software RAID, HW RAID on 3 different kernels, alongs= +ide +>> LSI and Adaptec SCSI controllers, and an Adaptec 24xx HW RAID adapter. +>> Results with bonnie++ and simple sequential read/write with dd. +>>=20 +>> I'll post them again here for reference in the next message. Yes, the +>> performance of the SmartArray controllers under Linux was abysmal, even = +when +>> run by the labs at HP. +>>=20 +>> - Luke +>>=20 +>>=20 +>>=20 +>> ---------------------------(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 + + + +--B_3208673994_10704975 +Content-Type: text/html; + charset=iso-8859-1 +Content-Transfer-Encoding: quoted-printable + + + +Re: [PERFORM] Poor performance on HP Package Cluster + + +Sure = +– I posted the excel spreadsheet to the list right after my message, b= +ut I think it blocks attachments.  I’ll send it to you now privat= +ely.
+
+I recommend switching to software RAID 10 or 5 using simple SCSI U320 adapt= +er(s) from LSI or Adaptec, which you can buy from HP if you must.
+
+Cheers,
+
+- Luke
+
+
+On 9/4/05 8:47 AM, "Ernst Einstein" <Crusader@gmx.ch> wrote= +:
+
+
Hi !
+
+Sorry, for my late answer. I was unavailable for a few days...
+
+Yes, I'm using the build-in HP Smart Array Controller. Both, the internal d= +isks, and the external storrage are using the controller.
+
+Can you send me your test results? I'm interested in it.
+
+I've done some testing now. I've imported the data again and tuned the DB l= +ike I was told in some performance howtos. Now, the database has a good perf= +ormance - until it has to read from the disks.
+
+Greetings Ernst
+
+
+Am Donnerstag, den 01.09.2005, 21:54 -0700 schrieb Luke Lonergan:
+

+Dan,
+
+On 9/1/05 4:02 PM, "Dan Harris" <fbsd@drivefaster.net> wrot= +e:
+
+> Do you have any sources for that information?  I am running dual<= +BR> +> SmartArray 6402's in my DL585 and haven't noticed anything poor about<= +BR> +> their performance.
+
+I've previously posted comprehensive results using the 5i and 6xxx series +smart arrays using software RAID, HW RAID on 3 different kernels, alongside= +
+LSI and Adaptec SCSI controllers, and an Adaptec 24xx HW RAID adapter.
+Results with bonnie++ and simple sequential read/write with dd.
+
+I'll post them again here for reference in the next message.  Yes, the= +
+performance of the SmartArray controllers under Linux was abysmal, even whe= +n
+run by the labs at HP.
+
+- Luke
+
+
+
+---------------------------(end of broadcast)--------------------------- +TIP 1: if posting/reading through Usenet, please send an appropriate
+       subscribe-nomail command to major= +domo@postgresql.org so that your
+       message can get through to the ma= +iling list cleanly
+

+
+ + + + +--B_3208673994_10704975-- + + +From pgsql-performance-owner@postgresql.org Sun Sep 4 20:01:12 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4C6E8D852D + for ; + Sun, 4 Sep 2005 20:01:11 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 07225-01 + for ; + Sun, 4 Sep 2005 23:01:10 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 059ACD81A3 + for ; + Sun, 4 Sep 2005 20:01:08 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j84N1AWn009275; + Sun, 4 Sep 2005 19:01:10 -0400 (EDT) +To: jan.l.peterson@gmail.com +Cc: pgsql-performance@postgresql.org +Subject: Re: poor VACUUM performance on large tables +In-reply-to: <72e966b00509032316166ff0cf@mail.gmail.com> +References: <72e966b00509032316166ff0cf@mail.gmail.com> +Comments: In-reply-to Jan Peterson + message dated "Sun, 04 Sep 2005 00:16:10 -0600" +Date: Sun, 04 Sep 2005 19:01:10 -0400 +Message-ID: <9274.1125874870@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/71 +X-Sequence-Number: 14379 + +Jan Peterson writes: +> We have been experiencing poor performance of VACUUM in our production +> database. + +Which PG version, exactly? + +> Everything works great until our rolling delete kicks in. Of course, +> we are doing periodic VACUUMS on all tables, with frequent VACUUMs on +> the more active tables. The problem arises when we start deleting the +> bulk data and have to VACUUM pg_largeobject and our other larger +> tables. We have seen VACUUM run for several hours (even tens of +> hours). + +Plain VACUUM (not FULL) certainly ought not take that long. (If you're +using VACUUM FULL, the answer is going to be "don't do that".) What +maintenance_work_mem (or vacuum_mem in older releases) are you running +it under? Can you get VACUUM VERBOSE output from some of these cases +so we can see which phase(s) are eating the time? It'd also be +interesting to watch the output of vmstat or local equivalent --- it +might just be that your I/O capability is nearly saturated and VACUUM is +pushing the system over the knee of the response curve. If so, the +vacuum delay options of 8.0 would be worth experimenting with. + +> Statistics are also skewed during this +> process and we have observed the planner choosing sequential scans on +> tables where it is obvious that an index scan would be more efficient. + +That's really pretty hard to believe; VACUUM doesn't affect the +statistics until the very end. Can you give some specifics of how +the "statistics are skewed"? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Sep 6 00:52:06 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 87346D79E7 + for ; + Sun, 4 Sep 2005 23:51:39 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 11958-03 + for ; + Mon, 5 Sep 2005 02:51:35 +0000 (GMT) +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 086D4D6E06 + for ; + Sun, 4 Sep 2005 23:51:33 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 9179331F59; Mon, 5 Sep 2005 04:51:38 +0200 (MET DST) +From: Martin Nickel +X-Newsgroups: pgsql.performance +Subject: Re: shared buffers +Date: Sun, 04 Sep 2005 21:56:01 -0500 +Organization: Hub.Org Networking Services +Lines: 32 +Message-ID: +References: <20050830015454.54152.qmail@web53204.mail.yahoo.com> + <4313BF95.3030105@familyhealth.com.au> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 8bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Pan/0.14.2 (This is not a psychotic episode. It's a cleansing + moment of clarity.) +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/75 +X-Sequence-Number: 14383 + +Chris, +Would you say that 30000 pages is a good maximum for a Postgres install? +We're running 8.0.3 on 64-bit SUSE on a dual Opteron box with 4G and have +shared_buffers set at 120000. I've moved it up and down (it was 160000 +when I got here) without any measurable performance difference. + +The reason I ask is because I occasionally see large-ish queries take +forever (like cancel-after-12-hours forever) and wondered if this could +result from shared_buffers being too large. + +Thanks for your (and anyone else's) help! +Martin Nickel + +On Tue, 30 Aug 2005 10:08:21 +0800, Christopher Kings-Lynne wrote: + +>> I forgot to say that it�s a 12GB database... +> +> That's actually not that large. +> +>> Ok, I�ll set shared buffers to 30.000 pages but even so "meminfo" and +>> "top" shouldn�t show some shared pages? +> +> Yeah. The reason for not setting buffers so high is because PostgreSQL +> cannot efficiently manage huge shared buffers, so you're better off +> giving the RAM to Linux's disk cache. +> +> Chris +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: Don't 'kill -9' the postmaster + + +From pgsql-performance-owner@postgresql.org Mon Sep 5 06:26:39 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BAC30D8000 + for ; + Mon, 5 Sep 2005 06:26:38 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 32485-08 + for ; + Mon, 5 Sep 2005 09:26:34 +0000 (GMT) +Received: from mail.androme.com (mail.androme.com [62.58.96.145]) + by svr1.postgresql.org (Postfix) with ESMTP id 91362D80AD + for ; + Mon, 5 Sep 2005 06:26:34 -0300 (ADT) +Received: from [127.0.0.1] ([192.168.10.56]) + by mail.androme.com (8.12.10/8.12.10) with ESMTP id j859QWxx026610 + for ; Mon, 5 Sep 2005 11:26:35 +0200 +Message-ID: <431C0F48.5050809@andromeiberica.com> +Date: Mon, 05 Sep 2005 11:26:32 +0200 +From: Arnau +Reply-To: arnaulist@andromeiberica.com +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: Advise about how to delete entries +References: <43183AC9.1060704@andromeiberica.com> + +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-15; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/72 +X-Sequence-Number: 14380 + +Hi all, + + > + > COPY FROM a file with all the ID's to delete, into a temporary +table, and do a joined delete to your main table (thus, only one query). + + + I already did this, but I don't have idea about how to do this join, +could you give me a hint ;-) ? + +Thank you very much +-- +Arnau + + +From pgsql-performance-owner@postgresql.org Tue Sep 6 00:55:54 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7FA73D726B + for ; + Mon, 5 Sep 2005 10:50:13 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 01467-05 + for ; + Mon, 5 Sep 2005 13:50:06 +0000 (GMT) +Received: from aut-vie-w2s021.bankgutmann.co.at + (Aut-vie-w2s021.bankgutmann.co.at [195.58.180.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 6DE31D7125 + for ; + Mon, 5 Sep 2005 10:50:07 -0300 (ADT) +Received: from aut-vie-w3s006.bankgutmann.co.at ([164.139.110.17]) by + aut-vie-w2s021.bankgutmann.co.at with Microsoft + SMTPSVC(6.0.3790.1830); Mon, 5 Sep 2005 15:50:07 +0200 +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: Postgresql Hardware - Recommendations +Date: Mon, 5 Sep 2005 15:50:07 +0200 +Message-ID: + +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: Postgresql Hardware - Recommendations +Thread-Index: AcWyILoJnwz6Zv+yRnidjfBke7BrJA== +From: +To: +Cc: +X-OriginalArrivalTime: 05 Sep 2005 13:50:07.0141 (UTC) + FILETIME=[B9895550:01C5B220] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.178 required=5 tests=[NO_REAL_NAME=0.178] +X-Spam-Level: +X-Archive-Number: 200509/76 +X-Sequence-Number: 14384 + +Hello, + +My company has decided to migrate our Oracle database to postgresql8. We +will aquire a new server for this, and would very much appreciate your +advice. + +NOTE: The applications accessing the database are developed and +maintained externally, and unfortunately, the developers have not yet +given us detailed information on their requirements. The only info I can +give so far is that the database size is about 60GB, and that it will be +frequently accessed by multiple users (about 100 will be connected +during business hours). The applications accessing the database are +mostly reporting tools. + +I know that the performance question will ultimately boil down to "it +depends what you want to do with it", but at the moment I'm very much +interested if there are any general issues we should look out for. + +The questions we are asking us now are: + +1) Intel or AMD (or alternate Platform) +Are we better of with Xeons or Opterons? Should we consider the IBM +OpenPower platform? + +2) CPUs vs cache +Would you rather have more CPUs or more cache? Eg: 4x Xeon 1MB vs 2x +Xeon 8MB + +3) CPUs vs Memory +Would you rather have 4x CPUs and 8GB of memory, or 2x CPUs with 16GB of +memory? + +Thanks in advance for all your replies! + +Best Regards, +Christian Kastner + +From pgsql-performance-owner@postgresql.org Tue Sep 6 01:01:36 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DC1ACD77EF + for ; + Tue, 6 Sep 2005 00:53:48 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 07380-04 + for ; + Tue, 6 Sep 2005 03:53:47 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 1B402D70F4 + for ; + Tue, 6 Sep 2005 00:53:46 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j863rf0N014136; + Mon, 5 Sep 2005 23:53:41 -0400 (EDT) +To: gdh@eyjar.is +Cc: pgsql-performance@postgresql.org +Subject: Re: Query slow after VACUUM ANALYZE +In-reply-to: <1913.213.220.100.208.1125483764.squirrel@www.eyjar.is> +References: <1913.213.220.100.208.1125483764.squirrel@www.eyjar.is> +Comments: In-reply-to gdh@eyjar.is + message dated "Wed, 31 Aug 2005 10:22:44 -0000" +Date: Mon, 05 Sep 2005 23:53:41 -0400 +Message-ID: <14135.1125978821@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/77 +X-Sequence-Number: 14385 + +gdh@eyjar.is writes: +> Any ideas what I can do to make the query running in < 10 seconds? + +Increase work_mem (or sort_mem in older releases). PG is dropping +back from the hash plan because it thinks the hashtable won't fit +in work_mem. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Sep 6 04:03:33 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 78A1ED725F + for ; + Tue, 6 Sep 2005 04:03:32 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 57598-02 + for ; + Tue, 6 Sep 2005 07:03:29 +0000 (GMT) +Received: from mx1.neopolitan.us (mx1.neopolitan.us [65.87.16.224]) + by svr1.postgresql.org (Postfix) with ESMTP id 9B5C8D70FC + for ; + Tue, 6 Sep 2005 04:03:28 -0300 (ADT) +Received: from [64.173.25.13] (HELO [192.168.2.45]) + by mx1.neopolitan.us (CommuniGate Pro SMTP 4.2.10) + with ESMTP id 10548555; Tue, 06 Sep 2005 00:03:29 -0700 +User-Agent: Microsoft-Entourage/11.1.0.040913 +Date: Tue, 06 Sep 2005 00:03:29 -0700 +Subject: Re: Postgresql Hardware - Recommendations +From: "J. Andrew Rogers" +To: , + +Message-ID: +In-Reply-To: + +Mime-version: 1.0 +Content-type: text/plain; + charset="US-ASCII" +Content-transfer-encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.312 required=5 tests=[AWL=-0.438, + DNS_FROM_RFC_ABUSE=0.374, DNS_FROM_RFC_POST=1.376] +X-Spam-Level: * +X-Archive-Number: 200509/82 +X-Sequence-Number: 14390 + + + + +On 9/5/05 6:50 AM, "Christian.Kastner@gutmann.at" + wrote: +> The questions we are asking us now are: +> +> 1) Intel or AMD (or alternate Platform) +> Are we better of with Xeons or Opterons? Should we consider the IBM +> OpenPower platform? + + +Opteron spanks Xeon for database loads. Advantage AMD, and you generally +won't have to spend much extra money for the privilege. I've never used +Postgres on the IBM OpenPower platform, but I would expect that it would +perform quite well, certainly better than the Xeons and probably competitive +with the Opterons in many respects -- I am not sufficiently knowledgeable to +make a definitive recommendation. + + +> 2) CPUs vs cache +> Would you rather have more CPUs or more cache? Eg: 4x Xeon 1MB vs 2x +> Xeon 8MB + + +I would expect that cache sizes are relatively unimportant compared to +number of processors, but it would depend on the specifics of your load. +Cache coherence is a significant issue for high concurrency database +applications, and a few megabytes of cache here and there will likely make +little difference for a 60GB database. Databases spend most of their time +playing in main memory, not in cache. The biggest advantage I can see to +bigger cache would be connection scaling, in which case you'll probably buy +more mileage with more processors. + +There are a lot of architecture dependencies here. Xeons scale badly to 4 +processors, Opterons scale just fine. + + + +> 3) CPUs vs Memory +> Would you rather have 4x CPUs and 8GB of memory, or 2x CPUs with 16GB of +> memory? + + +Uh, for what purpose? CPU and memory are not fungible, so how you +distribute them depends very much on your application. You can never have +too much memory for a large database, but having extra processors on a +scalable architecture is pretty nice too. What they both buy you is not +really related. + +The amount of memory you need is determined by the size of your cache-able +working set and the nature of your queries. Spend whatever money is left on +the processors; if your database spends all its time waiting for disks, no +quantity of processors will help you unless you are doing a lot of math on +the results. + + +YMMV, as always. Recommendations more specific than "Opterons rule, Xeons +suck" depend greatly on what you plan on doing with the database. + + +Cheers, + +J. Andrew Rogers + + + + +From pgsql-performance-owner@postgresql.org Tue Sep 6 08:02:32 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5F0E9D80D7 + for ; + Tue, 6 Sep 2005 08:02:30 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 21293-02 + for ; + Tue, 6 Sep 2005 11:02:25 +0000 (GMT) +Received: from sccrmhc14.comcast.net (sccrmhc14.comcast.net [204.127.202.59]) + by svr1.postgresql.org (Postfix) with ESMTP id 89FF7D80B2 + for ; + Tue, 6 Sep 2005 08:02:25 -0300 (ADT) +Received: from jafar.private.drule.org + (c-24-8-249-24.hsd1.co.comcast.net[24.8.249.24]) + by comcast.net (sccrmhc14) with ESMTP + id <2005090611022701400ekmahe>; Tue, 6 Sep 2005 11:02:27 +0000 +Received: from [192.168.0.51] (dhcp-51.private.drule.org [192.168.0.51]) + by jafar.private.drule.org (Postfix) with ESMTP id C9C742A51; + Tue, 6 Sep 2005 05:05:40 -0600 (MDT) +Message-ID: <431D77F5.4070307@drule.org> +Date: Tue, 06 Sep 2005 05:05:25 -0600 +From: Kevin +User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: arnaulist@andromeiberica.com +Cc: pgsql-performance@postgresql.org +Subject: Re: Advise about how to delete entries +References: <43183AC9.1060704@andromeiberica.com> + + <431C0F48.5050809@andromeiberica.com> +In-Reply-To: <431C0F48.5050809@andromeiberica.com> +Content-Type: text/plain; charset=ISO-8859-15; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 required=5 tests=[FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/83 +X-Sequence-Number: 14391 + +Arnau wrote: + +> Hi all, +> +> > +> > COPY FROM a file with all the ID's to delete, into a temporary +> table, and do a joined delete to your main table (thus, only one query). +> +> +> I already did this, but I don't have idea about how to do this join, +> could you give me a hint ;-) ? +> +> Thank you very much + +maybe something like this: + +DELETE FROM statistics_sasme s + LEFT JOIN temp_table t ON (s.statistic_id = t.statistic_id) +WHERE t.statistic_id IS NOT NULL + + +From pgsql-performance-owner@postgresql.org Tue Sep 6 10:04:09 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2F262D81E8 + for ; + Tue, 6 Sep 2005 10:04:09 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 53051-03 + for ; + Tue, 6 Sep 2005 13:04:02 +0000 (GMT) +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0387DD81B3 + for ; + Tue, 6 Sep 2005 10:04:00 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 58B7231F91; Tue, 6 Sep 2005 15:04:03 +0200 (MET DST) +From: Chris Browne +X-Newsgroups: pgsql.performance +Subject: Re: When to do a vacuum for highly active table +Date: Tue, 06 Sep 2005 08:48:56 -0400 +Organization: cbbrowne Computing Inc +Lines: 56 +Message-ID: <607jdumkef.fsf@dba2.int.libertyrms.com> +References: <20050830211356.48138.qmail@web31606.mail.mud.yahoo.com> + <20050830212545.5472718E718@linux.finestmedia.tv> +Mime-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +X-Complaints-To: usenet@news.hub.org +User-Agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4.17 (Jumbo Shrimp, linux) +Cancel-Lock: sha1:R5hLhPUDRk4tUidSsuC5SR0/t/Y= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.1 required=5 tests=[AWL=0.100] +X-Spam-Level: +X-Archive-Number: 200509/85 +X-Sequence-Number: 14393 + +rigmor.ukuhe@finestmedia.ee ("Rigmor Ukuhe") writes: + +>> -----Original Message----- +>> From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance- +>> owner@postgresql.org] On Behalf Of Markus Benne +>> Sent: Wednesday, August 31, 2005 12:14 AM +>> To: pgsql-performance@postgresql.org +>> Subject: [PERFORM] When to do a vacuum for highly active table +>> +>> We have a highly active table that has virtually all +>> entries updated every 5 minutes. Typical size of the +>> table is 50,000 entries, and entries have grown fat. +>> +>> We are currently vaccuming hourly, and towards the end +>> of the hour we are seeing degradation, when compared +>> to the top of the hour. +>> +>> Vaccum is slowly killing our system, as it is starting +>> to take up to 10 minutes, and load at the time of +>> vacuum is 6+ on a Linux box. During the vacuum, +>> overall system is goin unresponsive, then comes back +>> once vacuum completes. +> +> Play with vacuum_cost_delay option. In our case it made BIG difference +> (going from very heavy hitting to almost unnoticed vacuuming.) + +That helps only if the ONLY problem you're having is from the direct +I/O of the vacuum. + +If part of the problem is that the table is so large that it takes 4h +for VACUUM to complete, thereby leaving a transaction open for 4h, +thereby causing other degradations, then vacuum_cost_delay will have a +NEGATIVE impact, as it will mean that the vacuum on that table will +take even /more/ than 4h. :-( + +For the above scenario, it is almost certain that the solution comes +in two pieces: + +1. VACUUM FULL / CLUSTER to bring the size down. + + The table has grown "fat," and no number of repetitions of "plain + vacuum" will fix this. + +2. Do "plain vacuum" on the table VASTLY more frequently, probably + every 5 minutes, possibly more often than that. + + By doing this, you prevent things from getting so bad again. + +By the way, in this sort of situation, _ANY_ transaction that runs +more than about 5 minutes represents a serious enemy to performance, +as it will tend to cause the "hot" table to "get fatter." +-- +(reverse (concatenate 'string "gro.gultn" "@" "enworbbc")) +http://www.ntlug.org/~cbbrowne/linux.html +TECO Madness: a moment of regret, a lifetime of convenience. +-- Kent Pitman + +From pgsql-performance-owner@postgresql.org Tue Sep 6 09:59:51 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CBF30D7985 + for ; + Tue, 6 Sep 2005 09:59:50 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 50175-06 + for ; + Tue, 6 Sep 2005 12:59:45 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 2D45DD834F + for ; + Tue, 6 Sep 2005 09:59:43 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Subject: Re: Improving performance of a query +Date: Tue, 6 Sep 2005 08:59:46 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3417DD278@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Improving performance of a query +Thread-Index: AcWwy/CorXWnho5iRsihUjwQLGbIDACFcf3A +From: "Merlin Moncure" +To: "Carlos Benkendorf" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.056 required=5 tests=[AWL=0.006, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/84 +X-Sequence-Number: 14392 + +Carlos wrote: +SELECT * FROM SSIRRA where=20 +(YEAR =3D 2004 and CUSTOMER =3D 0000000004 and CODE =3D 00 and PART >=3D = +00) or=20 +(YEAR =3D 2004 and CUSTOMER =3D 0000000004 and CODE > 00) or=20 +(YEAR =3D 2004 and CUSTOMER > 0000000004) or=20 +(YEAR > 2004) +[snip] + +ah, the positional query. You can always rewrite this query in the +following form: + +(YEAR >=3D 2004) and +(YEAR =3D 2004 or CUSTOMER >=3D 0000000004) and +(YEAR =3D 2004 or CUSTOMER =3D 0000000004 or CODE >=3D 00) and +(YEAR =3D 2004 or CUSTOMER =3D 0000000004 or CODE =3D 00 or PART > 00)=20 + +This is better because it will index scan using 'year' (not customer or +part though). The true answer is to lobby for/develop proper row +constructor support so you can just=20 + +SELECT * FROM SSIRRA where (YEAR, CUSTOMER, CODE, PART) > (2004, +0000000004, 00, 00) + +this is designed to do what you are trying to do but currently doesn't +work quite right. + +note: in all these queries, 'order by YEAR, CUSTOMER, CODE, PART' should +probably be on the query. + +Other solution: use cursor/fetch or some type of materialized solution.=20 + +Merlin + +From pgsql-performance-owner@postgresql.org Tue Sep 6 11:09:08 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CF0B7D7985 + for ; + Tue, 6 Sep 2005 11:09:07 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 69772-10 + for ; + Tue, 6 Sep 2005 14:09:01 +0000 (GMT) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id 2E425D8385 + for ; + Tue, 6 Sep 2005 11:09:04 -0300 (ADT) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id F3AD235388; Tue, 6 Sep 2005 07:09:08 -0700 (PDT) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id F227B35320; Tue, 6 Sep 2005 07:09:08 -0700 (PDT) +Date: Tue, 6 Sep 2005 07:09:08 -0700 (PDT) +From: Stephan Szabo +To: Merlin Moncure +Cc: Carlos Benkendorf , + pgsql-performance@postgresql.org +Subject: Re: Improving performance of a query +In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB3417DD278@Herge.rcsinc.local> +Message-ID: <20050906070119.K35524@megazone.bigpanda.com> +References: <6EE64EF3AB31D5448D0007DD34EEB3417DD278@Herge.rcsinc.local> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/86 +X-Sequence-Number: 14394 + +On Tue, 6 Sep 2005, Merlin Moncure wrote: + +> Carlos wrote: +> SELECT * FROM SSIRRA where +> (YEAR = 2004 and CUSTOMER = 0000000004 and CODE = 00 and PART >= 00) or +> (YEAR = 2004 and CUSTOMER = 0000000004 and CODE > 00) or +> (YEAR = 2004 and CUSTOMER > 0000000004) or +> (YEAR > 2004) +> [snip] +> +> ah, the positional query. You can always rewrite this query in the +> following form: +> +> (YEAR >= 2004) and +> (YEAR = 2004 or CUSTOMER >= 0000000004) and +> (YEAR = 2004 or CUSTOMER = 0000000004 or CODE >= 00) and +> (YEAR = 2004 or CUSTOMER = 0000000004 or CODE = 00 or PART > 00) + +Unless I'm not seeing something, I don't think that's a correct +reformulation in general. If customer < 4 and year > 2004 the original +clause would return true but the reformulation would return false since +(year=2004 or customer >= 4) would be false. + +From pgsql-performance-owner@postgresql.org Tue Sep 6 11:12:33 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A20F8D6E40 + for ; + Tue, 6 Sep 2005 11:12:32 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 73191-06 + for ; + Tue, 6 Sep 2005 14:12:27 +0000 (GMT) +Received: from mercure-1.sigma.fr (mercure-2.sigma.fr [195.25.81.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 189C9D6D8A + for ; + Tue, 6 Sep 2005 11:12:26 -0300 (ADT) +Received: from localhost (localhost [127.0.0.1]) + by mercure-1.sigma.fr (Postfix) with ESMTP id 5B64C214 + for ; + Tue, 6 Sep 2005 16:12:29 +0200 (CEST) +Received: from mercure-1.sigma.fr ([127.0.0.1]) + by localhost (mercure-2 [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 09338-06 for ; + Tue, 6 Sep 2005 16:12:29 +0200 (CEST) +Received: from delpiv3000-124l (unknown [89.195.0.5]) + by mercure-1.sigma.fr (Postfix) with ESMTP id 2A86E21D + for ; + Tue, 6 Sep 2005 16:12:29 +0200 (CEST) +From: Marc Cousin +Organization: Sigma Informatique +To: pgsql-performance@postgresql.org +Subject: insert performance for win32 +Date: Tue, 6 Sep 2005 16:12:27 +0200 +User-Agent: KMail/1.8.2 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200509061612.27746.mcousin@sigma.fr> +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at sigma.fr +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/87 +X-Sequence-Number: 14395 + +Hi, + +I usually use PostgreSQL coupled with Linux, but I have to use Windows for a +perticular project. + +So I wanted to do some tests to know if the performance will be acceptable (I +don't need PostgreSQL to be as fast with windows as with linux, but it has to +be usable...). + +I started with trying to do lots of inserts, and I'm quite astonished by the +catastrophics results ... + +The test : +The computer was the same (my workstation, a PIV Dell with SATA disk), dual +boot + +The windows OS is XP. + +Both Oses are PostgreSQL 8.0.3 + +Both PostgreSQL clusters (windows and linux) have the same tuning +(shared_buffers=20000, wal_buffers=128, checkpoint_segments=10) + +Before each test, the clusters are vacuum analyzed, and the test database is +recreated. + +The script is quite dumb : +BEGIN; +CREATE TABLE test (col1 serial, col2 text); +INSERT INTO test (col2) values ('test'); +INSERT INTO test (col2) values ('test'); +INSERT INTO test (col2) values ('test'); +INSERT INTO test (col2) values ('test'); +INSERT INTO test (col2) values ('test'); +...... 500,000 times +Then COMMIT. + +I know it isn't realistic, but I needed to start with something :) + +The results are as follows : +Linux : 1'9'' +Windows : 9'38'' + +What I've tried to solve, and didn't work : + +- Deactivate antivirus on windows +- fsync=no +- raise the checkpoint_segments value (32) +- remove hyperthreading (who knows...) + +I don't know what could cause this (I'm not a windows admin...at all). All I +see is a very high kernel load during the execution of this script, but I +can't determine where it comes from. + + +I'd like to know if this is a know problem, if there is something I can do, +etc... + +Thanks a lot. + +From pgsql-performance-owner@postgresql.org Tue Sep 6 11:47:18 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 09E2AD8443 + for ; + Tue, 6 Sep 2005 11:47:17 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 84621-04 + for ; + Tue, 6 Sep 2005 14:47:10 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 3549ED83C7 + for ; + Tue, 6 Sep 2005 11:47:12 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Subject: Re: Improving performance of a query +Date: Tue, 6 Sep 2005 10:47:16 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3417DD27D@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Improving performance of a query +Thread-Index: AcWy7JDUTlW3CNSRS/CTaqPgJfpNdAAAEATA +From: "Merlin Moncure" +To: "Stephan Szabo" +Cc: , + "Carlos Benkendorf" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.056 required=5 tests=[AWL=0.006, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/88 +X-Sequence-Number: 14396 + +> > Carlos wrote: +> > SELECT * FROM SSIRRA where +> > (YEAR =3D 2004 and CUSTOMER =3D 0000000004 and CODE =3D 00 and PART = +>=3D 00) +or +> > (YEAR =3D 2004 and CUSTOMER =3D 0000000004 and CODE > 00) or +> > (YEAR =3D 2004 and CUSTOMER > 0000000004) or +> > (YEAR > 2004) +> > [snip] +> > +> > ah, the positional query. You can always rewrite this query in the +> > following form: +> > +> > (YEAR >=3D 2004) and +> > (YEAR =3D 2004 or CUSTOMER >=3D 0000000004) and +> > (YEAR =3D 2004 or CUSTOMER =3D 0000000004 or CODE >=3D 00) and +> > (YEAR =3D 2004 or CUSTOMER =3D 0000000004 or CODE =3D 00 or PART > = +00) +>=20 +> Unless I'm not seeing something, I don't think that's a correct +> reformulation in general. If customer < 4 and year > 2004 the original +> clause would return true but the reformulation would return false +since +> (year=3D2004 or customer >=3D 4) would be false. + +You are correct, you also have to exchange '=3D' with '>' to exchange +'and' with 'or'. =20 + +Correct answer is: +> > (YEAR >=3D 2004) and +> > (YEAR > 2004 or CUSTOMER >=3D 0000000004) and +> > (YEAR > 2004 or CUSTOMER > 0000000004 or CODE >=3D 00) and +> > (YEAR > 2004 or CUSTOMER > 0000000004 or CODE > 00 or PART > 00) + +It's easy to get tripped up here: the basic problem is how to get the +next record based on a multi part key. My ISAM bridge can write them +either way but the 'and' major form is always faster ;). + +MErlin + +From pgsql-performance-owner@postgresql.org Tue Sep 6 11:56:28 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2B049D8640 + for ; + Tue, 6 Sep 2005 11:56:27 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 87620-02 + for ; + Tue, 6 Sep 2005 14:56:19 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 33F1AD874E + for ; + Tue, 6 Sep 2005 11:56:21 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Subject: Re: insert performance for win32 +Date: Tue, 6 Sep 2005 10:56:26 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3417DD27E@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] insert performance for win32 +Thread-Index: AcWy7ewQXhRaT+X+SZupX21tCOxXygABB6HQ +From: "Merlin Moncure" +To: "Marc Cousin" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.056 required=5 tests=[AWL=0.006, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/89 +X-Sequence-Number: 14397 + +> Hi, +>=20 +> I usually use PostgreSQL coupled with Linux, but I have to use Windows +for +> a +> perticular project. +>=20 +> So I wanted to do some tests to know if the performance will be +acceptable +> (I +> don't need PostgreSQL to be as fast with windows as with linux, but it +has +> to +> be usable...). + +In my experience win32 is par with linux generally with a few gotchas on +either side. Are your times with fsync=3Dno? It's much harder to give +apples-apples comparison with fsync=3Don for various reasons. + +Are you running stats_command_string=3Don? Try disabling and compare +results. +Is your loading app running locally or on the server? + +I am very interesting in discovering sources of high cpu load problems +on win32. If you are still having problems could you get a gprof +profile together? There is a recent thread on win32-hackers discussing +how to do this. + +Merlin + + + +From pgsql-performance-owner@postgresql.org Tue Sep 6 12:06:29 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8D1DCD834F + for ; + Tue, 6 Sep 2005 12:04:28 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 87790-08 + for ; + Tue, 6 Sep 2005 15:04:25 +0000 (GMT) +Received: from EXCHANGE.sf.nimblefish.com (unknown [66.54.159.162]) + by svr1.postgresql.org (Postfix) with ESMTP id 03BF2D81FE + for ; + Tue, 6 Sep 2005 12:04:24 -0300 (ADT) +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_01C5B2F4.43A1015E" +Subject: Poor performance of delete by primary key +Date: Tue, 6 Sep 2005 08:04:22 -0700 +Message-ID: + <2F9239F5E316C54688FDA9814FF045D6EADACC@EXCHANGE.sf.nimblefish.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: Poor performance of delete by primary key +thread-index: AcWy9EOBO5xF/a4BSuuMRTGGqM18Hg== +From: "Brian Choate" +To: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.505 required=5 tests=[HTML_20_30=0.504, + HTML_MESSAGE=0.001] +X-Spam-Level: +X-Archive-Number: 200509/90 +X-Sequence-Number: 14398 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C5B2F4.43A1015E +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +Hello, + +We are seeing a very strange behavior from postgres. For one of our very = +common tasks we have to delete records from a table of around 500,000 = +rows. The delete is by id which is the primary key. It seems to be = +consistently taking around 10 minutes to preform. This is totally out of = +line with the rest of the performance of the database. + +This table does have children through foreign keys, but I am pretty sure = +that all foreign key constraints in the schema have indexes on their = +children.=20 + +Sometimes if we do a vacuum right before running the process the delete = +will go much faster. But then the next time we run the task, even just a = +few minutes later, the delete takes a long time to run. + +We deploy the same application also on Oracle. The schemas are pretty = +much identical. On similar hardware with actually about 4 to 5 times the = +data, Oracle does not seem to have the same problem. Not that that = +really means anything since the internals of Oracle and PostgreSQL are = +so different, but an interesting fact anyway. + +Any ideas on what might be going on? + +Thanks, +B. + +------_=_NextPart_001_01C5B2F4.43A1015E +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + +Poor performance of delete by primary key + + + + +

Hello,
+
+We are seeing a very strange behavior from postgres. For one of our very = +common tasks we have to delete records from a table of around 500,000 = +rows. The delete is by id which is the primary key. It seems to be = +consistently taking around 10 minutes to preform. This is totally out of = +line with the rest of the performance of the database.
+
+This table does have children through foreign keys, but I am pretty sure = +that all foreign key constraints in the schema have indexes on their = +children.
+
+Sometimes if we do a vacuum right before running the process the delete = +will go much faster. But then the next time we run the task, even just a = +few minutes later, the delete takes a long time to run.
+
+We deploy the same application also on Oracle. The schemas are pretty = +much identical. On similar hardware with actually about 4 to 5 times the = +data, Oracle does not seem to have the same problem. Not that that = +really means anything since the internals of Oracle and PostgreSQL are = +so different, but an interesting fact anyway.
+
+Any ideas on what might be going on?
+
+Thanks,
+B.
+
+

+ + + +------_=_NextPart_001_01C5B2F4.43A1015E-- + +From pgsql-performance-owner@postgresql.org Tue Sep 6 12:11:49 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C9647D6D8A + for ; + Tue, 6 Sep 2005 12:09:17 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91559-01 + for ; + Tue, 6 Sep 2005 15:09:12 +0000 (GMT) +Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.207]) + by svr1.postgresql.org (Postfix) with ESMTP id 18198D853E + for ; + Tue, 6 Sep 2005 12:09:11 -0300 (ADT) +Received: by xproxy.gmail.com with SMTP id i31so1076538wxd + for ; + Tue, 06 Sep 2005 08:09:10 -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=pmFJ8tIR+jsDmpNqfLa64qLMdnucOVDCRujpjC0Bk9LFdEM6OZxVe8SDx1GJ0IFNNxwsHluVv9MLTyLthPlLJe44wE4oaA0t72rVibI71QxRZDNJSH/KDXUnmZS35NBqO/vqO/rbAU4SwYZVpmV5v3mK3qfn2xBHLLfmQle0XTY= +Received: by 10.70.63.16 with SMTP id l16mr108720wxa; + Tue, 06 Sep 2005 08:09:10 -0700 (PDT) +Received: by 10.70.128.19 with HTTP; Tue, 6 Sep 2005 08:09:10 -0700 (PDT) +Message-ID: +Date: Tue, 6 Sep 2005 10:09:10 -0500 +From: Matthew Nuzum +Reply-To: newz@bearfruit.org +To: "Christian.Kastner@gutmann.at" +Subject: Re: Postgresql Hardware - Recommendations +Cc: pgsql-performance@postgresql.org +In-Reply-To: + +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.175 required=5 tests=[AWL=-1.151, RCVD_BY_IP=0.024, + RCVD_IN_BL_SPAMCOP_NET=1.832, TO_ADDRESS_EQ_REAL=0.47] +X-Spam-Level: * +X-Archive-Number: 200509/91 +X-Sequence-Number: 14399 + +On 9/5/05, Christian.Kastner@gutmann.at wrot= +e: +> ... The only info I can +> give so far is that the database size is about 60GB, and that it will be +> frequently accessed by multiple users (about 100 will be connected +> during business hours). The applications accessing the database are +> mostly reporting tools. + +Optimizing hardware for mostly selects is different than optimizing +for lots of inserts. You will get good responses from this list if you +can give a little more details. Here are some questions: +How do you get your data into the db? Do you do bullk loads at +periodic intervals during the day? Do you do frequent updates/inserts? + +You say reporting, do you use many stored procedures and calculations +on the server side? I've used some reporting apps that simply grab +tons of data from the server and then process it on the client side +(ODBC apps seem to do this), while other applications formulate the +queries and use stored procedures in order to transfer little data. + +Of your 60GB, how much of that is active? Does your budget allow you +to buy enough RAM to get your active data into the disk cache? For +reporting, this *might* be your biggest win. + +Here are some scenarios: +S1: Bulk uploads once or twice daily of about 250 MB of data. Few +inserts and updates during the day (1-2%). Reporting is largely done +on data from the last 5 business days. In this case you have < 2GB of +active data and your disk cache will hold all of your active data in +RAM (provided your db structure is diskcache friendly). An example of +this I have experienced is a sales application that queries current +inventory. Telephone agents queried, quieried, queried the +instock-inventory. + +S2: Same as above but reporting is largely done on data covering 200+ +business days. Its doubtful that you will get 50GB of RAM in your +server, you need to focus on disk speed. An example of this I have +experienced was an application that looked at sales trends and +performed commission calculations and projected sales forecasts. + +S3: Lots of inserts/updates throughout the day (15 - 25%) - you need +to focus on disk speed. The content management system my employer +develops fits this model. + +> 3) CPUs vs Memory +> Would you rather have 4x CPUs and 8GB of memory, or 2x CPUs with 16GB of +> memory? + +Very hard to say without knowing your application. I have limited +experience but what I've found is that applications that support +multiple db architectures do not fully utilize the database server and +CPU utilization is low. Disk and network i/o is high. I don't know if +your application supports multiple backeneds, but chances are good +your biggest wins will come from RAM, disk and network investments. + +--=20 +Matthew Nuzum +www.bearfruit.org + +From pgsql-performance-owner@postgresql.org Tue Sep 6 12:14:26 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7AB0CD83F4 + for ; + Tue, 6 Sep 2005 12:13:50 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 89020-09 + for ; + Tue, 6 Sep 2005 15:13:45 +0000 (GMT) +Received: from mercure-1.sigma.fr (mercure-2.sigma.fr [195.25.81.10]) + by svr1.postgresql.org (Postfix) with ESMTP id CADC6D8239 + for ; + Tue, 6 Sep 2005 12:13:44 -0300 (ADT) +Received: from localhost (localhost [127.0.0.1]) + by mercure-1.sigma.fr (Postfix) with ESMTP id 3C3511FC + for ; + Tue, 6 Sep 2005 17:13:43 +0200 (CEST) +Received: from mercure-1.sigma.fr ([127.0.0.1]) + by localhost (mercure-2 [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 12467-09 for ; + Tue, 6 Sep 2005 17:13:42 +0200 (CEST) +Received: from delpiv3000-124l (unknown [89.195.0.5]) + by mercure-1.sigma.fr (Postfix) with ESMTP id A8F611F5 + for ; + Tue, 6 Sep 2005 17:13:42 +0200 (CEST) +From: Marc Cousin +Organization: Sigma Informatique +Subject: Re: insert performance for win32 +Date: Tue, 6 Sep 2005 17:13:41 +0200 +User-Agent: KMail/1.8.2 +Cc: pgsql-performance@postgresql.org +References: <6EE64EF3AB31D5448D0007DD34EEB3417DD27E@Herge.rcsinc.local> +In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB3417DD27E@Herge.rcsinc.local> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +To: Undisclosed.Recipients: ; +Message-Id: <200509061713.41559.mcousin@sigma.fr> +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at sigma.fr +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/92 +X-Sequence-Number: 14400 + +> +> In my experience win32 is par with linux generally with a few gotchas on +> either side. =A0Are your times with fsync=3Dno? It's much harder to give +> apples-apples comparison with fsync=3Don for various reasons. +It is with fsync=3Doff on windows, fsync=3Don on linux + +> +> Are you running stats_command_string=3Don? =A0Try disabling and compare +> results. +Deactivated on windows, activated on linux + +> Is your loading app running locally or on the server? +Yes +> +> I am very interesting in discovering sources of high cpu load problems +> on win32. =A0If you are still having problems could you get a gprof +> profile together? =A0There is a recent thread on win32-hackers discussing +> how to do this. +I'll give it a look.... +> +> Merlin + +From pgsql-performance-owner@postgresql.org Tue Sep 6 12:32:08 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BDAD9D7D71 + for ; + Tue, 6 Sep 2005 12:32:06 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 95763-05 + for ; + Tue, 6 Sep 2005 15:32:04 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 40867D7CFE + for ; + Tue, 6 Sep 2005 12:32:03 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j86FW1Ws018163; + Tue, 6 Sep 2005 11:32:01 -0400 (EDT) +To: "Brian Choate" +Cc: pgsql-performance@postgresql.org +Subject: Re: Poor performance of delete by primary key +In-reply-to: + <2F9239F5E316C54688FDA9814FF045D6EADACC@EXCHANGE.sf.nimblefish.com> +References: + <2F9239F5E316C54688FDA9814FF045D6EADACC@EXCHANGE.sf.nimblefish.com> +Comments: In-reply-to "Brian Choate" + message dated "Tue, 06 Sep 2005 08:04:22 -0700" +Date: Tue, 06 Sep 2005 11:32:00 -0400 +Message-ID: <18162.1126020720@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/93 +X-Sequence-Number: 14401 + +"Brian Choate" writes: +> We are seeing a very strange behavior from postgres. For one of our very = +> common tasks we have to delete records from a table of around 500,000 = +> rows. The delete is by id which is the primary key. It seems to be = +> consistently taking around 10 minutes to preform. This is totally out of = +> line with the rest of the performance of the database. + +I'll bet this table has foreign-key references from elsewhere, and the +referencing columns are either not indexed, or not of the same datatype +as the master column. + +Unfortunately there's no very simple way to determine which FK is the +problem. (In 8.1 it'll be possible to do that with EXPLAIN ANALYZE, +but in existing releases EXPLAIN doesn't break out the time spent in +each trigger ...) You have to just eyeball the schema :-(. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Sep 6 12:43:25 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 38A3ED841D + for ; + Tue, 6 Sep 2005 12:43:24 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 01214-02 + for ; + Tue, 6 Sep 2005 15:43:18 +0000 (GMT) +Received: from newman.lshift.net (host226.lshift.net [195.172.218.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 241E8D8138 + for ; + Tue, 6 Sep 2005 12:43:16 -0300 (ADT) +Received: (qmail 20095 invoked by uid 1004); 6 Sep 2005 15:43:15 -0000 +Received: from 10.224.189.77 by newman (envelope-from , + uid 64011) with qmail-scanner-1.24 (clamdscan: 0.80/627. + Clear:RC:1(10.224.189.77):. + Processed in 0.013821 secs); 06 Sep 2005 15:43:15 -0000 +Received: from ponder.lshift.net (HELO localhost) ([10.224.189.77]) + (envelope-sender ) + by newman.lshift.net (qmail-ldap-1.03) with AES256-SHA encrypted SMTP + for ; 6 Sep 2005 15:43:15 -0000 +Date: Tue, 6 Sep 2005 16:43:15 +0100 +From: Matthew Sackman +To: pgsql-performance@postgresql.org +Subject: Re: Poor performance of delete by primary key +Message-ID: <20050906154315.GL382@pongo.lshift.net> +Mail-Followup-To: pgsql-performance@postgresql.org +References: + <2F9239F5E316C54688FDA9814FF045D6EADACC@EXCHANGE.sf.nimblefish.com> + <18162.1126020720@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <18162.1126020720@sss.pgh.pa.us> +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.269 required=5 tests=[AWL=-0.105, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200509/94 +X-Sequence-Number: 14402 + +On Tue, Sep 06, 2005 at 11:32:00AM -0400, Tom Lane wrote: +> "Brian Choate" writes: +> > We are seeing a very strange behavior from postgres. For one of our very = +> > common tasks we have to delete records from a table of around 500,000 = +> > rows. The delete is by id which is the primary key. It seems to be = +> > consistently taking around 10 minutes to preform. This is totally out of = +> > line with the rest of the performance of the database. +> +> I'll bet this table has foreign-key references from elsewhere, and the +> referencing columns are either not indexed, or not of the same datatype +> as the master column. + +Wouldn't setting the FK as deferrable and initially deferred help here +too as then the FK wouldn't be checked until the transaction ended? + +Matthew + +From pgsql-performance-owner@postgresql.org Tue Sep 6 12:55:46 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F3878D8817 + for ; + Tue, 6 Sep 2005 12:55:44 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 00357-09 + for ; + Tue, 6 Sep 2005 15:55:42 +0000 (GMT) +Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) + by svr1.postgresql.org (Postfix) with ESMTP id B5838D883C + for ; + Tue, 6 Sep 2005 12:55:39 -0300 (ADT) +Received: from mainbox.archonet.com + (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) + by smtp.metronet.co.uk (MetroNet Mail) with ESMTP + id 1DAEE4166A3; Tue, 6 Sep 2005 16:55:25 +0100 (BST) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mainbox.archonet.com (Postfix) with ESMTP id 356A915F1D; + Tue, 6 Sep 2005 16:51:12 +0100 (BST) +Received: from mainbox.archonet.com ([127.0.0.1]) + by localhost (mainbox [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 04875-10; Tue, 6 Sep 2005 16:51:09 +0100 (BST) +Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP id A723B15F1C; + Tue, 6 Sep 2005 16:51:09 +0100 (BST) +Message-ID: <431DBAE9.3060205@archonet.com> +Date: Tue, 06 Sep 2005 16:51:05 +0100 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Brian Choate +Cc: pgsql-performance@postgresql.org +Subject: Re: Poor performance of delete by primary key +References: + <2F9239F5E316C54688FDA9814FF045D6EADACC@EXCHANGE.sf.nimblefish.com> +In-Reply-To: + <2F9239F5E316C54688FDA9814FF045D6EADACC@EXCHANGE.sf.nimblefish.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.057 required=5 tests=[AWL=0.007, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/96 +X-Sequence-Number: 14404 + +Brian Choate wrote: +> Hello, +> +> We are seeing a very strange behavior from postgres. For one of our +> very common tasks we have to delete records from a table of around +> 500,000 rows. The delete is by id which is the primary key. It seems +> to be consistently taking around 10 minutes to preform. This is +> totally out of line with the rest of the performance of the database. + +> Any ideas on what might be going on? + +Well, it sounds like *something* isn't using an index. You say that all +your FK's are indexed, but that's something worth checking. Also keep an +eye out for type conflicts. + +If the system is otherwise idle, it might be worthwhile to compare +before and after values of pg_stat* (user-tables and user-indexes). + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Tue Sep 6 12:51:30 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9DCBDD815A + for ; + Tue, 6 Sep 2005 12:51:29 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 99889-08 + for ; + Tue, 6 Sep 2005 15:51:26 +0000 (GMT) +Received: from newman.lshift.net (host226.lshift.net [195.172.218.226]) + by svr1.postgresql.org (Postfix) with ESMTP id D5B53D8165 + for ; + Tue, 6 Sep 2005 12:51:24 -0300 (ADT) +Received: (qmail 20963 invoked by uid 1004); 6 Sep 2005 15:51:24 -0000 +Received: from 10.224.189.77 by newman (envelope-from , + uid 64011) with qmail-scanner-1.24 (clamdscan: 0.80/627. + Clear:RC:1(10.224.189.77):. + Processed in 0.014005 secs); 06 Sep 2005 15:51:24 -0000 +Received: from ponder.lshift.net (HELO localhost) ([10.224.189.77]) + (envelope-sender ) + by newman.lshift.net (qmail-ldap-1.03) with AES256-SHA encrypted SMTP + for ; 6 Sep 2005 15:51:24 -0000 +Date: Tue, 6 Sep 2005 16:51:24 +0100 +From: Matthew Sackman +To: pgsql-performance@postgresql.org +Subject: Re: Massive performance issues +Message-ID: <20050906155124.GM382@pongo.lshift.net> +Mail-Followup-To: pgsql-performance@postgresql.org +References: <20050901174231.GE23970@pongo.lshift.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20050901174231.GE23970@pongo.lshift.net> +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.275 required=5 tests=[AWL=-0.099, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200509/95 +X-Sequence-Number: 14403 + +Hi, + +Many thanks for all your thoughts and advice. With just 2GB or RAM, no +change to the harddisc (still SATA) but proper tuning of Postgresql +(still 7.4) and aggressive normalization to shrink row width, I have +managed to get suitable performance, with, when fully cached, queries on +a 5 million row data set, including queries such as: + +select to_char(sale_date, 'DD Mon YYYY') as sale_date_text, cost, + property_types.type as property_type, sale_types.type as sale_type, + flat_extra, number, street, loc1.component as locality_1, + loc2.component as locality_2, city.component as city, + county.component as county, postcode +from address + inner join ( + select id from address_components + where component = 'Woodborough' + ) as t1 + on locality_1_id = t1.id or locality_2_id = t1.id or city_id = t1.id + inner join ( + select id, street from streets where street = 'Lowdham Lane' + ) as t2 + on street_id = t2.id + inner join sale_types + on sale_types.id = sale_type_id + inner join property_types + on property_types.id = property_type_id + inner join address_components as county + on county_id = county.id + inner join address_components as city + on city_id = city.id + inner join address_components as loc2 + on locality_2_id = loc2.id + inner join address_components as loc1 + on locality_1_id = loc1.id +order by sale_date desc limit 11 offset 0 + +completing within 50ms. I've also now managed to request that the full +production system will have 4GB of RAM (there are still a few queries +that don't quite fit in 2GB of RAM) and a 15kRPM SCSI HD. + +So once again, thanks for all your help. I've literally been pulling my +hair out over this so it's great to have basically got it solved. + +Matthew + +From pgsql-performance-owner@postgresql.org Tue Sep 6 13:18:41 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4194CD8138 + for ; + Tue, 6 Sep 2005 13:16:47 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 10490-05 + for ; + Tue, 6 Sep 2005 16:16:44 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id EE722D7BC7 + for ; + Tue, 6 Sep 2005 13:16:42 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Subject: Re: insert performance for win32 +Date: Tue, 6 Sep 2005 12:16:42 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3417DD27F@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] insert performance for win32 +Thread-Index: AcWy9f2Tj5Xg3WF7RBOyPPyXdkzCbgAAKlZA +From: "Merlin Moncure" +To: "Marc Cousin" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.056 required=5 tests=[AWL=0.006, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/97 +X-Sequence-Number: 14405 + +> > In my experience win32 is par with linux generally with a few = +gotchas on +> > either side. =A0Are your times with fsync=3Dno? It's much harder to = +give +> > apples-apples comparison with fsync=3Don for various reasons. +> It is with fsync=3Doff on windows, fsync=3Don on linux + +well, inside a transaction this shouldn't have mattered anyways. +=20 +> > Are you running stats_command_string=3Don? =A0Try disabling and = +compare +> > results. +> Deactivated on windows, activated on linux +=20 +> > Is your loading app running locally or on the server? +> Yes + +hm :(. Well, you had me curious so I went ahead and re-ran your test = +case and profiled it (on windows). I got similar results time wise. = +It's interesting to note that the command I used to generate the test = +table before dumping w/inserts + +insert into test select nextval('test_id_seq'), 'test' from = +generate_series(1,500000)=20 + +ran in just a few seconds. =20 + +Well, I cut the #recs down to 50k and here is profile trace: + % cumulative self self total =20 + time seconds seconds calls s/call s/call name =20 + 10.78 0.62 0.62 50001 0.00 0.00 yyparse + 5.39 0.93 0.31 5101422 0.00 0.00 AllocSetAlloc + 4.52 1.19 0.26 799970 0.00 0.00 base_yylex + 2.78 1.35 0.16 299998 0.00 0.00 SearchCatCache + 2.43 1.49 0.14 554245 0.00 0.00 hash_search + 2.26 1.62 0.13 49998 0.00 0.00 XLogInsert + 1.74 1.72 0.10 453363 0.00 0.00 LWLockAcquire + 1.74 1.82 0.10 299988 0.00 0.00 ScanKeywordLookup + +This makes me wonder if we are looking in the wrong place. Maybe the = +problem is coming from psql? More results to follow. + +Merlin + +From pgsql-performance-owner@postgresql.org Tue Sep 6 14:10:24 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CA8AAD84CE + for ; + Tue, 6 Sep 2005 14:04:45 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 22318-09 + for ; + Tue, 6 Sep 2005 17:04:42 +0000 (GMT) +Received: from mir3-fs.mir3.com (mail.mir3.com [65.208.188.100]) + by svr1.postgresql.org (Postfix) with ESMTP id 92D93D8409 + for ; + Tue, 6 Sep 2005 14:04:39 -0300 (ADT) +Received: from archimedes ([172.16.2.68]) by mir3-fs.mir3.com with Microsoft + SMTPSVC(5.0.2195.6713); Tue, 6 Sep 2005 10:07:44 -0700 +Subject: Re: Poor performance of delete by primary key +From: Mark Lewis +To: Tom Lane +Cc: Brian Choate , + pgsql-performance@postgresql.org +In-Reply-To: <18162.1126020720@sss.pgh.pa.us> +References: + <2F9239F5E316C54688FDA9814FF045D6EADACC@EXCHANGE.sf.nimblefish.com> + <18162.1126020720@sss.pgh.pa.us> +Content-Type: text/plain +Organization: MIR3, Inc. +Date: Tue, 06 Sep 2005 10:04:38 -0700 +Message-Id: <1126026278.3310.76.camel@archimedes> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-16) +Content-Transfer-Encoding: 7bit +X-OriginalArrivalTime: 06 Sep 2005 17:07:44.0554 (UTC) + FILETIME=[7F84B8A0:01C5B305] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.08 required=5 tests=[AWL=0.080] +X-Spam-Level: +X-Archive-Number: 200509/98 +X-Sequence-Number: 14406 + +I had a similar problem, so I downloaded 8.1 from CVS, ran it on a +relatively gnarly dev workstation, imported a dump of my 8.0 database, +and ran my troublesome queries with the new EXPLAIN ANALYZE. + +This process took about an hour and worked great, provided that you've +actually named your foreign key constraints. Otherwise, you'll find out +that there's a trigger for a constraint called $3 that's taking up all +of your time, but you won't know what table that constraint is on. + +-- Mark + + + +On Tue, 2005-09-06 at 11:32 -0400, Tom Lane wrote: +> "Brian Choate" writes: +> > We are seeing a very strange behavior from postgres. For one of our very = +> > common tasks we have to delete records from a table of around 500,000 = +> > rows. The delete is by id which is the primary key. It seems to be = +> > consistently taking around 10 minutes to preform. This is totally out of = +> > line with the rest of the performance of the database. +> +> I'll bet this table has foreign-key references from elsewhere, and the +> referencing columns are either not indexed, or not of the same datatype +> as the master column. +> +> Unfortunately there's no very simple way to determine which FK is the +> problem. (In 8.1 it'll be possible to do that with EXPLAIN ANALYZE, +> but in existing releases EXPLAIN doesn't break out the time spent in +> each trigger ...) You have to just eyeball the schema :-(. +> +> regards, tom lane +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 3: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faq + + +From pgsql-performance-owner@postgresql.org Tue Sep 6 14:13:08 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1067AD8270 + for ; + Tue, 6 Sep 2005 14:11:22 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 22687-10 + for ; + Tue, 6 Sep 2005 17:11:19 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 9C802D822C + for ; + Tue, 6 Sep 2005 14:11:18 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Subject: Re: insert performance for win32 +Date: Tue, 6 Sep 2005 13:11:18 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3417DD281@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: re: [PERFORM] insert performance for win32 +Thread-Index: AcWy9f2Tj5Xg3WF7RBOyPPyXdkzCbgAAKlZAAAOn0+AAACtQgA== +From: "Merlin Moncure" +To: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.056 required=5 tests=[AWL=0.006, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/99 +X-Sequence-Number: 14407 + +> This makes me wonder if we are looking in the wrong place. Maybe the +> problem is coming from psql? More results to follow. + +problem is not coming from psql. =20 + +One thing I did notice that in a 250k insert transaction the insert time +grows with #recs inserted. Time to insert first 50k recs is about 27 +sec and last 50 k recs is 77 sec. I also confimed that size of table is +not playing a role here. + +Marc, can you do select timeofday() every 50k recs from linux? Also a +gprof trace from linux would be helpful. + +Merlin + +From pgsql-performance-owner@postgresql.org Tue Sep 6 15:08:09 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 61419D8504 + for ; + Tue, 6 Sep 2005 14:43:07 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 35222-03 + for ; + Tue, 6 Sep 2005 17:43:01 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 364F0D8270 + for ; + Tue, 6 Sep 2005 14:43:01 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j86HgxRg019192; + Tue, 6 Sep 2005 13:42:59 -0400 (EDT) +To: Mark Lewis +Cc: Brian Choate , + pgsql-performance@postgresql.org +Subject: Re: Poor performance of delete by primary key +In-reply-to: <1126026278.3310.76.camel@archimedes> +References: + <2F9239F5E316C54688FDA9814FF045D6EADACC@EXCHANGE.sf.nimblefish.com> + <18162.1126020720@sss.pgh.pa.us> + <1126026278.3310.76.camel@archimedes> +Comments: In-reply-to Mark Lewis + message dated "Tue, 06 Sep 2005 10:04:38 -0700" +Date: Tue, 06 Sep 2005 13:42:59 -0400 +Message-ID: <19191.1126028579@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/100 +X-Sequence-Number: 14408 + +Mark Lewis writes: +> I had a similar problem, so I downloaded 8.1 from CVS, ran it on a +> relatively gnarly dev workstation, imported a dump of my 8.0 database, +> and ran my troublesome queries with the new EXPLAIN ANALYZE. + +> This process took about an hour and worked great, provided that you've +> actually named your foreign key constraints. Otherwise, you'll find out +> that there's a trigger for a constraint called $3 that's taking up all +> of your time, but you won't know what table that constraint is on. + +But at least you've got something you can work with. Once you know the +name of the problem trigger you can look in pg_trigger to see which +other table it's connected to. Try something like + + select tgname, tgconstrrelid::regclass, tgargs from pg_trigger + where tgrelid = 'mytable'::regclass; + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Sep 6 17:44:31 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DFD22D8625 + for ; + Tue, 6 Sep 2005 17:34:14 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 78342-01 + for ; + Tue, 6 Sep 2005 20:34:11 +0000 (GMT) +Received: from web53209.mail.yahoo.com (web53209.mail.yahoo.com + [206.190.49.79]) + by svr1.postgresql.org (Postfix) with SMTP id 628EBD85C8 + for ; + Tue, 6 Sep 2005 17:34:11 -0300 (ADT) +Received: (qmail 32618 invoked by uid 60001); 6 Sep 2005 20:34:12 -0000 +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com.br; + h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; + b=jQOw8+5Uyu/seSVnRbZ51fJ9q53Bt9HGdt347NbQqCvz8nHrmCygfLrcA5W6AUm9kSW3OR+YEhA6/jJWmBNW17KnnNNTubM0iQSg70byaoSdRDRTAuxIXR0l7fadRr9lMYZzGC09+DaHuKI0yYCHAVvb5pTdvp6bi/XBsWcosTU= + ; +Message-ID: <20050906203412.32616.qmail@web53209.mail.yahoo.com> +Received: from [200.193.41.11] by web53209.mail.yahoo.com via HTTP; + Tue, 06 Sep 2005 17:34:12 ART +Date: Tue, 6 Sep 2005 17:34:12 -0300 (ART) +From: Carlos Henrique Reimer +Subject: log_duration times +To: pgsql-performance@postgresql.org +MIME-Version: 1.0 +Content-Type: multipart/alternative; boundary="0-496221878-1126038852=:31073" +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.647 required=5 tests=[AWL=-0.231, + DNS_FROM_RFC_ABUSE=0.374, HTML_20_30=0.504, HTML_MESSAGE=0.001] +X-Spam-Level: +X-Archive-Number: 200509/101 +X-Sequence-Number: 14409 + +--0-496221878-1126038852=:31073 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit + +Hi, + +We want to discover how to improve the performance of an application and with that intention I turned on log_duration, log_statement=all and the time stamp escape character (%t) of log_line_prefix. + +Subtracting the time stamp of the last SQL statement from the first one I disovered that the whole application takes about 10 seconds to run. Almost the same time we have at the client workstation. + +Adding all the log_duration times I found almost 3 seconds (30% of the total time). + +So, I realized that to improve performance it will be better to discover who is spending the 7 remaining seconds than making changes in database structure or SQL syntax. + +How could I discover who is using the 7 remaining seconds? Network? ODBC? Application? + +Thanks in advance! + +Reimer + + + +__________________________________________________ +Converse com seus amigos em tempo real com o Yahoo! Messenger +http://br.download.yahoo.com/messenger/ +--0-496221878-1126038852=:31073 +Content-Type: text/html; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit + +
Hi,
+
 
+
We want to discover how to improve the performance of an application and with that intention I turned on log_duration, log_statement=all and the time stamp escape character (%t) of log_line_prefix.
+
 
+
Subtracting the time stamp of the last SQL statement from the first one I disovered that the whole application takes about 10 seconds to run. Almost the same time we have at the client workstation.
+
 
+
Adding all the log_duration times I found almost 3 seconds (30% of the total time).
+
 
+
So, I realized that to improve performance it will be better to discover who is spending the 7 remaining seconds than making changes in database structure or SQL syntax.
+
 
+
How could I discover who is using the 7 remaining seconds? Network? ODBC? Application?
+
 
+
Thanks in advance!
+
 
+
Reimer
+
 
+
 

__________________________________________________
Converse com seus amigos em tempo real com o Yahoo! Messenger
http://br.download.yahoo.com/messenger/ +--0-496221878-1126038852=:31073-- + +From pgsql-performance-owner@postgresql.org Tue Sep 6 21:54:26 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 16A4AD8579 + for ; + Tue, 6 Sep 2005 21:54:26 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 35973-03 + for ; + Wed, 7 Sep 2005 00:54:21 +0000 (GMT) +Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.198]) + by svr1.postgresql.org (Postfix) with ESMTP id 76345D8525 + for ; + Tue, 6 Sep 2005 21:54:20 -0300 (ADT) +Received: by xproxy.gmail.com with SMTP id i31so1215690wxd + for ; + Tue, 06 Sep 2005 17:54:24 -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=Rt4jGk7VGXCwbvf/A3QCjqsdEkgf/ylialn00L2FgHpiejHgj07AW43pIzQUTQ0egTtuS4Ir8rSu36Kj8VfY0VmUK4dQwI+0Ehwgc48cT3FtN8YoR5TyqwsaGSCvWgv48EaQVbyq+2yz5Er7pj0JkJ/xL07heueeCuQajmh89EQ= +Received: by 10.70.29.12 with SMTP id c12mr128836wxc; + Tue, 06 Sep 2005 17:54:24 -0700 (PDT) +Received: by 10.70.115.1 with HTTP; Tue, 6 Sep 2005 17:54:24 -0700 (PDT) +Message-ID: <72e966b005090617543ad88811@mail.gmail.com> +Date: Tue, 6 Sep 2005 18:54:24 -0600 +From: Jan Peterson +Reply-To: jan.l.peterson@gmail.com +To: pgsql-performance@postgresql.org +Subject: Re: poor VACUUM performance on large tables +Cc: "Thomas F. O'Connell" , + Tom Lane +In-Reply-To: <9274.1125874870@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <72e966b00509032316166ff0cf@mail.gmail.com> + <9274.1125874870@sss.pgh.pa.us> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.024 required=5 tests=[RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200509/102 +X-Sequence-Number: 14410 + +Thomas F. O'Connell: +>Do you have your Free Space Map settings configured appropriately? + +Our current FSM settings are: +max_fsm_pages =3D 500000 # min max_fsm_relations*16, 6 bytes each +max_fsm_relations =3D 1000 # min 100, ~50 bytes each + +> You'll want to run a VACUUM VERBOSE and note the numbers at the end, +> which describe how many pages are used and how many are needed. +> max_fsm_pages should be set according to that, and you can set +> max_fsm_relations based on it, too, although typically one knows +> roughly how many relations are in a database. + +Here are the last two lines from a VACUUM VERBOSE FULL we did when the +database was totally full: + +INFO: free space map: 82 relations, 532349 pages stored; 632352 total +pages needed +DETAIL: Allocated FSM size: 1000 relations + 500000 pages =3D 2995 kB +shared memory. +VACUUM=20 + +Based on this, it looks like we could stand to bump up our FSM another +couple hundred thousand. Does it buy us anything to reduce the number +of FSM relations from the default of 1000? + +> have you experimented with pg_autovacuum + +We're not using pg_autovacuum. We have our own mechanism that works +basically the same as pg_autovacuum, but split into two separate +threads, one for large tables and one for small tables. We consider +tables to be "large" if their size exceeds 100MB. Tables are selected +for vacuuming if they've changed "enough" (I can get you actual +metrics for what is "enough", but I don't know off the top of my +head). Our main reason for splitting out small vs. large tables was +that the large tables take a long time to VACUUM and we didn't want +our small tables to go a long time between VACUUMs. Of course, due to +the transactional nature of VACUUM, we aren't really gaining much +here, anyway (this was one of the things we were hoping to address +with Hannu's patch, but there are issues with his patch on 8.0.2 that +we haven't tracked down yet). + +Tom Lane: +> Which PG version, exactly? + +We're currently running 8.0.2. + +> Plain VACUUM (not FULL) certainly ought not take that long. (If you're +> using VACUUM FULL, the answer is going to be "don't do that".) + +Heh, we're definitely not doing a VACUUM FULL. We're doing VACUUM +ANALYZE {tablename} exclusively, except when we get close to the +transaction id wraparound threshold when we do a VACUUM ANALYZE of the +entire database. + +> What maintenance_work_mem (or vacuum_mem in older releases) are=20 +> you running it under? =20 + +It looks like we are using the defaults for work_mem (1024) and +maintenance_work_mem (16384). We could certainly bump these up. Is +there a good way to determine what settings would be reasonable? I'll +note, however, that we had experimented with bumping these previously +and not noticed any change in performance. + +> Can you get VACUUM VERBOSE output from some of these cases +> so we can see which phase(s) are eating the time? =20 + +I'll get some, but it will take a few more days as we have recently +reset our test environment. I can get some sample runs of VACUUM +VERBOSE on pg_largeobject in a few hours (it takes a few hours to run) +and will post them when I have them. + +> It'd also be interesting to watch the output of vmstat or local=20 +> equivalent --- it might just be that your I/O capability is nearly=20 +> saturated and VACUUM is pushing the system over the knee=20 +> of the response curve. If so, the vacuum delay options of 8.0=20 +> would be worth experimenting with. + +We've been monitoring I/O rates with iostat and we're generally +running around 90% I/O usage after we kick into the rolling delete +stage (before we reach that stage, we're running around 20%-50% I/O +usage). We are definitely I/O bound, hence trying to find a way to +make VACUUM process less data. + +Our system (the database is on an appliance system) is a dual CPU box, +and we're burning about 25% of our CPU time in I/O waits (again, after +our rolling delete kicks in). A higher performance I/O subsystem is +something we could try. + +Our biggest concern with increasing the vacuum delay options is the +length of time it currently takes to VACUUM our large tables (and +pg_largeobject). Holding a transaction open for these long periods +degrades performance in other places. + +> > Statistics are also skewed during this +> > process and we have observed the planner choosing sequential scans on +> > tables where it is obvious that an index scan would be more efficient. +>=20 +> That's really pretty hard to believe; VACUUM doesn't affect the +> statistics until the very end. Can you give some specifics of how +> the "statistics are skewed"? + +I don't have any hard evidence for this, but we have noticed that at +certain times a particular query which we run will run for an +extremely long time (several hours). Re-running the query with +EXPLAIN always shows it using an index scan and it runs very quickly.=20 +We haven't been able to catch it with an EXPLAIN in the state where it +will take a long time (it's not deterministic). Our assumption is +that the planner is taking the wrong path because we can't figure out +any other reason why the query would take such a long time. We'll run +some more experiments and try to reproduce this behavior. Is there +anything specific that would help track this down (other than getting +EXPLAIN output showing the bogus execution plan)? + +Thanks for your help. + + -jan- +--=20 +Jan L. Peterson + + +From pgsql-performance-owner@postgresql.org Tue Sep 6 22:07:27 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E2B91D885B + for ; + Tue, 6 Sep 2005 22:07:26 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 39658-06 + for ; + Wed, 7 Sep 2005 01:07:23 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 1919AD87F0 + for ; + Tue, 6 Sep 2005 22:07:24 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j8717R25022357; + Tue, 6 Sep 2005 21:07:27 -0400 (EDT) +To: jan.l.peterson@gmail.com +Cc: pgsql-performance@postgresql.org, "Thomas F. O'Connell" +Subject: Re: poor VACUUM performance on large tables +In-reply-to: <72e966b005090617543ad88811@mail.gmail.com> +References: <72e966b00509032316166ff0cf@mail.gmail.com> + <9274.1125874870@sss.pgh.pa.us> + <72e966b005090617543ad88811@mail.gmail.com> +Comments: In-reply-to Jan Peterson + message dated "Tue, 06 Sep 2005 18:54:24 -0600" +Date: Tue, 06 Sep 2005 21:07:27 -0400 +Message-ID: <22356.1126055247@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/103 +X-Sequence-Number: 14411 + +Jan Peterson writes: +> Based on this, it looks like we could stand to bump up our FSM another +> couple hundred thousand. Does it buy us anything to reduce the number +> of FSM relations from the default of 1000? + +Not a lot; as the comment says, those slots are only about 50 bytes +each. (I think the true figure is closer to 70, according to some +measurements I did recently on CVS tip, but in any case it's less than +100 bytes apiece.) Still, a byte saved is a byte earned ... + +> It looks like we are using the defaults for work_mem (1024) and +> maintenance_work_mem (16384). We could certainly bump these up. Is +> there a good way to determine what settings would be reasonable? + +I'd bump up maintenance_work_mem by a factor of 10 and see if it makes a +difference. It should reduce the number of passes over the indexes when +vacuuming up lots of deleted rows. If you have lots of RAM you might be +able to increase it more, but try that for starters. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Sep 7 00:08:17 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3AFCBD7FFD + for ; + Wed, 7 Sep 2005 00:08:17 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 68416-06 + for ; + Wed, 7 Sep 2005 03:08:15 +0000 (GMT) +Received: from vscan01.westnet.com.au (vscan01.westnet.com.au [203.10.1.131]) + by svr1.postgresql.org (Postfix) with ESMTP id 33659D7F3F + for ; + Wed, 7 Sep 2005 00:08:14 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by localhost (Postfix) with ESMTP id B1EC676053F; + Wed, 7 Sep 2005 11:08:10 +0800 (WST) +Received: from vscan01.westnet.com.au ([127.0.0.1]) + by localhost (vscan01.westnet.com.au [127.0.0.1]) (amavisd-new, + port 10024) + with ESMTP id 13257-01; Wed, 7 Sep 2005 11:07:03 +0800 (WST) +Received: from [202.72.133.22] (dsl-202-72-133-22.wa.westnet.com.au + [202.72.133.22]) + by vscan01.westnet.com.au (Postfix) with ESMTP id 4FF247603D6; + Wed, 7 Sep 2005 11:07:03 +0800 (WST) +Message-ID: <431E5958.8040102@familyhealth.com.au> +Date: Wed, 07 Sep 2005 11:07:04 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: Brian Choate , + pgsql-performance@postgresql.org +Subject: Re: Poor performance of delete by primary key +References: + <2F9239F5E316C54688FDA9814FF045D6EADACC@EXCHANGE.sf.nimblefish.com> + <18162.1126020720@sss.pgh.pa.us> +In-Reply-To: <18162.1126020720@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.009 required=5 tests=[AWL=0.009] +X-Spam-Level: +X-Archive-Number: 200509/104 +X-Sequence-Number: 14412 + +> Unfortunately there's no very simple way to determine which FK is the +> problem. (In 8.1 it'll be possible to do that with EXPLAIN ANALYZE, +> but in existing releases EXPLAIN doesn't break out the time spent in +> each trigger ...) You have to just eyeball the schema :-(. + +phpPgAdmin has a handy info feature where you can see all tables that +refer to the current one. You can always go and steal that query to +find them... + +Chris + +From pgsql-performance-owner@postgresql.org Tue Sep 13 01:58:01 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2EE47D6E3B + for ; + Wed, 7 Sep 2005 14:06:33 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 84746-08 + for ; + Wed, 7 Sep 2005 17:06:27 +0000 (GMT) +Received: from hub.org (hub.org [200.46.204.220]) + by svr1.postgresql.org (Postfix) with ESMTP id C9B04D781C + for ; + Wed, 7 Sep 2005 14:06:27 -0300 (ADT) +Received: from localhost (av.hub.org [200.46.204.144]) + by hub.org (Postfix) with ESMTP id 987F564BA12 + for ; + Wed, 7 Sep 2005 14:06:24 -0300 (ADT) +Received: from hub.org ([200.46.204.220]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 87054-04 for ; + Wed, 7 Sep 2005 17:06:17 +0000 (GMT) +Received: from ganymede.hub.org (blk-222-82-85.eastlink.ca [24.222.82.85]) + by hub.org (Postfix) with ESMTP id A60A464BA01 + for ; + Wed, 7 Sep 2005 14:06:18 -0300 (ADT) +Received: by ganymede.hub.org (Postfix, from userid 1000) + id F1B5239FD2; Wed, 7 Sep 2005 14:06:17 -0300 (ADT) +Received: from localhost (localhost [127.0.0.1]) + by ganymede.hub.org (Postfix) with ESMTP id F0B9A399B5 + for ; + Wed, 7 Sep 2005 14:06:17 -0300 (ADT) +X-Return-Path: +X-Received: from localhost ([unix socket]) + by ganymede.hub.org (Cyrus v2.2.12) with LMTPA; + Wed, 07 Sep 2005 06:05:53 -0300 +X-Sieve: CMU Sieve 2.2 +X-Received: from localhost (localhost [127.0.0.1]) + by ganymede.hub.org (Postfix) with ESMTP id 6334E3D8B4 + for ; Wed, 7 Sep 2005 06:05:39 -0300 (ADT) +X-Received: from mail.postgresql.org [200.46.204.71] + by localhost with IMAP (fetchmail-6.2.5.2) + for scrappy@localhost (single-drop); + Wed, 07 Sep 2005 06:05:39 -0300 (ADT) +X-Received: from svr1.postgresql.org ([unix socket]) + by svr1.postgresql.org (Cyrus v2.2.12) with LMTPA; + Wed, 07 Sep 2005 06:04:50 -0300 +X-Sieve: CMU Sieve 2.2 +X-Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4B3A3D825F + for ; Wed, 7 Sep 2005 06:04:50 -0300 (ADT) +X-Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 63396-05 for ; + Wed, 7 Sep 2005 09:04:43 +0000 (GMT) +X-Received: from aut-vie-w2s021.bankgutmann.co.at + (Aut-vie-w2s021.bankgutmann.co.at [195.58.180.10]) + by svr1.postgresql.org (Postfix) with ESMTP id A477ED8089 + for ; + Wed, 7 Sep 2005 06:04:43 -0300 (ADT) +X-Received: from aut-vie-w3s006.bankgutmann.co.at ([164.139.110.17]) by + aut-vie-w2s021.bankgutmann.co.at with Microsoft + SMTPSVC(6.0.3790.1830); Wed, 7 Sep 2005 11:04:43 +0200 +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: Postgresql Hardware - Recommendations +Date: Wed, 7 Sep 2005 11:04:43 +0200 +Message-ID: + +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Postgresql Hardware - Recommendations +Thread-Index: AcWymcL1zcn7SJBTSXWCf6NJpF06QQA8Mbpg +From: +To: +X-OriginalArrivalTime: 07 Sep 2005 09:04:43.0771 (UTC) + FILETIME=[3009ECB0:01C5B38B] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-DCC: : +X-Spam-Pyzor: +ReSent-Date: Wed, 7 Sep 2005 14:06:11 -0300 (ADT) +Resent-From: "Marc G. Fournier" +Resent-To: pgsql-performance@postgresql.org +ReSent-Subject: AW: [PERFORM] Postgresql Hardware - Recommendations +ReSent-Message-ID: <20050907140611.R1104@ganymede.hub.org> +X-Virus-Scanned: by amavisd-new at hub.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.124 required=5 tests=[AWL=0.896, + FORGED_RCVD_HELO=0.05, NO_REAL_NAME=0.178] +X-Spam-Level: * +X-Archive-Number: 200509/156 +X-Sequence-Number: 14464 + +Andrew, Matthew, thanks to you both four your advice. I'm sorry I = +couldn't provide more details to the situation, I will post again as = +soon I get them.=20 + +Time to share your insights with the colleagues :) + +Best Regards, +Chris + +-----Urspr=FCngliche Nachricht----- +Von: Paul Ramsey [mailto:pramsey@refractions.net]=20 +Gesendet: Dienstag, 06. September 2005 06:13 +An: Kastner Christian; Kastner Christian +Betreff: Re: [PERFORM] Postgresql Hardware - Recommendations + +For a database, I would almost always prioritize: +- I/O +- RAM +- CPU + +So, fast drives (SCSI 10000RPM or better in a RAID configuration, =20 +more spindles =3D=3D more throughput), then memory (more memory =3D=3D = +more =20 +of the database off disk in cache =3D=3D faster response), then more CPU = +=20 +(more concurrent request handling). + +Paul + +On 5-Sep-05, at 6:50 AM, =20 + wrote: + +> Hello, +> +> My company has decided to migrate our Oracle database to =20 +> postgresql8. We +> will aquire a new server for this, and would very much appreciate your +> advice. +> +> NOTE: The applications accessing the database are developed and +> maintained externally, and unfortunately, the developers have not yet +> given us detailed information on their requirements. The only info =20 +> I can +> give so far is that the database size is about 60GB, and that it =20 +> will be +> frequently accessed by multiple users (about 100 will be connected +> during business hours). The applications accessing the database are +> mostly reporting tools. +> +> I know that the performance question will ultimately boil down to "it +> depends what you want to do with it", but at the moment I'm very much +> interested if there are any general issues we should look out for. +> +> The questions we are asking us now are: +> +> 1) Intel or AMD (or alternate Platform) +> Are we better of with Xeons or Opterons? Should we consider the IBM +> OpenPower platform? +> +> 2) CPUs vs cache +> Would you rather have more CPUs or more cache? Eg: 4x Xeon 1MB vs 2x +> Xeon 8MB +> +> 3) CPUs vs Memory +> Would you rather have 4x CPUs and 8GB of memory, or 2x CPUs with =20 +> 16GB of +> memory? +> +> Thanks in advance for all your replies! +> +> Best Regards, +> Christian Kastner +> +> ---------------------------(end of =20 +> broadcast)--------------------------- +> TIP 3: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faq +> + + +From pgsql-performance-owner@postgresql.org Wed Sep 7 09:02:12 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A9EEDD6EF7 + for ; + Wed, 7 Sep 2005 09:02:11 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 01493-07 + for ; + Wed, 7 Sep 2005 12:02:06 +0000 (GMT) +Received: from mercure-1.sigma.fr (mercure-2.sigma.fr [195.25.81.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 34171D6E87 + for ; + Wed, 7 Sep 2005 09:02:05 -0300 (ADT) +Received: from localhost (localhost [127.0.0.1]) + by mercure-1.sigma.fr (Postfix) with ESMTP id 65CFB1B8; + Wed, 7 Sep 2005 14:02:05 +0200 (CEST) +Received: from mercure-1.sigma.fr ([127.0.0.1]) + by localhost (mercure-2 [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 10598-10; Wed, 7 Sep 2005 14:02:05 +0200 (CEST) +Received: from delpiv3000-124l (unknown [89.195.0.5]) + by mercure-1.sigma.fr (Postfix) with ESMTP id 310D11B5; + Wed, 7 Sep 2005 14:02:05 +0200 (CEST) +From: Marc Cousin +Organization: Sigma Informatique +To: pgsql-performance@postgresql.org +Subject: Re: insert performance for win32 +Date: Wed, 7 Sep 2005 14:02:02 +0200 +User-Agent: KMail/1.8.2 +Cc: "Merlin Moncure" +References: <6EE64EF3AB31D5448D0007DD34EEB3417DD281@Herge.rcsinc.local> +In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB3417DD281@Herge.rcsinc.local> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200509071402.02402.mcousin@sigma.fr> +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at sigma.fr +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/105 +X-Sequence-Number: 14413 + +On Tuesday 06 September 2005 19:11, Merlin Moncure wrote: +> > This makes me wonder if we are looking in the wrong place. Maybe the +> > problem is coming from psql? More results to follow. +> +> problem is not coming from psql. +> +> One thing I did notice that in a 250k insert transaction the insert time +> grows with #recs inserted. Time to insert first 50k recs is about 27 +> sec and last 50 k recs is 77 sec. I also confimed that size of table is +> not playing a role here. +> +> Marc, can you do select timeofday() every 50k recs from linux? Also a +> gprof trace from linux would be helpful. +> + +Here's the timeofday ... i'll do the gprof as soon as I can. +Every 50000 rows... + +Wed Sep 07 13:58:13.860378 2005 CEST +Wed Sep 07 13:58:20.926983 2005 CEST +Wed Sep 07 13:58:27.928385 2005 CEST +Wed Sep 07 13:58:35.472813 2005 CEST +Wed Sep 07 13:58:42.825709 2005 CEST +Wed Sep 07 13:58:50.789486 2005 CEST +Wed Sep 07 13:58:57.553869 2005 CEST +Wed Sep 07 13:59:04.298136 2005 CEST +Wed Sep 07 13:59:11.066059 2005 CEST +Wed Sep 07 13:59:19.368694 2005 CEST + + + + + +> Merlin +> +> ---------------------------(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 Sep 7 09:04:21 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 519BAD781D + for ; + Wed, 7 Sep 2005 09:04:20 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 00420-10 + for ; + Wed, 7 Sep 2005 12:04:12 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 05F1FD76A0 + for ; + Wed, 7 Sep 2005 09:04:12 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Subject: Re: insert performance for win32 +Date: Wed, 7 Sep 2005 08:04:15 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3417DD28C@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] insert performance for win32 +Thread-Index: AcWzo/iGZmx6nsIrRgq0PsOmwcdaBwAAD41g +From: "Merlin Moncure" +To: "Marc Cousin" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.056 required=5 tests=[AWL=0.006, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/106 +X-Sequence-Number: 14414 + +> > One thing I did notice that in a 250k insert transaction the insert +time +> > grows with #recs inserted. Time to insert first 50k recs is about +27 +> > sec and last 50 k recs is 77 sec. I also confimed that size of +table is +> > not playing a role here. +> > +> > Marc, can you do select timeofday() every 50k recs from linux? Also +a +> > gprof trace from linux would be helpful. +> > +>=20 +> Here's the timeofday ... i'll do the gprof as soon as I can. +> Every 50000 rows... +>=20 +Were those all in a single transaction? + +Merlin + +From pgsql-hackers-win32-owner@postgresql.org Wed Sep 7 10:08:21 2005 +X-Original-To: pgsql-hackers-win32-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 61681D77CC; + Wed, 7 Sep 2005 10:08:19 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18498-03; Wed, 7 Sep 2005 13:08:15 +0000 (GMT) +Received: from Herge.rcsinc.local (c-67-174-137-10.hsd1.mi.comcast.net + [67.174.137.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 55DD0D77C0; + Wed, 7 Sep 2005 10:08:16 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Subject: Re: [PERFORM] insert performance for win32 +Date: Wed, 7 Sep 2005 09:08:18 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3417DD290@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] insert performance for win32 +Thread-Index: AcWzo/iGZmx6nsIrRgq0PsOmwcdaBwABsKbA +From: "Merlin Moncure" +To: "Marc Cousin" +Cc: , + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.842 required=5 tests=[FORGED_RCVD_HELO=0.05, + RCVD_IN_NJABL_DUL=1.655, RCVD_IN_SORBS_DUL=0.137] +X-Spam-Level: * +X-Archive-Number: 200509/1 +X-Sequence-Number: 3367 + +> On Tuesday 06 September 2005 19:11, Merlin Moncure wrote: +> Here's the timeofday ... i'll do the gprof as soon as I can. +> Every 50000 rows... +>=20 +> Wed Sep 07 13:58:13.860378 2005 CEST +> Wed Sep 07 13:58:20.926983 2005 CEST +> Wed Sep 07 13:58:27.928385 2005 CEST +> Wed Sep 07 13:58:35.472813 2005 CEST +> Wed Sep 07 13:58:42.825709 2005 CEST +> Wed Sep 07 13:58:50.789486 2005 CEST +> Wed Sep 07 13:58:57.553869 2005 CEST +> Wed Sep 07 13:59:04.298136 2005 CEST +> Wed Sep 07 13:59:11.066059 2005 CEST +> Wed Sep 07 13:59:19.368694 2005 CEST + +ok, I've been in crunching profile profile graphs, and so far have been +only been able to draw following conclusions. + +For bulk, 'in-transaction' insert: +1. win32 is slower than linux. win32 time for each insert grows with # +inserts in xact, linux does not (or grows much slower). Win32 starts +out about 3x slower and grows to 10x slower after 250k inserts. + +2. ran a 50k profile vs. 250k profile. Nothing jumps out as being +slower or faster: most time is spent in yyparse on either side. From +this my preliminary conclusion is that there is something going on in +the win32 api which is not showing in the profile. + +3. The mingw gprof cumulative seconds does not show measurable growth in +cpu time/insert in 50k/250k profile. + +I'm now talking suggestions about where to look for performance problems +:(. +Merlin + +From pgsql-hackers-win32-owner@postgresql.org Wed Sep 7 12:05:35 2005 +X-Original-To: pgsql-hackers-win32-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E9116D6E15; + Wed, 7 Sep 2005 12:02:18 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 52389-01; Wed, 7 Sep 2005 15:02:15 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id AB402D7D48; + Wed, 7 Sep 2005 12:02:14 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j87F2D5h027313; + Wed, 7 Sep 2005 11:02:13 -0400 (EDT) +To: "Merlin Moncure" +Cc: "Marc Cousin" , + pgsql-performance@postgresql.org, pgsql-hackers-win32@postgresql.org +Subject: Re: [PERFORM] insert performance for win32 +In-reply-to: <6EE64EF3AB31D5448D0007DD34EEB3417DD290@Herge.rcsinc.local> +References: <6EE64EF3AB31D5448D0007DD34EEB3417DD290@Herge.rcsinc.local> +Comments: In-reply-to "Merlin Moncure" + message dated "Wed, 07 Sep 2005 09:08:18 -0400" +Date: Wed, 07 Sep 2005 11:02:13 -0400 +Message-ID: <27312.1126105333@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/2 +X-Sequence-Number: 3368 + +"Merlin Moncure" writes: +> ok, I've been in crunching profile profile graphs, and so far have been +> only been able to draw following conclusions. + +> For bulk, 'in-transaction' insert: +> 1. win32 is slower than linux. win32 time for each insert grows with # +> inserts in xact, linux does not (or grows much slower). Win32 starts +> out about 3x slower and grows to 10x slower after 250k inserts. + +Just to be clear: what you were testing was + BEGIN; + INSERT ... VALUES (...); + repeat insert many times + COMMIT; +with each statement issued as a separate PQexec() operation, correct? +Was this set up as a psql script, or specialized C code? (If a psql +script, I wonder whether it's psql that's chewing the time.) + +> 2. ran a 50k profile vs. 250k profile. Nothing jumps out as being +> slower or faster: most time is spent in yyparse on either side. From +> this my preliminary conclusion is that there is something going on in +> the win32 api which is not showing in the profile. + +Hmm. Client/server data transport maybe? It would be interesting to +try inserting the same data in other ways: + * COPY from client + * COPY from disk file + * INSERT/SELECT from another table +and see whether you see a similar slowdown. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Sep 7 13:43:55 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9AC0CD781C + for ; + Wed, 7 Sep 2005 13:22:34 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 69959-08 + for ; + Wed, 7 Sep 2005 16:22:30 +0000 (GMT) +Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.207]) + by svr1.postgresql.org (Postfix) with ESMTP id CF03AD77C0 + for ; + Wed, 7 Sep 2005 13:22:28 -0300 (ADT) +Received: by zproxy.gmail.com with SMTP id z31so2745470nzd + for ; + Wed, 07 Sep 2005 09:22: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=Zop+D+F0RCiXPvVoGAyWrV5s03NNAySiHq4VGzuP63ZsYmX19duOfumDRjH2JrsZWRhOntjCVoaOekYIIR2SdqVwDpzC5OLFZOVWpDvVoZNTjNp+yzSxC9hexkQgWm/o/6ekqoC5qyeol8gy7B1j0fBxqJnN28wpKc17vsW1KlI= +Received: by 10.36.25.13 with SMTP id 13mr3650924nzy; + Wed, 07 Sep 2005 09:22:27 -0700 (PDT) +Received: by 10.36.22.17 with HTTP; Wed, 7 Sep 2005 09:22:27 -0700 (PDT) +Message-ID: +Date: Wed, 7 Sep 2005 12:22:27 -0400 +From: Christian Compagnon +To: pgsql-performance@postgresql.org +Subject: Query take 101 minutes, help, please +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.024 required=5 tests=[RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200509/109 +X-Sequence-Number: 14417 + +Hello, + +I'm a newbie in postgresql, I've installed it on a Windows XP machine +( I can't use linux, it's a company machine ), I'm courious why this +query takes so long + +SELECT "Rut Cliente" +FROM "Internet_Abril" +WHERE "Rut Cliente" NOT IN ((SELECT "Rut Cliente" FROM +"Internet_Enero") UNION (SELECT "Rut Cliente" FROM +"Internet_Febrero") UNION (SELECT "Rut Cliente" FROM +"Internet_Marzo")); + +it takes about 100 minutes to complete the query. +All tables has index created ( Rut Cliente is a VarChar ), and tables +has 50.000 records each. + +The explain for the query tells the following + +"QUERY PLAN + Seq Scan on "Internet_Abril" (cost=3D19406.67..62126112.70 rows=3D24731 w= +idth=3D13) + Filter: (NOT (subplan)) + SubPlan + -> Materialize (cost=3D19406.67..21576.07 rows=3D136740 width=3D13= +) + -> Unique (cost=3D17784.23..18467.93 rows=3D136740 width=3D13) + -> Sort (cost=3D17784.23..18126.08 rows=3D136740 width=3D13) + Sort +Key: "Rut Cliente" + -> Append (cost=3D0.00..3741.80 rows=3D136740 width=3D13) + -> Subquery Scan "*SELECT* 1" (cost=3D0.00..1233.38 +rows=3D45069 width=3D13) + -> Seq Scan on "Internet_Enero" (cost=3D0.00..782.69 +rows=3D45069 width=3D13) + -> Subquery Scan "*SELECT* 2" (cost=3D0.00..1104.06 +rows=3D40353 width=3D13) + -> Seq Scan on "Internet_Febrero" (cost=3D0.00..700.53 +rows=3D40353 width=3D13) + -> Subquery Scan "*SELECT* 3" (cost=3D0.00..1404.36 +rows=3D51318 width=3D13) + -> Seq Scan on "Internet_Marzo" (cost=3D0.00..891.18 +rows=3D51318 width=3D13) + +Any help will be apreciated, It's for my thesis + + +saludos +Christian + +From pgsql-performance-owner@postgresql.org Wed Sep 7 13:58:35 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BB0D8D7F1F + for ; + Wed, 7 Sep 2005 13:58:01 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 88073-01 + for ; + Wed, 7 Sep 2005 16:57:58 +0000 (GMT) +Received: from cassarossa.samfundet.no (cassarossa.samfundet.no + [129.241.93.19]) + by svr1.postgresql.org (Postfix) with ESMTP id 6D6C7D7D27 + for ; + Wed, 7 Sep 2005 13:57:57 -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 1ED3FD-0000LW-6g + for pgsql-performance@postgresql.org; Wed, 07 Sep 2005 18:57:55 +0200 +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1ED3FC-0003Jp-00 + for ; Wed, 07 Sep 2005 18:57:54 +0200 +Date: Wed, 7 Sep 2005 18:57:54 +0200 +From: "Steinar H. Gunderson" +To: pgsql-performance@postgresql.org +Subject: Re: Query take 101 minutes, help, please +Message-ID: <20050907165754.GA12319@uio.no> +Mail-Followup-To: pgsql-performance@postgresql.org +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Disposition: inline +In-Reply-To: +X-Operating-System: Linux 2.6.11.8 on a i686 +X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.014 required=5 tests=[AWL=0.014] +X-Spam-Level: +X-Archive-Number: 200509/110 +X-Sequence-Number: 14418 + +On Wed, Sep 07, 2005 at 12:22:27PM -0400, Christian Compagnon wrote: +> I'm a newbie in postgresql, I've installed it on a Windows XP machine +> ( I can't use linux, it's a company machine ), I'm courious why this +> query takes so long + +It sounds like you've set work_mem too low; increasing it might help. Also +try rewriting your query to + + SELECT "Rut Cliente" + FROM "Internet_Abril" + WHERE + "Rut Cliente" NOT IN ( SELECT "Rut Cliente" FROM "Internet_Enero" ) + AND "Rut Cliente" NOT IN ( SELECT "Rut Cliente" FROM "Internet_Febrero" ) + AND "Rut Cliente" NOT IN ( SELECT "Rut Cliente" FROM "Internet_Marzo" ) + +(I'm not sure how optimized UNION inside an IN/NOT IN is.) + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-performance-owner@postgresql.org Wed Sep 7 15:21:14 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DEB9BD6E3B + for ; + Wed, 7 Sep 2005 14:09:47 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 89434-05 + for ; + Wed, 7 Sep 2005 17:09:42 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.195]) + by svr1.postgresql.org (Postfix) with ESMTP id 59F70D7F82 + for ; + Wed, 7 Sep 2005 14:09:41 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id 36so1435804wra + for ; + Wed, 07 Sep 2005 10:09:40 -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=ldED98D7CIRe4S+crJI2Y3HrVJEr+RDhY/dhgVD+hidCGBdMmCfAHlnpzP7lBYcLLj66ZQ4RA0AtrGMh34oggd4V6HJ2imHDlNHJRlTLpqTkUDL+yom9VQQmLfZ0aqdyZNn+dcdLBRdlEuE2uWE0wOWCy2UDsPwIpqzxceNqX3o= +Received: by 10.54.104.11 with SMTP id b11mr4732489wrc; + Wed, 07 Sep 2005 10:09:40 -0700 (PDT) +Received: by 10.54.42.25 with HTTP; Wed, 7 Sep 2005 10:09:39 -0700 (PDT) +Message-ID: +Date: Wed, 7 Sep 2005 19:09:39 +0200 +From: Meetesh Karia +Reply-To: meetesh.karia@alumni.duke.edu +To: Christian Compagnon +Subject: Re: Query take 101 minutes, help, please +Cc: pgsql-performance@postgresql.org +In-Reply-To: +Mime-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_9481_15360451.1126112979508" +References: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.17 required=5 tests=[AWL=0.059, HTML_40_50=0.086, + HTML_MESSAGE=0.001, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200509/111 +X-Sequence-Number: 14419 + +------=_Part_9481_15360451.1126112979508 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +PG is creating the union of January, February and March tables first and=20 +that doesn't have an index on it. If you're going to do many queries using= +=20 +the union of those three tables, you might want to place their contents int= +o=20 +one table and create an index on it. + +Otherwise, try something like this: + +SELECT "Rut Cliente" +FROM "Internet_Abril" +WHERE "Rut Cliente" NOT IN (SELECT "Rut Cliente" FROM +"Internet_Enero") +AND "Rut Cliente" NOT IN (SELECT "Rut Cliente" FROM +"Internet_Febrero") +AND "Rut Cliente" NOT IN (SELECT "Rut Cliente" FROM +"Internet_Marzo"); + +You could also compare the performance of that to this and choose the one= +=20 +that works the best: + +SELECT "Rut Cliente" +FROM "Internet_Abril" a +LEFT JOIN "Internet_Enero" e ON a."Rut Cliente" =3D e."Rut Cliente" +LEFT JOIN "Internet_Febrero" f ON a."Rut Cliente" =3D f."Rut Cliente" +LEFT JOIN "Internet_Marzo" m ON a."Rut Cliente" =3D m."Rut Cliente" +WHERE e."Rut Cliente" IS NULL AND f."Rut Cliente" IS NULL and m."Rut=20 +Cliente" IS NULL; + +Meetesh + +On 9/7/05, Christian Compagnon wrote: +>=20 +> Hello, +>=20 +> I'm a newbie in postgresql, I've installed it on a Windows XP machine +> ( I can't use linux, it's a company machine ), I'm courious why this +> query takes so long +>=20 +> SELECT "Rut Cliente" +> FROM "Internet_Abril" +> WHERE "Rut Cliente" NOT IN ((SELECT "Rut Cliente" FROM +> "Internet_Enero") UNION (SELECT "Rut Cliente" FROM +> "Internet_Febrero") UNION (SELECT "Rut Cliente" FROM +> "Internet_Marzo")); +>=20 +> it takes about 100 minutes to complete the query. +> All tables has index created ( Rut Cliente is a VarChar ), and tables +> has 50.000 records each. +>=20 +> The explain for the query tells the following +>=20 +> "QUERY PLAN +> Seq Scan on "Internet_Abril" (cost=3D19406.67..62126112.70 rows=3D24731= +=20 +> width=3D13) +> Filter: (NOT (subplan)) +> SubPlan +> -> Materialize (cost=3D19406.67..21576.07 rows=3D136740 width=3D13) +> -> Unique (cost=3D17784.23..18467.93 rows=3D136740 width=3D13) +> -> Sort (cost=3D17784.23..18126.08 rows=3D136740 width=3D13) +> Sort +> Key: "Rut Cliente" +> -> Append (cost=3D0.00..3741.80 rows=3D136740 width=3D13) +> -> Subquery Scan "*SELECT* 1" (cost=3D0.00..1233.38 +> rows=3D45069 width=3D13) +> -> Seq Scan on "Internet_Enero" (cost=3D0.00..782.69 +> rows=3D45069 width=3D13) +> -> Subquery Scan "*SELECT* 2" (cost=3D0.00..1104.06 +> rows=3D40353 width=3D13) +> -> Seq Scan on "Internet_Febrero" (cost=3D0.00..700.53 +> rows=3D40353 width=3D13) +> -> Subquery Scan "*SELECT* 3" (cost=3D0.00..1404.36 +> rows=3D51318 width=3D13) +> -> Seq Scan on "Internet_Marzo" (cost=3D0.00..891.18 +> rows=3D51318 width=3D13) +>=20 +> Any help will be apreciated, It's for my thesis +>=20 +>=20 +> saludos +> Christian +>=20 +> ---------------------------(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 +> + +------=_Part_9481_15360451.1126112979508 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +PG is creating the union of January, February and March tables first +and that doesn't have an index on it.  If you're going to do many +queries using the union of those three tables, you might want to place +their contents into one table and create an index on it.
+
+Otherwise, try something like this:
+
+SELECT "Rut Cliente"
+FROM "Internet_Abril"
+WHERE "Rut Cliente"  NOT IN (SELECT "Rut Cliente" = + FROM
+"Internet_Enero")
+AND "Rut Cliente" NOT IN (SELECT "Rut Cliente"  FR= +OM
+"Internet_Febrero")
+AND "Rut Cliente" NOT IN (SELECT "Rut Cliente"  FR= +OM
+"Internet_Marzo");
+
+You could also compare the performance of that to this and choose the one t= +hat works the best:
+
+SELECT "Rut Cliente"
+ +FROM "Internet_Abril" a
+LEFT JOIN "Internet_Enero" e ON a."Rut Cliente" =3D e.&= +quot;Rut Cliente"
+LEFT JOIN "Internet_Febrero" f ON a."Rut Cliente" =3D f= +."Rut Cliente"
+LEFT JOIN "Internet_Marzo" m ON a."Rut Cliente" =3D m.&= +quot;Rut Cliente"
+WHERE e."Rut Cliente" IS NULL AND f."Rut Cliente" IS NU= +LL and m."Rut Cliente" IS NULL;
+
+Meetesh

On 9/7/05, Christian Compagnon <ccompagnon@gmail.com> wrote:
+Hello,

I'm a newbie in postgresql, I've installed it on a Windows XP= + machine
( I can't use linux, it's a company machine ), I'm courious why= + this
query takes so long

SELECT "Rut Cliente"
FROM = +"Internet_Abril" +
WHERE "Rut Cliente"  NOT IN ((SELECT "Rut Clie= +nte"  FROM
"Internet_Enero") UNION (SELECT &quo= +t;Rut Cliente"  FROM
"Internet_Febrero") UNION = +(SELECT "Rut Cliente"  FROM +
"Internet_Marzo"));

it takes about 100 minutes to comp= +lete the query.
All tables has index created ( Rut Cliente is a VarChar = +), and tables
has 50.000 records each.

The explain for the query = +tells the following +

"QUERY PLAN
Seq Scan on "Internet_Abril" &n= +bsp;(cost=3D19406.67..62126112.70 rows=3D24731 width=3D13)
  F= +ilter: (NOT (subplan))
   SubPlan
    &= +nbsp;  ->  Materialize  (cost=3D19406.67..21576= +.07 rows=3D136740 width=3D13) +
        ->  Unique= +  (cost=3D17784.23..18467.93 +rows=3D136740 width=3D13)
       &nbs= +p;->  Sort  (cost=3D17784.23..18126.08 rows=3D136740= + width=3D13)
          = +;            &n= +bsp;            = +;            &n= +bsp;            = +;   +Sort
Key: "Rut Cliente"
      = +;    ->  Append  (cost=3D0.00..3= +741.80 +rows=3D136740 width=3D13)
       &nbs= +p;  ->  Subquery +Scan "*SELECT* 1"  (cost=3D0.00..1233.38
rows=3D4506= +9 width=3D13)
         &nbs= +p; +->  Seq Scan on +"Internet_Enero"  (cost=3D0.00..782.69
rows=3D45069 = +width=3D13)
           +->  Subquery Scan "*SELECT* +2"  (cost=3D0.00..1104.06
rows=3D40353 width=3D13)
&nb= +sp;            +->  Seq Scan on +"Internet_Febrero"  (cost=3D0.00..700.53
rows=3D4035= +3 width=3D13)
         &nbs= +p; +->  Subquery Scan "*SELECT* +3"  (cost=3D0.00..1404.36
rows=3D51318 width=3D13)
&nb= +sp;           ->&= +nbsp; Seq +Scan on "Internet_Marzo"  (cost=3D0.00..891.18
rows= +=3D51318 width=3D13)

Any help will be apreciated, It's for my thesis= +


saludos
Christian

---------------------------(end of = +broadcast)--------------------------- +
TIP 1: if posting/reading through Usenet, please send an appropriate       subscribe-nomail command to majordomo@postgresql.org so that y= +our
       message can get through to the = +mailing list cleanly +

+ +------=_Part_9481_15360451.1126112979508-- + +From pgsql-performance-owner@postgresql.org Wed Sep 7 16:27:24 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B4999D8107 + for ; + Wed, 7 Sep 2005 14:57:53 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 99996-10 + for ; + Wed, 7 Sep 2005 17:57:50 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 79FBDD80F9 + for ; + Wed, 7 Sep 2005 14:57:48 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j87Hvav1028615; + Wed, 7 Sep 2005 13:57:36 -0400 (EDT) +To: "Steinar H. Gunderson" +Cc: pgsql-performance@postgresql.org +Subject: Re: Query take 101 minutes, help, please +In-reply-to: <20050907165754.GA12319@uio.no> +References: + <20050907165754.GA12319@uio.no> +Comments: In-reply-to "Steinar H. Gunderson" + message dated "Wed, 07 Sep 2005 18:57:54 +0200" +Date: Wed, 07 Sep 2005 13:57:36 -0400 +Message-ID: <28614.1126115856@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/113 +X-Sequence-Number: 14421 + +"Steinar H. Gunderson" writes: +> (I'm not sure how optimized UNION inside an IN/NOT IN is.) + +NOT IN is pretty nonoptimal, period. It'd help a lot to boost work_mem +to the point where the planner figures it can use a hashtable (look for +EXPLAIN to say "hashed subplan" rather than just "subplan"). Of course, +if there's enough stuff in the UNION that that drives you into swapping, +it's gonna be painful anyway. + +Using UNION ALL instead of UNION might save a few cycles too. + +If you're willing to rewrite the query wholesale, you could try the old +trick of a LEFT JOIN where you discard rows for which there's a match, +ie, the righthand join value isn't NULL. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Sep 7 15:41:17 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 34C73D819D + for ; + Wed, 7 Sep 2005 15:41:09 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 15322-02 + for ; + Wed, 7 Sep 2005 18:41:02 +0000 (GMT) +Received: from wumpus.mythic-beasts.com (wumpus.mythic-beasts.com + [212.69.37.9]) + by svr1.postgresql.org (Postfix) with ESMTP id 40CA7D8187 + for ; + Wed, 7 Sep 2005 15:40:58 -0300 (ADT) +Received: from sphinx.mythic-beasts.com ([212.69.37.6]) + by wumpus.mythic-beasts.com with esmtp (Exim 4.44) + id 1ED4qv-000302-Et + for pgsql-performance@postgresql.org; Wed, 07 Sep 2005 19:40:57 +0100 +Received: from xelah (helo=localhost) + by sphinx.mythic-beasts.com with local-esmtp (Exim 4.51) + id 1ED4qv-0007Ix-AK + for pgsql-performance@postgresql.org; Wed, 07 Sep 2005 19:40:57 +0100 +Date: Wed, 7 Sep 2005 19:40:57 +0100 (BST) +From: Alex Hayward +X-X-Sender: xelah@sphinx.mythic-beasts.com +To: pgsql-performance@postgresql.org +Subject: Re: Query take 101 minutes, help, please +In-Reply-To: +Message-ID: +References: + +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.207 required=5 tests=[UPPERCASE_25_50=0.207] +X-Spam-Level: +X-Archive-Number: 200509/112 +X-Sequence-Number: 14420 + +On Wed, 7 Sep 2005, Meetesh Karia wrote: + +> PG is creating the union of January, February and March tables first and +> that doesn't have an index on it. If you're going to do many queries using +> the union of those three tables, you might want to place their contents into +> one table and create an index on it. +> +> Otherwise, try something like this: +> +> SELECT "Rut Cliente" +> FROM "Internet_Abril" +> WHERE "Rut Cliente" NOT IN (SELECT "Rut Cliente" FROM +> "Internet_Enero") +> AND "Rut Cliente" NOT IN (SELECT "Rut Cliente" FROM +> "Internet_Febrero") +> AND "Rut Cliente" NOT IN (SELECT "Rut Cliente" FROM +> "Internet_Marzo"); + +You may also wish to try: + +SELECT "Rut Cliente" +FROM "Internet_Abril" +WHERE NOT EXISTS + (SELECT 1 FROM "Internet_Enero" + WHERE "Internet_Enero"."Rut Cliente"="Internet_Abril"."Rut Cliente") +AND NOT EXISTS + (SELECT 1 FROM "Internet_Febrero" + WHERE "Internet_Febrero"."Rut Cliente"="Internet_Abril"."Rut Cliente") +AND NOT EXISTS + (SELECT 1 FROM "Internet_Marzo" + WHERE "Internet_Marzo"."Rut Cliente"="Internet_Abril"."Rut Cliente") + +which will probably scan the indexes on the January, February and March +indexes once for each row in the April table. + + +From pgsql-performance-owner@postgresql.org Wed Sep 7 18:44:11 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 879F0D7F27 + for ; + Wed, 7 Sep 2005 18:38:49 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 55110-09 + for ; + Wed, 7 Sep 2005 21:38:36 +0000 (GMT) +Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 52D2FD7B95 + for ; + Wed, 7 Sep 2005 18:38:32 -0300 (ADT) +Received: by flake.decibel.org (Postfix, from userid 1001) + id 936221527C; Wed, 7 Sep 2005 16:38:34 -0500 (CDT) +Date: Wed, 7 Sep 2005 16:38:34 -0500 +From: "Jim C. Nasby" +To: Christopher Kings-Lynne +Cc: Tom Lane , Brian Choate , + pgsql-performance@postgresql.org +Subject: Re: Poor performance of delete by primary key +Message-ID: <20050907213834.GB83885@pervasive.com> +References: + <2F9239F5E316C54688FDA9814FF045D6EADACC@EXCHANGE.sf.nimblefish.com> + <18162.1126020720@sss.pgh.pa.us> + <431E5958.8040102@familyhealth.com.au> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <431E5958.8040102@familyhealth.com.au> +X-Operating-System: FreeBSD 4.11-RELEASE-p10 i386 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.9i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 required=5 tests=[AWL=0.007] +X-Spam-Level: +X-Archive-Number: 200509/114 +X-Sequence-Number: 14422 + +On Wed, Sep 07, 2005 at 11:07:04AM +0800, Christopher Kings-Lynne wrote: +> >Unfortunately there's no very simple way to determine which FK is the +> >problem. (In 8.1 it'll be possible to do that with EXPLAIN ANALYZE, +> >but in existing releases EXPLAIN doesn't break out the time spent in +> >each trigger ...) You have to just eyeball the schema :-(. +> +> phpPgAdmin has a handy info feature where you can see all tables that +> refer to the current one. You can always go and steal that query to +> find them... + +You can also use pg_user_foreighn_key* from +http://pgfoundry.org/projects/newsysviews/. +-- +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 Sep 9 02:54:23 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 47A6ED869F + for ; + Fri, 9 Sep 2005 02:54:22 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 47846-10 + for ; + Fri, 9 Sep 2005 05:54:18 +0000 (GMT) +Received: from hotmail.com (bay18-f24.bay18.hotmail.com [65.54.187.74]) + by svr1.postgresql.org (Postfix) with ESMTP id 1122DD860C + for ; + Fri, 9 Sep 2005 02:54:16 -0300 (ADT) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Thu, 8 Sep 2005 22:54:16 -0700 +Message-ID: +Received: from 203.144.143.7 by by18fd.bay18.hotmail.msn.com with HTTP; + Fri, 09 Sep 2005 05:54:15 GMT +X-Originating-IP: [203.144.143.7] +X-Originating-Email: [maccran@hotmail.com] +X-Sender: maccran@hotmail.com +From: "wisan watcharinporn" +To: pgsql-performance@postgresql.org +Subject: please comment on cpu 32 bit or 64 bit +Date: Fri, 09 Sep 2005 05:54:15 +0000 +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed +X-OriginalArrivalTime: 09 Sep 2005 05:54:16.0297 (UTC) + FILETIME=[E98F4590:01C5B502] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=2.338 required=5 tests=[AWL=-0.437, + DNS_FROM_RFC_ABUSE=0.374, DNS_FROM_RFC_POST=1.376, + MSGID_FROM_MTA_HEADER=0, RCVD_IN_NJABL_PROXY=1.026] +X-Spam-Level: ** +X-Archive-Number: 200509/115 +X-Sequence-Number: 14423 + +please help me , +comment on postgresql (8.x.x) performance on cpu AMD, INTEL +and why i should use 32 bit or 64 cpu ? (what the performance difference) + +thank you + +_________________________________________________________________ +Express yourself instantly with MSN Messenger! Download today it's FREE! +http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/ + + +From pgsql-performance-owner@postgresql.org Fri Sep 9 03:32:30 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6DEEAD7D0F + for ; + Fri, 9 Sep 2005 03:32:28 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 79110-02 + for ; + Fri, 9 Sep 2005 06:32:22 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.202]) + by svr1.postgresql.org (Postfix) with ESMTP id 2AE03D7851 + for ; + Fri, 9 Sep 2005 03:32:22 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id 36so1745116wra + for ; + Thu, 08 Sep 2005 23:32:23 -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:mime-version:content-type:content-transfer-encoding:content-disposition; + b=kMI3gSXb9IpSpliJk1yzWzoeg44pMx7U9LvfBzoUWEL86Pkw3BMBVNq4Ytc3eSm2PuEtptPcoML/RspwbPjI3K5I7JpJlqO1Spuae+hUZctMrNXRkEG8ivQwW1XaYatp/rb4KmNrvm98pD7BCMhXvR9OAWxBv0g6oiYOU2TgjMw= +Received: by 10.54.25.77 with SMTP id 77mr16324wry; + Thu, 08 Sep 2005 23:32:23 -0700 (PDT) +Received: by 10.54.109.4 with HTTP; Thu, 8 Sep 2005 23:32:21 -0700 (PDT) +Message-ID: <38c00bae050908233278ab6cc8@mail.gmail.com> +Date: Fri, 9 Sep 2005 15:32:21 +0900 +From: "Choe, Cheng-Dae" +Reply-To: whitekid@gmail.com +To: pgsql-performance@postgresql.org +Subject: Too slow query, do you have an idea to optimize? +Mime-Version: 1.0 +Content-Type: text/plain; charset=EUC-KR +Content-Transfer-Encoding: base64 +Content-Disposition: inline +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.024 required=5 tests=[RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200509/116 +X-Sequence-Number: 14424 + +SSBuZWVkIHRvIGdlbmVyYXRlIHVudXNlZCByYW5kb20gaWQgd2l0aCBmb3JtYXQgaXMgSURbMC05 +XXs0fQpzbyBpIHdyaXRlIGJlbG93IHF1ZXJ5IGJ1dCBpdCBzZWVtcyB0byBiZSB0b28gc2xvdwoK +U0VMRUNUICogRlJPTSAoIAogICAgU0VMRUNUIHVzZXJfaWQgRlJPTSAoCiAgICAgICAgU0VMRUNU +ICdJRCcgfHwgTFBBRChyLCA0LCAnMCcpIEFTIHVzZXJfaWQgCiAgICBGUk9NIGdlbmVyYXRlX3Nl +cmllcygxLCA5OTk5KSBhcyByKSBBUyBzIAogICAgRVhDRVBUCiAgICBTRUxFQ1QgdXNlcl9pZCBG +Uk9NIGFjY291bnQgKSBBUyB0IApPUkRFUiBCWSByYW5kb20oKSAKTElNSVQgMQoKYW5kIEkgZXhl +Y3V0ZSBleHBsYWluIGFuYWx5emUgcXVlcnkuCi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t +LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t +LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t +LS0tLS0tLS0tLS0tLS0tLS0tLQpMaW1pdCAgKGNvc3Q9MzE4LjE3Li4zMTguMTcgcm93cz0xIHdp +ZHRoPTMyKSAoYWN0dWFsCnRpbWU9NzMxLjcwMy4uNzMxLjcwNyByb3dzPTEgbG9vcHM9MSkKICAg +LT4gIFNvcnQgIChjb3N0PTMxOC4xNy4uMzE4Ljk1IHJvd3M9MzEyIHdpZHRoPTMyKSAoYWN0dWFs +CnRpbWU9NzMxLjY5My4uNzMxLjY5MyByb3dzPTEgbG9vcHM9MSkKICAgICAgICAgU29ydCBLZXk6 +IHJhbmRvbSgpCiAgICAgICAgIC0+ICBTdWJxdWVyeSBTY2FuIHQgIChjb3N0PTI4NS43OS4uMzA1 +LjI0IHJvd3M9MzEyIHdpZHRoPTMyKQooYWN0dWFsIHRpbWU9NDI0LjI5OS4uNjU5LjE5MyByb3dz +PTk5OTkgbG9vcHM9MSkKICAgICAgICAgICAgICAgLT4gIFNldE9wIEV4Y2VwdCAgKGNvc3Q9Mjg1 +Ljc5Li4zMDEuMzUgcm93cz0zMTEKd2lkdGg9MTYpIChhY3R1YWwgdGltZT00MjQuMjY2Li41NjYu +MjU0IHJvd3M9OTk5OSBsb29wcz0xKQogICAgICAgICAgICAgICAgICAgICAtPiAgU29ydCAgKGNv +c3Q9Mjg1Ljc5Li4yOTMuNTcgcm93cz0zMTEyCndpZHRoPTE2KSAoYWN0dWFsIHRpbWU9NDI0LjEz +OS4uNDcwLjUyOSByb3dzPTEyMTExIGxvb3BzPTEpCiAgICAgICAgICAgICAgICAgICAgICAgICAg +IFNvcnQgS2V5OiB1c2VyX2lkCiAgICAgICAgICAgICAgICAgICAgICAgICAgIC0+ICBBcHBlbmQg +IChjb3N0PTAuMDAuLjEwNS4yNCByb3dzPTMxMTIKd2lkdGg9MTYpIChhY3R1YWwgdGltZT01LjU3 +Mi4uMjc2LjQ4NSByb3dzPTEyMTExIGxvb3BzPTEpCiAgICAgICAgICAgICAgICAgICAgICAgICAg +ICAgICAgIC0+ICBTdWJxdWVyeSBTY2FuICIqU0VMRUNUKiAxIiAKKGNvc3Q9MC4wMC4uMzAuMDAg +cm93cz0xMDAwIHdpZHRoPTQpIChhY3R1YWwgdGltZT01LjU2NS4uMTQ5LjYxNQpyb3dzPTk5OTkg +bG9vcHM9MSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLT4gIEZ1bmN0 +aW9uIFNjYW4gb24KZ2VuZXJhdGVfc2VyaWVzIHIgIChjb3N0PTAuMDAuLjIwLjAwIHJvd3M9MTAw +MCB3aWR0aD00KSAoYWN0dWFsCnRpbWU9NS41NTMuLjYzLjIyNCByb3dzPTk5OTkgbG9vcHM9MSkK +ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLT4gIFN1YnF1ZXJ5IFNjYW4gIipTRUxF +Q1QqIDIiIAooY29zdD0wLjAwLi43NS4yNCByb3dzPTIxMTIgd2lkdGg9MTYpIChhY3R1YWwgdGlt +ZT0wLjAzMC4uMjguNDczCnJvd3M9MjExMiBsb29wcz0xKQogICAgICAgICAgICAgICAgICAgICAg +ICAgICAgICAgICAgICAgICAtPiAgU2VxIFNjYW4gb24gYWNjb3VudCAKKGNvc3Q9MC4wMC4uNTQu +MTIgcm93cz0yMTEyIHdpZHRoPTE2KSAoYWN0dWFsIHRpbWU9MC4wMTkuLjEwLjE1NQpyb3dzPTIx +MTIgbG9vcHM9MSkKVG90YWwgcnVudGltZTogNzM4LjgwOSBtcwoKCmRvIHlvdSBoYXZlIGFueSBp +ZGVhIGZvciBvcHRpbWl6ZT8KLS0gCkNob2UsIENoZW5nLURhZSjD1sGktOspCkJsb2c6IGh0dHA6 +Ly93d3cuY29tZG9uZ2luLmNvbS8K + +From pgsql-performance-owner@postgresql.org Fri Sep 9 03:59:37 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BF508D8815 + for ; + Fri, 9 Sep 2005 03:59:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81056-08 + for ; + Fri, 9 Sep 2005 06:59:32 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 976B1D8813 + for ; + Fri, 9 Sep 2005 03:59:31 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j896wGSf007660; + Fri, 9 Sep 2005 02:58:17 -0400 (EDT) +To: "wisan watcharinporn" +Cc: pgsql-performance@postgresql.org +Subject: Re: please comment on cpu 32 bit or 64 bit +In-reply-to: +References: +Comments: In-reply-to "wisan watcharinporn" + message dated "Fri, 09 Sep 2005 05:54:15 -0000" +Date: Fri, 09 Sep 2005 02:58:16 -0400 +Message-ID: <7659.1126249096@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/118 +X-Sequence-Number: 14426 + +"wisan watcharinporn" writes: +> comment on postgresql (8.x.x) performance on cpu AMD, INTEL +> and why i should use 32 bit or 64 cpu ? (what the performance difference) + +For most database applications, you're better off spending your money +on faster disk drives and/or more RAM than on a sexier CPU. + +Maybe your application doesn't follow that general rule --- but since +you told us exactly zero about what your application is, this advice +is worth what you paid for it ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Sep 9 03:58:53 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7E5C4D87FB + for ; + Fri, 9 Sep 2005 03:58:51 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 85651-02 + for ; + Fri, 9 Sep 2005 06:58:48 +0000 (GMT) +Received: from houston.familyhealth.com.au (houston.au.fhnetwork.com + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 1AE34D87E8 + for ; + Fri, 9 Sep 2005 03:58:47 -0300 (ADT) +Received: from houston.familyhealth.com.au (localhost [127.0.0.1]) + by houston.familyhealth.com.au (Postfix) with ESMTP id 37FC324FFF; + Fri, 9 Sep 2005 14:58:44 +0800 (WST) +Received: from [127.0.0.1] (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (Postfix) with ESMTP id 6347824FF7; + Fri, 9 Sep 2005 14:58:43 +0800 (WST) +Message-ID: <43213307.8050501@familyhealth.com.au> +Date: Fri, 09 Sep 2005 15:00:23 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: whitekid@gmail.com +Cc: pgsql-performance@postgresql.org +Subject: Re: Too slow query, do you have an idea to optimize? +References: <38c00bae050908233278ab6cc8@mail.gmail.com> +In-Reply-To: <38c00bae050908233278ab6cc8@mail.gmail.com> +Content-Type: text/plain; charset=EUC-KR +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: chriskl@familyhealth.com.au +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.062 required=5 tests=[AWL=0.012, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/117 +X-Sequence-Number: 14425 + +Generate them all into a table and just delete them as you use them. +It's only 10000 rows... + +Chris + +Choe, Cheng-Dae wrote: +> I need to generate unused random id with format is ID[0-9]{4} +> so i write below query but it seems to be too slow +> +> SELECT * FROM ( +> SELECT user_id FROM ( +> SELECT 'ID' || LPAD(r, 4, '0') AS user_id +> FROM generate_series(1, 9999) as r) AS s +> EXCEPT +> SELECT user_id FROM account ) AS t +> ORDER BY random() +> LIMIT 1 +> +> and I execute explain analyze query. +> ------------------------------------------------------------------------------------------------------------------------------------------------------------------ +> Limit (cost=318.17..318.17 rows=1 width=32) (actual +> time=731.703..731.707 rows=1 loops=1) +> -> Sort (cost=318.17..318.95 rows=312 width=32) (actual +> time=731.693..731.693 rows=1 loops=1) +> Sort Key: random() +> -> Subquery Scan t (cost=285.79..305.24 rows=312 width=32) +> (actual time=424.299..659.193 rows=9999 loops=1) +> -> SetOp Except (cost=285.79..301.35 rows=311 +> width=16) (actual time=424.266..566.254 rows=9999 loops=1) +> -> Sort (cost=285.79..293.57 rows=3112 +> width=16) (actual time=424.139..470.529 rows=12111 loops=1) +> Sort Key: user_id +> -> Append (cost=0.00..105.24 rows=3112 +> width=16) (actual time=5.572..276.485 rows=12111 loops=1) +> -> Subquery Scan "*SELECT* 1" +> (cost=0.00..30.00 rows=1000 width=4) (actual time=5.565..149.615 +> rows=9999 loops=1) +> -> Function Scan on +> generate_series r (cost=0.00..20.00 rows=1000 width=4) (actual +> time=5.553..63.224 rows=9999 loops=1) +> -> Subquery Scan "*SELECT* 2" +> (cost=0.00..75.24 rows=2112 width=16) (actual time=0.030..28.473 +> rows=2112 loops=1) +> -> Seq Scan on account +> (cost=0.00..54.12 rows=2112 width=16) (actual time=0.019..10.155 +> rows=2112 loops=1) +> Total runtime: 738.809 ms +> +> +> do you have any idea for optimize? + + +From pgsql-performance-owner@postgresql.org Sat Sep 10 00:23:26 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7DDA9D7BD3 + for ; + Sat, 10 Sep 2005 00:23:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 48368-01 + for ; + Sat, 10 Sep 2005 03:23:23 +0000 (GMT) +Received: from hub.org (hub.org [200.46.204.220]) + by svr1.postgresql.org (Postfix) with ESMTP id 99251D76E4 + for ; + Sat, 10 Sep 2005 00:23:23 -0300 (ADT) +Received: from localhost (av.hub.org [200.46.204.144]) + by hub.org (Postfix) with ESMTP id 9E59064BB53 + for ; + Sat, 10 Sep 2005 00:23:23 -0300 (ADT) +Received: from hub.org ([200.46.204.220]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 46206-07 for ; + Sat, 10 Sep 2005 03:23:21 +0000 (GMT) +Received: from ganymede.hub.org (blk-222-82-85.eastlink.ca [24.222.82.85]) + by hub.org (Postfix) with ESMTP id B4CBB64BB52 + for ; + Sat, 10 Sep 2005 00:23:21 -0300 (ADT) +Received: by ganymede.hub.org (Postfix, from userid 1000) + id 770503DF19; Sat, 10 Sep 2005 00:23:19 -0300 (ADT) +Received: from localhost (localhost [127.0.0.1]) + by ganymede.hub.org (Postfix) with ESMTP id 75DBC3DF0C + for ; + Sat, 10 Sep 2005 00:23:19 -0300 (ADT) +Date: Sat, 10 Sep 2005 00:23:19 -0300 (ADT) +From: "Marc G. Fournier" +X-X-Sender: scrappy@ganymede.hub.org +To: pgsql-performance@postgresql.org +Subject: CHECK vs REFERENCES +Message-ID: <20050910001821.E1170@ganymede.hub.org> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed +X-Virus-Scanned: by amavisd-new at hub.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.046 required=5 tests=[AWL=-0.004, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/119 +X-Sequence-Number: 14427 + + +Which is faster, where the list involved is fixed? My thought is that +since it doesn't have to check a seperate table, the CHECK itself should +be the faster of the two, but I can't find anything that seems to validate +that theory ... + +The case is where I just want to check that a value being inserted is one +of a few possible values, with that list of values rarely (if ever) +changing, so havng a 'flexible list' REFERENCED seems relatively overkill +... + +Thoughts, or pointers to a doc that disproves, or proves, what I believe? + +Thanks ... + +---- +Marc G. Fournier Hub.Org Networking Services (http://www.hub.org) +Email: scrappy@hub.org Yahoo!: yscrappy ICQ: 7615664 + +From pgsql-performance-owner@postgresql.org Sat Sep 10 00:49:18 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F36B8D7015; + Sat, 10 Sep 2005 00:49:17 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 51903-03; Sat, 10 Sep 2005 03:49:14 +0000 (GMT) +Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) + by svr1.postgresql.org (Postfix) with ESMTP id 470CAD6F3C; + Sat, 10 Sep 2005 00:49:13 -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 j8A3n8it039580 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); + Fri, 9 Sep 2005 21:49:11 -0600 (MDT) + (envelope-from mfuhr@winnie.fuhr.org) +Received: from winnie.fuhr.org (localhost [127.0.0.1]) + by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j8A3n76R040482; + Fri, 9 Sep 2005 21:49:07 -0600 (MDT) + (envelope-from mfuhr@winnie.fuhr.org) +Received: (from mfuhr@localhost) + by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j8A3n7lc040481; + Fri, 9 Sep 2005 21:49:07 -0600 (MDT) (envelope-from mfuhr) +Date: Fri, 9 Sep 2005 21:49:07 -0600 +From: Michael Fuhr +To: "Marc G. Fournier" +Cc: pgsql-performance@postgresql.org +Subject: Re: CHECK vs REFERENCES +Message-ID: <20050910034907.GA40382@winnie.fuhr.org> +References: <20050910001821.E1170@ganymede.hub.org> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20050910001821.E1170@ganymede.hub.org> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.109 required=5 tests=[AWL=-0.098, + UPPERCASE_25_50=0.207] +X-Spam-Level: +X-Archive-Number: 200509/120 +X-Sequence-Number: 14428 + +On Sat, Sep 10, 2005 at 12:23:19AM -0300, Marc G. Fournier wrote: +> Which is faster, where the list involved is fixed? My thought is that +> since it doesn't have to check a seperate table, the CHECK itself should +> be the faster of the two, but I can't find anything that seems to validate +> that theory ... + +Why not just benchmark each method as you intend to use them? Here's +a simplistic example: + +CREATE TABLE test_none ( + val integer NOT NULL +); + +CREATE TABLE test_check ( + val integer NOT NULL CHECK (val IN (1, 2, 3, 4, 5)) +); + +CREATE TABLE test_vals ( + id integer PRIMARY KEY +); +INSERT INTO test_vals SELECT * FROM generate_series(1, 5); + +CREATE TABLE test_fk ( + val integer NOT NULL REFERENCES test_vals +); + +\timing + +INSERT INTO test_none SELECT 1 FROM generate_series(1, 100000); +INSERT 0 100000 +Time: 3109.089 ms + +INSERT INTO test_check SELECT 1 FROM generate_series(1, 100000); +INSERT 0 100000 +Time: 3492.344 ms + +INSERT INTO test_fk SELECT 1 FROM generate_series(1, 100000); +INSERT 0 100000 +Time: 23578.853 ms + +-- +Michael Fuhr + +From pgsql-performance-owner@postgresql.org Sat Sep 10 01:03:13 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0F3C7D864A; + Sat, 10 Sep 2005 01:03:13 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 51115-08; Sat, 10 Sep 2005 04:03:10 +0000 (GMT) +Received: from hub.org (hub.org [200.46.204.220]) + by svr1.postgresql.org (Postfix) with ESMTP id 0C29BD8632; + Sat, 10 Sep 2005 01:03:11 -0300 (ADT) +Received: from localhost (av.hub.org [200.46.204.144]) + by hub.org (Postfix) with ESMTP id 71FD264B9FC; + Sat, 10 Sep 2005 01:03:11 -0300 (ADT) +Received: from hub.org ([200.46.204.220]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 55727-03; Sat, 10 Sep 2005 04:03:05 +0000 (GMT) +Received: from ganymede.hub.org (blk-222-82-85.eastlink.ca [24.222.82.85]) + by hub.org (Postfix) with ESMTP id DE9D164B906; + Sat, 10 Sep 2005 01:03:05 -0300 (ADT) +Received: by ganymede.hub.org (Postfix, from userid 1000) + id 0DEBD368B9; Sat, 10 Sep 2005 01:03:04 -0300 (ADT) +Received: from localhost (localhost [127.0.0.1]) + by ganymede.hub.org (Postfix) with ESMTP id 07693353E2; + Sat, 10 Sep 2005 01:03:04 -0300 (ADT) +Date: Sat, 10 Sep 2005 01:03:03 -0300 (ADT) +From: "Marc G. Fournier" +X-X-Sender: scrappy@ganymede.hub.org +To: Michael Fuhr +Cc: "Marc G. Fournier" , + pgsql-performance@postgresql.org +Subject: Re: CHECK vs REFERENCES +In-Reply-To: <20050910034907.GA40382@winnie.fuhr.org> +Message-ID: <20050910010141.O1170@ganymede.hub.org> +References: <20050910001821.E1170@ganymede.hub.org> + <20050910034907.GA40382@winnie.fuhr.org> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed +X-Virus-Scanned: by amavisd-new at hub.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.046 required=5 tests=[AWL=-0.004, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/121 +X-Sequence-Number: 14429 + +On Fri, 9 Sep 2005, Michael Fuhr wrote: + +> On Sat, Sep 10, 2005 at 12:23:19AM -0300, Marc G. Fournier wrote: +>> Which is faster, where the list involved is fixed? My thought is that +>> since it doesn't have to check a seperate table, the CHECK itself should +>> be the faster of the two, but I can't find anything that seems to validate +>> that theory ... +> +> Why not just benchmark each method as you intend to use them? Here's +> a simplistic example: +> +> CREATE TABLE test_none ( +> val integer NOT NULL +> ); +> +> CREATE TABLE test_check ( +> val integer NOT NULL CHECK (val IN (1, 2, 3, 4, 5)) +> ); +> +> CREATE TABLE test_vals ( +> id integer PRIMARY KEY +> ); +> INSERT INTO test_vals SELECT * FROM generate_series(1, 5); +> +> CREATE TABLE test_fk ( +> val integer NOT NULL REFERENCES test_vals +> ); +> +> \timing +> +> INSERT INTO test_none SELECT 1 FROM generate_series(1, 100000); +> INSERT 0 100000 +> Time: 3109.089 ms +> +> INSERT INTO test_check SELECT 1 FROM generate_series(1, 100000); +> INSERT 0 100000 +> Time: 3492.344 ms +> +> INSERT INTO test_fk SELECT 1 FROM generate_series(1, 100000); +> INSERT 0 100000 +> Time: 23578.853 ms + +Yowch, I expected CHECK to be better ... but not so significantly ... I +figured I'd be saving milliseconds, which, on a busy server, would add up +fast ... but not 10k' of milliseconds ... + +Thanks, that definitely shows a major benefit ... + +---- +Marc G. Fournier Hub.Org Networking Services (http://www.hub.org) +Email: scrappy@hub.org Yahoo!: yscrappy ICQ: 7615664 + +From pgsql-performance-owner@postgresql.org Sat Sep 10 02:40:56 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7E909D7E59 + for ; + Sat, 10 Sep 2005 02:40:55 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81256-01 + for ; + Sat, 10 Sep 2005 05:40:49 +0000 (GMT) +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5D0FCD77EE + for ; + Sat, 10 Sep 2005 02:40:48 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 3839931F82; Sat, 10 Sep 2005 07:40:47 +0200 (MET DST) +From: Chris Browne +X-Newsgroups: pgsql.performance +Subject: Re: please comment on cpu 32 bit or 64 bit +Date: Sat, 10 Sep 2005 01:21:09 -0400 +Organization: cbbrowne Computing Inc +Lines: 29 +Message-ID: <608xy5sdkq.fsf@dba2.int.libertyrms.com> +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +X-Complaints-To: usenet@news.hub.org +User-Agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4.17 (Jumbo Shrimp, linux) +Cancel-Lock: sha1:53+3N/VtP//qA6YVWql632/B58g= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.097 required=5 tests=[AWL=0.097] +X-Spam-Level: +X-Archive-Number: 200509/122 +X-Sequence-Number: 14430 + +maccran@hotmail.com ("wisan watcharinporn") writes: +> please help me , +> comment on postgresql (8.x.x) performance on cpu AMD, INTEL +> and why i should use 32 bit or 64 cpu ? (what the performance difference) + +Generally speaking, the width of your I/O bus will be more important +to performance than the width of the processor bus. + +That is, having more and better disk will have more impact on +performance than getting a better CPU. + +That being said, if you plan to have a system with significantly more +than 2GB of memory, there seem to be pretty substantial benefits to +the speed of AMD memory bus access, and that can be quite significant, +given that if you have a lot of memory, and thus are often operating +out of cache, and are slinging around big queries, THAT implies a lot +of shoving data around in memory. AMD/Opteron has a way faster memory +bus than the Intel/Xeon systems. + +But this is only likely to be significant if you're doing processing +intense enough that you commonly have >> 4GB of memory in use. + +If not, then you'd better focus on I/O speed, which is typically +pretty independent of the CPU... +-- +(format nil "~S@~S" "cbbrowne" "ntlug.org") +http://www.ntlug.org/~cbbrowne/rdbms.html +"Anyway I know how to not be bothered by consing on the fly." +-- Dave Moon + +From pgsql-performance-owner@postgresql.org Sat Sep 10 11:42:17 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 09076D8A8C; + Sat, 10 Sep 2005 11:42:17 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18140-05; Sat, 10 Sep 2005 14:42:13 +0000 (GMT) +Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) + by svr1.postgresql.org (Postfix) with ESMTP id 5097CD78F2; + Sat, 10 Sep 2005 10:06:27 -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 j8AD6S3g040369 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); + Sat, 10 Sep 2005 07:06:30 -0600 (MDT) + (envelope-from mfuhr@winnie.fuhr.org) +Received: from winnie.fuhr.org (localhost [127.0.0.1]) + by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j8AD6RGn045646; + Sat, 10 Sep 2005 07:06:28 -0600 (MDT) + (envelope-from mfuhr@winnie.fuhr.org) +Received: (from mfuhr@localhost) + by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j8AD6R8p045645; + Sat, 10 Sep 2005 07:06:27 -0600 (MDT) (envelope-from mfuhr) +Date: Sat, 10 Sep 2005 07:06:27 -0600 +From: Michael Fuhr +To: "Marc G. Fournier" +Cc: pgsql-performance@postgresql.org +Subject: Re: CHECK vs REFERENCES +Message-ID: <20050910130627.GA45586@winnie.fuhr.org> +References: <20050910001821.E1170@ganymede.hub.org> + <20050910034907.GA40382@winnie.fuhr.org> + <20050910010141.O1170@ganymede.hub.org> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20050910010141.O1170@ganymede.hub.org> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.005 required=5 tests=[AWL=0.005] +X-Spam-Level: +X-Archive-Number: 200509/123 +X-Sequence-Number: 14431 + +On Sat, Sep 10, 2005 at 01:03:03AM -0300, Marc G. Fournier wrote: +> On Fri, 9 Sep 2005, Michael Fuhr wrote: +> >INSERT INTO test_check SELECT 1 FROM generate_series(1, 100000); +> >INSERT 0 100000 +> >Time: 3492.344 ms +> > +> >INSERT INTO test_fk SELECT 1 FROM generate_series(1, 100000); +> >INSERT 0 100000 +> >Time: 23578.853 ms +> +> Yowch, I expected CHECK to be better ... but not so significantly ... I +> figured I'd be saving milliseconds, which, on a busy server, would add up +> fast ... but not 10k' of milliseconds ... + +Results will differ depending on the table structure: if you're +indexing ten columns and have five triggers then the foreign key +check will have less of an overall impact. + +-- +Michael Fuhr + +From pgsql-performance-owner@postgresql.org Sun Sep 11 04:46:55 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6BF57D7903 + for ; + Sun, 11 Sep 2005 04:46:54 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 65701-03 + for ; + Sun, 11 Sep 2005 07:46:50 +0000 (GMT) +Received: from mail.markdilger.com (or-65-40-225-74.sta.sprint-hsd.net + [65.40.225.74]) + by svr1.postgresql.org (Postfix) with ESMTP id 639C2D78F8 + for ; + Sun, 11 Sep 2005 04:46:46 -0300 (ADT) +Received: from [192.168.2.6] ([192.168.2.6]) + (TLS: TLSv1/SSLv3,256bits,AES256-SHA) + by mail.markdilger.com with esmtp; Sun, 11 Sep 2005 00:51:10 -0700 + id 000207D8.4323E1EE.00002E7A +Message-ID: <4323E016.2060606@markdilger.com> +Date: Sun, 11 Sep 2005 00:43:18 -0700 +From: Mark Dilger +User-Agent: Mozilla Thunderbird 1.0 (X11/20050130) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: performance discrepancy indexing one column versus two columns +X-Enigmail-Version: 0.89.5.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 required=5 tests=[FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/124 +X-Sequence-Number: 14432 + +All, + +In the psql output below, I would expect the second query to run faster, because +the b-tree index on two columns knows the values of 'b' for any given value of +'a', and hence does not need to fetch a row from the actual table. I am not +seeing a speed-up, however, so I expect my understanding of the index mechanism +is wrong. Could anyone enlighten me? + +Specifically, I would expect the first query to walk the b-tree looking for +values of 'a' equal to 1, 100001, etc., and then a dereference over to the main +table to fetch the value for column 'b'. + +But I would expect the second query to walk the b-tree looking for values of 'a' +equal to 1, 100001, etc., and then find on that same page in the b-tree the +value of 'b', thereby avoiding the dereference and extra page fetch. + +Is the problem that the two-column b-tree contains more data, is spread across +more disk pages, and is hence slower to access, canceling out the performance +gain of not having to fetch from the main table? Or is the query system not +using the second column information from the index and doing the table fetch +anyway? Or does the index store the entire row from the main table regardless +of the column being indexed? + +I am running postgresql 8.0.3 on a Pentium 4 with ide hard drives and the +default configuration file settings. + +Thanks in advance, + +mark + + + +mark=# create sequence test_id_seq; +CREATE SEQUENCE +mark=# create table test (a integer not null default nextval('test_id_seq'), b +integer not null); +CREATE TABLE +mark=# create function testfunc () returns void as $$ +mark$# declare +mark$# i integer; +mark$# begin +mark$# for i in 1..1000000 loop +mark$# insert into test (b) values (i); +mark$# end loop; +mark$# return; +mark$# end; +mark$# $$ language plpgsql; +CREATE FUNCTION +mark=# select * from testfunc(); + testfunc +---------- + +(1 row) + +mark=# select count(*) from test; + count +--------- + 1000000 +(1 row) + +mark=# create index test_single_idx on test(a); +CREATE INDEX +mark=# vacuum full; +VACUUM +mark=# analyze; +ANALYZE +mark=# explain analyze select b from test where a in (1, 100001, 200001, 300001, +400001, 500001, 600001, 700001, 800001, 900001); + + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Index Scan using test_single_idx, test_single_idx, test_single_idx, +test_single_idx, test_single_idx, test_single_idx, test_single_idx, +test_single_idx, test_single_idx, test_single_idx on test (cost=0.00..30.36 +rows=10 width=4) (actual time=0.145..0.917 rows=10 loops=1) + Index Cond: ((a = 1) OR (a = 100001) OR (a = 200001) OR (a = 300001) OR (a = +400001) OR (a = 500001) OR (a = 600001) OR (a = 700001) OR (a = 800001) OR(a = +900001)) + Total runtime: 1.074 ms +(3 rows) + +mark=# drop index test_single_idx; +DROP INDEX +mark=# create index test_double_idx on test(a,b); +CREATE INDEX +mark=# vacuum full; +VACUUM +mark=# analyze; +ANALYZE +mark=# explain analyze select b from test where a in (1, 100001, 200001, 300001, +400001, 500001, 600001, 700001, 800001, 900001); + + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Index Scan using test_double_idx, test_double_idx, test_double_idx, +test_double_idx, test_double_idx, test_double_idx, test_double_idx, +test_double_idx, test_double_idx, test_double_idx on test (cost=0.00..43.48 +rows=10 width=4) (actual time=0.283..1.119 rows=10 loops=1) + Index Cond: ((a = 1) OR (a = 100001) OR (a = 200001) OR (a = 300001) OR (a = +400001) OR (a = 500001) OR (a = 600001) OR (a = 700001) OR (a = 800001) OR(a = +900001)) + Total runtime: 1.259 ms +(3 rows) + +From pgsql-performance-owner@postgresql.org Sun Sep 11 05:06:11 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 045C5D774D + for ; + Sun, 11 Sep 2005 05:06:10 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 66918-07 + for ; + Sun, 11 Sep 2005 08:06:05 +0000 (GMT) +Received: from linuxworld.com.au (unknown [203.34.46.50]) + by svr1.postgresql.org (Postfix) with ESMTP id 87A68D7312 + for ; + Sun, 11 Sep 2005 05:06:03 -0300 (ADT) +Received: from linuxworld.com.au (IDENT:swm@localhost.localdomain [127.0.0.1]) + by linuxworld.com.au (8.13.2/8.13.2) with ESMTP id j8B853ho004528; + Sun, 11 Sep 2005 18:05:03 +1000 +Received: from localhost (swm@localhost) + by linuxworld.com.au (8.13.2/8.13.2/Submit) with ESMTP id + j8B853qC004525; Sun, 11 Sep 2005 18:05:03 +1000 +X-Authentication-Warning: linuxworld.com.au: swm owned process doing -bs +Date: Sun, 11 Sep 2005 18:05:03 +1000 (EST) +From: Gavin Sherry +X-X-Sender: swm@linuxworld.com.au +To: Mark Dilger +Cc: pgsql-performance@postgresql.org +Subject: Re: performance discrepancy indexing one column versus +In-Reply-To: <4323E016.2060606@markdilger.com> +Message-ID: +References: <4323E016.2060606@markdilger.com> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.001 required=5 tests=[AWL=0.001] +X-Spam-Level: +X-Archive-Number: 200509/125 +X-Sequence-Number: 14433 + +On Sun, 11 Sep 2005, Mark Dilger wrote: + +> All, +> +> In the psql output below, I would expect the second query to run faster, +> because the b-tree index on two columns knows the values of 'b' for any +> given value of 'a', and hence does not need to fetch a row from the +> actual table. I am not seeing a speed-up, however, so I expect my +> understanding of the index mechanism is wrong. Could anyone enlighten +> me? + +A common but incorrect assumption. We must consult the underlying table +when we do an index scan so that we can check visibility information. The +reason it is stored there in the table is so that we have only one place +to check for tuple visibility and therefore avoid race conditions. + +A brief explanation of this system is described here: +http://www.postgresql.org/docs/8.0/static/mvcc.html. + +and this page shows what information we store in the to do visibility +checks: + +http://www.postgresql.org/docs/8.0/static/storage-page-layout.html + +Thanks, + +Gavin + +From pgsql-performance-owner@postgresql.org Sun Sep 11 05:29:15 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6DADBD7302 + for ; + Sun, 11 Sep 2005 05:29:14 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 73065-07 + for ; + Sun, 11 Sep 2005 08:29:11 +0000 (GMT) +Received: from pharmaline.de (mail.pharmaline.de [62.153.135.34]) + by svr1.postgresql.org (Postfix) with ESMTP id 8B000D6F4B + for ; + Sun, 11 Sep 2005 05:29:11 -0300 (ADT) +Received: from [192.168.0.5] (84.60.151.89) by pharmaline.de with ESMTP + (Eudora Internet Mail Server 3.2.6) for + ; Sun, 11 Sep 2005 10:29:10 +0200 +Mime-Version: 1.0 (Apple Message framework v734) +Content-Transfer-Encoding: 7bit +Message-Id: <33A6D7B7-FDF3-456E-9154-402E9C5BC5D9@pharmaline.de> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +To: pgsql-performance@postgresql.org +From: Guido Neitzer +Subject: Index not used with prepared statement +Date: Sun, 11 Sep 2005 10:29:09 +0200 +X-Mailer: Apple Mail (2.734) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/126 +X-Sequence-Number: 14434 + +Hi. + +I have a performance problem with prepared statements (JDBC prepared +statement). + +This query: + +PreparedStatement st = conn.prepareStatement("SELECT id FROM +dga_dienstleister WHERE plz like '45257'"); + +does use an index. + +This query: + + String plz = "45257"; + PreparedStatement st = conn.prepareStatement("SELECT id FROM +dga_dienstleister WHERE plz like ?"); + st.setString(1, plz); + +does NOT use an index. + +As it should in the end result in absolutely the same statement, the +index should be used all the time. I have to set the +protocolVersion=2 and use the JDBC2 driver to get it working (but +then the statements are created like in the first query, so no +solution, only a workaround). + +I'm not sure whether this is a bug (I think it is) or a problem of +understanding. + +Known problem? + +I have tried PG 8.0.1, 8.0.3, 8.1beta with the JDBC-drivers + +- postgresql-8.0-312.jdbc2.jar --> okay with protocolVersion=2 in the +URL +- postgresql-8.0-312.jdbc3.jar --> not okay whatever I do + +I'm on Mac OS X, if that matters. + +cug + +From pgsql-performance-owner@postgresql.org Sun Sep 11 06:03:33 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F3EAED7302 + for ; + Sun, 11 Sep 2005 06:03:32 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 79563-07 + for ; + Sun, 11 Sep 2005 09:03:28 +0000 (GMT) +Received: from smtp2.rz.uni-karlsruhe.de (smtp2.rz.uni-karlsruhe.de + [129.13.185.218]) + by svr1.postgresql.org (Postfix) with ESMTP id 44F82D6F4B + for ; + Sun, 11 Sep 2005 06:03:27 -0300 (ADT) +Received: from rzstud1.stud.uni-karlsruhe.de (rzstud1.stud.uni-karlsruhe.de + [193.196.41.33]) + by smtp2.rz.uni-karlsruhe.de with esmtp (Exim 4.43 #1) + id 1EENkG-0007hC-7W; Sun, 11 Sep 2005 11:03:28 +0200 +Received: from uwi7 by rzstud1.stud.uni-karlsruhe.de with local (Exim 3.36 #1) + id 1EENkO-0003f3-00; Sun, 11 Sep 2005 11:03:36 +0200 +From: Andreas Seltenreich +To: Guido Neitzer +Cc: pgsql-performance@postgresql.org +Subject: Re: Index not used with prepared statement +References: <33A6D7B7-FDF3-456E-9154-402E9C5BC5D9@pharmaline.de> +X-PGP-Key: 0x2C006B340F8C8C1B +X-Face: $:F<87a[gD1?#R6S3j21cr1&C&7bd63GHC.tSdskUb}hhwG(ci*=D5kJ<_N+p9q(7-, + PnG. + Et.Yh (Guido + Neitzer's message of "Sun, 11 Sep 2005 10:29:09 +0200") +User-Agent: Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux) +Message-ID: <87vf18x9gk.fsf@gate450.dyndns.org> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.001 required=5 tests=[AWL=0.001] +X-Spam-Level: +X-Archive-Number: 200509/127 +X-Sequence-Number: 14435 + +Guido Neitzer schrob: + +> I have a performance problem with prepared statements (JDBC prepared +> statement). +> +> This query: +> +> PreparedStatement st = conn.prepareStatement("SELECT id FROM +> dga_dienstleister WHERE plz like '45257'"); +> +> does use an index. +> +> This query: +> +> String plz = "45257"; +> PreparedStatement st = conn.prepareStatement("SELECT id FROM +> dga_dienstleister WHERE plz like ?"); +> st.setString(1, plz); +> +> does NOT use an index. +> +> As it should in the end result in absolutely the same statement, the +> index should be used all the time. + +I'm not perfectly sure, but since the index could only be used with a +subset of all possible parameters (the pattern for like has to be +left-anchored), I could imagine the planner has to avoid the index in +order to produce an universal plan (the thing behind a prepared +statement). + +Is there a reason you are using the like operator at all? IMO using +the =-operator instead in your example should produce an "index-using +prepared statement". + +HTH +Andreas +-- + +From pgsql-performance-owner@postgresql.org Sun Sep 11 07:35:19 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2A2B5D7B89 + for ; + Sun, 11 Sep 2005 07:35:18 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 03055-06 + for ; + Sun, 11 Sep 2005 10:35:11 +0000 (GMT) +Received: from pharmaline.de (mail.pharmaline.de [62.153.135.34]) + by svr1.postgresql.org (Postfix) with ESMTP id 4447DD77D0 + for ; + Sun, 11 Sep 2005 07:35:09 -0300 (ADT) +Received: from [192.168.4.11] (62.153.135.40) by pharmaline.de with ESMTP + (Eudora Internet Mail Server 3.2.6); Sun, 11 Sep 2005 12:35:12 +0200 +Mime-Version: 1.0 (Apple Message framework v734) +In-Reply-To: <87vf18x9gk.fsf@gate450.dyndns.org> +References: <33A6D7B7-FDF3-456E-9154-402E9C5BC5D9@pharmaline.de> + <87vf18x9gk.fsf@gate450.dyndns.org> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <9FDFDA1B-5A2B-465F-A4BA-ED70D1BCE62A@pharmaline.de> +Content-Transfer-Encoding: 7bit +From: Guido Neitzer +Subject: Re: Index not used with prepared statement +Date: Sun, 11 Sep 2005 12:35:09 +0200 +To: Andreas Seltenreich , + pgsql-performance@postgresql.org +X-Mailer: Apple Mail (2.734) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/128 +X-Sequence-Number: 14436 + +On 11.09.2005, at 11:03 Uhr, Andreas Seltenreich wrote: + +> I'm not perfectly sure, but since the index could only be used with a +> subset of all possible parameters (the pattern for like has to be +> left-anchored), I could imagine the planner has to avoid the index in +> order to produce an universal plan (the thing behind a prepared +> statement). + +Hmm. Now I get it. So I have to look that my framework doesn't +produce a preparedStatement, instead build a complete statement +string. Weird. + +> Is there a reason you are using the like operator at all? IMO using +> the =-operator instead in your example should produce an "index-using +> prepared statement". + +Yes, you are right, but then I can't pass anything like '45%' to the +query. It will just return nothing. + +I use the "like" because I build the queries on the fly and add a % +at the end where necessary. + +And, to be clear: this is a minimal example, most of my queries are +generated by a framework. This was an example to test the behaviour. + +Okay, I had problems with the understanding of prepared statements on +the client and the server side. What I thought was, that I get a +preparedStatement by JDBC which also inserts the values into the +string and this is executed on the server side. + +cug + +From pgsql-performance-owner@postgresql.org Sun Sep 11 09:36:31 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 653B1D6E46 + for ; + Sun, 11 Sep 2005 09:36:30 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 29059-07 + for ; + Sun, 11 Sep 2005 12:36:25 +0000 (GMT) +Received: from sccmmhc92.asp.att.net (sccmmhc92.asp.att.net [204.127.203.212]) + by svr1.postgresql.org (Postfix) with ESMTP id 0BF5BD6E0B + for ; + Sun, 11 Sep 2005 09:36:23 -0300 (ADT) +Received: from juju.arbash-meinel.com ([12.214.18.81]) + by sccmmhc92.asp.att.net (sccmmhc92) with ESMTP + id <20050911123623m9200lajhve>; Sun, 11 Sep 2005 12:36:23 +0000 +Received: by juju.arbash-meinel.com (Postfix, from userid 505) + id 1D2CA55FCC; Sun, 11 Sep 2005 07:36:22 -0500 (CDT) +Received: from [209.101.126.19] (unknown [209.101.126.19]) + by juju.arbash-meinel.com (Postfix) with ESMTP id C312E55FA7; + Sun, 11 Sep 2005 07:36:08 -0500 (CDT) +Message-ID: <432424A9.4060403@arbash-meinel.com> +Date: Sun, 11 Sep 2005 08:35:53 -0400 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Martin Nickel +Cc: pgsql-performance@postgresql.org +Subject: Re: shared buffers +References: <20050830015454.54152.qmail@web53204.mail.yahoo.com> + <4313BF95.3030105@familyhealth.com.au> + +In-Reply-To: +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig7527593C6661C605725824D1" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 required=5 tests=[FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/129 +X-Sequence-Number: 14437 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig7527593C6661C605725824D1 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 7bit + +Martin Nickel wrote: +> Chris, +> Would you say that 30000 pages is a good maximum for a Postgres install? +> We're running 8.0.3 on 64-bit SUSE on a dual Opteron box with 4G and have +> shared_buffers set at 120000. I've moved it up and down (it was 160000 +> when I got here) without any measurable performance difference. + +What I've read on the mailing list, is that usually the sweet spot is +actually around 10k pages. 120k seems far too high. + +I believe that the major fixes to the buffer manager are more in 8.1 +rather than 8.0, so you probably are hitting some problems. (The biggest +problem was that there were places that require doing a complete scan +through shared memory looking for dirty pages, or some such). + +> +> The reason I ask is because I occasionally see large-ish queries take +> forever (like cancel-after-12-hours forever) and wondered if this could +> result from shared_buffers being too large. + +There are lots of possibilities for why these take so long, perhaps you +would want to post them, and we can try to help. +For instance, if you have a foreign key reference from one table to +another, and don't have indexes on both sides, then deleting from the +referenced table, will cause a sequential scan on the referring table +for *each* deleted row. (IIRC). + +John +=:-> + +> +> Thanks for your (and anyone else's) help! +> Martin Nickel + +--------------enig7527593C6661C605725824D1 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFDJCStJdeBCYSNAAMRAhSqAJ4rj5xXBOPOXHaVFoe+AqT9Cr/TIgCdFWIZ +InLHDRTxNp/zVWS5NybgoV0= +=I6fd +-----END PGP SIGNATURE----- + +--------------enig7527593C6661C605725824D1-- + +From pgsql-performance-owner@postgresql.org Sun Sep 11 14:13:04 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C1DE4D79FD + for ; + Sun, 11 Sep 2005 14:13:02 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 08614-05 + for ; + Sun, 11 Sep 2005 17:13:00 +0000 (GMT) +Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.203]) + by svr1.postgresql.org (Postfix) with ESMTP id D7F7BD72E9 + for ; + Sun, 11 Sep 2005 14:12:59 -0300 (ADT) +Received: by xproxy.gmail.com with SMTP id i31so2217353wxd + for ; + Sun, 11 Sep 2005 10:12:58 -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:mime-version:content-type:content-transfer-encoding:content-disposition; + b=gvm9xMt0ystHE3Qo7Dymtb10GhSz3c6PIKQHqf8rb/0VCfWT+47cUjC3KRZQ5Gw9t6aSUXPGgWSZIUd8C2R7/Z3rmDQSnjj15EMKwWHdTN9PG7fRitmDiJE72p+dk+S7CD5HMg1prsWaJy0JM2IN7GbBF7XkkfrKr/uhPsZDcCs= +Received: by 10.70.102.16 with SMTP id z16mr79803wxb; + Sun, 11 Sep 2005 10:12:58 -0700 (PDT) +Received: by 10.70.100.7 with HTTP; Sun, 11 Sep 2005 10:12:58 -0700 (PDT) +Message-ID: <130df19305091110125a2d174f@mail.gmail.com> +Date: Sun, 11 Sep 2005 20:12:58 +0300 +From: Ksenia Marasanova +Reply-To: ksenia.marasanova@gmail.com +To: pgsql-performance@postgresql.org +Subject: LEFT JOIN optimization +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.024 required=5 tests=[RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200509/130 +X-Sequence-Number: 14438 + +Hi list, + +I don't have much experience with Postgres optimization, somehow I was +happily avoiding anything more difficult than simple select statement, +and it was working all right. + +Now LEFT JOIN must be used, and I am not happy with the performance: +It takes about 5 seconds to run very simple LEFT JOIN query on a table +"user_" with ~ 13.000 records left joined to table "church" with ~ 300 +records on Powerbook PPC 1.67 GHz with 1.5 GB ram. +Is it normal? + +Some details: + +test=3D# explain select * from user_ left join church on user_.church_id +=3D church.id; + QUERY PLAN =20 +--------------------------------------------------------------------- + Hash Left Join (cost=3D6.44..7626.69 rows=3D12763 width=3D325) + Hash Cond: ("outer".church_id =3D "inner".id) + -> Seq Scan on user_ (cost=3D0.00..7430.63 rows=3D12763 width=3D245) + -> Hash (cost=3D5.75..5.75 rows=3D275 width=3D80) + -> Seq Scan on church (cost=3D0.00..5.75 rows=3D275 width=3D80) +(5 rows) + + + From what I understand, it doesn't use foreign key index on user_ +table. So I tried: + +mydb=3D# set enable_seqscan=3D'false'; +SET +mydb=3D# explain select * from user_ left join church on user_.church_id +=3D church.id; + QUERY PLAN +---------------------------------------------------------------------------= +------------------ + Merge Right Join (cost=3D0.00..44675.77 rows=3D12763 width=3D325) + Merge Cond: ("outer".id =3D "inner".church_id) + -> Index Scan using chirch_pkey on church (cost=3D0.00..17.02 +rows=3D275 width=3D80) + -> Index Scan using user__church_id on user_ (cost=3D0.00..44500.34 +rows=3D12763 width=3D245) +(4 rows) + + +It's my first time reading Query plans, but from wat I understand, it +doesn't make the query faster.. + +Any tips are greatly appreciated. +--=20 +Ksenia + +From pgsql-performance-owner@postgresql.org Sun Sep 11 18:11:44 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 13D4CD8094 + for ; + Sun, 11 Sep 2005 18:00:28 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 31766-10 + for ; + Sun, 11 Sep 2005 21:00:21 +0000 (GMT) +Received: from ns.snowman.net (ns.snowman.net [66.92.160.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 59065D8220 + for ; + Sun, 11 Sep 2005 18:00:09 -0300 (ADT) +Received: by ns.snowman.net (Postfix, from userid 1000) + id 6B91717AD3; Sun, 11 Sep 2005 17:00:36 -0400 (EDT) +Date: Sun, 11 Sep 2005 17:00:36 -0400 +From: Stephen Frost +To: Ksenia Marasanova +Cc: pgsql-performance@postgresql.org +Subject: Re: LEFT JOIN optimization +Message-ID: <20050911210035.GC6026@ns.snowman.net> +Mail-Followup-To: Ksenia Marasanova , + pgsql-performance@postgresql.org +References: <130df19305091110125a2d174f@mail.gmail.com> +Mime-Version: 1.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; boundary="RTNKHHDM+1AXWjxM" +Content-Disposition: inline +In-Reply-To: <130df19305091110125a2d174f@mail.gmail.com> +X-Editor: Vim http://www.vim.org/ +X-Info: http://www.snowman.net +X-Operating-System: Linux/2.4.24ns.3.0 (i686) +X-Uptime: 16:59:06 up 92 days, 13:15, 9 users, load average: 0.05, 0.07, 0.08 +User-Agent: Mutt/1.5.9i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.004 required=5 tests=[AWL=0.004] +X-Spam-Level: +X-Archive-Number: 200509/131 +X-Sequence-Number: 14439 + + +--RTNKHHDM+1AXWjxM +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline + +* Ksenia Marasanova (ksenia.marasanova@gmail.com) wrote: +> Any tips are greatly appreciated. + +EXPLAIN ANALYZE of the same queries would be much more useful. + + Thanks, + + Stephen + +--RTNKHHDM+1AXWjxM +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) + +iD8DBQFDJJrzrzgMPqB3kigRAgurAKCF+rAqT0tVdckcoTYp2CM/PDbDsgCfXdzS +uUVp88enOJ66xRcnBZqor2Q= +=alwG +-----END PGP SIGNATURE----- + +--RTNKHHDM+1AXWjxM-- + +From pgsql-performance-owner@postgresql.org Sun Sep 11 18:48:02 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B5CE9D7EBD + for ; + Sun, 11 Sep 2005 18:48:00 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 49044-06 + for ; + Sun, 11 Sep 2005 21:47:55 +0000 (GMT) +Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.193]) + by svr1.postgresql.org (Postfix) with ESMTP id 9F7DDD7EE6 + for ; + Sun, 11 Sep 2005 18:47:55 -0300 (ADT) +Received: by xproxy.gmail.com with SMTP id i31so2249314wxd + for ; + Sun, 11 Sep 2005 14:47:57 -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:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=SBtm8ycA1++3fuXzars5+UvABHuGuHKwN8kXVycndeO4DF8l1mmMmbAqa+NufCack5Zqf5bH5NLWBKoyIPECc1LAewqpD2b/pTa2TaTLOKV6+VNQ/9s93jXxJke0kPXo0SOzeP/IGs4ZHViN2TUrsTVQZH7rSq9klruDIah/vOs= +Received: by 10.70.96.19 with SMTP id t19mr63297wxb; + Sun, 11 Sep 2005 14:47:57 -0700 (PDT) +Received: by 10.70.100.7 with HTTP; Sun, 11 Sep 2005 14:47:57 -0700 (PDT) +Message-ID: <130df19305091114477e2e581b@mail.gmail.com> +Date: Mon, 12 Sep 2005 00:47:57 +0300 +From: Ksenia Marasanova +Reply-To: ksenia.marasanova@gmail.com +To: pgsql-performance@postgresql.org +Subject: Re: LEFT JOIN optimization +In-Reply-To: <20050911210035.GC6026@ns.snowman.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <130df19305091110125a2d174f@mail.gmail.com> + <20050911210035.GC6026@ns.snowman.net> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.482 required=5 tests=[AWL=0.458, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200509/132 +X-Sequence-Number: 14440 + +2005/9/12, Stephen Frost : +> * Ksenia Marasanova (ksenia.marasanova@gmail.com) wrote: +> > Any tips are greatly appreciated. +>=20 +> EXPLAIN ANALYZE of the same queries would be much more useful. + +Thanks, here it is: + +test=3D# explain analyze select * from user_ left join church on +user_.church_id =3D church.id; + QUERY PLAN +---------------------------------------------------------------------------= +-------------------------------------------- + Hash Left Join (cost=3D6.44..7626.69 rows=3D12763 width=3D325) (actual +time=3D388.573..2016.929 rows=3D12763 loops=3D1) + Hash Cond: ("outer".church_id =3D "inner".id) + -> Seq Scan on user_ (cost=3D0.00..7430.63 rows=3D12763 width=3D245) +(actual time=3D360.431..1120.012 rows=3D12763 loops=3D1) + -> Hash (cost=3D5.75..5.75 rows=3D275 width=3D80) (actual +time=3D27.985..27.985 rows=3D0 loops=3D1) + -> Seq Scan on church (cost=3D0.00..5.75 rows=3D275 width=3D80) +(actual time=3D0.124..26.953 rows=3D275 loops=3D1) + Total runtime: 2025.946 ms +(6 rows) + +test=3D# set enable_seqscan=3D'false'; +SET +test=3D# explain analyze select * from user_ left join church on +user_.church_id =3D church.id; + =20 +QUERY PLAN +---------------------------------------------------------------------------= +------------------------------------------------------------------- + Merge Right Join (cost=3D0.00..44675.77 rows=3D12763 width=3D325) (actual +time=3D0.808..2119.099 rows=3D12763 loops=3D1) + Merge Cond: ("outer".id =3D "inner".church_id) + -> Index Scan using chirch_pkey on church (cost=3D0.00..17.02 +rows=3D275 width=3D80) (actual time=3D0.365..5.471 rows=3D275 loops=3D1) + -> Index Scan using user__church_id on user_ (cost=3D0.00..44500.34 +rows=3D12763 width=3D245) (actual time=3D0.324..1243.348 rows=3D12763 loops= +=3D1) + Total runtime: 2131.364 ms +(5 rows) + + +I followed some tips on the web and vacuum-ed database, I think the +query is faster now, almost acceptable, but still interesting to know +if it possible to optimize it... + +Thanks again, +--=20 +Ksenia + +From pgsql-performance-owner@postgresql.org Sun Sep 11 21:34:30 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DAB11D85D5 + for ; + Sun, 11 Sep 2005 21:34:27 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 04656-04 + for ; + Mon, 12 Sep 2005 00:34:22 +0000 (GMT) +Received: from ns.snowman.net (ns.snowman.net [66.92.160.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 7C03DD858C + for ; + Sun, 11 Sep 2005 21:34:22 -0300 (ADT) +Received: by ns.snowman.net (Postfix, from userid 1000) + id 7ED7617AD3; Sun, 11 Sep 2005 20:34:50 -0400 (EDT) +Date: Sun, 11 Sep 2005 20:34:50 -0400 +From: Stephen Frost +To: Ksenia Marasanova +Cc: pgsql-performance@postgresql.org +Subject: Re: LEFT JOIN optimization +Message-ID: <20050912003450.GD6026@ns.snowman.net> +Mail-Followup-To: Ksenia Marasanova , + pgsql-performance@postgresql.org +References: <130df19305091110125a2d174f@mail.gmail.com> + <20050911210035.GC6026@ns.snowman.net> + <130df19305091114477e2e581b@mail.gmail.com> +Mime-Version: 1.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; boundary="gkIXscVEwe9sR2ZH" +Content-Disposition: inline +In-Reply-To: <130df19305091114477e2e581b@mail.gmail.com> +X-Editor: Vim http://www.vim.org/ +X-Info: http://www.snowman.net +X-Operating-System: Linux/2.4.24ns.3.0 (i686) +X-Uptime: 20:27:12 up 92 days, 16:43, 9 users, load average: 0.04, 0.06, 0.06 +User-Agent: Mutt/1.5.9i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.004 required=5 tests=[AWL=0.004] +X-Spam-Level: +X-Archive-Number: 200509/133 +X-Sequence-Number: 14441 + + +--gkIXscVEwe9sR2ZH +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +Content-Transfer-Encoding: quoted-printable + +* Ksenia Marasanova (ksenia.marasanova@gmail.com) wrote: +> test=3D# explain analyze select * from user_ left join church on +> user_.church_id =3D church.id; +[...] +> Total runtime: 2025.946 ms +> (6 rows) +>=20 +> test=3D# set enable_seqscan=3D'false'; +> SET +> test=3D# explain analyze select * from user_ left join church on +> user_.church_id =3D church.id; +> =20 +[...] +> Total runtime: 2131.364 ms +> (5 rows) +>=20 +>=20 +> I followed some tips on the web and vacuum-ed database, I think the +> query is faster now, almost acceptable, but still interesting to know +> if it possible to optimize it... + +I have to say that it does seem a bit slow for only 12,000 rows.. +What's the datatype of user_.church_id and church.id? Are you sure you +really want all 12,000 rows every time you run that query? Perhaps +there's a 'where' clause you could apply with an associated index to +limit the query to just what you actually need? + +You'll noticed from above, though, that the non-index scan is faster. +I'd expect that when using a left-join query: you have to go through the +entire table on an open left-join like that, a sequencial scan is going +to be the best way to do that. The fact that church.id is hashed makes +the solution the planner came up with almost certainly the best one +possible. + +Are you sure a left-join is what you want? Sounds like maybe you've +moved (for some reason) from a regular join to a left join with a +filtering in the application which is probably a bad move... If you can +use at least some filtering in the database I expect that'd help.. + + Thanks, + + Stephen + +--gkIXscVEwe9sR2ZH +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) + +iD8DBQFDJM0qrzgMPqB3kigRAo3ZAJ0frqfYceegGylIhkOZQ65d76IjcQCfRxO6 +hsNHlBuWhH0QAEtw1A+C8Ys= +=oDN1 +-----END PGP SIGNATURE----- + +--gkIXscVEwe9sR2ZH-- + +From pgsql-performance-owner@postgresql.org Mon Sep 12 01:59:06 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1F91FD7167 + for ; + Mon, 12 Sep 2005 01:59:04 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 77116-10 + for ; + Mon, 12 Sep 2005 04:59:00 +0000 (GMT) +Received: from sccmmhc91.asp.att.net (sccmmhc91.asp.att.net [204.127.203.211]) + by svr1.postgresql.org (Postfix) with ESMTP id D63D1D713D + for ; + Mon, 12 Sep 2005 01:58:59 -0300 (ADT) +Received: from juju.arbash-meinel.com ([12.214.18.81]) + by sccmmhc91.asp.att.net (sccmmhc91) with ESMTP + id <20050912045854m9100psbehe>; Mon, 12 Sep 2005 04:58:58 +0000 +Received: by juju.arbash-meinel.com (Postfix, from userid 505) + id 6948D55FCC; Sun, 11 Sep 2005 23:58:53 -0500 (CDT) +Received: from [209.101.126.19] (unknown [209.101.126.19]) + by juju.arbash-meinel.com (Postfix) with ESMTP id E094C55FA7; + Sun, 11 Sep 2005 23:58:48 -0500 (CDT) +Message-ID: <43250AFA.7010900@arbash-meinel.com> +Date: Mon, 12 Sep 2005 00:58:34 -0400 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Guido Neitzer +Cc: pgsql-performance@postgresql.org +Subject: Re: Prepared statement not using index +References: <08E57775-5E88-42B0-926D-21CAFB21CF24@pharmaline.de> +In-Reply-To: <08E57775-5E88-42B0-926D-21CAFB21CF24@pharmaline.de> +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enigAF6C9EEC5C4289FFE3491839" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.038 required=5 tests=[AWL=-0.013, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/134 +X-Sequence-Number: 14442 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enigAF6C9EEC5C4289FFE3491839 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 7bit + +Guido Neitzer wrote: +> Hi. +> +> I have an interesting problem with the JDBC drivers. When I use a +> select like this: +> +> "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)> +> +> the existing index on the plz column is not used. +> +> When I the same select with a concrete value, the index IS used. +> +> I use PostgreSQL 8.0.3 on Mac OS X and the JDBC driver 8.0-312 JDBC 3. +> +> After a lot of other things, I tried using a 7.4 driver and with this, +> the index is used in both cases. +> +> Why can this happen? Is there a setting I might have not seen? +> Something I do wrong? +> +> cug + +I've had this problem in the past. In my case, the issue was that the +column I was searching had a mixed blend of possible values. For +example, with 1M rows, the number 3 occurred 100 times, but the number +18 occurred 700,000 times. + +So when I manually did a search for 3, it naturally realized that it +could use an index scan, because it had the statistics to say it was +very selective. If I manually did a search for 18, it switched to +sequential scan, because it was not very selective (both are the correct +plans). + +But if you create a prepared statement, parameterized on this number, +postgres has no way of knowing ahead of time, whether you will be asking +about 3 or 18, so when the query is prepared, it has to be pessimistic, +and avoid worst case behavior, so it choses to always use a sequential scan. + +The only way I got around this was with writing a plpgsql function which +used the EXECUTE syntax to dynamically re-plan part of the query. + +Hope this makes sense. This may or may not be your problem, without +knowing more about you setup. But the symptoms seem similar. + +John +=:-> + +--------------enigAF6C9EEC5C4289FFE3491839 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFDJQr+JdeBCYSNAAMRAihxAKCnuq5S288ZgKQjUsSvrgbU5ppgqgCePJ52 +tJwn/5Je02FAiB8ut83Qn8k= +=dIbd +-----END PGP SIGNATURE----- + +--------------enigAF6C9EEC5C4289FFE3491839-- + +From pgsql-performance-owner@postgresql.org Mon Sep 12 02:06:55 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 782BFD70BF + for ; + Mon, 12 Sep 2005 02:06:54 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81129-08 + for ; + Mon, 12 Sep 2005 05:06:51 +0000 (GMT) +Received: from sccmmhc91.asp.att.net (sccmmhc91.asp.att.net [204.127.203.211]) + by svr1.postgresql.org (Postfix) with ESMTP id C2859D6FBB + for ; + Mon, 12 Sep 2005 02:06:51 -0300 (ADT) +Received: from juju.arbash-meinel.com ([12.214.18.81]) + by sccmmhc91.asp.att.net (sccmmhc91) with ESMTP + id <20050912050651m9100ps21ke>; Mon, 12 Sep 2005 05:06:51 +0000 +Received: by juju.arbash-meinel.com (Postfix, from userid 505) + id 38E2055FCC; Mon, 12 Sep 2005 00:06:51 -0500 (CDT) +Received: from [209.101.126.19] (unknown [209.101.126.19]) + by juju.arbash-meinel.com (Postfix) with ESMTP id 08DEA55FA7; + Mon, 12 Sep 2005 00:06:43 -0500 (CDT) +Message-ID: <43250CE1.6090602@arbash-meinel.com> +Date: Mon, 12 Sep 2005 01:06:41 -0400 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Kevin +Cc: arnaulist@andromeiberica.com, pgsql-performance@postgresql.org +Subject: Re: Advise about how to delete entries +References: <43183AC9.1060704@andromeiberica.com> + + <431C0F48.5050809@andromeiberica.com> <431D77F5.4070307@drule.org> +In-Reply-To: <431D77F5.4070307@drule.org> +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enigDD752B50F7A119A757208707" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.038 required=5 tests=[AWL=-0.013, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/135 +X-Sequence-Number: 14443 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enigDD752B50F7A119A757208707 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 7bit + +Kevin wrote: +> Arnau wrote: +> +>> Hi all, +>> +>> > +>> > COPY FROM a file with all the ID's to delete, into a temporary +>> table, and do a joined delete to your main table (thus, only one query). +>> +>> +>> I already did this, but I don't have idea about how to do this join, +>> could you give me a hint ;-) ? +>> +>> Thank you very much +> +> +> maybe something like this: +> +> DELETE FROM statistics_sasme s +> LEFT JOIN temp_table t ON (s.statistic_id = t.statistic_id) +> WHERE t.statistic_id IS NOT NULL +> + +Why can't you do: +DELETE FROM statistics_sasme s JOIN temp_table t ON (s.statistic_id = +t.statistic_id); + +Or possibly: + +DELETE FROM statistics_sasme s + WHERE s.id IN (SELECT t.statistic_id FROM temp_table t); + +I'm not sure how delete exactly works with joins, but the IN form should +be approximately correct. + +John +=:-> + + +--------------enigDD752B50F7A119A757208707 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFDJQzhJdeBCYSNAAMRAlMQAJ9M4gp+3FwiIiWvqIi9dNfZnhGycgCaAtir +BVTS7qLnC8m6Sk5OZOz+iag= +=FfAs +-----END PGP SIGNATURE----- + +--------------enigDD752B50F7A119A757208707-- + +From pgsql-performance-owner@postgresql.org Mon Sep 12 06:11:37 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0DBBED864E + for ; + Mon, 12 Sep 2005 06:11:36 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 46952-04 + for ; + Mon, 12 Sep 2005 09:11:29 +0000 (GMT) +Received: from tamar.dmr.co.uk (tamar.dmr.co.uk [195.112.52.166]) + by svr1.postgresql.org (Postfix) with ESMTP id 9CA0BD7EEE + for ; + Mon, 12 Sep 2005 06:11:29 -0300 (ADT) +Received: from HFPORT.dmr.co.uk (pennsoft.gotadsl.co.uk [81.6.232.68]) + by tamar.dmr.co.uk (8.12.11/8.12.11) with ESMTP id j8C9BRfA005153 + for ; Mon, 12 Sep 2005 10:11:28 +0100 +Message-Id: <5.1.0.14.0.20050912100150.01f47f18@mailserver.dmr.co.uk> +X-Sender: hf1@mailserver.dmr.co.uk +X-Mailer: QUALCOMM Windows Eudora Version 5.1 +Date: Mon, 12 Sep 2005 10:14:25 +0100 +To: pgsql-performance@postgresql.org +From: Hilary Forbes +Subject: Slow update +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 required=5 tests=[FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/136 +X-Sequence-Number: 14444 + +Hello everyone + +I must be doing something very wrong here so help please! I have two tables + +tableA has 300,000 recs +tableB has 20,000 recs + +I need to set the value of a field in table A to a value in table B depending on the existence of the record in table B. So what I have done is + +UPDATE tableA set a.val1=b.somefield FROM tableA a, tableB b WHERE a.key1=b.key1; + +The primary key of tableA is key1 and that of tableB is key1 ie the join is on primary keys. + +The "optimizer" has elected to d a sequential scan on tableA to determine which fields to update rather than the query being driveb by tableB and it is taking forever. Surely I must be able to force the system to read down tableB in preference to reading down tableA? + +(Please don't ask why tableA and tableB are not amalgamated - that's another story altogether!!!) + +Many thanks in advance +Hilary + + +Hilary Forbes +The DMR Information and Technology Group (www.dmr.co.uk) +Direct tel 01689 889950 Fax 01689 860330 +DMR is a UK registered trade mark of DMR Limited +********************************************************** + + +From pgsql-performance-owner@postgresql.org Mon Sep 12 07:37:34 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 58E89D6FBB + for ; + Mon, 12 Sep 2005 07:37:33 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 69961-01 + for ; + Mon, 12 Sep 2005 10:37:30 +0000 (GMT) +Received: from email.aon.at (warsl404pip6.highway.telekom.at [195.3.96.89]) + by svr1.postgresql.org (Postfix) with ESMTP id 6E1EBD6EA2 + for ; + Mon, 12 Sep 2005 07:37:27 -0300 (ADT) +Received: (qmail 22570 invoked from network); 12 Sep 2005 10:37:25 -0000 +Received: from m150p012.dipool.highway.telekom.at (HELO PASCAL) + ([62.46.8.172]) + (envelope-sender ) + by smarthub74.highway.telekom.at (qmail-ldap-1.03) with SMTP + for ; 12 Sep 2005 10:37:25 -0000 +From: Manfred Koizar +To: ksenia.marasanova@gmail.com +Cc: pgsql-performance@postgresql.org +Subject: Re: LEFT JOIN optimization +Date: Mon, 12 Sep 2005 12:41:28 +0200 +Message-ID: +References: <130df19305091110125a2d174f@mail.gmail.com> + <20050911210035.GC6026@ns.snowman.net> + <130df19305091114477e2e581b@mail.gmail.com> +In-Reply-To: <130df19305091114477e2e581b@mail.gmail.com> +X-Mailer: Forte Agent 2.0/32.652 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.195 required=5 tests=[AWL=0.145, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/137 +X-Sequence-Number: 14445 + +On Mon, 12 Sep 2005 00:47:57 +0300, Ksenia Marasanova + wrote: +> -> Seq Scan on user_ (cost=0.00..7430.63 rows=12763 width=245) +>(actual time=360.431..1120.012 rows=12763 loops=1) + +If 12000 rows of the given size are stored in more than 7000 pages, then +there is a lot of free space in these pages. Try VACUUM FULL ... + +Servus + Manfred + +From pgsql-performance-owner@postgresql.org Mon Sep 12 07:55:22 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B1D04D8AD1 + for ; + Mon, 12 Sep 2005 07:55:20 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 76040-05 + for ; + Mon, 12 Sep 2005 10:55:16 +0000 (GMT) +Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) + by svr1.postgresql.org (Postfix) with ESMTP id 9C717D8B96 + for ; + Mon, 12 Sep 2005 07:55:17 -0300 (ADT) +Received: from mainbox.archonet.com + (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) + by smtp.metronet.co.uk (MetroNet Mail) with ESMTP + id E44AD401D7A; Mon, 12 Sep 2005 11:55:12 +0100 (BST) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mainbox.archonet.com (Postfix) with ESMTP id 52E9215F1D; + Mon, 12 Sep 2005 11:51:21 +0100 (BST) +Received: from mainbox.archonet.com ([127.0.0.1]) + by localhost (mainbox [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 22166-03; Mon, 12 Sep 2005 11:51:18 +0100 (BST) +Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP id 3450215F1C; + Mon, 12 Sep 2005 11:51:18 +0100 (BST) +Message-ID: <43255DA5.9030602@archonet.com> +Date: Mon, 12 Sep 2005 11:51:17 +0100 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Hilary Forbes +Cc: pgsql-performance@postgresql.org +Subject: Re: Slow update +References: <5.1.0.14.0.20050912100150.01f47f18@mailserver.dmr.co.uk> +In-Reply-To: <5.1.0.14.0.20050912100150.01f47f18@mailserver.dmr.co.uk> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.058 required=5 tests=[AWL=0.008, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/138 +X-Sequence-Number: 14446 + +Hilary Forbes wrote: +> +> I need to set the value of a field in table A to a value in table B depending on the existence of the record in table B. So what I have done is +> +> UPDATE tableA set a.val1=b.somefield FROM tableA a, tableB b WHERE a.key1=b.key1; + +Check the EXPLAIN carefully, are you sure the tableA in "UPDATE" is the +same as that in your "FROM" clause. If so, why are you SETting a.val1? + +If not, you've probably got an unconstrained join. +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Mon Sep 12 09:38:46 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7FB39D82ED + for ; + Mon, 12 Sep 2005 09:38:45 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 12728-03 + for ; + Mon, 12 Sep 2005 12:38:36 +0000 (GMT) +Received: from net2.micro-automation.com (net2.micro-automation.com + [64.7.141.29]) + by svr1.postgresql.org (Postfix) with SMTP id B367DD81C2 + for ; + Mon, 12 Sep 2005 09:38:36 -0300 (ADT) +Received: (qmail 19359 invoked from network); 12 Sep 2005 12:38:37 -0000 +Received: from dcdsl.ebox.com (HELO ?192.168.1.2?) (davec@64.7.143.116) + by net2.micro-automation.com with SMTP; 12 Sep 2005 12:38:37 -0000 +In-Reply-To: <08E57775-5E88-42B0-926D-21CAFB21CF24@pharmaline.de> +References: <08E57775-5E88-42B0-926D-21CAFB21CF24@pharmaline.de> +Mime-Version: 1.0 (Apple Message framework v734) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <8800F410-0A1C-4AD4-96F0-B3193638056F@fastcrypt.com> +Cc: pgsql-performance@postgresql.org +Content-Transfer-Encoding: 7bit +From: Dave Cramer +Subject: Re: Prepared statement not using index +Date: Mon, 12 Sep 2005 08:38:35 -0400 +To: Guido Neitzer +X-Mailer: Apple Mail (2.734) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.013 required=5 tests=[AWL=0.013] +X-Spam-Level: +X-Archive-Number: 200509/139 +X-Sequence-Number: 14447 + +The difference between the 7.4 driver and the 8.0.3 driver is the +8.0.3 driver is using server side prepared statements and binding the +parameter to the type in setXXX(n,val). + +The 7.4 driver just replaces the ? with the value and doesn't use +server side prepared statements. + +Dave + + +On 1-Sep-05, at 7:09 PM, Guido Neitzer wrote: + +> Hi. +> +> I have an interesting problem with the JDBC drivers. When I use a +> select like this: +> +> "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)> +> +> the existing index on the plz column is not used. +> +> When I the same select with a concrete value, the index IS used. +> +> I use PostgreSQL 8.0.3 on Mac OS X and the JDBC driver 8.0-312 JDBC 3. +> +> After a lot of other things, I tried using a 7.4 driver and with +> this, the index is used in both cases. +> +> Why can this happen? Is there a setting I might have not seen? +> Something I do wrong? +> +> cug +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 5: don't forget to increase your free space map settings +> +> + + +From pgsql-performance-owner@postgresql.org Mon Sep 12 10:22:15 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CA116D8B46 + for ; + Mon, 12 Sep 2005 10:22:14 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 27328-01 + for ; + Mon, 12 Sep 2005 13:22:09 +0000 (GMT) +Received: from pharmaline.de (mail.pharmaline.de [62.153.135.34]) + by svr1.postgresql.org (Postfix) with ESMTP id EC6C1D8AF8 + for ; + Mon, 12 Sep 2005 10:22:08 -0300 (ADT) +Received: from [192.168.2.121] (62.153.135.40) by pharmaline.de with ESMTP + (Eudora Internet Mail Server 3.2.6); Mon, 12 Sep 2005 15:22:11 +0200 +Mime-Version: 1.0 (Apple Message framework v734) +In-Reply-To: <8800F410-0A1C-4AD4-96F0-B3193638056F@fastcrypt.com> +References: <08E57775-5E88-42B0-926D-21CAFB21CF24@pharmaline.de> + <8800F410-0A1C-4AD4-96F0-B3193638056F@fastcrypt.com> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <410580B5-429B-421B-9469-72EDECC4D7D5@pharmaline.de> +Content-Transfer-Encoding: 7bit +From: Guido Neitzer +Subject: Re: Prepared statement not using index +Date: Mon, 12 Sep 2005 15:22:11 +0200 +To: Dave Cramer , pgsql-performance@postgresql.org +X-Mailer: Apple Mail (2.734) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/140 +X-Sequence-Number: 14448 + +On 12.09.2005, at 14:38 Uhr, Dave Cramer wrote: + +> The difference between the 7.4 driver and the 8.0.3 driver is the +> 8.0.3 driver is using server side prepared statements and binding +> the parameter to the type in setXXX(n,val). + +Would be a good idea when this were configurable. + +I found my solution (use the JDBC2 drivers with protocolVersion=2), +but how long will this work? + +cug + +From pgsql-performance-owner@postgresql.org Mon Sep 12 10:26:46 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 39BA7D8836 + for ; + Mon, 12 Sep 2005 10:26:45 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25630-06 + for ; + Mon, 12 Sep 2005 13:26:39 +0000 (GMT) +Received: from biglumber.com (biglumber.com [207.228.252.42]) + by svr1.postgresql.org (Postfix) with SMTP id D9358D869B + for ; + Mon, 12 Sep 2005 10:26:39 -0300 (ADT) +Received: (qmail 31671 invoked from network); 12 Sep 2005 13:26:44 -0000 +Received: from unknown (HELO localhost) (207.228.252.42) + by 0 with SMTP; 12 Sep 2005 13:26:44 -0000 +From: "Greg Sabino Mullane" +To: pgsql-performance@postgresql.org +Subject: Re: Prepared statement not using index +X-PGP-Key: 2529 DF6A B8F7 9407 E944 45B4 BC9B 9067 1496 4AC8 +X-Request-PGP: + http://www.biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8 +In-Reply-To: <8800F410-0A1C-4AD4-96F0-B3193638056F@fastcrypt.com> +Date: Mon, 12 Sep 2005 13:26:44 -0000 +X-Mailer: JoyMail 1.48 +Message-ID: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.093 required=5 tests=[AWL=0.093] +X-Spam-Level: +X-Archive-Number: 200509/141 +X-Sequence-Number: 14449 + + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + + +> The difference between the 7.4 driver and the 8.0.3 driver is the +> 8.0.3 driver is using server side prepared statements and binding the +> parameter to the type in setXXX(n,val). +> +> The 7.4 driver just replaces the ? with the value and doesn't use +> server side prepared statements. + +DBD::Pg has a few flags that enables you to do things like purposely avoid +using server side prepares, and force a reprepare of a particular statement. +Perhaps something like that is available for the JDBC driver? If not, +maybe someone would be willing to add it in? + +- -- +Greg Sabino Mullane greg@turnstep.com +PGP Key: 0x14964AC8 200509120925 +https://www.biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8 + +-----BEGIN PGP SIGNATURE----- + +iEYEARECAAYFAkMlgdAACgkQvJuQZxSWSsjMlQCePc4dpE0BCT3W//y/N9uolkmK +ViIAnjR1fF14KbP+cX+xV8lmdlL6Be2k +=NtXw +-----END PGP SIGNATURE----- + + + +From pgsql-performance-owner@postgresql.org Mon Sep 12 10:34:00 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2430AD86F1 + for ; + Mon, 12 Sep 2005 10:33:59 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 27381-07 + for ; + Mon, 12 Sep 2005 13:33:53 +0000 (GMT) +Received: from wolff.to (wolff.to [66.93.197.194]) + by svr1.postgresql.org (Postfix) with SMTP id 4B35DD85CA + for ; + Mon, 12 Sep 2005 10:33:54 -0300 (ADT) +Received: (qmail 22741 invoked by uid 500); 12 Sep 2005 13:34:11 -0000 +Date: Mon, 12 Sep 2005 08:34:11 -0500 +From: Bruno Wolff III +To: Hilary Forbes +Cc: pgsql-performance@postgresql.org +Subject: Re: Slow update +Message-ID: <20050912133411.GA21730@wolff.to> +Mail-Followup-To: Hilary Forbes , + pgsql-performance@postgresql.org +References: <5.1.0.14.0.20050912100150.01f47f18@mailserver.dmr.co.uk> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <5.1.0.14.0.20050912100150.01f47f18@mailserver.dmr.co.uk> +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/142 +X-Sequence-Number: 14450 + +On Mon, Sep 12, 2005 at 10:14:25 +0100, + Hilary Forbes wrote: +> Hello everyone +> +> I must be doing something very wrong here so help please! I have two tables +> +> tableA has 300,000 recs +> tableB has 20,000 recs +> +> I need to set the value of a field in table A to a value in table B depending on the existence of the record in table B. So what I have done is +> +> UPDATE tableA set a.val1=b.somefield FROM tableA a, tableB b WHERE a.key1=b.key1; +> +> The primary key of tableA is key1 and that of tableB is key1 ie the join is on primary keys. +> +> The "optimizer" has elected to d a sequential scan on tableA to determine which fields to update rather than the query being driveb by tableB and it is taking forever. Surely I must be able to force the system to read down tableB in preference to reading down tableA? + +It would help to see the exact query and the explain analyze output. Hopefully +you didn't really write the query similar to above, since it is using illegal +syntax and the if it was changed slightly to become legal than it would do a +cross join of table A with the inner join of tableA and tableB, which isn't +what you want. + +From pgsql-performance-owner@postgresql.org Mon Sep 12 11:07:26 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CC9B6D8A7E + for ; + Mon, 12 Sep 2005 11:07:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 39538-02 + for ; + Mon, 12 Sep 2005 14:07:21 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id A207ED86E1 + for ; + Mon, 12 Sep 2005 11:07:23 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j8CE7QVG021153; + Mon, 12 Sep 2005 10:07:26 -0400 (EDT) +To: Hilary Forbes +Cc: pgsql-performance@postgresql.org +Subject: Re: Slow update +In-reply-to: <5.1.0.14.0.20050912100150.01f47f18@mailserver.dmr.co.uk> +References: <5.1.0.14.0.20050912100150.01f47f18@mailserver.dmr.co.uk> +Comments: In-reply-to Hilary Forbes + message dated "Mon, 12 Sep 2005 10:14:25 +0100" +Date: Mon, 12 Sep 2005 10:07:26 -0400 +Message-ID: <21152.1126534046@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/143 +X-Sequence-Number: 14451 + +Hilary Forbes writes: +> I need to set the value of a field in table A to a value in table B depending on the existence of the record in table B. So what I have done is + +> UPDATE tableA set a.val1=b.somefield FROM tableA a, tableB b WHERE a.key1=b.key1; + +You've written an unconstrained join to a second copy of tableA. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Sep 12 12:28:38 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 52779D8AF1 + for ; + Mon, 12 Sep 2005 12:28:37 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 63402-02 + for ; + Mon, 12 Sep 2005 15:28:34 +0000 (GMT) +Received: from net2.micro-automation.com (net2.micro-automation.com + [64.7.141.29]) + by svr1.postgresql.org (Postfix) with SMTP id 4FBF1D8A86 + for ; + Mon, 12 Sep 2005 12:28:33 -0300 (ADT) +Received: (qmail 21481 invoked from network); 12 Sep 2005 15:28:28 -0000 +Received: from dcdsl.ebox.com (HELO ?192.168.1.2?) (davec@64.7.143.116) + by net2.micro-automation.com with SMTP; 12 Sep 2005 15:28:28 -0000 +In-Reply-To: <410580B5-429B-421B-9469-72EDECC4D7D5@pharmaline.de> +References: <08E57775-5E88-42B0-926D-21CAFB21CF24@pharmaline.de> + <8800F410-0A1C-4AD4-96F0-B3193638056F@fastcrypt.com> + <410580B5-429B-421B-9469-72EDECC4D7D5@pharmaline.de> +Mime-Version: 1.0 (Apple Message framework v734) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <9E7179CC-5E87-4DDD-8541-671BF4CA09BD@fastcrypt.com> +Cc: pgsql-performance@postgresql.org +Content-Transfer-Encoding: 7bit +From: Dave Cramer +Subject: Re: Prepared statement not using index +Date: Mon, 12 Sep 2005 11:28:27 -0400 +To: Guido Neitzer +X-Mailer: Apple Mail (2.734) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.013 required=5 tests=[AWL=0.013] +X-Spam-Level: +X-Archive-Number: 200509/144 +X-Sequence-Number: 14452 + + +On 12-Sep-05, at 9:22 AM, Guido Neitzer wrote: + +> On 12.09.2005, at 14:38 Uhr, Dave Cramer wrote: +> +> +>> The difference between the 7.4 driver and the 8.0.3 driver is the +>> 8.0.3 driver is using server side prepared statements and binding +>> the parameter to the type in setXXX(n,val). +>> +> +> Would be a good idea when this were configurable. +You found the configuration for it +> +> I found my solution (use the JDBC2 drivers with protocolVersion=2), +> but how long will this work? + +I think you would be better understanding what the correct type is +for the index to work properly. +> +> cug +> +> + + +From pgsql-performance-owner@postgresql.org Mon Sep 12 12:30:27 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9CAA1D8BED + for ; + Mon, 12 Sep 2005 12:30:21 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 63402-04 + for ; + Mon, 12 Sep 2005 15:30:17 +0000 (GMT) +Received: from net2.micro-automation.com (net2.micro-automation.com + [64.7.141.29]) + by svr1.postgresql.org (Postfix) with SMTP id DF8F6D8A03 + for ; + Mon, 12 Sep 2005 12:30:16 -0300 (ADT) +Received: (qmail 21504 invoked from network); 12 Sep 2005 15:30:16 -0000 +Received: from dcdsl.ebox.com (HELO ?192.168.1.2?) (davec@64.7.143.116) + by net2.micro-automation.com with SMTP; 12 Sep 2005 15:30:16 -0000 +In-Reply-To: +References: +Mime-Version: 1.0 (Apple Message framework v734) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: +Cc: pgsql-performance@postgresql.org +Content-Transfer-Encoding: 7bit +From: Dave Cramer +Subject: Re: Prepared statement not using index +Date: Mon, 12 Sep 2005 11:30:14 -0400 +To: Greg Sabino Mullane +X-Mailer: Apple Mail (2.734) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.013 required=5 tests=[AWL=0.013] +X-Spam-Level: +X-Archive-Number: 200509/145 +X-Sequence-Number: 14453 + +It's added, just use the old protocol . + +Here are the connection parameters + +http://jdbc.postgresql.org/documentation/head/connect.html#connection- +parameters + +Dave + + +On 12-Sep-05, at 9:26 AM, Greg Sabino Mullane wrote: + +> +> -----BEGIN PGP SIGNED MESSAGE----- +> Hash: SHA1 +> +> +> +>> The difference between the 7.4 driver and the 8.0.3 driver is the +>> 8.0.3 driver is using server side prepared statements and binding the +>> parameter to the type in setXXX(n,val). +>> +>> The 7.4 driver just replaces the ? with the value and doesn't use +>> server side prepared statements. +>> +> +> DBD::Pg has a few flags that enables you to do things like +> purposely avoid +> using server side prepares, and force a reprepare of a particular +> statement. +> Perhaps something like that is available for the JDBC driver? If not, +> maybe someone would be willing to add it in? +> +> - -- +> Greg Sabino Mullane greg@turnstep.com +> PGP Key: 0x14964AC8 200509120925 +> https://www.biglumber.com/x/web? +> pk=2529DF6AB8F79407E94445B4BC9B906714964AC8 +> +> -----BEGIN PGP SIGNATURE----- +> +> iEYEARECAAYFAkMlgdAACgkQvJuQZxSWSsjMlQCePc4dpE0BCT3W//y/N9uolkmK +> ViIAnjR1fF14KbP+cX+xV8lmdlL6Be2k +> =NtXw +> -----END PGP SIGNATURE----- +> +> +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 5: don't forget to increase your free space map settings +> +> + + +From pgsql-performance-owner@postgresql.org Mon Sep 12 18:04:19 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 17E79D8C36 + for ; + Mon, 12 Sep 2005 18:04:18 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 84305-06 + for ; + Mon, 12 Sep 2005 21:04:11 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.198]) + by svr1.postgresql.org (Postfix) with ESMTP id E494ED8C15 + for ; + Mon, 12 Sep 2005 18:04:08 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id 36so2306622wra + for ; + Mon, 12 Sep 2005 14:04:06 -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:mime-version:content-type; + b=E6W03NBVKmyUSaudhtvittvuZ/b8KW30hiT4MywWDptFw+nymcGXNuV5FLiw71rs5ee4BHhOBlkOd3nwdUZvLl/Qr0C0LTZXhh3JGS5gmGbjteyutd6xOTAaJZVd3F6RkBcPlAaymxBBqQ3e+kDaiKd+mTMZ1tIoCFVcjZetqiA= +Received: by 10.54.4.14 with SMTP id 14mr3002022wrd; + Mon, 12 Sep 2005 14:04:06 -0700 (PDT) +Received: by 10.54.158.11 with HTTP; Mon, 12 Sep 2005 14:04:06 -0700 (PDT) +Message-ID: <84621a6050912140464c380c3@mail.gmail.com> +Date: Mon, 12 Sep 2005 16:04:06 -0500 +From: Brandon Black +Reply-To: blblack@gmail.com +To: pgsql-performance@postgresql.org +Subject: Performance considerations for very heavy INSERT traffic +Mime-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_11275_6416434.1126559046664" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.163 required=5 tests=[HTML_00_10=0.138, + HTML_MESSAGE=0.001, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200509/146 +X-Sequence-Number: 14454 + +------=_Part_11275_6416434.1126559046664 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +I'm in the process of developing an application which uses PostgreSQL for= +=20 +data storage. Our database traffic is very atypical, and as a result it has= +=20 +been rather challenging to figure out how to best tune PostgreSQL on what= +=20 +development hardware we have, as well as to figure out exactly what we=20 +should be evaluating and eventually buying for production hardware. + +The vast, overwhelming majority of our database traffic is pretty much a=20 +non-stop stream of INSERTs filling up tables. It is akin to data=20 +acquisition. Several thousand clients are sending once-per-minute updates= +=20 +full of timestamped numerical data at our central server, which in turn=20 +performs INSERTs into several distinct tables as part of the transaction fo= +r=20 +that client. We're talking on the order of ~100 transactions per second,=20 +each containing INSERTs to multiple tables (which contain only integer and= +=20 +floating point columns and a timestamp column - the primary key (and only= +=20 +index) is on a unique integer ID for the client and the timestamp). The=20 +transaction load is spread evenly over time by having the clients send thei= +r=20 +per-minute updates at random times rather than on the exact minute mark. + +There will of course be users using a web-based GUI to extract data from=20 +these tables and display them in graphs and whatnot, but the SELECT query= +=20 +traffic will always be considerably less frequent and intensive than the=20 +incessant INSERTs, and it's not that big a deal if the large queries take a= +=20 +little while to run. + +This data also expires - rows with timestamps older than X days will be=20 +DELETEd periodically (once an hour or faster), such that the tables will=20 +reach a relatively stable size (pg_autovacuum is handling vacuuming for now= +,=20 +but considering our case, we're thinking of killing pg_autovacuum in favor= +=20 +of having the periodic DELETE process also do a vacuum of affected tables= +=20 +right after the DELETE, and then have it vacuum the other low traffic table= +s=20 +once a day while it's at it). + +There is an aggregation layer in place which proxies the inbound data from= +=20 +the clients into a small(er) number of persistent postgresql backend=20 +processes. Right now we're doing one aggregator per 128 clients (so instead= +=20 +of 128 seperate database connections over the course of a minute for a smal= +l=20 +transaction each, there is a single database backend that is constantly=20 +committing transactions at a rate of ~ 2/second). At a test load of ~1,000= +=20 +clients, we would have 8 aggregators running and 8 postgresql backends.=20 +Testing has seemed to indicate we should aggregate even harder - the planne= +d=20 +production load is ~5,000 clients initially, but will grow to almost double= +=20 +that in the not-too-distant future, and that would mean ~40 backends at 128= +=20 +clients each initially. Even on 8 cpus, I'm betting 40 concurrent backends= +=20 +doing 2 tps is much worse off than 10 backends doing 8 tps. + +Test hardware right now is a dual Opteron with 4G of ram, which we've barel= +y=20 +gotten 1,000 clients running against. Current disk hardware in testing is= +=20 +whatever we could scrape together (4x 3-ware PCI hardware RAID controllers,= +=20 +with 8 SATA drives in a RAID10 array off of each - aggregated up in a 4-way= +=20 +stripe with linux md driver and then formatted as ext3 with an appropriate= +=20 +stride parameter and data=3Dwriteback). Production will hopefully be a 4-8-= +way=20 +Opteron, 16 or more G of RAM, and a fiberchannel hardware raid array or two= +=20 +(~ 1TB available RAID10 storage) with 15krpm disks and battery-backed write= +=20 +cache. + +I know I haven't provided a whole lot of application-level detail here, but= +=20 +does anyone have any general advice on tweaking postgresql to deal with a= +=20 +very heavy load of concurrent and almost exclusively write-only=20 +transactions? Increasing shared_buffers seems to always help, even out to= +=20 +half of the dev box's ram (2G). A 100ms commit_delay seemed to help, but=20 +tuning it (and _siblings) has been difficult. We're using 8.0 with the=20 +default 8k blocksize, but are strongly considering both developing against= +=20 +8.1 (seems it might handle the heavy concurrency better), and re-compiling= +=20 +with 32k blocksize since our storage arrays will inevitably be using fairly= +=20 +wide stripes. Any advice on any of this (other than drop the project while= +=20 +you're still a little bit sane)? + +--Brandon + +------=_Part_11275_6416434.1126559046664 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +
+I'm in the process of developing an application which uses PostgreSQL +for data storage.  Our database traffic is very atypical, and as a +result it has been rather challenging to figure out how to best tune +PostgreSQL on what development hardware we have, as well as to figure +out exactly what we should be evaluating and eventually buying for +production hardware.
+
+The vast, overwhelming majority of our database traffic is pretty much +a non-stop stream of INSERTs filling up tables.  It is akin to +data acquisition.  Several thousand clients are sending +once-per-minute updates full of timestamped numerical data at our +central server, which in turn performs INSERTs into several distinct +tables as part of the transaction for that client.  We're talking +on the order of ~100 transactions per second, each containing INSERTs +to multiple tables (which contain only integer and floating point +columns and a timestamp column - the primary key (and only index) is on +a unique integer ID for the client and the timestamp).  The +transaction load is spread evenly over time by having the clients send +their per-minute updates at random times rather than on the exact +minute mark.
+
+There will of course be users using a web-based GUI to extract data +from these tables and display them in graphs and whatnot, but the +SELECT query traffic will always be considerably less frequent and +intensive than the incessant INSERTs, and it's not that big a deal if +the large queries take a little while to run.
+
+This data also expires - rows with timestamps older than X days will be +DELETEd periodically (once an hour or faster), such that the tables +will reach a relatively stable size (pg_autovacuum is handling +vacuuming for now, but considering our case, we're thinking of killing +pg_autovacuum in favor of having the periodic DELETE process also do a +vacuum of affected tables right after the DELETE, and then have it +vacuum the other low traffic tables once a day while it's at it).
+
+There is an aggregation layer in place which proxies the inbound data +from the clients into a small(er) number of persistent postgresql +backend processes.  Right now we're doing one aggregator per 128 +clients (so instead of 128 seperate database connections over the +course of a minute for a small transaction each, there is a single +database backend that is constantly committing transactions at a rate +of ~ 2/second).  At a test load of ~1,000 clients, we would have 8 +aggregators running and 8 postgresql backends.  Testing has seemed +to indicate we should aggregate even harder - the planned production +load is ~5,000 clients initially, but will grow to almost double that +in the not-too-distant future, and that would mean ~40 backends at 128 +clients each initially.  Even on 8 cpus, I'm betting 40 concurrent +backends doing 2 tps is much worse off than 10 backends doing 8 tps.
+
+ +Test hardware right now is a dual Opteron with 4G of ram, which we've +barely gotten 1,000 clients running against.  Current disk hardware in +testing is whatever we could scrape together (4x 3-ware PCI hardware +RAID controllers, with 8 SATA drives in a RAID10 array off of each - +aggregated up in a 4-way stripe with linux md driver and then formatted +as ext3 with an appropriate stride parameter and data=3Dwriteback).  +Production will hopefully be a 4-8-way Opteron, 16 or more G of RAM, +and a fiberchannel hardware raid array or two (~ 1TB available RAID10 stora= +ge) with 15krpm disks and +battery-backed write cache.
+
+I know I haven't provided a whole lot of application-level detail here, +but does anyone have any general advice on tweaking postgresql to deal +with a very heavy load of concurrent and almost exclusively write-only +transactions?  Increasing shared_buffers seems to always help, +even out to half of the dev box's ram (2G).  A 100ms commit_delay +seemed to help, but tuning it (and _siblings) has been difficult.  +We're using 8.0 with the default 8k blocksize, but are strongly +considering both developing against 8.1 (seems it might handle the +heavy concurrency better), and re-compiling with 32k blocksize since +our storage arrays will inevitably be using fairly wide stripes.  +Any advice on any of this (other than drop the project while you're +still a little bit sane)?
+
+--Brandon
+
+ +------=_Part_11275_6416434.1126559046664-- + +From pgsql-performance-owner@postgresql.org Mon Sep 12 18:24:33 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6EB6AD8C58 + for ; + Mon, 12 Sep 2005 18:24:31 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 17953-04 + for ; + Mon, 12 Sep 2005 21:24:26 +0000 (GMT) +Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id BDA56D8C4C + for ; + Mon, 12 Sep 2005 18:24:26 -0300 (ADT) +Received: (qmail 3939 invoked from network); 12 Sep 2005 23:25:05 +0200 +Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) + by boutiquenumerique.com with SMTP; 12 Sep 2005 23:25:05 +0200 +To: blblack@gmail.com, pgsql-performance@postgresql.org +Subject: Re: Performance considerations for very heavy INSERT traffic +References: <84621a6050912140464c380c3@mail.gmail.com> +Message-ID: +Date: Mon, 12 Sep 2005 23:24:24 +0200 +From: PFC +Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= +Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +In-Reply-To: <84621a6050912140464c380c3@mail.gmail.com> +User-Agent: Opera M2/8.0 (Linux, build 1095) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/147 +X-Sequence-Number: 14455 + + + +> I know I haven't provided a whole lot of application-level detail here, + + You did ! + + What about : + + - using COPY instead of INSERT ? + (should be easy to do from the aggregators) + + - using Bizgres ? + (which was designed for your use case) + + - splitting the xlog and the data on distinct physical drives or arrays + + - benchmarking something else than ext3 + (xfs ? reiser3 ?) + +From pgsql-performance-owner@postgresql.org Mon Sep 12 18:45:26 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9755DD8C5D + for ; + Mon, 12 Sep 2005 18:45:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 20583-07 + for ; + Mon, 12 Sep 2005 21:45:21 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.194]) + by svr1.postgresql.org (Postfix) with ESMTP id 27E44D8C5C + for ; + Mon, 12 Sep 2005 18:45:20 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id i21so1672461wra + for ; + Mon, 12 Sep 2005 14:45:22 -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=svI19yXiUq2YrJ+ej5ql3VoHGGOvQkW8IW2J307hXJPPgWYTGga0OUrvQccy5M1usvNlyX3UdYLA9fyn4tZu3JgvqN1bO+bKr88PZTz7YdrX27lAnFrAxEpU9JQjkzYoL3VUBD68qkQpkFeRhWgtKuX40w/L8icj3brSKZTR8v0= +Received: by 10.54.100.11 with SMTP id x11mr2966309wrb; + Mon, 12 Sep 2005 14:45:21 -0700 (PDT) +Received: by 10.54.86.7 with HTTP; Mon, 12 Sep 2005 14:45:21 -0700 (PDT) +Message-ID: <33c6269f05091214459a87345@mail.gmail.com> +Date: Mon, 12 Sep 2005 17:45:21 -0400 +From: Alex Turner +Reply-To: armtuk@gmail.com +To: blblack@gmail.com +Subject: Re: Performance considerations for very heavy INSERT traffic +Cc: pgsql-performance@postgresql.org +In-Reply-To: <84621a6050912140464c380c3@mail.gmail.com> +Mime-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_3564_4087839.1126561521744" +References: <84621a6050912140464c380c3@mail.gmail.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.172 required=5 tests=[AWL=0.009, HTML_00_10=0.138, + HTML_MESSAGE=0.001, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200509/149 +X-Sequence-Number: 14457 + +------=_Part_3564_4087839.1126561521744 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Split your system into multiple partitions of RAID 10s.For max performance,= +=20 +ten drive RAID 10 for pg_xlog (This will max out a PCI-X bus) on Bus A,=20 +multiple 4/6Drive RAID 10s for tablespaces on Bus B. For max performance I= +=20 +would recommend using one RAID 10 for raw data tables, one for aggregate=20 +tables and one for indexes. More RAM will only help you with queries agains= +t=20 +your data, if you are pre-aggregating, then you may not need all that much= +=20 +RAM. + +You can easily get 100 tansacts per second with even less hardware with a= +=20 +little data partitioning. + +Choose your controller carefully as many don't co-operate with linux well. + +Alex Turner +NetEconomist + +On 9/12/05, Brandon Black wrote: +>=20 +>=20 +> I'm in the process of developing an application which uses PostgreSQL for= +=20 +> data storage. Our database traffic is very atypical, and as a result it h= +as=20 +> been rather challenging to figure out how to best tune PostgreSQL on what= +=20 +> development hardware we have, as well as to figure out exactly what we=20 +> should be evaluating and eventually buying for production hardware. +>=20 +> The vast, overwhelming majority of our database traffic is pretty much a= +=20 +> non-stop stream of INSERTs filling up tables. It is akin to data=20 +> acquisition. Several thousand clients are sending once-per-minute updates= +=20 +> full of timestamped numerical data at our central server, which in turn= +=20 +> performs INSERTs into several distinct tables as part of the transaction = +for=20 +> that client. We're talking on the order of ~100 transactions per second,= +=20 +> each containing INSERTs to multiple tables (which contain only integer an= +d=20 +> floating point columns and a timestamp column - the primary key (and only= +=20 +> index) is on a unique integer ID for the client and the timestamp). The= +=20 +> transaction load is spread evenly over time by having the clients send th= +eir=20 +> per-minute updates at random times rather than on the exact minute mark. +>=20 +> There will of course be users using a web-based GUI to extract data from= +=20 +> these tables and display them in graphs and whatnot, but the SELECT query= +=20 +> traffic will always be considerably less frequent and intensive than the= +=20 +> incessant INSERTs, and it's not that big a deal if the large queries take= + a=20 +> little while to run. +>=20 +> This data also expires - rows with timestamps older than X days will be= +=20 +> DELETEd periodically (once an hour or faster), such that the tables will= +=20 +> reach a relatively stable size (pg_autovacuum is handling vacuuming for n= +ow,=20 +> but considering our case, we're thinking of killing pg_autovacuum in favo= +r=20 +> of having the periodic DELETE process also do a vacuum of affected tables= +=20 +> right after the DELETE, and then have it vacuum the other low traffic tab= +les=20 +> once a day while it's at it). +>=20 +> There is an aggregation layer in place which proxies the inbound data fro= +m=20 +> the clients into a small(er) number of persistent postgresql backend=20 +> processes. Right now we're doing one aggregator per 128 clients (so inste= +ad=20 +> of 128 seperate database connections over the course of a minute for a sm= +all=20 +> transaction each, there is a single database backend that is constantly= +=20 +> committing transactions at a rate of ~ 2/second). At a test load of ~1,00= +0=20 +> clients, we would have 8 aggregators running and 8 postgresql backends.= +=20 +> Testing has seemed to indicate we should aggregate even harder - the plan= +ned=20 +> production load is ~5,000 clients initially, but will grow to almost doub= +le=20 +> that in the not-too-distant future, and that would mean ~40 backends at 1= +28=20 +> clients each initially. Even on 8 cpus, I'm betting 40 concurrent backend= +s=20 +> doing 2 tps is much worse off than 10 backends doing 8 tps. +>=20 +> Test hardware right now is a dual Opteron with 4G of ram, which we've=20 +> barely gotten 1,000 clients running against. Current disk hardware in=20 +> testing is whatever we could scrape together (4x 3-ware PCI hardware RAID= +=20 +> controllers, with 8 SATA drives in a RAID10 array off of each - aggregate= +d=20 +> up in a 4-way stripe with linux md driver and then formatted as ext3 with= + an=20 +> appropriate stride parameter and data=3Dwriteback). Production will hopef= +ully=20 +> be a 4-8-way Opteron, 16 or more G of RAM, and a fiberchannel hardware ra= +id=20 +> array or two (~ 1TB available RAID10 storage) with 15krpm disks and=20 +> battery-backed write cache. +>=20 +> I know I haven't provided a whole lot of application-level detail here,= +=20 +> but does anyone have any general advice on tweaking postgresql to deal wi= +th=20 +> a very heavy load of concurrent and almost exclusively write-only=20 +> transactions? Increasing shared_buffers seems to always help, even out to= +=20 +> half of the dev box's ram (2G). A 100ms commit_delay seemed to help, but= +=20 +> tuning it (and _siblings) has been difficult. We're using 8.0 with the=20 +> default 8k blocksize, but are strongly considering both developing agains= +t=20 +> 8.1 (seems it might handle the heavy concurrency better), and re-compilin= +g=20 +> with 32k blocksize since our storage arrays will inevitably be using fair= +ly=20 +> wide stripes. Any advice on any of this (other than drop the project whil= +e=20 +> you're still a little bit sane)? +>=20 +> --Brandon +>=20 +> + +------=_Part_3564_4087839.1126561521744 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Split your system into multiple partitions of RAID 10s.For max +performance,  ten drive RAID 10 for pg_xlog (This will max out a +PCI-X bus) on Bus A, multiple 4/6Drive RAID 10s for tablespaces on Bus +B. For max performance I would recommend using one RAID 10 for raw data +tables, one for aggregate tables and one for indexes.  More RAM +will only help you with queries against your data, if you are +pre-aggregating, then you may not need all that much RAM.
+
+You can easily get 100 tansacts per second with even less hardware with a l= +ittle data partitioning.
+
+Choose your controller carefully as many don't co-operate with linux well.<= +br>
+Alex Turner
+NetEconomist
+
On 9/12/05, Brandon Black <blblack@gmai= +l.com> wrote:
+
+I'm in the process of developing an application which uses PostgreSQL +for data storage.  Our database traffic is very atypical, and as a +result it has been rather challenging to figure out how to best tune +PostgreSQL on what development hardware we have, as well as to figure +out exactly what we should be evaluating and eventually buying for +production hardware.
+
+The vast, overwhelming majority of our database traffic is pretty much +a non-stop stream of INSERTs filling up tables.  It is akin to +data acquisition.  Several thousand clients are sending +once-per-minute updates full of timestamped numerical data at our +central server, which in turn performs INSERTs into several distinct +tables as part of the transaction for that client.  We're talking +on the order of ~100 transactions per second, each containing INSERTs +to multiple tables (which contain only integer and floating point +columns and a timestamp column - the primary key (and only index) is on +a unique integer ID for the client and the timestamp).  The +transaction load is spread evenly over time by having the clients send +their per-minute updates at random times rather than on the exact +minute mark.
+
+There will of course be users using a web-based GUI to extract data +from these tables and display them in graphs and whatnot, but the +SELECT query traffic will always be considerably less frequent and +intensive than the incessant INSERTs, and it's not that big a deal if +the large queries take a little while to run.
+
+This data also expires - rows with timestamps older than X days will be +DELETEd periodically (once an hour or faster), such that the tables +will reach a relatively stable size (pg_autovacuum is handling +vacuuming for now, but considering our case, we're thinking of killing +pg_autovacuum in favor of having the periodic DELETE process also do a +vacuum of affected tables right after the DELETE, and then have it +vacuum the other low traffic tables once a day while it's at it).
+
+There is an aggregation layer in place which proxies the inbound data +from the clients into a small(er) number of persistent postgresql +backend processes.  Right now we're doing one aggregator per 128 +clients (so instead of 128 seperate database connections over the +course of a minute for a small transaction each, there is a single +database backend that is constantly committing transactions at a rate +of ~ 2/second).  At a test load of ~1,000 clients, we would have 8 +aggregators running and 8 postgresql backends.  Testing has seemed +to indicate we should aggregate even harder - the planned production +load is ~5,000 clients initially, but will grow to almost double that +in the not-too-distant future, and that would mean ~40 backends at 128 +clients each initially.  Even on 8 cpus, I'm betting 40 concurrent +backends doing 2 tps is much worse off than 10 backends doing 8 tps.
+
+ +Test hardware right now is a dual Opteron with 4G of ram, which we've +barely gotten 1,000 clients running against.  Current disk hardware in +testing is whatever we could scrape together (4x 3-ware PCI hardware +RAID controllers, with 8 SATA drives in a RAID10 array off of each - +aggregated up in a 4-way stripe with linux md driver and then formatted +as ext3 with an appropriate stride parameter and data=3Dwriteback).  +Production will hopefully be a 4-8-way Opteron, 16 or more G of RAM, +and a fiberchannel hardware raid array or two (~ 1TB available RAID10 stora= +ge) with 15krpm disks and +battery-backed write cache.
+
+I know I haven't provided a whole lot of application-level detail here, +but does anyone have any general advice on tweaking postgresql to deal +with a very heavy load of concurrent and almost exclusively write-only +transactions?  Increasing shared_buffers seems to always help, +even out to half of the dev box's ram (2G).  A 100ms commit_delay +seemed to help, but tuning it (and _siblings) has been difficult.  +We're using 8.0 with the default 8k blocksize, but are strongly +considering both developing against 8.1 (seems it might handle the +heavy concurrency better), and re-compiling with 32k blocksize since +our storage arrays will inevitably be using fairly wide stripes.  +Any advice on any of this (other than drop the project while you're +still a little bit sane)?
+
+--Brandon
+
+ +

+ +------=_Part_3564_4087839.1126561521744-- + +From pgsql-performance-owner@postgresql.org Mon Sep 12 19:02:32 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D2961D8C36 + for ; + Mon, 12 Sep 2005 19:02:30 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 27278-03 + for ; + Mon, 12 Sep 2005 22:02:27 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.194]) + by svr1.postgresql.org (Postfix) with ESMTP id 4356ED8C53 + for ; + Mon, 12 Sep 2005 19:02:27 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id 36so2315677wra + for ; + Mon, 12 Sep 2005 15:02:30 -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:in-reply-to:mime-version:content-type:references; + b=nzU+k1g53iFyoKAPWWYfI7EoebevJ+94BroLiFw7HJjLJrqGfqQ0DcxUjWoQzTl29U6Boz5IO3pgeMkVMFE0J6WuAunGR7Z9otQnZYBMpmeeKXSir2NkXUgCrjTJYgCh6VE31cCVXoMZhIMQGhfSOmdEH2oPdQeJgCf/LM8UOR4= +Received: by 10.54.57.23 with SMTP id f23mr288wra; + Mon, 12 Sep 2005 15:02:30 -0700 (PDT) +Received: by 10.54.158.11 with HTTP; Mon, 12 Sep 2005 15:02:30 -0700 (PDT) +Message-ID: <84621a60509121502603bd56c@mail.gmail.com> +Date: Mon, 12 Sep 2005 17:02:30 -0500 +From: Brandon Black +Reply-To: blblack@gmail.com +To: PFC , + pgsql-performance@postgresql.org +Subject: Re: Performance considerations for very heavy INSERT traffic +In-Reply-To: +Mime-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_11494_29519225.1126562550353" +References: <84621a6050912140464c380c3@mail.gmail.com> + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.137 required=5 tests=[AWL=0.026, HTML_40_50=0.086, + HTML_MESSAGE=0.001, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200509/150 +X-Sequence-Number: 14458 + +------=_Part_11494_29519225.1126562550353 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +On 9/12/05, PFC wrote: +>=20 +>=20 +>=20 +> > I know I haven't provided a whole lot of application-level detail here, +>=20 +> You did ! +>=20 +> What about : +>=20 +> - using COPY instead of INSERT ? +> (should be easy to do from the aggregators) + + +Possibly, although it would kill the current design of returning the=20 +database transaction status for a single client packet back to the client o= +n=20 +transaction success/failure. The aggregator could put several clients' data= +=20 +into a series of delayed multi-row copy statements. + +- using Bizgres ? +> (which was designed for your use case) + + +I only briefly scanned their "About" page, but they didn't sound=20 +particularly suited to my case at the time (it sounded kinds buzzwordy=20 +actually, which I suppose is great for business apps people :) ). We're mor= +e=20 +of a sciency shop. I'll go look at the project in more detail tonight in=20 +light of your recommendation. + +- splitting the xlog and the data on distinct physical drives or arrays + + +That would almost definitely help, I haven't tried it yet. Speaking of the= +=20 +xlog, anyone know anything specific about the WAL tuning parameters for=20 +heavy concurrent write traffic? What little I could dig up on WAL tuning wa= +s=20 +contradictory, and testing some random changes to the parameters hasn't bee= +n=20 +very conclusive yet. I would imagine the WAL buffers stuff could potentiall= +y=20 +have a large effect for us. + +- benchmarking something else than ext3 +> (xfs ? reiser3 ?) +>=20 + +We've had bad experiences under extreme and/or strange workloads with XFS= +=20 +here in general, although this is the first major postgresql project - the= +=20 +rest were with other applications writing to XFS. Bad experiences like XFS= +=20 +filesystems "detecting internal inconsistencies" at runtime and unmounting= +=20 +themselves from within the kernel module (much to the dismay of application= +s=20 +with open files on the filesystem), on machines with validated good=20 +hardware. It has made me leary of using anything other than ext3 for fear o= +f=20 +stability problems. Reiser3 might be worth taking a look at though. + +Thanks for the ideas, +-- Brandon + +------=_Part_11494_29519225.1126562550353 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +

On 9/12/05, PFC <lists@bo= +utiquenumerique.com> wrote:
+

> I know I haven't provided a whole lot of application-level det= +ail here,

        You did !<= +br>
        What about :

= +        - using COPY instead of INS= +ERT ?
           = +     (should +be easy to do from the aggregators)

+Possibly, although it would kill the current design of returning the +database transaction status for a single client packet back to the +client on transaction success/failure.   The aggregator could put +several clients' data into a series of delayed multi-row copy +statements.
+

 &= +nbsp;      - using Bizgres ?
  &= +nbsp;           &nbs= +p; (which +was designed for your use case)

+I only briefly scanned their "About" page, but they didn't sound +particularly suited to my case at the time (it sounded kinds buzzwordy +actually, which I suppose is great for business apps people :) ).  +We're more of a sciency shop.  I'll go look at the project in more +detail tonight in light of your recommendation.
+

 &= +nbsp;      - splitting the xlog and the data = +on distinct physical drives or arrays
+

+That would almost definitely help, I haven't tried it yet.  +Speaking of the xlog, anyone know anything specific about the WAL +tuning parameters for heavy concurrent write traffic?  What little +I could dig up on WAL tuning was contradictory, and testing some random +changes to the parameters hasn't been very conclusive yet.  I +would imagine the WAL buffers stuff could potentially have a large +effect for us.
+

 &= +nbsp;      - benchmarking something else than= + ext3
           = +     (xfs ? reiser3 ?) +

+We've had bad experiences under extreme and/or strange workloads with +XFS here in general, although this is the first major postgresql +project - the rest were with other applications writing to XFS.  +Bad experiences like XFS filesystems "detecting internal +inconsistencies" at runtime and unmounting themselves from within the +kernel module (much to the dismay of applications with open files on +the filesystem), on machines with validated good hardware.  It has +made me leary of using anything other than ext3 for fear of stability +problems.  Reiser3 might be worth taking a look at though.
+
+Thanks for the ideas,
+-- Brandon
+ +------=_Part_11494_29519225.1126562550353-- + +From pgsql-performance-owner@postgresql.org Mon Sep 12 18:37:33 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3BF2BD8C15 + for ; + Mon, 12 Sep 2005 18:37:32 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 15162-07 + for ; + Mon, 12 Sep 2005 21:37:25 +0000 (GMT) +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id EBC6ED8C53 + for ; + Mon, 12 Sep 2005 18:37:26 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id CFC6631F81; Mon, 12 Sep 2005 23:37:28 +0200 (MET DST) +From: "Qingqing Zhou" +X-Newsgroups: pgsql.performance +Subject: Re: Performance considerations for very heavy INSERT traffic +Date: Mon, 12 Sep 2005 17:37:19 -0700 +Organization: Hub.Org Networking Services +Lines: 76 +Message-ID: +References: <84621a6050912140464c380c3@mail.gmail.com> +Mime-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0025_01C5B7C0.A035C750" +X-Complaints-To: usenet@news.hub.org +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.243 required=5 tests=[AWL=-0.038, HTML_50_60=0.095, + HTML_MESSAGE=0.001, PRIORITY_NO_NAME=1.185] +X-Spam-Level: * +X-Archive-Number: 200509/148 +X-Sequence-Number: 14456 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0025_01C5B7C0.A035C750 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + "Brandon Black" wrote ... + + Increasing shared_buffers seems to always help, even out to half of = +the dev box's ram (2G). =20 + + Though officially PG does not prefer huge shared_buffers size, I did = +see several times that performance was boosted in case IO is the = +bottleneck. Also, if you want to use big bufferpool setting, make sure = +your version has Tom's split BufMgrLock patch + = +(http://archives.postgresql.org/pgsql-committers/2005-03/msg00025.php), = +which might already in 8.0.x somewhere. And if you want to use = +bufferpool bigger than 2G on 64-bit machine, you may need 8.1 = +(http://archives.postgresql.org/pgsql-committers/2005-08/msg00221.php). + + Regards, + Qingqing +------=_NextPart_000_0025_01C5B7C0.A035C750 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
 
+ +
"Brandon Black" <blblack@gmail.com> wrote = +...
+

Increasing shared_buffers seems to always help, even out to = +half of=20 + the dev box's ram (2G). 
+
 
+
Though officially PG does not prefer = +huge=20 + shared_buffers size, I did see several times = +that performance was=20 + boosted in case IO is the bottleneck. Also, if you want to use big = +bufferpool=20 + setting, make sure your version has Tom's split BufMgrLock = +patch
+
(http://archives.postgresql.org/pgsql-committers/2005-03/msg00025.php= +),=20 + which might already in 8.0.x somewhere. And if you want to use = +bufferpool=20 + bigger than 2G on 64-bit machine, you may need 8.1 (http://archives.postgresql.org/pgsql-committers/2005-08/msg00221.php= +).
+
 
+
Regards,
+
Qingqing
+ +------=_NextPart_000_0025_01C5B7C0.A035C750-- + + +From pgsql-performance-owner@postgresql.org Mon Sep 12 21:56:45 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CF37ED8C80 + for ; + Mon, 12 Sep 2005 21:56:41 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 71287-08 + for ; + Tue, 13 Sep 2005 00:56:37 +0000 (GMT) +Received: from unicorn.rentec.com (unicorn.rentec.com [216.223.240.9]) + by svr1.postgresql.org (Postfix) with ESMTP id 46030D8C52 + for ; + Mon, 12 Sep 2005 21:56:35 -0300 (ADT) +Received: from ram.rentec.com (mailhost [192.5.35.66]) + by unicorn.rentec.com (8.13.1/8.12.1) with ESMTP id j8D0uGIl015500 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); + Mon, 12 Sep 2005 20:56:18 -0400 (EDT) +X-Source: non-mednet +Received: from [172.16.160.108] (stange-dhcp2.rentec.com [172.16.160.108]) + by ram.rentec.com (8.13.1/8.12.1) with ESMTP id j8D0uEiX002501; + Mon, 12 Sep 2005 20:56:15 -0400 (EDT) +Message-ID: <43261F8A.1060506@rentec.com> +Date: Mon, 12 Sep 2005 20:38:34 -0400 +From: Alan Stange +Organization: Renaissance Technologies Corp. +User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: blblack@gmail.com +Cc: PFC , + pgsql-performance@postgresql.org +Subject: Re: Performance considerations for very heavy INSERT traffic +References: <84621a6050912140464c380c3@mail.gmail.com> + + <84621a60509121502603bd56c@mail.gmail.com> +In-Reply-To: <84621a60509121502603bd56c@mail.gmail.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Logged: Logged by unicorn.rentec.com as j8D0uGIl015500 at Mon Sep 12 + 20:56:18 2005 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.015 required=5 tests=[AWL=0.015] +X-Spam-Level: +X-Archive-Number: 200509/151 +X-Sequence-Number: 14459 + +Brandon Black wrote: + +> +> +> On 9/12/05, *PFC* > wrote: +> +> +> +> - benchmarking something else than ext3 +> (xfs ? reiser3 ?) +> +> +> We've had bad experiences under extreme and/or strange workloads with +> XFS here in general, although this is the first major postgresql +> project - the rest were with other applications writing to XFS. Bad +> experiences like XFS filesystems "detecting internal inconsistencies" +> at runtime and unmounting themselves from within the kernel module +> (much to the dismay of applications with open files on the +> filesystem), on machines with validated good hardware. It has made me +> leary of using anything other than ext3 for fear of stability +> problems. Reiser3 might be worth taking a look at though. + +Just one tidbit. We tried XFS on a very active system similar to what +you describe. Dual opterons, 8GB memory, fiber channel drives, 2.6 +kernel, etc. And the reliability was awful. We spent a lot of time +making changes one at a time to try and isolate the cause; when we +switched out from XFS to ReiserFS our stability problems went away. + +It may be the case that the XFS problems have all been corrected in +newer kernels, but I'm not going to put too much effort into trying that +again. + + +I recently built a postgres with 32KB block sizes and have been doing +some testing. For our particular workloads it has been a win. + +-- Alan + +From pgsql-performance-owner@postgresql.org Tue Sep 13 00:08:03 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 29089D81C2 + for ; + Tue, 13 Sep 2005 00:07:59 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 10740-07 + for ; + Tue, 13 Sep 2005 03:07:57 +0000 (GMT) +Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) + by svr1.postgresql.org (Postfix) with ESMTP id EE36ED796A + for ; + Tue, 13 Sep 2005 00:07:55 -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 1EF19B-0002Hv-00; Mon, 12 Sep 2005 23:07:49 -0400 +To: blblack@gmail.com +Cc: pgsql-performance@postgresql.org +Subject: Re: Performance considerations for very heavy INSERT traffic +References: <84621a6050912140464c380c3@mail.gmail.com> +In-Reply-To: <84621a6050912140464c380c3@mail.gmail.com> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 12 Sep 2005 23:07:49 -0400 +Message-ID: <87slw91x8a.fsf@stark.xeocode.com> +Lines: 90 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.005 required=5 tests=[AWL=0.005] +X-Spam-Level: +X-Archive-Number: 200509/152 +X-Sequence-Number: 14460 + + +Brandon Black writes: + +> The vast, overwhelming majority of our database traffic is pretty much a +> non-stop stream of INSERTs filling up tables. + +That part Postgres should handle pretty well. It should be pretty much limited +by your I/O bandwidth so big raid 1+0 arrays are ideal. Putting the WAL on a +dedicated array would also be critical. + +The WAL parameters like commit_delay and commit_siblings are a bit of a +mystery. Nobody has done any extensive testing of them. It would be quite +helpful if you find anything conclusive and post it. It would also be +surprising if they had a very large effect. They almost got chopped recently +because they weren't believed to be useful. + +You might also ponder whether you need to by issuing a commit for every datum. +If you only need to commit periodically you can get much better throughput. I +suppose that's the same as commit_siblings. It would be interesting to know if +you can get those parameters to perform as well as batching up records +yourself. + +> There will of course be users using a web-based GUI to extract data from +> these tables and display them in graphs and whatnot, but the SELECT query +> traffic will always be considerably less frequent and intensive than the +> incessant INSERTs, and it's not that big a deal if the large queries take a +> little while to run. + +I do fear these queries. Even if they aren't mostly terribly intensive if +you're pushing the edges of your write I/O bandwidth then a single seek to +satisfy one of these selects could really hurt your throughput. + +That said, as long as your WAL is on a dedicated drive Postgres's architecture +should in theory be ideal and allow you do run these things with impunity. The +WAL is purely write-only and it's the only thing your inserts will be blocking +on. + +> This data also expires - rows with timestamps older than X days will be +> DELETEd periodically (once an hour or faster), such that the tables will +> reach a relatively stable size (pg_autovacuum is handling vacuuming for now, +> but considering our case, we're thinking of killing pg_autovacuum in favor +> of having the periodic DELETE process also do a vacuum of affected tables +> right after the DELETE, and then have it vacuum the other low traffic tables +> once a day while it's at it). + +Ay, there's the rub. + +Taking this approach means you have vacuums running which have to scan your +entire table and your inserts are being sprayed all over the disk. + +An alternative you may consider is using partitioned tables. Then when you +want to expire old records you simply drop the oldest partition. Or in your +case you might rotate through the partitions, so you just truncate the oldest +one and start inserting into it. + +Unfortunately there's no built-in support for partitioned tables in Postgres. +You get to roll your own using UNION ALL or using inherited tables. Various +people have described success with each option though they both have +downsides too. + +Using partitioned tables you would never need to delete any records except for +when you delete all of them. So you would never need to run vacuum except on +newly empty partitions. That avoids having to scan through all those pages +that you know will never have holes. If you use TRUNCATE (or VACUUM ALL or +CLUSTER) that would mean your inserts are always sequential too (though it +also means lots of block allocations along the way, possibly not an +advantage). + +This may be a lot more work to set up and maintain but I think it would be a +big performance win. It would directly speed up the WAL writes by avoiding +those big full page dumps. And it would also cut out all the I/O traffic +vacuum generates. + + +> Increasing shared_buffers seems to always help, even out to half of the dev +> box's ram (2G). + +Half should be a pessimal setting. It means virtually everything is buffered +twice. Once in the kernel and once in Postgres. Effectively halving your +memory. If that's really helping try raising it even further, to something +like 90% of your memory. But the conventional dogma is that shared buffers +should never be more than about 10k no matter how much memory you have. Let +the kernel do the bulk of the buffering. + +That said it's even more mysterious in your situation. Why would a large +shared buffers help insert-only performance much at all? My guess is that it's +letting the vacuums complete quicker. Perhaps try raising work_mem? + +-- +greg + + +From pgsql-performance-owner@postgresql.org Tue Sep 13 00:40:32 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 21816D8CC4 + for ; + Tue, 13 Sep 2005 00:39:19 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18819-01 + for ; + Tue, 13 Sep 2005 03:39:17 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.203]) + by svr1.postgresql.org (Postfix) with ESMTP id D0FA0D8CAF + for ; + Tue, 13 Sep 2005 00:39:15 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id i22so1581184wra + for ; + Mon, 12 Sep 2005 20:39:15 -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=qrIMWRRyTBuD8tiTMXokI66WgxAvTr+sQwa+3aZjTQ3dGFw2SflcKUBK7x9VdLWlWOupbZVXICj2ezgOgm8qy6cBL5AR1hTgav8sBgf2cLdWfGngCFxkmjHF5JVAXBUqbI0yYcNrsjD5QgPVFHHXTOceuPmcQrsDW3RVLD97Nnw= +Received: by 10.54.38.42 with SMTP id l42mr201669wrl; + Mon, 12 Sep 2005 20:39:14 -0700 (PDT) +Received: by 10.54.120.18 with HTTP; Mon, 12 Sep 2005 20:39:14 -0700 (PDT) +Message-ID: <59d991c40509122039773cac17@mail.gmail.com> +Date: Mon, 12 Sep 2005 23:39:14 -0400 +From: Christopher Petrilli +Reply-To: petrilli@gmail.com +To: blblack@gmail.com +Subject: Re: Performance considerations for very heavy INSERT traffic +Cc: pgsql-performance@postgresql.org +In-Reply-To: <84621a6050912140464c380c3@mail.gmail.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <84621a6050912140464c380c3@mail.gmail.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.135 required=5 tests=[AWL=0.111, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200509/153 +X-Sequence-Number: 14461 + +On 9/12/05, Brandon Black wrote: +>=20 +> I'm in the process of developing an application which uses PostgreSQL fo= +r +> data storage. Our database traffic is very atypical, and as a result it = +has +> been rather challenging to figure out how to best tune PostgreSQL on what +> development hardware we have, as well as to figure out exactly what we +> should be evaluating and eventually buying for production hardware. + +A few suggestions... + +1) Switch to COPY if you can, it's anywhere from 10-100x faster than +INSERT, but it does not necessarily fit your idea of updating multiple +tables. In that case, try and enlarge the transaction's scope and do +multiple INSERTs in the same transaction. Perhaps batching once per +second, or 5 seconds, and returning the aggregate result ot the +clients. + +2) Tune ext3. The default configuration wrecks high-write situations. + Look into data=3Dwriteback for mounting, turning off atime (I hope +you've done this already) updates, and also modifying the scheduler to +the elevator model. This is poorly documented in Linux (like just +about everything), but it's crtical. + +3) Use 8.1 and strongly look at Bizgres. The data partitioning is critical. + +4) Make sure you are not touching more data than you need, and don't +have any extraneous indexes. Use the planner to make sure every index +is used, as it substantially increases the write load. + +I've worked on a few similar applications, and this is a hard thing in +any database, even Oracle. + +Chris=20 + +--=20 +| Christopher Petrilli +| petrilli@gmail.com + +From pgsql-performance-owner@postgresql.org Tue Sep 13 00:44:43 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 30E3AD8421 + for ; + Tue, 13 Sep 2005 00:44:40 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 20729-02 + for ; + Tue, 13 Sep 2005 03:44:37 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.201]) + by svr1.postgresql.org (Postfix) with ESMTP id 98419D8403 + for ; + Tue, 13 Sep 2005 00:44:35 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id 36so2356435wra + for ; + Mon, 12 Sep 2005 20:44:35 -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:in-reply-to:mime-version:content-type:references; + b=l+gKbYxCLhf+rjN2PV7dhiPUT8Q7aFjHChrp/Mx+cbYY1eyz0wfZOKiOhP3CRr4v74xVqex8zpBpnfp3pG5fN8HcU6LJkVyagYHRDlmOjOgf48Wxa8CcBBXozOX7y5qMv/ZmkIAOSEhb61ZrDYy2fcmBq9OQ+B5UGkBLQoVuqZQ= +Received: by 10.54.57.23 with SMTP id f23mr177462wra; + Mon, 12 Sep 2005 20:44:35 -0700 (PDT) +Received: by 10.54.158.11 with HTTP; Mon, 12 Sep 2005 20:44:35 -0700 (PDT) +Message-ID: <84621a605091220442775249b@mail.gmail.com> +Date: Mon, 12 Sep 2005 22:44:35 -0500 +From: Brandon Black +Reply-To: blblack@gmail.com +To: Greg Stark , pgsql-performance@postgresql.org +Subject: Re: Performance considerations for very heavy INSERT traffic +In-Reply-To: <87slw91x8a.fsf@stark.xeocode.com> +Mime-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_12365_28318204.1126583075426" +References: <84621a6050912140464c380c3@mail.gmail.com> + <87slw91x8a.fsf@stark.xeocode.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.229 required=5 tests=[AWL=-0.091, HTML_10_20=0.295, + HTML_MESSAGE=0.001, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200509/154 +X-Sequence-Number: 14462 + +------=_Part_12365_28318204.1126583075426 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +On 12 Sep 2005 23:07:49 -0400, Greg Stark wrote: + +>=20 +> The WAL parameters like commit_delay and commit_siblings are a bit of a +> mystery. Nobody has done any extensive testing of them. It would be quite +> helpful if you find anything conclusive and post it. It would also be +> surprising if they had a very large effect. They almost got chopped=20 +> recently +> because they weren't believed to be useful. +>=20 +> You might also ponder whether you need to by issuing a commit for every= +=20 +> datum. +> If you only need to commit periodically you can get much better=20 +> throughput. I +> suppose that's the same as commit_siblings. It would be interesting to=20 +> know if +> you can get those parameters to perform as well as batching up records +> yourself. + + +Ideally I'd like to commit the data seperately, as the data could contain= +=20 +errors which abort the transaction, but it may come down to batching it and= +=20 +coding things such that I can catch and discard the offending row and retry= +=20 +the transaction if it fails (which should be fairly rare I would hope). I= +=20 +was hoping that the commit_delay/commit_siblings stuff would allow me to=20 +maintain simplistic transaction failure isolation while giving some of the= +=20 +benefits of batching things up, as you've said. I have seen performance=20 +gains with it set at 100ms and a 3-6 siblings with 8 backends running, but = +I=20 +haven't been able to extensively tune these values, they were mostly random= +=20 +guesses that seemed to work. My cycles of performance testing take a while,= +=20 +at least a day or two per change being tested, and the differences can even= +=20 +then be hard to see due to variability in the testing load (as it's not=20 +really a static test load, but a window on reality). On top of that, with= +=20 +the time it takes, I've succumbed more than once to the temptation of=20 +tweaking more than one thing per performance run, which really muddies the= +=20 +results. + +> Increasing shared_buffers seems to always help, even out to half of the= +=20 +> dev +> > box's ram (2G). +>=20 +> Half should be a pessimal setting. It means virtually everything is=20 +> buffered +> twice. Once in the kernel and once in Postgres. Effectively halving your +> memory. If that's really helping try raising it even further, to somethin= +g +> like 90% of your memory. But the conventional dogma is that shared buffer= +s +> should never be more than about 10k no matter how much memory you have.= +=20 +> Let +> the kernel do the bulk of the buffering. +>=20 +> That said it's even more mysterious in your situation. Why would a large +> shared buffers help insert-only performance much at all? My guess is that= +=20 +> it's +> letting the vacuums complete quicker. Perhaps try raising work_mem? + + +I find it odd as well. After reading the standard advice on shared_buffers,= +=20 +I had only intended on raising it slightly. But seeing ever-increasing=20 +performance gains, I just kept tuning it upwards all the way to the 2G=20 +limit, and saw noticeable gains every time. During at least some of the tes= +t=20 +cycles, there was no deleting or vacuuming going on, just insert traffic. I= +=20 +guessed that shared_buffers' caching strategy must have been much more=20 +effective than the OS cache at something or other, but I don't know what=20 +exactly. The only important read traffic that comes to mind is the index=20 +which is both being constantly updated and constantly checked for primary= +=20 +key uniqueness violations. + +All of these replies here on the list (and a private one or two) have given= +=20 +me a long list of things to try, and I feel confident that at least some of= +=20 +them will gain me enough performance to comfortably deploy this application= +=20 +in the end on somewhat reasonable hardware. Thanks to everyone here on the= +=20 +list for all the suggestions, it has been very helpful in giving me=20 +directions to go with this that I hadn't thought of before. + +When I finally get all of this sorted out and working reasonably optimally,= +=20 +I'll be sure to come back and report what techniques/settings did and didn'= +t=20 +work for this workload. + +-- Brandon + +------=_Part_12365_28318204.1126583075426 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +

On 12 Sep 2005 23:07:49 -0400, Greg Stark <gsstark@mit.edu> wrote:
+

The WAL param= +eters like commit_delay and commit_siblings are a bit of a
mystery. Nobo= +dy has done any extensive testing of them. It would be quite +
helpful if you find anything conclusive and post it. It would also besurprising if they had a very large effect. They almost got chopped recen= +tly
because they weren't believed to be useful.

You might also po= +nder whether you need to by issuing a commit for every datum. +
If you only need to commit periodically you can get much better through= +put. I
suppose that's the same as commit_siblings. It would be interesti= +ng to know if
you can get those parameters to perform as well as batchin= +g up records +
yourself.

+Ideally I'd like to commit the data seperately, as the data could +contain errors which abort the transaction, but it may come down to +batching it and coding things such that I can catch and discard the +offending row and retry the transaction if it fails (which should be +fairly rare I would hope).  I was hoping that the +commit_delay/commit_siblings stuff would allow me to maintain +simplistic transaction failure isolation while giving some of the +benefits of batching things up, as you've said.  I have seen +performance gains with it set at 100ms and a 3-6 siblings with 8 +backends running, but I haven't been able to extensively tune these +values, they were mostly random guesses that seemed to work.  My +cycles of performance testing take a while, at least a day or two per +change being tested, and the differences can even then be hard to see +due to variability in the testing load (as it's not really a static +test load, but a window on reality).  On top of that, with the +time it takes, I've succumbed more than once to the temptation of +tweaking more than one thing per performance run, which really muddies +the results.
+

+
> Increasing s= +hared_buffers seems to always help, even out to half of the dev
> box= +'s ram (2G). +

Half should be a pessimal setting. It means virtually everything is= + buffered
twice. Once in the kernel and once in Postgres. Effectively ha= +lving your
memory. If that's really helping try raising it even further,= + to something +
like 90% of your memory. But the conventional dogma is that shared buff= +ers
should never be more than about 10k no matter how much memory you ha= +ve. Let
the kernel do the bulk of the buffering.

That said it's e= +ven more mysterious in your situation. Why would a large +
shared buffers help insert-only performance much at all? My guess is th= +at it's
letting the vacuums complete quicker. Perhaps try raising work_m= +em?

+I find it odd as well.  After reading the standard advice on +shared_buffers, I had only intended on raising it slightly.  But +seeing ever-increasing performance gains, I just kept tuning it upwards +all the way to the 2G limit, and saw noticeable gains every time.  +During at least some of the test cycles, there was no deleting or +vacuuming going on, just insert traffic.  I guessed that +shared_buffers' caching strategy must have been much more effective +than the OS cache at something or other, but I don't know what +exactly.  The only important read traffic that comes to mind is +the index which is both being constantly updated and constantly checked +for primary key uniqueness violations.
+
+All of these replies here on the list (and a private one or two) have +given me a long list of things to try, and I feel confident that at +least some of them will gain me enough performance to comfortably +deploy this application in the end on somewhat reasonable +hardware.  Thanks to everyone here on the list for all the +suggestions, it has been very helpful in giving me directions to go +with this that I hadn't thought of before.
+
+When I finally get all of this sorted out and working reasonably +optimally, I'll be sure to come back and report what +techniques/settings did and didn't work for this workload.
+
+-- Brandon
+
+ +------=_Part_12365_28318204.1126583075426-- + +From pgsql-performance-owner@postgresql.org Tue Sep 13 00:54:01 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2B46BD76BA + for ; + Tue, 13 Sep 2005 00:53:58 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 22316-05 + for ; + Tue, 13 Sep 2005 03:53:56 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.206]) + by svr1.postgresql.org (Postfix) with ESMTP id 5C2A4D6E69 + for ; + Tue, 13 Sep 2005 00:53:55 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id 36so2357630wra + for ; + Mon, 12 Sep 2005 20:53:55 -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:in-reply-to:mime-version:content-type:references; + b=FnTFga/ej/E7rLKPEIWK1mwq5AHBfW5ctFrA8emT/fGEBSw3IzbFebTdtgyqa3uHgQsbbsK/YUC5Nf/fucj5tU36SUjEh5GQFWKf1wnUVvtKHwTIQe6aOQxb+JrdBJVqwF2oH0rkePmwmsoBzTs7+t1748W4JKbQye7lMGmNP3A= +Received: by 10.54.21.44 with SMTP id 44mr190289wru; + Mon, 12 Sep 2005 20:53:55 -0700 (PDT) +Received: by 10.54.158.11 with HTTP; Mon, 12 Sep 2005 20:53:55 -0700 (PDT) +Message-ID: <84621a605091220533aa8fa12@mail.gmail.com> +Date: Mon, 12 Sep 2005 22:53:55 -0500 +From: Brandon Black +Reply-To: blblack@gmail.com +To: petrilli@gmail.com, pgsql-performance@postgresql.org +Subject: Re: Performance considerations for very heavy INSERT traffic +In-Reply-To: <59d991c40509122039773cac17@mail.gmail.com> +Mime-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_12393_22884737.1126583635048" +References: <84621a6050912140464c380c3@mail.gmail.com> + <59d991c40509122039773cac17@mail.gmail.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.139 required=5 tests=[AWL=0.058, HTML_30_40=0.056, + HTML_MESSAGE=0.001, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200509/155 +X-Sequence-Number: 14463 + +------=_Part_12393_22884737.1126583635048 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +On 9/12/05, Christopher Petrilli wrote: +>=20 +>=20 +> 2) Tune ext3. The default configuration wrecks high-write situations. +> Look into data=3Dwriteback for mounting, turning off atime (I hope +> you've done this already) updates, and also modifying the scheduler to +> the elevator model. This is poorly documented in Linux (like just +> about everything), but it's crtical. + + +I'm using noatime and data=3Dwriteback already. I changed my scheduler from= +=20 +the default anticipatory to deadline and saw an improvement, but I haven't= +=20 +yet delved into playing with specific elevator tunable values per-device. + +3) Use 8.1 and strongly look at Bizgres. The data partitioning is critical. + + +I've just started down the path of getting 8.1 running with a larger block= +=20 +size, and tommorow I'm going to look at Bizgres's partitioning as opposed t= +o=20 +some manual schemes. Will the current Bizgres have a lot of the performance= +=20 +enhancements of 8.1 already (or will 8.1 or 8.2 eventually get Bizgres's=20 +partitioning?)? + +-- Brandon + +------=_Part_12393_22884737.1126583635048 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +

On 9/12/05, Christopher Petrilli <= +petrilli@gmail.com> wrote:
+
2) Tune ext3.  The default configuration wrecks high-write si= +tuations.
Look into data=3Dwriteback for mounting, turning off atime (I= + hope
you've done this already) updates, and also modifying the schedule= +r to
+the elevator model.  This is poorly documented in Linux (like jus= +t
about everything), but it's crtical.

+I'm using noatime and data=3Dwriteback already.  I changed my +scheduler from the default anticipatory to deadline and saw an +improvement, but I haven't yet delved into playing with specific +elevator tunable values per-device.
+

3) Use = +8.1 and strongly look at Bizgres. The data partitioning is critical. +

+I've just started down the path of getting 8.1 running with a larger +block size, and tommorow I'm going to look at Bizgres's partitioning as +opposed to some manual schemes.  Will the current Bizgres have a +lot of the performance enhancements of 8.1 already (or will 8.1 or 8.2 +eventually get Bizgres's partitioning?)?
+

-- Brandon
+
+ +------=_Part_12393_22884737.1126583635048-- + +From pgsql-performance-owner@postgresql.org Tue Sep 13 02:03:03 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 04F61D78C3 + for ; + Tue, 13 Sep 2005 02:02:21 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 44460-03 + for ; + Tue, 13 Sep 2005 05:02:17 +0000 (GMT) +Received: from pop-sarus.atl.sa.earthlink.net (pop-sarus.atl.sa.earthlink.net + [207.69.195.72]) + by svr1.postgresql.org (Postfix) with ESMTP id F3AD8D78C6 + for ; + Tue, 13 Sep 2005 02:02:17 -0300 (ADT) +Received: from elwamui-cypress.atl.sa.earthlink.net ([209.86.224.32]) + by pop-sarus.atl.sa.earthlink.net with esmtp (Exim 3.36 #10) + id 1EF2vw-0001hl-00; Tue, 13 Sep 2005 01:02:16 -0400 +Message-ID: + <27245012.1126587736278.JavaMail.root@elwamui-cypress.atl.sa.earthlink.net> +Date: Tue, 13 Sep 2005 01:02:16 -0400 (EDT) +From: Ron Peacetree +Reply-To: Ron Peacetree +To: blblack@gmail.com, pgsql-performance@postgresql.org +Subject: Re: Performance considerations for very heavy INSERT +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Mailer: Earthlink Zoo Mail 1.0 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.374 required=5 tests=[DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200509/157 +X-Sequence-Number: 14465 + +>From: Brandon Black +>Sent: Sep 12, 2005 5:04 PM +>To: pgsql-performance@postgresql.org +>Subject: [PERFORM] Performance considerations for very heavy INSERT traffic + +>I'm in the process of developing an application which uses PostgreSQL for +>data storage. Our database traffic is very atypical, and as a result it has +>been rather challenging to figure out how to best tune PostgreSQL on what +>development hardware we have, as well as to figure out exactly what we +>should be evaluating and eventually buying for production hardware. + +>The vast, overwhelming majority of our database traffic is pretty much a +>non-stop stream of INSERTs filling up tables. It is akin to data +>acquisition. Several thousand clients are sending once-per-minute updates +>full of timestamped numerical data at our central server, which in turn +>performs INSERTs into several distinct tables as part of the transaction for +>that client. We're talking on the order of ~100 transactions per second, +>each containing INSERTs to multiple tables (which contain only integer and +>floating point columns and a timestamp column - the primary key (and only +>index) is on a unique integer ID for the client and the timestamp). The +>transaction load is spread evenly over time by having the clients send their +>per-minute updates at random times rather than on the exact minute mark. + +I have built two such systems. TBF, neither used PostgreSQL. OTOH, the principles are the same. + +One perhaps non-obvious point: You definitely are going to want a way to adjust exactly when a specific client is sending its approximately once-per-minute update via functionality similar to adjtime(). Such functionality will be needed to smooth the traffic across the clients as much as possible over the 1 minute polling period given the real-world vagracies of WAN connections. + +Put your current active data acquisition table on its own RAID 10 array, and keep it _very_ small and simple in structure (see below for a specific suggestion regarding this). If you must have indexes for this table, put them on a _different_ array. Basically, you are going to treat the active table like you would an log file: you want as little HD head movement as possible so appending to the table is effectively sequential IO. + +As in a log file, you will get better performance if you batch your updates to HD into reasonably sized chunks rather than writing to HD every INSERT. + +The actual log file will have to be treated in the same way to avoid it becoming a performance bottleneck. + + +>There will of course be users using a web-based GUI to extract data from +>these tables and display them in graphs and whatnot, but the SELECT query +>traffic will always be considerably less frequent and intensive than the +>incessant INSERTs, and it's not that big a deal if the large queries take a +>little while to run. + +More details here would be helpful. + + +>This data also expires - rows with timestamps older than X days will be +>DELETEd periodically (once an hour or faster), such that the tables will +>reach a relatively stable size (pg_autovacuum is handling vacuuming for now, +>but considering our case, we're thinking of killing pg_autovacuum in favor +>of having the periodic DELETE process also do a vacuum of affected tables +>right after the DELETE, and then have it vacuum the other low traffic tables +>once a day while it's at it). + +Design Idea: split the data into tables where _at most_ the tables are of the size that all the data in the table expires at the same time and DROP the entire table rather than scanning a big table for deletes at the same time you want to do inserts to said. Another appropriate size for these tables may be related to the chunk you want to write INSERTS to HD in. + +This will also have the happy side effect of breaking the data into smaller chunks that are more likely to be cached in their entirety when used. + + +>There is an aggregation layer in place which proxies the inbound data from +>the clients into a small(er) number of persistent postgresql backend +>processes. Right now we're doing one aggregator per 128 clients (so instead +>of 128 seperate database connections over the course of a minute for a small +>transaction each, there is a single database backend that is constantly +>committing transactions at a rate of ~ 2/second). At a test load of ~1,000 +>clients, we would have 8 aggregators running and 8 postgresql backends. +>Testing has seemed to indicate we should aggregate even harder - the planned +>production load is ~5,000 clients initially, but will grow to almost double +>that in the not-too-distant future, and that would mean ~40 backends at 128 +>clients each initially. Even on 8 cpus, I'm betting 40 concurrent backends +>doing 2 tps is much worse off than 10 backends doing 8 tps. + +Experience has taught me that the above is not likely to be the proper architecture for this kind of application. + +The best exact approach is dependent on The Details, but in general you want to optimize the amount of data sent from NIC to CPU per transfer (multiple small copies and lots of interrupts _kill_ system performance) and use a combined Threading and Event Queue model with Processor Affinity being used to optimize the NIC <-> CPU path for a given NIC. Have each physical NIC+CPU Affinity set be hidden underneath an overall Virtual NIC+CPU abstraction for load balancing purposes. The traffic thinks it's talking to one NIC attached to one CPU. + +This architecture allowed for a 4P Xeon system (Compaq Proliant 8500s) to handle 250K+ simultaneous active web connections. In 2000 using Windows 2K. As HW + SW has gotten better, it has scaled very well. It's a very high performance model. + +Such an architecture using AMD64 CPUs running a 64b Linux 2.6 distro now in late 2005 should _easily_ handle your projected demand with plenty of room for growth. + + +>Test hardware right now is a dual Opteron with 4G of ram, which we've barely +>gotten 1,000 clients running against. Current disk hardware in testing is +>whatever we could scrape together (4x 3-ware PCI hardware RAID controllers, +>with 8 SATA drives in a RAID10 array off of each - aggregated up in a 4-way +>stripe with linux md driver and then formatted as ext3 with an appropriate +>stride parameter and data=writeback). Production will hopefully be a 4-8-way +>Opteron, 16 or more G of RAM, and a fiberchannel hardware raid array or two +>(~ 1TB available RAID10 storage) with 15krpm disks and battery-backed write +>cache. + +For deployment, get a 2P or 4P 16 DIMM slot mainboard and stuff it with at least 16GB of RAM. A 2P 16 DIMM slot mainboard like the IWill DK88 (Tyan and a few others also have such boards in the works) is IMHO your best bet. + +IME, you will not need CPU for this application as much as you will need RAM first and HD IO bandwidth second. +Get a 1C2P AMD64 system and don't worry about CPU until you are CPU bound. I highly doubt you will need more CPU than a 2C2P (4 cores total) based on say 4400+'s, 4600+'s, or 4800+'s can provide. + + +>I know I haven't provided a whole lot of application-level detail here, but +>does anyone have any general advice on tweaking postgresql to deal with a +>very heavy load of concurrent and almost exclusively write-only +>transactions? Increasing shared_buffers seems to always help, even out to +>half of the dev box's ram (2G). A 100ms commit_delay seemed to help, but +>tuning it (and _siblings) has been difficult. We're using 8.0 with the +>default 8k blocksize, but are strongly considering both developing against +>8.1 (seems it might handle the heavy concurrency better), and re-compiling +>with 32k blocksize since our storage arrays will inevitably be using fairly +>wide stripes. Any advice on any of this (other than drop the project while +>you're still a little bit sane)? + +Since you are doing more writing than reading, and those writes are going to be relatively small, you may not get as much out of block sizes larger than the average DB write. + +My initial instinct on this point is that you should keep the size of the "chunk" the same from NIC to CPU to HD, and make said chunk as large as possible. + + +Hope this helps, +Ron Peacetree + +PS. Yes, I'm available under the proper circumstances for a consulting gig. + + +From pgsql-performance-owner@postgresql.org Tue Sep 13 08:05:25 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B8157D8C38 + for ; + Tue, 13 Sep 2005 08:05:24 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 29912-09 + for ; + Tue, 13 Sep 2005 11:05:18 +0000 (GMT) +Received: from www.epot.cz (sramek.casablanca.cz [81.0.254.161]) + by svr1.postgresql.org (Postfix) with ESMTP id D766FD8B51 + for ; + Tue, 13 Sep 2005 08:05:17 -0300 (ADT) +Received: from www.epot.cz (localhost [127.0.0.1]) + by www.epot.cz (8.13.3/8.12.10) with ESMTP id j8DB59Z1052485 + for ; + Tue, 13 Sep 2005 13:05:09 +0200 (CEST) (envelope-from dali@insula.cz) +Received: (from xsramek01@localhost) + by www.epot.cz (8.13.3/8.12.10/Submit) id j8DB59aP052483 + for pgsql-performance@postgresql.org; + Tue, 13 Sep 2005 13:05:09 +0200 (CEST) (envelope-from dali@insula.cz) +X-Authentication-Warning: www.epot.cz: xsramek01 set sender to dali@insula.cz + using -f +Date: Tue, 13 Sep 2005 13:05:09 +0200 +From: Dalibor Sramek +To: pgsql-performance@postgresql.org +Subject: Low performance on Windows problem +Message-ID: <20050913110509.GA52174@www.epot.cz> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned-By: Clam AntiVirus - OK +X-Scanned-By: MIMEDefang 2.52 on 81.0.254.161 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 required=5 tests=[FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/158 +X-Sequence-Number: 14466 + +Hello. + +I would like to build a shared repository for Enterprise Architect +(http://www.sparxsystems.com.au/ea.htm) using PostgreSQL. I have done it +before with Linux and FreeBSD servers and everything was working out of the +box. The repository is pretty simple database with less than 100 tables (the +schema is at +http://www.sparxsystems.com.au/downloads/corp/Postgres_Basemodel.sql). + +The problem is that at the moment I have only a Windows XP "server" at my +disposal. I have installed PostgreSQL 8.0.3 for Windows and set the +repository up. Unfortunately the performance is unacceptable: every +operation with the model stored in the repository is by the order of +magnitude slower than on the FreeBSD server with half as good hardware. +(BTW CPU load is nearly 0, network load is under 5%, the machine has 1GB +RAM and the database size is 14MB.) + +I have tried to: +- tweak the postgresql.conf - no apparent change +- kill all unnecessary services - no apparent change +- install MySQL on the same machine to compare - it is as fast as PostgreSQL + on FreeBSD (= way faster than PG on the machine) + +Anyway I believe the problem is in the Win PostgreSQL server but I have no +idea where to look and neither do I have much time to spend. +(Also I really do not want to run MySQL ;-) + +Any suggestions are welcome. + +Thanks + +Dalibor Sramek + +P.S. + +More information about EA PGSQL repositories: +http://sparxsystems.com.au/resources/corporate/ +http://sparxsystems.com.au/EAUserGuide/index.html?connecttoapostgresqlreposi.htm +http://sparxsystems.com.au/EAUserGuide/index.html?setupapostgresqlodbcdriver.htm + +-- +Dalibor Sramek http://www.insula.cz/dali \ In the eyes of cats + / dalibor.sramek@insula.cz \ all things +/ >H blog http://www.transhumanismus.cz/blog.php \ belong to cats. + +From pgsql-performance-owner@postgresql.org Tue Sep 13 08:17:32 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D0A6ED789A + for ; + Tue, 13 Sep 2005 08:17:31 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 30210-10 + for ; + Tue, 13 Sep 2005 11:17:26 +0000 (GMT) +Received: from front-mail.cpln.ch (mail.cpln.ch [157.26.190.4]) + by svr1.postgresql.org (Postfix) with ESMTP id 8C301D723D + for ; + Tue, 13 Sep 2005 08:17:25 -0300 (ADT) +Received: from back-mail.cpln.ch ([157.26.160.7]) by front-mail.cpln.ch with + Microsoft SMTPSVC(6.0.3790.211); Tue, 13 Sep 2005 13:17:27 +0200 +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: Opencms6 ans Postgres8 +Date: Tue, 13 Sep 2005 13:17:27 +0200 +Message-ID: <3E2CA694B71ECB45B3486CE93F8B956E49E3BA@back-mail.cpln.ch> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: Opencms6 ans Postgres8 +Thread-Index: AcW4VLk1tW7rcnL4SKaOHdAap3dZMA== +From: "Bouchard Sylvie" +To: +X-OriginalArrivalTime: 13 Sep 2005 11:17:27.0787 (UTC) + FILETIME=[B970D3B0:01C5B854] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.312 required=5 tests=[AWL=0.262, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/159 +X-Sequence-Number: 14467 + +Good afternoon, +We have an application based on opencms6 / Tomcat5. The data management = +of the content is kept in a PostgreSQL 8.0.2 base. +The pages' display is extremely slow (it can take up to several minutes = +per refresh). Thus, it would not be applicable in production. +Material configuration details of the server hosting PostgreSQL : +- Windows Server 2003 +- Bi-processor Intel Xeon 3.0 GHz +- RAM 4 Go +- Disks on SAN - access through optical fibre +I have noticed that several sequential accesses happen on the tables of = +the cms during the questioning. +My questions : +What would be the best configuration parameters of the postgresql.conf = +file (or another file) to enhance the performances ? +What could we do on Opencms' side to improve the data interrogation? +Is the creation of the tables (index) through opencms optimum ? +Your advices are most welcome. +Sylvie + + + +From pgsql-performance-owner@postgresql.org Tue Sep 13 08:58:28 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DB594D7F2B + for ; + Tue, 13 Sep 2005 08:58:26 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 42731-04 + for ; + Tue, 13 Sep 2005 11:58:19 +0000 (GMT) +Received: from Herge.rcsinc.local (unknown [70.89.208.142]) + by svr1.postgresql.org (Postfix) with ESMTP id 42989D778E + for ; + Tue, 13 Sep 2005 08:58:20 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Subject: Re: Low performance on Windows problem +Date: Tue, 13 Sep 2005 07:58:20 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3417DD312@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Low performance on Windows problem +Thread-Index: AcW4VgNz6wPRE73uRFy9sw6lUcPaWgAA9AAA +From: "Merlin Moncure" +To: "Dalibor Sramek" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.036 required=5 tests=[AWL=-0.015, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/160 +X-Sequence-Number: 14468 + +> Hello. +>=20 +> I would like to build a shared repository for Enterprise Architect +> (http://www.sparxsystems.com.au/ea.htm) using PostgreSQL. I have done +it +> before with Linux and FreeBSD servers and everything was working out +of +> the +> box. The repository is pretty simple database with less than 100 +tables +> (the +> schema is at +> http://www.sparxsystems.com.au/downloads/corp/Postgres_Basemodel.sql). +>=20 +> The problem is that at the moment I have only a Windows XP "server" at +my +> disposal. I have installed PostgreSQL 8.0.3 for Windows and set the +> repository up. Unfortunately the performance is unacceptable: every +> operation with the model stored in the repository is by the order of +> magnitude slower than on the FreeBSD server with half as good +hardware. +> (BTW CPU load is nearly 0, network load is under 5%, the machine has +1GB +> RAM and the database size is 14MB.) +>=20 +> I have tried to: +> - tweak the postgresql.conf - no apparent change +> - kill all unnecessary services - no apparent change +> - install MySQL on the same machine to compare - it is as fast as +> PostgreSQL +> on FreeBSD (=3D way faster than PG on the machine) +=20 +Can you give specific examples of cases that are not performing like you +expect? If possible, give a few queries with explain analyze times and +all that. + +Are you syncing your data? Win32 fsync is about 1/3 as fast as linux +fsync, although this was changed to fsync_writethrough for clarification +purposes. + +Merlin + +From pgsql-performance-owner@postgresql.org Tue Sep 13 10:50:13 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F246BD8C6F + for ; + Tue, 13 Sep 2005 10:50:12 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 65157-09 + for ; + Tue, 13 Sep 2005 13:50:03 +0000 (GMT) +Received: from www.epot.cz (sramek.casablanca.cz [81.0.254.161]) + by svr1.postgresql.org (Postfix) with ESMTP id 322D1D6D85 + for ; + Tue, 13 Sep 2005 10:50:04 -0300 (ADT) +Received: from www.epot.cz (localhost [127.0.0.1]) + by www.epot.cz (8.13.3/8.12.10) with ESMTP id j8DDnun1055433; + Tue, 13 Sep 2005 15:49:56 +0200 (CEST) (envelope-from dali@insula.cz) +Received: (from xsramek01@localhost) + by www.epot.cz (8.13.3/8.12.10/Submit) id j8DDnpnU055431; + Tue, 13 Sep 2005 15:49:51 +0200 (CEST) (envelope-from dali@insula.cz) +X-Authentication-Warning: www.epot.cz: xsramek01 set sender to dali@insula.cz + using -f +Date: Tue, 13 Sep 2005 15:49:51 +0200 +From: Dalibor Sramek +To: Merlin Moncure +Cc: pgsql-performance@postgresql.org +Subject: Re: Low performance on Windows problem +Message-ID: <20050913134951.GA53837@www.epot.cz> +References: <6EE64EF3AB31D5448D0007DD34EEB3417DD312@Herge.rcsinc.local> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB3417DD312@Herge.rcsinc.local> +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned-By: Clam AntiVirus - OK +X-Scanned-By: MIMEDefang 2.52 on 81.0.254.161 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 required=5 tests=[FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/161 +X-Sequence-Number: 14469 + +On Tue, Sep 13, 2005 at 07:58:20AM -0400, Merlin Moncure wrote: +> Can you give specific examples of cases that are not performing like you +> expect? If possible, give a few queries with explain analyze times and +> all that. + +O.K. I have found one particular problem: + +2005-09-13 14:43:02 LOG: statement: declare SQL_CUR03949008 cursor for +SELECT * FROM t_umlpattern +2005-09-13 14:43:02 LOG: duration: 0.000 ms +2005-09-13 14:43:02 LOG: statement: fetch 1000 in SQL_CUR03949008 +2005-09-13 14:43:22 LOG: duration: 20185.000 ms + +This command is executed while a model is loaded from the repository. + +The table definition is: +CREATE TABLE t_umlpattern ( + PatternID INTEGER DEFAULT nextval('"patternid_seq"'::text) NOT NULL +PRIMARY KEY, + PatternCategory VARCHAR(100), + PatternName VARCHAR(150), + Style VARCHAR(250), + Notes TEXT, + PatternXML TEXT, + Version VARCHAR(50) +); + +It has just 23 rows but the PatternXML column is rather large. The table +dump has over 900 kB. + +Now +select * from t_umlpattern limit 2 + +takes 1500+ msec on the Windows machine and 60 on a comparable Linux +machine. Both selects performed from remote PgAdmin. +The same select performed localy on the windows machine takes 60 msec. + +So I guess the problem is in the transfer of the bigger amount of data from +the Windows server. + +I put the dump at http://www.insula.cz/dali/misc/table.zip + +Could anybody confirm the difference? + +Thanks for any suggestions. + +Dalibor Sramek + +-- +Dalibor Sramek http://www.insula.cz/dali \ In the eyes of cats + / dalibor.sramek@insula.cz \ all things +/ >H blog http://www.transhumanismus.cz/blog.php \ belong to cats. + +From pgsql-performance-owner@postgresql.org Tue Sep 13 11:10:09 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 64CFDD8D39 + for ; + Tue, 13 Sep 2005 11:10:07 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 75580-06 + for ; + Tue, 13 Sep 2005 14:10:01 +0000 (GMT) +Received: from ns.snowman.net (ns.snowman.net [66.92.160.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 464F2D862D + for ; + Tue, 13 Sep 2005 11:10:02 -0300 (ADT) +Received: by ns.snowman.net (Postfix, from userid 1000) + id 685AB17AD3; Tue, 13 Sep 2005 10:10:31 -0400 (EDT) +Date: Tue, 13 Sep 2005 10:10:31 -0400 +From: Stephen Frost +To: Brandon Black +Cc: Greg Stark , pgsql-performance@postgresql.org +Subject: Re: Performance considerations for very heavy INSERT traffic +Message-ID: <20050913141031.GJ6026@ns.snowman.net> +Mail-Followup-To: Brandon Black , + Greg Stark , pgsql-performance@postgresql.org +References: <84621a6050912140464c380c3@mail.gmail.com> + <87slw91x8a.fsf@stark.xeocode.com> + <84621a605091220442775249b@mail.gmail.com> +Mime-Version: 1.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; boundary="WI3x0E7Qla8PXOxb" +Content-Disposition: inline +In-Reply-To: <84621a605091220442775249b@mail.gmail.com> +X-Editor: Vim http://www.vim.org/ +X-Info: http://www.snowman.net +X-Operating-System: Linux/2.4.24ns.3.0 (i686) +X-Uptime: 10:08:07 up 94 days, 6:24, 11 users, load average: 0.01, 0.09, 0.09 +User-Agent: Mutt/1.5.9i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.004 required=5 tests=[AWL=0.004] +X-Spam-Level: +X-Archive-Number: 200509/162 +X-Sequence-Number: 14470 + + +--WI3x0E7Qla8PXOxb +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +Content-Transfer-Encoding: quoted-printable + +* Brandon Black (blblack@gmail.com) wrote: +> Ideally I'd like to commit the data seperately, as the data could contain= +=20 +> errors which abort the transaction, but it may come down to batching it a= +nd=20 +> coding things such that I can catch and discard the offending row and ret= +ry=20 +> the transaction if it fails (which should be fairly rare I would hope). I= +=20 + +Don't really know if it'd be better, or worse, or what, but another +thought to throw out there is to perhaps use savepoints instead of full +transactions? Not sure if that's more expensive or cheaper than doing +full commits but it might be something to consider. + +> When I finally get all of this sorted out and working reasonably optimall= +y,=20 +> I'll be sure to come back and report what techniques/settings did and did= +n't=20 +> work for this workload. + +That'd be great, many thanks, + + Stephen + +--WI3x0E7Qla8PXOxb +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) + +iD8DBQFDJt3WrzgMPqB3kigRAtKVAJ4hZygNkds1YkkSHMTzcnq4w4nruQCgnUzG +XE5xhwTNvrQjpMchqZil9CA= +=cq5c +-----END PGP SIGNATURE----- + +--WI3x0E7Qla8PXOxb-- + +From pgsql-performance-owner@postgresql.org Tue Sep 13 11:20:17 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EFDADD8D3D + for ; + Tue, 13 Sep 2005 11:20:14 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 77201-07 + for ; + Tue, 13 Sep 2005 14:20:04 +0000 (GMT) +Received: from Herge.rcsinc.local (unknown [70.89.208.142]) + by svr1.postgresql.org (Postfix) with ESMTP id B5C19D8D05 + for ; + Tue, 13 Sep 2005 11:20:03 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Subject: Re: Low performance on Windows problem +Date: Tue, 13 Sep 2005 10:20:05 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3417DD315@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Low performance on Windows problem +Thread-Index: AcW4ahCBOcYF9Fw/R3eTRFskBMbaYAAAu5uw +From: "Merlin Moncure" +To: "Dalibor Sramek" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.036 required=5 tests=[AWL=-0.014, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/163 +X-Sequence-Number: 14471 + +> On Tue, Sep 13, 2005 at 07:58:20AM -0400, Merlin Moncure wrote: +> This command is executed while a model is loaded from the repository. +>=20 +> The table definition is: +> CREATE TABLE t_umlpattern ( +> PatternID INTEGER DEFAULT nextval('"patternid_seq"'::text) NOT +NULL +> PRIMARY KEY, +> PatternCategory VARCHAR(100), +> PatternName VARCHAR(150), +> Style VARCHAR(250), +> Notes TEXT, +> PatternXML TEXT, +> Version VARCHAR(50) +> ); +>=20 +> It has just 23 rows but the PatternXML column is rather large. The +table +> dump has over 900 kB. +>=20 +> Now +> select * from t_umlpattern limit 2 +>=20 +> takes 1500+ msec on the Windows machine and 60 on a comparable Linux +> machine. Both selects performed from remote PgAdmin. +> The same select performed localy on the windows machine takes 60 msec. +>=20 +> So I guess the problem is in the transfer of the bigger amount of data +> from +> the Windows server. +>=20 +> I put the dump at http://www.insula.cz/dali/misc/table.zip +>=20 +> Could anybody confirm the difference? +=20 +I loaded your dump and was able to select entire table in trivial time +from both pgAdmin and psql shell. I am suspecting some type of tcp +problem here. Can you confirm slow times on unloaded server? + +Merlin + +From pgsql-performance-owner@postgresql.org Tue Sep 13 11:50:54 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6C445D8999 + for ; + Tue, 13 Sep 2005 11:34:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 77779-09 + for ; + Tue, 13 Sep 2005 14:34:19 +0000 (GMT) +Received: from www.epot.cz (sramek.casablanca.cz [81.0.254.161]) + by svr1.postgresql.org (Postfix) with ESMTP id 93BC6D7F2B + for ; + Tue, 13 Sep 2005 11:34:20 -0300 (ADT) +Received: from www.epot.cz (localhost [127.0.0.1]) + by www.epot.cz (8.13.3/8.12.10) with ESMTP id j8DEYJQW001149; + Tue, 13 Sep 2005 16:34:19 +0200 (CEST) (envelope-from dali@insula.cz) +Received: (from xsramek01@localhost) + by www.epot.cz (8.13.3/8.12.10/Submit) id j8DEYE0I001147; + Tue, 13 Sep 2005 16:34:14 +0200 (CEST) (envelope-from dali@insula.cz) +X-Authentication-Warning: www.epot.cz: xsramek01 set sender to dali@insula.cz + using -f +Date: Tue, 13 Sep 2005 16:34:02 +0200 +From: Dalibor Sramek +To: Merlin Moncure +Cc: pgsql-performance@postgresql.org +Subject: Re: Low performance on Windows problem +Message-ID: <20050913143401.GA913@www.epot.cz> +References: <6EE64EF3AB31D5448D0007DD34EEB3417DD315@Herge.rcsinc.local> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB3417DD315@Herge.rcsinc.local> +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned-By: Clam AntiVirus - OK +X-Scanned-By: MIMEDefang 2.52 on 81.0.254.161 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 required=5 tests=[FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/164 +X-Sequence-Number: 14472 + +On Tue, Sep 13, 2005 at 10:20:05AM -0400, Merlin Moncure wrote: +> I loaded your dump and was able to select entire table in trivial time +> from both pgAdmin and psql shell. I am suspecting some type of tcp +> problem here. Can you confirm slow times on unloaded server? + +Did you run the select remotely on a Windows server? + +Yes the server load is practically 0. Note the difference between local and +remote execution of the command. I think you are right about the network +problem possibility. But it is bound to PostgreSQL. MySQL on the same +machine (and same database content) had no problem. + +So are there any known issues with PostgreSQL on Windows sending data to +remote hosts connected via ODBC? +What should I do to find out more debug info? + +Thanks + +Dalibor Sramek + +-- +Dalibor Sramek http://www.insula.cz/dali \ In the eyes of cats + / dalibor.sramek@insula.cz \ all things +/ >H blog http://www.transhumanismus.cz/blog.php \ belong to cats. + +From pgsql-performance-owner@postgresql.org Tue Sep 13 12:07:31 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B8F4DD8D1A + for ; + Tue, 13 Sep 2005 12:01:31 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81388-10 + for ; + Tue, 13 Sep 2005 15:01:26 +0000 (GMT) +Received: from gwmta.wicourts.gov (gwmta.wicourts.gov [165.219.244.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 31F29D8D08 + for ; + Tue, 13 Sep 2005 12:01:25 -0300 (ADT) +Received: from Courts-MTA by gwmta.wicourts.gov + with Novell_GroupWise; Tue, 13 Sep 2005 10:01:25 -0500 +Message-Id: +X-Mailer: Novell GroupWise Internet Agent 6.5.4 +Date: Tue, 13 Sep 2005 10:01:13 -0500 +From: "Kevin Grittner" +To: , +Cc: +Subject: Re: Low performance on Windows problem +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.005 required=5 tests=[AWL=0.005] +X-Spam-Level: +X-Archive-Number: 200509/166 +X-Sequence-Number: 14474 + +This is sounding suspiciously similar to behavior I've seen with other = +types of TCP database connections when the tcp-no-delay option is not on. = +Is it possible that the ODBC driver for Windows is not successfully = +setting this up? +=20 +-Kevin +=20 +=20 +>>> Dalibor Sramek 09/13/05 9:34 AM >>> +On Tue, Sep 13, 2005 at 10:20:05AM -0400, Merlin Moncure wrote: +> I loaded your dump and was able to select entire table in trivial time +> from both pgAdmin and psql shell. I am suspecting some type of tcp +> problem here. Can you confirm slow times on unloaded server? + +Did you run the select remotely on a Windows server? + +Yes the server load is practically 0. Note the difference between local = +and +remote execution of the command. I think you are right about the network +problem possibility. But it is bound to PostgreSQL. MySQL on the same +machine (and same database content) had no problem. + +So are there any known issues with PostgreSQL on Windows sending data to +remote hosts connected via ODBC? +What should I do to find out more debug info? + + +From pgsql-performance-owner@postgresql.org Tue Sep 13 12:06:29 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4C54DD8D45 + for ; + Tue, 13 Sep 2005 12:06:18 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 89516-02 + for ; + Tue, 13 Sep 2005 15:06:12 +0000 (GMT) +Received: from Herge.rcsinc.local (unknown [70.89.208.142]) + by svr1.postgresql.org (Postfix) with ESMTP id 1D76AD8CEE + for ; + Tue, 13 Sep 2005 12:06:10 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Subject: Re: Low performance on Windows problem +Date: Tue, 13 Sep 2005 11:05:00 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3417DD31A@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Low performance on Windows problem +Thread-Index: AcW4cD/Ybg3znjFHTjyytu3Cd8bmAAAAyj/Q +From: "Merlin Moncure" +To: "Dalibor Sramek" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.036 required=5 tests=[AWL=-0.014, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/165 +X-Sequence-Number: 14473 + +> Did you run the select remotely on a Windows server? + +yes. +=20 +> Yes the server load is practically 0. Note the difference between +local +> and +> remote execution of the command. I think you are right about the +network +> problem possibility. But it is bound to PostgreSQL. MySQL on the same +> machine (and same database content) had no problem. +>=20 +> So are there any known issues with PostgreSQL on Windows sending data +to +> remote hosts connected via ODBC? +> What should I do to find out more debug info? + +1. turn on all your logging and make sure we looking at the right place +(planner stats, etc). +2. run explain analyze and compare timings (which returns only explain +output). +3. do a select max(patternxml) test.t_umlpattern and observe the time. +4. do a select substr(patternxml, 1, 10) from test.t_umlpattern and +observe the time. +5. do select array_accum(q::text) from generate_series(1,10000) q; + +if array_accum errors out, do: + +CREATE AGGREGATE public.array_accum ( + sfunc =3D array_append, + basetype =3D anyelement, + stype =3D anyarray, + initcond =3D '{}' +); + +and observe the time. + +Merlin + +From pgsql-performance-owner@postgresql.org Tue Sep 13 13:04:55 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7E152D8D4F + for ; + Tue, 13 Sep 2005 12:25:52 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 95304-01 + for ; + Tue, 13 Sep 2005 15:25:50 +0000 (GMT) +Received: from i-free.spb.ru (i-free.spb.ru [194.105.194.152]) + by svr1.postgresql.org (Postfix) with ESMTP id EC4ACD6D9D + for ; + Tue, 13 Sep 2005 12:25:46 -0300 (ADT) +Received: from localhost (localhost [127.0.0.1]) + by i-free.spb.ru (Postfix) with ESMTP id 7C750308CB; + Tue, 13 Sep 2005 19:25:44 +0400 (MSD) +Received: from i-free.spb.ru ([127.0.0.1]) + by localhost (i-free [127.0.0.1]) (amavisd-new, port 10024) with LMTP + id 15421-01-2; Tue, 13 Sep 2005 19:25:44 +0400 (MSD) +Received: from office1.i-free.ru (office1.i-free.ru [81.222.216.82]) + by i-free.spb.ru (Postfix) with ESMTP id 0D11429CDD; + Tue, 13 Sep 2005 19:25:43 +0400 (MSD) +Received: from [192.168.0.250] (helo=deepcore) + by office1.i-free.ru with smtp (Exim 3.36 #1 (Debian)) + id 1EFCfH-0003ND-00; Tue, 13 Sep 2005 19:25:43 +0400 +Date: Tue, 13 Sep 2005 19:26:38 +0400 +From: evgeny gridasov +To: blblack@gmail.com +Cc: pgsql-performance@postgresql.org +Subject: Re: Performance considerations for very heavy INSERT +Message-Id: <20050913192638.3093c63c.eugrid@fpm.kubsu.ru> +In-Reply-To: <84621a6050912140464c380c3@mail.gmail.com> +References: <84621a6050912140464c380c3@mail.gmail.com> +X-Mailer: Sylpheed version 2.0.0 (GTK+ 2.6.2; i486-pc-linux-gnu) +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at i-free.spb.ru +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/169 +X-Sequence-Number: 14477 + +On Mon, 12 Sep 2005 16:04:06 -0500 +Brandon Black wrote: + +I've seen serveral tests PostgreSQL on JFS file system, it runs faster than using ext3. +Our production server works using JFS and RAID10, +we have 250K+ transactions per day and everything is OK. +Try switching to separate RAID10 arrays and use one for xlog, and others for data. +If you are using indexes, try to put them on separate RAID10 array. + +> Test hardware right now is a dual Opteron with 4G of ram, which we've barely +> gotten 1,000 clients running against. Current disk hardware in testing is +> whatever we could scrape together (4x 3-ware PCI hardware RAID controllers, +> with 8 SATA drives in a RAID10 array off of each - aggregated up in a 4-way +> stripe with linux md driver and then formatted as ext3 with an appropriate +> stride parameter and data=writeback). Production will hopefully be a 4-8-way +> Opteron, 16 or more G of RAM, and a fiberchannel hardware raid array or two +> (~ 1TB available RAID10 storage) with 15krpm disks and battery-backed write +> cache. + +-- +Evgeny Gridasov +Software Developer +I-Free, Russia + +From pgsql-performance-owner@postgresql.org Tue Sep 13 12:57:03 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AB051D6E69 + for ; + Tue, 13 Sep 2005 12:31:07 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 95293-04 + for ; + Tue, 13 Sep 2005 15:31:04 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.197]) + by svr1.postgresql.org (Postfix) with ESMTP id 2CF4BD8D0A + for ; + Tue, 13 Sep 2005 12:31:00 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id 36so2444532wra + for ; + Tue, 13 Sep 2005 08:30:59 -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:in-reply-to:mime-version:content-type:references; + b=dmyxwjiGAjKmXIwsNF7K7beoSpFOH4yi91/S3bmLNvZyDnc40nl27v2t3uJRxdFj2ZKWt0QXol3jmwv+ccsvJFVZa2GHQ5WCpGGIe0dZctpokeuKmHHvz+kZU4v+4VpVjOMMz/BkTqch3sDPEGOcpbW/uiQCMODPSLNiogxWp4g= +Received: by 10.54.43.21 with SMTP id q21mr560383wrq; + Tue, 13 Sep 2005 08:30:59 -0700 (PDT) +Received: by 10.54.158.11 with HTTP; Tue, 13 Sep 2005 08:30:59 -0700 (PDT) +Message-ID: <84621a6050913083079ef0559@mail.gmail.com> +Date: Tue, 13 Sep 2005 10:30:59 -0500 +From: Brandon Black +Reply-To: blblack@gmail.com +To: petrilli@gmail.com, pgsql-performance@postgresql.org +Subject: Re: Performance considerations for very heavy INSERT traffic +In-Reply-To: <59d991c40509122039773cac17@mail.gmail.com> +Mime-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_14396_27311434.1126625459081" +References: <84621a6050912140464c380c3@mail.gmail.com> + <59d991c40509122039773cac17@mail.gmail.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.349 required=5 tests=[AWL=-0.180, HTML_20_30=0.504, + HTML_MESSAGE=0.001, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200509/168 +X-Sequence-Number: 14476 + +------=_Part_14396_27311434.1126625459081 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +On 9/12/05, Christopher Petrilli wrote: +>=20 +>=20 +> 3) Use 8.1 and strongly look at Bizgres. The data partitioning is=20 +> critical. + + +I started looking closer at my options for partitioning (inheritance, union= +=20 +all), and at Bizgres today. Bizgres partitioning appears to be basically th= +e=20 +same kind of inheritance partitioning one can do in mainline PostgreSQL. Am= +=20 +I correct in thinking that the main difference is that they've coded suppor= +t=20 +for "enable_constraint_exclusion=3Dtrue" so that the query planner can be m= +ore=20 +effective at taking advantage of the partitioning when you've specified=20 +CHECK constraints on the child tables? I may go for 8.1 instead in that=20 +case, as the main win I'm looking for is that with inheritance I'll be doin= +g=20 +inserts into smaller tables instead of ones that grow to unmanageable sizes= +=20 +(and that I can drop old child tables instead of delete/vacuum). + +------=_Part_14396_27311434.1126625459081 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +

On 9/12/05, Christopher Petrilli <= +petrilli@gmail.com> wrote:
+
3) Use 8.1 and strongly look at Bizgres. The data partitioning is criti= +cal.

+ +I started looking closer at my options for partitioning (inheritance, +union all), and at Bizgres today.  Bizgres partitioning appears to be +basically the same kind of inheritance partitioning one can do in +mainline PostgreSQL.  Am I correct in thinking that the main differenc= +e +is that they've coded support for "enable_constraint_exclusion=3Dtrue&= +quot; so +that the query planner can be more effective at taking advantage of the +partitioning when you've specified CHECK constraints on the child +tables?  I may go for 8.1 instead in that case, as the main win I'm +looking for is that with inheritance I'll be doing inserts into smaller +tables instead of ones that grow to unmanageable sizes (and that I can +drop old child tables instead of delete/vacuum).
+
+
+ +------=_Part_14396_27311434.1126625459081-- + +From pgsql-performance-owner@postgresql.org Tue Sep 13 12:53:55 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 121EBD87F7 + for ; + Tue, 13 Sep 2005 12:32:23 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 90425-08 + for ; + Tue, 13 Sep 2005 15:32:17 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 231BAD8479 + for ; + Tue, 13 Sep 2005 12:32:16 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j8DFW24J023482; + Tue, 13 Sep 2005 11:32:02 -0400 (EDT) +To: Dalibor Sramek +Cc: Merlin Moncure , + pgsql-performance@postgresql.org +Subject: Re: Low performance on Windows problem +In-reply-to: <20050913134951.GA53837@www.epot.cz> +References: <6EE64EF3AB31D5448D0007DD34EEB3417DD312@Herge.rcsinc.local> + <20050913134951.GA53837@www.epot.cz> +Comments: In-reply-to Dalibor Sramek + message dated "Tue, 13 Sep 2005 15:49:51 +0200" +Date: Tue, 13 Sep 2005 11:32:02 -0400 +Message-ID: <23481.1126625522@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/167 +X-Sequence-Number: 14475 + +Dalibor Sramek writes: +> select * from t_umlpattern limit 2 +> takes 1500+ msec on the Windows machine and 60 on a comparable Linux +> machine. Both selects performed from remote PgAdmin. +> The same select performed localy on the windows machine takes 60 msec. + +So it's a networking issue. I haven't paid real close attention to +Windows problems, but I recall that we've heard a couple of reports +of Windows performance problems that were resolved by removing various +third-party network filters and/or installing Windows service pack +updates. Check through the list archives ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Sep 13 13:21:24 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 61E97D7EB7 + for ; + Tue, 13 Sep 2005 13:17:04 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 02431-07 + for ; + Tue, 13 Sep 2005 16:16:59 +0000 (GMT) +Received: from mailhost.intellivid.com (mailhost.intellivid.com + [64.32.200.11]) + by svr1.postgresql.org (Postfix) with ESMTP id 4CC54D8CEA + for ; + Tue, 13 Sep 2005 13:16:56 -0300 (ADT) +Received: from [192.168.2.68] (spectre.intellivid.com [192.168.2.68]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (Client did not present a certificate) + by newmail.intellivid.com (Postfix) with ESMTP id 2094DF180EB; + Tue, 13 Sep 2005 12:16:55 -0400 (EDT) +Subject: Re: Performance considerations for very heavy INSERT +From: Ian Westmacott +To: blblack@gmail.com +Cc: pgsql-performance@postgresql.org +In-Reply-To: <84621a6050913083079ef0559@mail.gmail.com> +References: <84621a6050912140464c380c3@mail.gmail.com> + <59d991c40509122039773cac17@mail.gmail.com> + <84621a6050913083079ef0559@mail.gmail.com> +Content-Type: text/plain +Organization: Intellivid Corp. +Message-Id: <1126628214.11675.55.camel@spectre.intellivid.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Tue, 13 Sep 2005 12:16:55 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/170 +X-Sequence-Number: 14478 + +On Tue, 2005-09-13 at 11:30, Brandon Black wrote: +> I started looking closer at my options for partitioning (inheritance, +> union all), and at Bizgres today. Bizgres partitioning appears to be +> basically the same kind of inheritance partitioning one can do in +> mainline PostgreSQL. Am I correct in thinking that the main +> difference is that they've coded support for +> "enable_constraint_exclusion=true" so that the query planner can be +> more effective at taking advantage of the partitioning when you've +> specified CHECK constraints on the child tables? I may go for 8.1 +> instead in that case, as the main win I'm looking for is that with +> inheritance I'll be doing inserts into smaller tables instead of ones +> that grow to unmanageable sizes (and that I can drop old child tables +> instead of delete/vacuum). + +Perhaps I missed something in this thread, but don't forget +you still need vacuum to reclaim XIDs. + + --Ian + + + +From pgsql-performance-owner@postgresql.org Tue Sep 13 14:21:34 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4983FD6E69 + for ; + Tue, 13 Sep 2005 14:21:32 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 14206-09 + for ; + Tue, 13 Sep 2005 17:21:27 +0000 (GMT) +Received: from mx1.surnet.cl (mx2.surnet.cl [216.155.73.181]) + by svr1.postgresql.org (Postfix) with ESMTP id 1D025D8D5E + for ; + Tue, 13 Sep 2005 14:21:26 -0300 (ADT) +Received: from unknown (HELO cluster.surnet.cl) ([216.155.73.165]) + by mx1.surnet.cl with ESMTP; 13 Sep 2005 13:21:12 -0400 +X-IronPort-AV: i="3.97,106,1125892800"; d="scan'208"; a="9169193:sNHT29812920" +Received: from alvh.no-ip.org (216.155.86.232) by cluster.surnet.cl (7.0.043) + (authenticated as alvherre@surnet.cl) + id 4322D7BF002CE23C; Tue, 13 Sep 2005 13:21:26 -0400 +Received: by alvh.no-ip.org (Postfix, from userid 1000) + id 6DBBDC2F862; Tue, 13 Sep 2005 13:22:43 -0400 (CLT) +Date: Tue, 13 Sep 2005 13:22:43 -0400 +From: Alvaro Herrera +To: Ian Westmacott +Cc: blblack@gmail.com, pgsql-performance@postgresql.org +Subject: Re: Performance considerations for very heavy INSERT +Message-ID: <20050913172243.GA18107@surnet.cl> +Mail-Followup-To: Ian Westmacott , + blblack@gmail.com, pgsql-performance@postgresql.org +References: <84621a6050912140464c380c3@mail.gmail.com> + <59d991c40509122039773cac17@mail.gmail.com> + <84621a6050913083079ef0559@mail.gmail.com> + <1126628214.11675.55.camel@spectre.intellivid.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Disposition: inline +Content-Transfer-Encoding: 8bit +In-Reply-To: <1126628214.11675.55.camel@spectre.intellivid.com> +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=2.669 required=5 tests=[AWL=-0.728, + DNS_FROM_RFC_ABUSE=0.374, DNS_FROM_RFC_POST=1.376, FORGED_RCVD_HELO=0.05, + RCVD_IN_SORBS_MISC=1.597] +X-Spam-Level: ** +X-Archive-Number: 200509/171 +X-Sequence-Number: 14479 + +On Tue, Sep 13, 2005 at 12:16:55PM -0400, Ian Westmacott wrote: +> On Tue, 2005-09-13 at 11:30, Brandon Black wrote: +> > I started looking closer at my options for partitioning (inheritance, +> > union all), and at Bizgres today. Bizgres partitioning appears to be +> > basically the same kind of inheritance partitioning one can do in +> > mainline PostgreSQL. Am I correct in thinking that the main +> > difference is that they've coded support for +> > "enable_constraint_exclusion=true" so that the query planner can be +> > more effective at taking advantage of the partitioning when you've +> > specified CHECK constraints on the child tables? I may go for 8.1 +> > instead in that case, as the main win I'm looking for is that with +> > inheritance I'll be doing inserts into smaller tables instead of ones +> > that grow to unmanageable sizes (and that I can drop old child tables +> > instead of delete/vacuum). +> +> Perhaps I missed something in this thread, but don't forget +> you still need vacuum to reclaim XIDs. + +Yes, but if you are going to drop the partition before 1 billion +transactions, you can skip vacuuming it completely. + +-- +Alvaro Herrera -- Valdivia, Chile Architect, www.EnterpriseDB.com +"Es fil�sofo el que disfruta con los enigmas" (G. Coli) + +From pgsql-performance-owner@postgresql.org Tue Sep 13 16:54:23 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 19606D8D46 + for ; + Tue, 13 Sep 2005 16:21:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 48916-07 + for ; + Tue, 13 Sep 2005 19:21:29 +0000 (GMT) +Received: from www.epot.cz (sramek.casablanca.cz [81.0.254.161]) + by svr1.postgresql.org (Postfix) with ESMTP id 520D0D86F2 + for ; + Tue, 13 Sep 2005 16:21:28 -0300 (ADT) +Received: from www.epot.cz (localhost [127.0.0.1]) + by www.epot.cz (8.13.3/8.12.10) with ESMTP id j8DJLN0Y005473; + Tue, 13 Sep 2005 21:21:23 +0200 (CEST) (envelope-from dali@insula.cz) +Received: (from xsramek01@localhost) + by www.epot.cz (8.13.3/8.12.10/Submit) id j8DJLKA3005472; + Tue, 13 Sep 2005 21:21:20 +0200 (CEST) (envelope-from dali@insula.cz) +X-Authentication-Warning: www.epot.cz: xsramek01 set sender to dali@insula.cz + using -f +Date: Tue, 13 Sep 2005 21:21:20 +0200 +From: Dalibor Sramek +To: Tom Lane +Cc: pgsql-performance@postgresql.org +Subject: Re: Low performance on Windows problem +Message-ID: <20050913192120.GA5370@www.epot.cz> +References: <6EE64EF3AB31D5448D0007DD34EEB3417DD312@Herge.rcsinc.local> + <20050913134951.GA53837@www.epot.cz> + <23481.1126625522@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <23481.1126625522@sss.pgh.pa.us> +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned-By: Clam AntiVirus - OK +X-Scanned-By: MIMEDefang 2.52 on 81.0.254.161 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 required=5 tests=[AWL=-0.000, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/172 +X-Sequence-Number: 14480 + +On Tue, Sep 13, 2005 at 11:32:02AM -0400, Tom Lane wrote: +> So it's a networking issue. I haven't paid real close attention to +> ... +> updates. Check through the list archives ... + +This one +http://archives.postgresql.org/pgsql-performance/2005-06/msg00593.php + +seems to be very similar to my problem. Somebody suggested that setting +TCP_NODELAY option to the TCP connection may help. Before I dive into the +source: could some win-pg guru tell me if the Windows server tries to set +this option? Is it possible to change it via configuration? Is there a way +to find out if the TCP_NODELAY option was actually used for a connection? + +Anyway thank you all. I believe I am getting closer to a solution. + +Dalibor Sramek + +-- +Dalibor Sramek http://www.insula.cz/dali \ In the eyes of cats + / dalibor.sramek@insula.cz \ all things +/ >H blog http://www.transhumanismus.cz/blog.php \ belong to cats. + +From pgsql-performance-owner@postgresql.org Tue Sep 13 17:01:38 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4D5ECD8D5A + for ; + Tue, 13 Sep 2005 17:01:19 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 57148-10 + for ; + Tue, 13 Sep 2005 20:01:16 +0000 (GMT) +Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.202]) + by svr1.postgresql.org (Postfix) with ESMTP id 30767D8D46 + for ; + Tue, 13 Sep 2005 17:01:16 -0300 (ADT) +Received: by rproxy.gmail.com with SMTP id 1so33141rny + for ; + Tue, 13 Sep 2005 13: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:mime-version:content-type; + b=DVogbQOnOxlffYxVIGLWjQw2Ji+eo2Ofi2+8Pd8M297A/u9EZHpmtzHNCg/rd9ImGR4G2SDfrSv5/YXi0YrtHCaRl6bQB0sIeJ5Z99srJcOasVcRe8YrRmf8sFAfhVVnqzj0WFSQ3Cj2L59IwaLRLpVhvLdSr0HbGUbctVtzVJw= +Received: by 10.11.117.14 with SMTP id p14mr10206cwc; + Tue, 13 Sep 2005 13:01:16 -0700 (PDT) +Received: by 10.11.117.12 with HTTP; Tue, 13 Sep 2005 13:01:16 -0700 (PDT) +Message-ID: +Date: Tue, 13 Sep 2005 17:01:16 -0300 +From: Luiz Cesar de Lara +Reply-To: laralc@gmail.com +To: pgsql-performance@postgresql.org +Subject: unsubscribe +Mime-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_3767_8309189.1126641676310" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.54 required=5 tests=[AWL=-0.198, HTML_MESSAGE=0.001, + HTML_SHORT_LENGTH=0.713, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200509/173 +X-Sequence-Number: 14481 + +------=_Part_3767_8309189.1126641676310 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +unsubscribe-digest + +------=_Part_3767_8309189.1126641676310 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +unsubscribe-digest + +------=_Part_3767_8309189.1126641676310-- + +From pgsql-performance-owner@postgresql.org Mon Sep 19 19:37:22 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C49E2D8479 + for ; + Tue, 13 Sep 2005 17:24:05 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 66239-07 + for ; + Tue, 13 Sep 2005 20:24:00 +0000 (GMT) +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 17D4CD6E69 + for ; + Tue, 13 Sep 2005 17:24:00 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 45F8031F82; Tue, 13 Sep 2005 22:24:01 +0200 (MET DST) +From: "cydatamatt@gmail.com" +X-Newsgroups: pgsql.performance +Subject: How many tables is too many tables? +Date: 13 Sep 2005 13:23:52 -0700 +Organization: http://groups.google.com +Lines: 52 +Message-ID: <1126643032.787041.127400@z14g2000cwz.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/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; + rv:1.8b4) Gecko/20050908 Firefox/1.4,gzip(gfe),gzip(gfe) +Complaints-To: groups-abuse@google.com +Injection-Info: z14g2000cwz.googlegroups.com; posting-host=66.68.127.201; + posting-account=Xkq_jw0AAABOgBoG3cIfOrqwj2zOdvXQ +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/201 +X-Sequence-Number: 14509 + +I have a database of hundreds of millions of web links (between sites) +in Postgres. For each link, we record the url, the referer, and the +most recent date the link exists. I'm having some serious performance +issues when it comes to writing new data into the database. + +One machine is simply not going to be able to scale with the quantities +of links we hope to store information about and we want to move to some +kind of cluster. Because of the quantities of data, it seems to make +sense to go for a cluster setup such that in a 4 machine cluster, each +machine has a quarter of the data (is this "Share nothing," or, "Share +everything"?). To that end, we figured a good first step was to +partition the data on one machine into multiple tables defining the +logic which would find the appropriate table given a piece of data. +Then, we assumed, adding the logic to find the appropriate machine and +database in our cluster would only be an incremental upgrade. + +We implemented a partitioning scheme that segments the data by the +referring domain of each link. This is clearly not the most regular +(in terms of even distribution) means of partitioning, but the data in +each table is most likely related to each other, so queries would hit +the smallest number of tables. We currently have around 400,000 tables +and I would estimate that the vast majority of these tables are +relatively small (less than 200 rows). + +Our queries use UNION ALL to combine data from multiple tables (when +that's applicable, never more than 1000 tables at once, usually much +fewer). When writing to the database, the table for the referring +domain is locked while data is added and updated for the whole +referring domain at once. We only store one copy of each link, so when +loading we have to do a SELECT (for the date) then INSERT or UPDATE +where applicable for each link. + +At this point, the primary performance bottleneck is in adding +additional data to the database. Our loader program (we load text +files of link information) is currently getting about 40 rows a second, +which is nowhere near the performance we need to be seeing. In theory, +we want to be able to re-write our entire archive of data within on a +1-2 month cycle, so this is a very heavy write application (though +we're also constantly generating reports from the data, so its not +write only). + +Is the total number of tables prohibitively affecting our write speed +or is that an IO problem that can only be addressed by better drive +partitioning (all data is on one drive, which I've already read is a +problem)? Is this approach to data partitioning one which makes any +sense for performance, or should we move to a more normal distribution +of links across fewer tables which house more rows each? + +Thanks in advance for your advice. + +-matt + + +From pgsql-performance-owner@postgresql.org Tue Sep 13 18:09:43 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 17528D8D50 + for ; + Tue, 13 Sep 2005 18:08:30 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 71660-10 + for ; + Tue, 13 Sep 2005 21:08:26 +0000 (GMT) +Received: from greywolf.vistashare.net (65-116-16-98.dia.cust.qwest.net + [65.116.16.98]) + by svr1.postgresql.org (Postfix) with ESMTP id 1F90BD7F34 + for ; + Tue, 13 Sep 2005 18:08:26 -0300 (ADT) +Received: from phoenix.vistashare.net (phoenix.vistashare.net [10.100.2.210]) + by greywolf.vistashare.net (Postfix) with ESMTP id DEA2569A87 + for ; + Tue, 13 Sep 2005 17:08:27 -0400 (EDT) +From: Chris Kratz +Organization: VistaShare +To: pgsql-performance@postgresql.org +Subject: Help with performance on current status column +Date: Tue, 13 Sep 2005 17:08:26 -0400 +User-Agent: KMail/1.8 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200509131708.26638.chris.kratz@vistashare.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 required=5 tests=[FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/174 +X-Sequence-Number: 14482 + +Hello All, + +We are struggling with a specific query that is killing us. When doing +explain analyze on the entire query, we *seem* to be getting killed by the +estimated number of rows on a case statement calculation. + +I've included a snippet from the explain analyze of the much larger query. The +line in question, (cost=0.00..106.52 rows=1 width=16) (actual +time=0.048..67.728 rows=4725 loops=1) shows that it returned 4700 rows +instead of 1 which when coupled with a later join causes the statement to run +over 3 minutes.[1] + +It seems that it thinks that the scan on role_id is going to return 1 row, but +in reality returns 4725 rows. The case statement causing the problem uses +todays date to see if a particular row is still active. Here is a test case +showing how far off the estimate is from the reality. [2] + +I'm not too surprised to see that the estimate is off because it is +calculated, but does anyone know either how to make the estimate more +accurate so it picks a better plan, or is there a better way to do a "status" +function based off of the current date so that it is more efficient? I've +played with statistics on this table (racheting them up to 1000) with no +change in the plan. + +Any thoughts? + +-Chris + +[1] explain analyze snippet from larger query +-> Nested Loop (cost=0.00..955.70 rows=1 width=204) (actual +time=3096.689..202704.649 rows=17 loops=1) + Join Filter: ("inner".nameid = "outer".name_id) + -> Nested Loop (cost=0.00..112.25 rows=1 width=33) (actual +time=0.271..90.760 rows=4725 loops=1) + -> Index Scan using role_definition_description_idx on +role_definition rdf (cost=0.00..5.72 rows=1 width=21) (actual +time=0.215..0.218 rows=1 loops=1) + Index Cond: (description = 'Participant'::text) + Filter: (program_id = 120) + -> Index Scan using roles_role_id_idx on roles rol +(cost=0.00..106.52 rows=1 width=16) (actual time=0.048..67.728 rows=4725 +loops=1) + Index Cond: (rol.role_id = "outer".role_id) + Filter: (CASE WHEN (role_id IS NULL) THEN NULL::text WHEN +(("begin" IS NOT NULL) AND ("end" IS NOT NULL)) THEN CASE WHEN +((('now'::text)::date >= "begin") AND (('now'::text)::date <= "end")) THEN +'Active'::text ELSE 'Inactive'::text END WHEN ("begin" IS NOT NULL) THEN CASE +WHEN (('now'::text)::date >= "begin") THEN 'Active'::text ELSE +'Inactive'::text END WHEN ("end" IS NOT NULL) THEN CASE WHEN +(('now'::text)::date <= "end") THEN 'Active'::text ELSE 'Inactive'::text END +ELSE 'Active'::text END = 'Active'::text) + -> Nested Loop Left Join (cost=0.00..842.19 rows=97 width=175) (actual +time=6.820..42.863 rows=21 loops=4725) + -> Index Scan using namemaster_programid_idx on namemaster dem +(cost=0.00..470.12 rows=97 width=164) (actual time=6.811..42.654 rows=21 +loops=4725) + Index Cond: (programid = 120) + Filter: ((name_float_lfm ~~* '%clark%'::text) OR +(metaphone(name_float_lfm, 4) = 'KLRK'::text) OR (soundex(name_float_lfm) = +'C462'::text)) + -> Index Scan using validanswerid_pk on validanswer ina +(cost=0.00..3.82 rows=1 width=19) (actual time=0.003..0.004 rows=1 +loops=99225) + Index Cond: (ina.validanswerid = "outer".inactive) + +--------------------- +[2] A much simpler statement triggers the incorrect row counts here. + +explain analyze +select * +from roles rol +where + + CASE + WHEN rol.role_id IS NULL + THEN NULL + WHEN rol."begin" IS NOT NULL and rol."end" IS NOT NULL + THEN + CASE WHEN TIMESTAMP 'now'>=rol."begin" and TIMESTAMP +'now'<=rol."end" + THEN 'Active' + ELSE 'Inactive' END + WHEN rol."begin" IS NOT NULL + THEN + CASE WHEN TIMESTAMP 'now'>=rol."begin" + THEN 'Active' + ELSE 'Inactive' END + WHEN rol."end" IS NOT NULL + THEN + CASE WHEN TIMESTAMP 'now'<=rol."end" + THEN 'Active' + ELSE 'Inactive' END + ELSE 'Active' + END = 'Active' + +Seq Scan on roles rol (cost=0.00..2368.54 rows=413 width=20) (actual +time=0.046..562.635 rows=79424 loops=1) + Filter: (CASE WHEN (role_id IS NULL) THEN NULL::text WHEN (("begin" IS NOT +NULL) AND ("end" IS NOT NULL)) THEN CASE WHEN (('2005-09-13 +16:43:18.721214'::timestamp without time zone >= "begin") AND ('2005-09-13 +16:43:18.721214'::timestamp without time zone <= "end")) THEN 'Active'::text +ELSE 'Inactive'::text END WHEN ("begin" IS NOT NULL) THEN CASE WHEN +('2005-09-13 16:43:18.721214'::timestamp without time zone >= "begin") THEN +'Active'::text ELSE 'Inactive'::text END WHEN ("end" IS NOT NULL) THEN CASE +WHEN ('2005-09-13 16:43:18.721214'::timestamp without time zone <= "end") +THEN 'Active'::text ELSE 'Inactive'::text END ELSE 'Active'::text END = +'Active'::text) + Total runtime: 884.456 ms +(3 rows) +-- +Chris Kratz + +From pgsql-performance-owner@postgresql.org Tue Sep 13 19:28:34 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8F05DD7164 + for ; + Tue, 13 Sep 2005 19:28:32 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 96628-05 + for ; + Tue, 13 Sep 2005 22:28:26 +0000 (GMT) +Received: from cs.uoregon.edu (vitalstatistix.cs.uoregon.edu [128.223.4.19]) + by svr1.postgresql.org (Postfix) with ESMTP id 24970D8D36 + for ; + Tue, 13 Sep 2005 19:28:25 -0300 (ADT) +Received: from ix.cs.uoregon.edu (lili@ix [128.223.4.21]) + by cs.uoregon.edu (8.13.4/8.13.4) with ESMTP id j8DMSKZS016532 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) + for ; + Tue, 13 Sep 2005 15:28:26 -0700 (PDT) +Date: Tue, 13 Sep 2005 15:28:19 -0700 (PDT) +From: li li +To: pgsql-performance@postgresql.org +Subject: unsubscribe +In-Reply-To: +Message-ID: +References: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: ClamAV version 0.86.2, + clamav-milter version 0.86 on vitalstatistix +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.127 required=5 tests=[BLANK_LINES_70_80=1.127] +X-Spam-Level: * +X-Archive-Number: 200509/175 +X-Sequence-Number: 14483 + + + +unsubscribe-digest + + +From pgsql-performance-owner@postgresql.org Tue Sep 13 19:50:46 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D3EF4D8DB3 + for ; + Tue, 13 Sep 2005 19:50:44 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 02446-02 + for ; + Tue, 13 Sep 2005 22:50:40 +0000 (GMT) +Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.201]) + by svr1.postgresql.org (Postfix) with ESMTP id 2FAC8D8DA0 + for ; + Tue, 13 Sep 2005 19:50:39 -0300 (ADT) +Received: by xproxy.gmail.com with SMTP id h27so9623wxd + for ; + Tue, 13 Sep 2005 15:50:42 -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:mime-version:content-type; + b=QEj7U1VA6+ivOGz8h+YSEsgSov6pLPheLIf697WX3Qlt/Xr6yOQ412BPH7nqXUqbedIPXKQoOLCn2aNUMJuNRgEXyf01JrmRwAMn0MIT6FFW1mmi05+3trg5bXW7pk4xlzkug5CYyOV9WgbX54PsFjm8eFpHn+zGD61cG7+Djao= +Received: by 10.70.30.9 with SMTP id d9mr41716wxd; + Tue, 13 Sep 2005 15:50:42 -0700 (PDT) +Received: by 10.70.18.3 with HTTP; Tue, 13 Sep 2005 15:50:42 -0700 (PDT) +Message-ID: +Date: Tue, 13 Sep 2005 19:50:42 -0300 +From: Pryscila B Guttoski +Reply-To: pryscila.lista@gmail.com +To: pgsql-performance@postgresql.org +Subject: About method of PostgreSQL's Optimizer +Mime-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_28033_21851233.1126651842832" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.995 required=5 tests=[HTML_00_10=0.138, + HTML_MESSAGE=0.001, RCVD_BY_IP=0.024, RCVD_IN_BL_SPAMCOP_NET=1.832] +X-Spam-Level: * +X-Archive-Number: 200509/176 +X-Sequence-Number: 14484 + +------=_Part_28033_21851233.1126651842832 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Hello all! + +On my master course, I'm studying the PostgreSQL's optimizer. +I don't know if anyone in this list have been participated from the=20 +PostgreSQL's Optimizer development, but maybe someone can help me on this= +=20 +question. +PostgreSQL generates all possible plans of executing the query (using an=20 +almost exhaustive search), then gives a cost to each plan and finally the= +=20 +cheapest one is selected for execution. +There are other methods for query optimization, one of them is based on pla= +n=20 +transformations (for example, using A-Star algorithm) instead of plan=20 +constructions used by PostgreSQL.=20 +Does anyone know why this method was choosen? Are there any papers or=20 +researches about it? + +Thank's a lot, +Pryscila. + +------=_Part_28033_21851233.1126651842832 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Hello all!
+
+On my master course, I'm studying the PostgreSQL's optimizer.
+I don't know if anyone in this list have been participated from the +PostgreSQL's Optimizer development, but maybe someone can help me on +this question.
+PostgreSQL generates all possible plans of executing the query (using +an almost exhaustive search), then gives a cost to each plan and +finally the cheapest one is selected for execution.
+There are other methods for query optimization, one of them is based on +plan transformations (for example, using A-Star algorithm) instead of +plan constructions used by PostgreSQL.
+Does anyone know why this method was choosen? Are there any papers or resea= +rches about it?
+
+Thank's a lot,
+Pryscila.
+ + +------=_Part_28033_21851233.1126651842832-- + +From pgsql-performance-owner@postgresql.org Tue Sep 13 20:16:39 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AA28CD8DAA + for ; + Tue, 13 Sep 2005 20:16:37 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 06452-06 + for ; + Tue, 13 Sep 2005 23:16:27 +0000 (GMT) +Received: from mailbox.samurai.com (mailbox.samurai.com [205.207.28.82]) + by svr1.postgresql.org (Postfix) with ESMTP id 014EBD8AC5 + for ; + Tue, 13 Sep 2005 20:16:28 -0300 (ADT) +Received: from localhost (mailbox.samurai.com [205.207.28.82]) + by mailbox.samurai.com (Postfix) with ESMTP id B350D2396AB; + Tue, 13 Sep 2005 19:16:30 -0400 (EDT) +Received: from mailbox.samurai.com ([205.207.28.82]) + by localhost (mailbox.samurai.com [205.207.28.82]) (amavisd-new, + port 10024) + with LMTP id 92674-01-9; Tue, 13 Sep 2005 19:16:27 -0400 (EDT) +Received: from [192.168.1.101] (d226-86-55.home.cgocable.net [24.226.86.55]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mailbox.samurai.com (Postfix) with ESMTP id 2F9A923968A; + Tue, 13 Sep 2005 19:16:27 -0400 (EDT) +Message-ID: <43275DCA.7040006@samurai.com> +Date: Tue, 13 Sep 2005 19:16:26 -0400 +From: Neil Conway +User-Agent: Mozilla Thunderbird 1.0.2 (Macintosh/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pryscila.lista@gmail.com +Cc: pgsql-performance@postgresql.org +Subject: Re: About method of PostgreSQL's Optimizer +References: +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at mailbox.samurai.com +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/177 +X-Sequence-Number: 14485 + +Pryscila B Guttoski wrote: +> On my master course, I'm studying the PostgreSQL's optimizer. +> I don't know if anyone in this list have been participated from the +> PostgreSQL's Optimizer development, but maybe someone can help me on this +> question. + +pgsql-hackers might be more appropriate. + +> PostgreSQL generates all possible plans of executing the query (using an +> almost exhaustive search), then gives a cost to each plan and finally the +> cheapest one is selected for execution. +> There are other methods for query optimization, one of them is based on plan +> transformations (for example, using A-Star algorithm) instead of plan +> constructions used by PostgreSQL. + +Right, the main query planner uses a nearly-exhaustive search. For +queries with many joins (when the cost of an exhaustive search would be +prohibitive), "GEQO" is used, which uses a genetic algorithm to avoid an +exhaustive search of the solution space. + +> Does anyone know why this method was choosen? + +As far as I know, the main planner algorithm is fairly standard and is +mainly different from System R's canonical algorithm in the details, +like whether non-left-deep plans are pruned. + +> Are there any papers or researches about it? + +There are many papers on the System R algorithm and similar techniques, +which should explain the basic motivations for the design. I'm not aware +of any papers specifically on the PostgreSQL query optimizer, although +there have been a few presentations on it: + +http://neilc.treehou.se/optimizer.pdf +http://conferences.oreillynet.com/presentations/os2003/lane_tom.pdf + +-Neil + +From pgsql-performance-owner@postgresql.org Tue Sep 13 20:21:30 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0D7D7D8DC6 + for ; + Tue, 13 Sep 2005 20:21:28 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 09761-04 + for ; + Tue, 13 Sep 2005 23:21:23 +0000 (GMT) +Received: from hosting.commandprompt.com (128.commandprompt.com + [207.173.200.128]) + by svr1.postgresql.org (Postfix) with ESMTP id B94D0D8DC5 + for ; + Tue, 13 Sep 2005 20:21:23 -0300 (ADT) +Received: from [192.168.1.55] (fc1smp [66.93.38.87]) (authenticated bits=0) + by hosting.commandprompt.com (8.13.4/8.13.4) with ESMTP id + j8DNHtee024159; Tue, 13 Sep 2005 16:17:55 -0700 +Message-ID: <43275F56.8020303@commandprompt.com> +Date: Tue, 13 Sep 2005 16:23:02 -0700 +From: "Joshua D. Drake" +Organization: Command Prompt, Inc. +User-Agent: Mozilla Thunderbird 1.0.6-1.1.fc4 (X11/20050720) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pryscila.lista@gmail.com +Cc: pgsql-performance@postgresql.org +Subject: Re: About method of PostgreSQL's Optimizer +References: +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Greylist: Sender succeded SMTP AUTH authentication, not delayed by + milter-greylist-1.6 (hosting.commandprompt.com [192.168.1.101]); + Tue, 13 Sep 2005 16:17:55 -0700 (PDT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.012 required=5 tests=[AWL=0.012] +X-Spam-Level: +X-Archive-Number: 200509/178 +X-Sequence-Number: 14486 + +Pryscila B Guttoski wrote: +> Hello all! +> +> On my master course, I'm studying the PostgreSQL's optimizer. +> I don't know if anyone in this list have been participated from the +> PostgreSQL's Optimizer development, but maybe someone can help me on +> this question. +> PostgreSQL generates all possible plans of executing the query (using an +> almost exhaustive search), then gives a cost to each plan and finally +> the cheapest one is selected for execution. +> There are other methods for query optimization, one of them is based on +> plan transformations (for example, using A-Star algorithm) instead of +> plan constructions used by PostgreSQL. +> Does anyone know why this method was choosen? Are there any papers or +> researches about it? + +You may want to pass this question over to pgsql-hackers. + +Sincerely, + +Joshua D. Drake + + +> +> Thank's a lot, +> Pryscila. + + +-- +Your PostgreSQL solutions company - Command Prompt, Inc. 1.800.492.2240 +PostgreSQL Replication, Consulting, Custom Programming, 24x7 support +Managed Services, Shared and Dedicated Hosting +Co-Authors: plPHP, plPerlNG - http://www.commandprompt.com/ + +From pgsql-performance-owner@postgresql.org Tue Sep 13 20:36:11 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id ED032D8DBF + for ; + Tue, 13 Sep 2005 20:34:26 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 10811-07 + for ; + Tue, 13 Sep 2005 23:34:19 +0000 (GMT) +Received: from mail.clickdiario.com (mail.clickdiario.com [70.85.167.114]) + by svr1.postgresql.org (Postfix) with ESMTP id 65104D8DB5 + for ; + Tue, 13 Sep 2005 20:34:20 -0300 (ADT) +Received: from localhost (localhost [127.0.0.1]) + by mail.clickdiario.com (Postfix) with ESMTP id 99F1810458; + Tue, 13 Sep 2005 18:36:58 -0500 (CDT) +Received: from mail.clickdiario.com ([127.0.0.1]) + by localhost (mail.clickdiario.com [127.0.0.1]) (amavisd-new, + port 10024) + with ESMTP id 20302-05; Tue, 13 Sep 2005 18:36:58 -0500 (CDT) +Received: from cristian (unknown [216.230.158.50]) + by mail.clickdiario.com (Postfix) with ESMTP id 1EC731002D; + Tue, 13 Sep 2005 18:36:56 -0500 (CDT) +Message-ID: <013601c5b8bb$564f7450$6500a8c0@gt.ClickDiario.local> +From: "Cristian Prieto" +To: , +References: +Subject: Re: About method of PostgreSQL's Optimizer +Date: Tue, 13 Sep 2005 17:31:54 -0600 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0133_01C5B889.088CC240" +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2900.2180 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at example.com +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.065 required=5 tests=[AWL=-0.031, HTML_50_60=0.095, + HTML_MESSAGE=0.001] +X-Spam-Level: +X-Archive-Number: 200509/179 +X-Sequence-Number: 14487 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0133_01C5B889.088CC240 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +I know you almost had read this, but I think it is a good paper to start = +with...=20 + +http://lca2005.linux.org.au/Papers/Neil%20Conway/Inside%20the%20PostgreSQ= +L%20Query%20Optimizer/pg_query_optimizer.pdf + +Anyway, do you know where could I get more info and theory about = +database optimizer plan? (in general) I like that topic, thanks a lot = +man! + ----- Original Message -----=20 + From: Pryscila B Guttoski=20 + To: pgsql-performance@postgresql.org=20 + Sent: Tuesday, September 13, 2005 4:50 PM + Subject: [PERFORM] About method of PostgreSQL's Optimizer + + + Hello all! + + On my master course, I'm studying the PostgreSQL's optimizer. + I don't know if anyone in this list have been participated from the = +PostgreSQL's Optimizer development, but maybe someone can help me on = +this question. + PostgreSQL generates all possible plans of executing the query (using = +an almost exhaustive search), then gives a cost to each plan and finally = +the cheapest one is selected for execution. + There are other methods for query optimization, one of them is based = +on plan transformations (for example, using A-Star algorithm) instead of = +plan constructions used by PostgreSQL.=20 + Does anyone know why this method was choosen? Are there any papers or = +researches about it? + + Thank's a lot, + Pryscila. + +------=_NextPart_000_0133_01C5B889.088CC240 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
I know you almost had read this, but I = +think it is=20 +a good paper to start with...
+
 
+
http://lca2005.linu= +x.org.au/Papers/Neil%20Conway/Inside%20the%20PostgreSQL%20Query%20Optimiz= +er/pg_query_optimizer.pdf
+
 
+
Anyway, do you know where could I get = +more info and=20 +theory about database optimizer plan? (in general) I like that topic, = +thanks a=20 +lot man!
+ +
----- Original Message -----
+ From:=20 + Pryscila B Guttoski = + +
To: pgsql-performance@postgr= +esql.org=20 +
+
Sent: Tuesday, September 13, = +2005 4:50=20 + PM
+
Subject: [PERFORM] About method = +of=20 + PostgreSQL's Optimizer
+

Hello all!

On my master course, I'm studying the = + + PostgreSQL's optimizer.
I don't know if anyone in this list have = +been=20 + participated from the PostgreSQL's Optimizer development, but maybe = +someone=20 + can help me on this question.
PostgreSQL generates all possible = +plans of=20 + executing the query (using an almost exhaustive search), then gives a = +cost to=20 + each plan and finally the cheapest one is selected for = +execution.
There are=20 + other methods for query optimization, one of them is based on plan=20 + transformations (for example, using A-Star algorithm) instead of plan=20 + constructions used by PostgreSQL.
Does anyone know why this method = +was=20 + choosen? Are there any papers or researches about it?

Thank's a = + + lot,
Pryscila.
+ +------=_NextPart_000_0133_01C5B889.088CC240-- + + +From pgsql-performance-owner@postgresql.org Tue Sep 13 20:37:06 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 24D57D8DCA + for ; + Tue, 13 Sep 2005 20:37:04 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 13479-02 + for ; + Tue, 13 Sep 2005 23:36:56 +0000 (GMT) +Received: from mail.clickdiario.com (mail.clickdiario.com [70.85.167.114]) + by svr1.postgresql.org (Postfix) with ESMTP id B3E18D8DDC + for ; + Tue, 13 Sep 2005 20:36:58 -0300 (ADT) +Received: from localhost (localhost [127.0.0.1]) + by mail.clickdiario.com (Postfix) with ESMTP id 27BAE10458 + for ; + Tue, 13 Sep 2005 18:39:38 -0500 (CDT) +Received: from mail.clickdiario.com ([127.0.0.1]) + by localhost (mail.clickdiario.com [127.0.0.1]) (amavisd-new, + port 10024) + with ESMTP id 20299-08 for ; + Tue, 13 Sep 2005 18:39:38 -0500 (CDT) +Received: from cristian (unknown [216.230.158.50]) + by mail.clickdiario.com (Postfix) with ESMTP id 248FD1002D + for ; + Tue, 13 Sep 2005 18:39:36 -0500 (CDT) +Message-ID: <014a01c5b8bb$b57cfe70$6500a8c0@gt.ClickDiario.local> +From: "Cristian Prieto" +To: +Subject: Any other idea for better performance? +Date: Tue, 13 Sep 2005 17:34:36 -0600 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0147_01C5B889.6956BE50" +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2900.2180 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at example.com +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.032 required=5 tests=[AWL=0.004, HTML_60_70=0.027, + HTML_MESSAGE=0.001] +X-Spam-Level: +X-Archive-Number: 200509/180 +X-Sequence-Number: 14488 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0147_01C5B889.6956BE50 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +Hi, I've reading around there about some way to help pgsql with the data = +caching using memcached inside the sps in the database (not in the = +application), does anybody have success with that? + +Thanks a lot! +------=_NextPart_000_0147_01C5B889.6956BE50 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
Hi, I've reading around there about = +some way to=20 +help pgsql with the data caching using memcached inside the sps in the = +database=20 +(not in the application), does anybody have success with = +that?
+
 
+
Thanks a = +lot!
+ +------=_NextPart_000_0147_01C5B889.6956BE50-- + + +From pgsql-performance-owner@postgresql.org Tue Sep 13 21:40:51 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A0386D8D36 + for ; + Tue, 13 Sep 2005 21:40:49 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28826-03 + for ; + Wed, 14 Sep 2005 00:40:44 +0000 (GMT) +Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.193]) + by svr1.postgresql.org (Postfix) with ESMTP id 4E15DD8377 + for ; + Tue, 13 Sep 2005 21:40:45 -0300 (ADT) +Received: by xproxy.gmail.com with SMTP id i27so24021wxd + for ; + Tue, 13 Sep 2005 17:40:45 -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:in-reply-to:mime-version:content-type:references; + b=ETv7eoCpj13gWbN5SfSGoFRzae0sbc8vbbtY0XgyVO0nuGsWuV+HtxqXG1YwH7d+y9u62vQpEt0JIw6AYinIv8QhdggLJKcbQqpoEUuAT4JfPpDfbJe/bcIIFGV/gWJLk0ydBgwc9q/O3rt5ZgJHtYYCQIi2P9z/mn8XJ6bgGrs= +Received: by 10.70.21.12 with SMTP id 12mr5830wxu; + Tue, 13 Sep 2005 17:40:45 -0700 (PDT) +Received: by 10.70.18.3 with HTTP; Tue, 13 Sep 2005 17:40:45 -0700 (PDT) +Message-ID: +Date: Tue, 13 Sep 2005 21:40:45 -0300 +From: Pryscila B Guttoski +Reply-To: pryscila.lista@gmail.com +To: pgsql-performance@postgresql.org +Subject: Re: About method of PostgreSQL's Optimizer +In-Reply-To: <43275DCA.7040006@samurai.com> +Mime-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_28539_30568457.1126658445096" +References: + <43275DCA.7040006@samurai.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.262 required=5 tests=[AWL=0.733, HTML_20_30=0.504, + HTML_MESSAGE=0.001, RCVD_BY_IP=0.024] +X-Spam-Level: * +X-Archive-Number: 200509/181 +X-Sequence-Number: 14489 + +------=_Part_28539_30568457.1126658445096 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Thank's guys! +I'll send to pgsql-hackers... + +[]'s +Pryscila + +On 9/13/05, Neil Conway wrote: +>=20 +> Pryscila B Guttoski wrote: +> > On my master course, I'm studying the PostgreSQL's optimizer. +> > I don't know if anyone in this list have been participated from the +> > PostgreSQL's Optimizer development, but maybe someone can help me on=20 +> this +> > question. +>=20 +> pgsql-hackers might be more appropriate. +>=20 +> > PostgreSQL generates all possible plans of executing the query (using a= +n +> > almost exhaustive search), then gives a cost to each plan and finally= +=20 +> the +> > cheapest one is selected for execution. +> > There are other methods for query optimization, one of them is based on= +=20 +> plan +> > transformations (for example, using A-Star algorithm) instead of plan +> > constructions used by PostgreSQL. +>=20 +> Right, the main query planner uses a nearly-exhaustive search. For +> queries with many joins (when the cost of an exhaustive search would be +> prohibitive), "GEQO" is used, which uses a genetic algorithm to avoid an +> exhaustive search of the solution space. +>=20 +> > Does anyone know why this method was choosen? +>=20 +> As far as I know, the main planner algorithm is fairly standard and is +> mainly different from System R's canonical algorithm in the details, +> like whether non-left-deep plans are pruned. +>=20 +> > Are there any papers or researches about it? +>=20 +> There are many papers on the System R algorithm and similar techniques, +> which should explain the basic motivations for the design. I'm not aware +> of any papers specifically on the PostgreSQL query optimizer, although +> there have been a few presentations on it: +>=20 +> http://neilc.treehou.se/optimizer.pdf +> http://conferences.oreillynet.com/presentations/os2003/lane_tom.pdf +>=20 +> -Neil +> + +------=_Part_28539_30568457.1126658445096 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Thank's guys!
+I'll send to pgsql-hackers...
+
+[]'s
+Pryscila

On 9/13/05, Neil Conway <ne= +ilc@samurai.com> wrote:
+Pryscila B Guttoski wrote:
> On my master course, I'm studying the Po= +stgreSQL's optimizer.
> I don't know if anyone in this list have been= + participated from the
> PostgreSQL's Optimizer development, but mayb= +e someone can help me on this +
> question.

pgsql-hackers might be more appropriate.

&= +gt; PostgreSQL generates all possible plans of executing the query (using a= +n
> almost exhaustive search), then gives a cost to each plan and fin= +ally the +
> cheapest one is selected for execution.
> There are other me= +thods for query optimization, one of them is based on plan
> transfor= +mations (for example, using A-Star algorithm) instead of plan
> const= +ructions used by PostgreSQL. +

Right, the main query planner uses a nearly-exhaustive search. For<= +br>queries with many joins (when the cost of an exhaustive search would be<= +br>prohibitive), "GEQO" is used, which uses a genetic algorithm t= +o avoid an +
exhaustive search of the solution space.

> Does anyone know w= +hy this method was choosen?

As far as I know, the main planner algor= +ithm is fairly standard and is
mainly different from System R's canonica= +l algorithm in the details, +
like whether non-left-deep plans are pruned.

> Are there any = +papers or researches about it?

There are many papers on the System R= + algorithm and similar techniques,
which should explain the basic motiva= +tions for the design. I'm not aware +
of any papers specifically on the PostgreSQL query optimizer, although<= +br>there have been a few presentations on it:

http://neilc.treehou.se/optimizer.pdf
+http://conferences.oreillynet.com/presentations/os2003/lane_tom.pdf

-Neil

+ +------=_Part_28539_30568457.1126658445096-- + +From pgsql-hackers-owner@postgresql.org Tue Sep 13 21:42:40 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 21DFBD8377 + for ; + Tue, 13 Sep 2005 21:42:00 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28988-01 + for ; + Wed, 14 Sep 2005 00:41:50 +0000 (GMT) +Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.192]) + by svr1.postgresql.org (Postfix) with ESMTP id 70D43D81CE + for ; + Tue, 13 Sep 2005 21:41:51 -0300 (ADT) +Received: by xproxy.gmail.com with SMTP id i27so24234wxd + for ; + Tue, 13 Sep 2005 17:41:56 -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:in-reply-to:mime-version:content-type:references; + b=EAtBBrHTUQCCewm9OsCp30wO1WYJlopr3scMH+LwOb94uT+wxVDvGA915kK/JXPT8BHX27HEcVJe+HA0FP4qwqyNtQ6mfOxi8q7FHB2Cd+dVhFeJXnmwCMqKkjNnoOF+yn+E4rGCDcLp8y79qCJxGBsqrF9UFbpO9lgVxfOW3yg= +Received: by 10.70.40.14 with SMTP id n14mr6030wxn; + Tue, 13 Sep 2005 17:41:56 -0700 (PDT) +Received: by 10.70.18.3 with HTTP; Tue, 13 Sep 2005 17:41:55 -0700 (PDT) +Message-ID: +Date: Tue, 13 Sep 2005 21:41:56 -0300 +From: Pryscila B Guttoski +Reply-To: pryscila.lista@gmail.com +To: pgsql-hackers@postgresql.org +Subject: About method of PostgreSQL's Optimizer +In-Reply-To: +Mime-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_28551_10923804.1126658516010" +References: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.835 required=5 tests=[AWL=0.672, HTML_00_10=0.138, + HTML_MESSAGE=0.001, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200509/632 +X-Sequence-Number: 73029 + +------=_Part_28551_10923804.1126658516010 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Hello all! + +On my master course, I'm studying the PostgreSQL's optimizer. +I don't know if anyone in this list have been participated from the=20 +PostgreSQL's Optimizer development, but maybe someone can help me on this= +=20 +question. +PostgreSQL generates all possible plans of executing the query (using an=20 +almost exhaustive search), then gives a cost to each plan and finally the= +=20 +cheapest one is selected for execution. +There are other methods for query optimization, one of them is based on pla= +n=20 +transformations (for example, using A-Star algorithm) instead of plan=20 +constructions used by PostgreSQL.=20 +Does anyone know why this method was choosen? Are there any papers or=20 +researches about it? + +Thank's a lot, +Pryscila. + +------=_Part_28551_10923804.1126658516010 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Hello all!
+
+On my master course, I'm studying the PostgreSQL's optimizer.
+I don't know if anyone in this list have been participated from the +PostgreSQL's Optimizer development, but maybe someone can help me on +this question.
+PostgreSQL generates all possible plans of executing the query (using +an almost exhaustive search), then gives a cost to each plan and +finally the cheapest one is selected for execution.
+There are other methods for query optimization, one of them is based on +plan transformations (for example, using A-Star algorithm) instead of +plan constructions used by PostgreSQL.
+Does anyone know why this method was choosen? Are there any papers or resea= +rches about it?
+
+Thank's a lot,
+Pryscila.
+ + +
+ +------=_Part_28551_10923804.1126658516010-- + +From pgsql-performance-owner@postgresql.org Tue Sep 13 22:35:02 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5C097D8E04 + for ; + Tue, 13 Sep 2005 22:34:59 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34993-08 + for ; + Wed, 14 Sep 2005 01:34:51 +0000 (GMT) +Received: from mailbox.samurai.com (mailbox.samurai.com [205.207.28.82]) + by svr1.postgresql.org (Postfix) with ESMTP id CFE30D8E03 + for ; + Tue, 13 Sep 2005 22:34:51 -0300 (ADT) +Received: from localhost (mailbox.samurai.com [205.207.28.82]) + by mailbox.samurai.com (Postfix) with ESMTP id C7A3F239795; + Tue, 13 Sep 2005 21:34:55 -0400 (EDT) +Received: from mailbox.samurai.com ([205.207.28.82]) + by localhost (mailbox.samurai.com [205.207.28.82]) (amavisd-new, + port 10024) + with LMTP id 04666-01-10; Tue, 13 Sep 2005 21:34:51 -0400 (EDT) +Received: from [192.168.1.101] (d226-86-55.home.cgocable.net [24.226.86.55]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mailbox.samurai.com (Postfix) with ESMTP id 30580239797; + Tue, 13 Sep 2005 21:34:51 -0400 (EDT) +Message-ID: <43277E3A.7070703@samurai.com> +Date: Tue, 13 Sep 2005 21:34:50 -0400 +From: Neil Conway +User-Agent: Mozilla Thunderbird 1.0.2 (Macintosh/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Cristian Prieto +Cc: pryscila.lista@gmail.com, pgsql-performance@postgresql.org +Subject: Re: About method of PostgreSQL's Optimizer +References: + <013601c5b8bb$564f7450$6500a8c0@gt.ClickDiario.local> +In-Reply-To: <013601c5b8bb$564f7450$6500a8c0@gt.ClickDiario.local> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at mailbox.samurai.com +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/182 +X-Sequence-Number: 14490 + +Cristian Prieto wrote: +> Anyway, do you know where could I get more info and theory about +> database optimizer plan? (in general) + +Personally I like this survey paper on query optimization: + + http://citeseer.csail.mit.edu/371707.html + +The paper also cites a lot of other papers that cover specific +techniques in more detail. + +-Neil + +From pgsql-performance-owner@postgresql.org Tue Sep 13 23:27:11 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8C59DD8DFB + for ; + Tue, 13 Sep 2005 23:27:00 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 48882-08 + for ; + Wed, 14 Sep 2005 02:26:54 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 05349D8DDF + for ; + Tue, 13 Sep 2005 23:26:56 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j8E2QwHQ028319; + Tue, 13 Sep 2005 22:26:58 -0400 (EDT) +To: Neil Conway +Cc: pryscila.lista@gmail.com, pgsql-performance@postgresql.org +Subject: Re: About method of PostgreSQL's Optimizer +In-reply-to: <43275DCA.7040006@samurai.com> +References: + <43275DCA.7040006@samurai.com> +Comments: In-reply-to Neil Conway + message dated "Tue, 13 Sep 2005 19:16:26 -0400" +Date: Tue, 13 Sep 2005 22:26:58 -0400 +Message-ID: <28318.1126664818@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/183 +X-Sequence-Number: 14491 + +Neil Conway writes: +> Pryscila B Guttoski wrote: +>> On my master course, I'm studying the PostgreSQL's optimizer. +>> I don't know if anyone in this list have been participated from the +>> PostgreSQL's Optimizer development, but maybe someone can help me on this +>> question. + +> pgsql-hackers might be more appropriate. + +AFAIK the basic code goes back to Berkeley days. Elein might possibly +remember something about it, but no one else that's on the project now +was involved then. The right place to look would be in the Berkeley +project's publications: + +http://db.cs.berkeley.edu//papers/ + +I agree with Neil's point that it's a spiritual descendant of System R +and there's plenty of material about that in the general database +literature. + + regards, tom lane + +From pgsql-hackers-owner@postgresql.org Wed Sep 14 00:08:43 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 36F41D76AB + for ; + Wed, 14 Sep 2005 00:08:40 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 63432-09 + for ; + Wed, 14 Sep 2005 03:08:36 +0000 (GMT) +Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.206]) + by svr1.postgresql.org (Postfix) with ESMTP id D7AAFD70C9 + for ; + Wed, 14 Sep 2005 00:08:34 -0300 (ADT) +Received: by rproxy.gmail.com with SMTP id 34so43418rns + for ; + Tue, 13 Sep 2005 20:08:32 -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=nVkTPe6uS7TgyhVEMPw5fe6H7397Bxr7KhALPjNcmEOy3YAf+N4GK1IwdiqJrobTst3T6wKIDiTq4fWpZimpJQWJtE2+9SjouesdVPbyJhEgerBAz++9gp0oJ2ucrz1npj0IfseE3/PlnLTf1SC8D6M5qERgY38N8kNAFAY6nQU= +Received: by 10.11.119.50 with SMTP id r50mr13065cwc; + Tue, 13 Sep 2005 20:08:32 -0700 (PDT) +Received: by 10.11.119.38 with HTTP; Tue, 13 Sep 2005 20:08:31 -0700 (PDT) +Message-ID: <36e6829205091320085993ceba@mail.gmail.com> +Date: Tue, 13 Sep 2005 23:08:31 -0400 +From: "Jonah H. Harris" +Reply-To: jonah.harris@gmail.com +To: pryscila.lista@gmail.com +Subject: Re: About method of PostgreSQL's Optimizer +Cc: pgsql-hackers@postgresql.org +In-Reply-To: +Mime-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_5829_7451872.1126667311980" +References: + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.549 required=5 tests=[AWL=0.020, HTML_20_30=0.504, + HTML_MESSAGE=0.001, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200509/638 +X-Sequence-Number: 73035 + +------=_Part_5829_7451872.1126667311980 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Pryscila, + +While I haven't been too involved in the open source PostgreSQL optimizer, = +I=20 +have done some work on it and optimizers in other database systems. + +Based on my work, it is my opinion that PostgreSQL, as-well-as other=20 +databases which use a cost-based optimizer, prefer a breadth-first algorith= +m=20 +because one cannot determine the "real" cost of each node at run-time=20 +without systematically examining all possibilities through calculation. Thi= +s=20 +is the opposite of a rule-based optimizer which defines heuristics which ca= +n=20 +be evaulated by a best-first algorithm such as A*. + +In a cost-based optimizer, the system must calculate the "cost" of each pat= +h=20 +based on data that changes during run-time including indexing, cardinality,= +=20 +tuple size, available memory, CPU usage, disk access times, etc. To a=20 +cost-based optimizer, every query is unique and therefore cannot follow a= +=20 +weighted path in the same fashion. I can certainly see A* being used in a= +=20 +rule-based optimizer but not in a real-time cost-based optimizer. + +Perhaps Tom, Bruce, et al have more specifics on PostgreSQL's=20 +implementation. + +-Jonah + + + +On 9/13/05, Pryscila B Guttoski wrote: +>=20 +> Hello all! +>=20 +> On my master course, I'm studying the PostgreSQL's optimizer. +> I don't know if anyone in this list have been participated from the=20 +> PostgreSQL's Optimizer development, but maybe someone can help me on this= +=20 +> question. +> PostgreSQL generates all possible plans of executing the query (using an= +=20 +> almost exhaustive search), then gives a cost to each plan and finally the= +=20 +> cheapest one is selected for execution. +> There are other methods for query optimization, one of them is based on= +=20 +> plan transformations (for example, using A-Star algorithm) instead of pla= +n=20 +> constructions used by PostgreSQL.=20 +> Does anyone know why this method was choosen? Are there any papers or=20 +> researches about it? +>=20 +> Thank's a lot, +> Pryscila. +> =20 + + + +--=20 +Respectfully, + +Jonah H. Harris, Database Internals Architect +EnterpriseDB Corporation +http://www.enterprisedb.com/ + +------=_Part_5829_7451872.1126667311980 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Pryscila,
+
+While I haven't been too involved in the open source PostgreSQL +optimizer, I have done some work on it and optimizers in other database +systems.
+
+Based on my work, it is my opinion that PostgreSQL, as-well-as other +databases which use a cost-based optimizer, prefer a breadth-first +algorithm because one cannot determine the "real" cost of each no= +de at +run-time without systematically examining all possibilities through +calculation.  This is the opposite of a rule-based optimizer which +defines heuristics which can be evaulated by a best-first algorithm +such as A*.
+
+In a cost-based optimizer, the system must calculate the "cost" o= +f each +path based on data that changes during run-time including indexing, +cardinality, tuple size, available memory, CPU usage, disk access +times, etc.  To a cost-based optimizer, every query is unique and +therefore cannot follow a weighted path in the same fashion.  I +can certainly see A* being used in a rule-based optimizer but not in a +real-time cost-based optimizer.
+
+Perhaps Tom, Bruce, et al have more specifics on PostgreSQL's implementatio= +n.
+
+-Jonah
+
+
+
On 9/13/05, Pryscila B Guttoski <pryscila.lista@gmail.com> wrote:
+Hello all!
+
+On my master course, I'm studying the PostgreSQL's optimizer.
+I don't know if anyone in this list have been participated from the +PostgreSQL's Optimizer development, but maybe someone can help me on +this question.
+PostgreSQL generates all possible plans of executing the query (using +an almost exhaustive search), then gives a cost to each plan and +finally the cheapest one is selected for execution.
+There are other methods for query optimization, one of them is based on +plan transformations (for example, using A-Star algorithm) instead of +plan constructions used by PostgreSQL.
+Does anyone know why this method was choosen? Are there any papers or resea= +rches about it?
+
+Thank's a lot,
+Pryscila.
+ + +
+ +



--
Respectfully,
Jonah H. Harris, Database Internals Architect
EnterpriseDB Corporat= +ion
http://www.enterprisedb.com= +/ +
+ +------=_Part_5829_7451872.1126667311980-- + +From pgsql-performance-owner@postgresql.org Wed Sep 14 00:22:02 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5FC70D853A + for ; + Wed, 14 Sep 2005 00:20:43 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 67886-03 + for ; + Wed, 14 Sep 2005 03:20:20 +0000 (GMT) +Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.200]) + by svr1.postgresql.org (Postfix) with ESMTP id 69AA6D70BC + for ; + Wed, 14 Sep 2005 00:20:19 -0300 (ADT) +Received: by xproxy.gmail.com with SMTP id h28so68224wxd + for ; + Tue, 13 Sep 2005 20:20:19 -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=frIOsZ5FTajXRlotera0I/JZWGhm7PawyPA0Km16RCzNvgrfxAEOlxNBNZdwDW62hLoVnj3GJWGeEhwEdq0qacivsO56vTE+OG2xCZLtsbXmlktp3S2APDDBt91BATbZdOcU76cDKVBEEomuU70I0aSUJai7cQ2eZogYe+Y5yuU= +Received: by 10.70.131.13 with SMTP id e13mr116560wxd; + Tue, 13 Sep 2005 20:20:19 -0700 (PDT) +Received: by 10.70.18.3 with HTTP; Tue, 13 Sep 2005 20:20:19 -0700 (PDT) +Message-ID: +Date: Wed, 14 Sep 2005 00:20:19 -0300 +From: Pryscila B Guttoski +Reply-To: pryscila.lista@gmail.com +To: Tom Lane +Subject: Re: About method of PostgreSQL's Optimizer +Cc: Neil Conway , pgsql-performance@postgresql.org +In-Reply-To: <28318.1126664818@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_29428_5839971.1126668019297" +References: + <43275DCA.7040006@samurai.com> <28318.1126664818@sss.pgh.pa.us> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.404 required=5 tests=[AWL=-0.509, HTML_30_40=0.056, + HTML_MESSAGE=0.001, RCVD_BY_IP=0.024, + RCVD_IN_BL_SPAMCOP_NET=1.832] +X-Spam-Level: * +X-Archive-Number: 200509/184 +X-Sequence-Number: 14492 + +------=_Part_29428_5839971.1126668019297 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Hi guys, + +I really appreciate your suggestions abouts papers, specially this one:=20 +http://citeseer.csail.mit.edu/371707.html + +I found some answers on it, like this: + +Q: Why the main query planner uses a nearly-exhaustive search? +A: (Page 20 - 4.2.2) ... up to about ten joins, dynamic programming is=20 +preferred over the randomized algorithms because it is faster and it=20 +guarantees finding the optimal plan. For larger queries, the situation is= +=20 +reversed, and despite the probabilistic nature of the randomized algorithms= +,=20 +their efficiency makes them the algorithms of choice.=20 + +Also in this paper, there is something about the A* algorithm very=20 +interesting for my research. + +I have one more question, sorry for doing it on this list, but only here I= +=20 +had answers... +Does anybody hear anything about using PDDL ("Planning Domain Definition=20 +Language") for query optimization? + +[]'s, +Pryscila + +On 9/13/05, Tom Lane wrote: +>=20 +> Neil Conway writes: +> > Pryscila B Guttoski wrote: +> >> On my master course, I'm studying the PostgreSQL's optimizer. +> >> I don't know if anyone in this list have been participated from the +> >> PostgreSQL's Optimizer development, but maybe someone can help me on= +=20 +> this +> >> question. +>=20 +> > pgsql-hackers might be more appropriate. +>=20 +> AFAIK the basic code goes back to Berkeley days. Elein might possibly +> remember something about it, but no one else that's on the project now +> was involved then. The right place to look would be in the Berkeley +> project's publications: +>=20 +> http://db.cs.berkeley.edu//papers/ +>=20 +> I agree with Neil's point that it's a spiritual descendant of System R +> and there's plenty of material about that in the general database +> literature. +>=20 +> regards, tom lane +> + +------=_Part_29428_5839971.1126668019297 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Hi guys,
+
+I really appreciate your suggestions abouts papers, specially this one: http://citeseer.csail.mi= +t.edu/371707.html +
+
+I found some answers on it, like this:
+
+Q: Why the main query planner uses a nearly-exhaustive search?
+A: (Page 20 - 4.2.2) ... up to about ten joins, dynamic programming is +preferred over the randomized algorithms because it is faster and it +guarantees finding the optimal plan. For larger queries, the situation +is reversed, and despite the probabilistic nature of the randomized +algorithms, their efficiency makes them the algorithms of choice.
+
+Also in this paper, there is something about the A* algorithm very interest= +ing for my research.
+
+I have one more question, sorry for doing it on this list, but only here I = +had answers...
+Does anybody hear anything about using PDDL ("Planning Domain Definiti= +on Language") for query optimization?
+
+[]'s,
+Pryscila
+
On 9/13/05, Tom Lane <tgl@sss.pgh.pa.us= +> wrote:
+Neil Conway <neilc@samurai.com&= +gt; writes:
> Pryscila B Guttoski wrote:
>> On my master cou= +rse, I'm studying the PostgreSQL's optimizer.
>> I don't know if a= +nyone in this list have been participated from the +
>> PostgreSQL's Optimizer development, but maybe someone can help= + me on this
>> question.

> pgsql-hackers might be more a= +ppropriate.

AFAIK the basic code goes back to Berkeley days. &n= +bsp;Elein might possibly +
remember something about it, but no one else that's on the project now<= +br>was involved then.  The right place to look would be in the Be= +rkeley
project's publications:

+http://db.cs.berkeley.edu//papers/

I agree with Neil's point tha= +t it's a spiritual descendant of System R
and there's plenty of material= + about that in the general database
literature.

   = +;            &n= +bsp;        regards, +tom lane

+ +------=_Part_29428_5839971.1126668019297-- + +From pgsql-performance-owner@postgresql.org Wed Sep 14 06:15:27 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 12F7CD8E45 + for ; + Wed, 14 Sep 2005 06:15:27 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 47009-09 + for ; + Wed, 14 Sep 2005 09:15:22 +0000 (GMT) +Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) + by svr1.postgresql.org (Postfix) with ESMTP id F077BD6F0C + for ; + Wed, 14 Sep 2005 06:15:19 -0300 (ADT) +Received: from mainbox.archonet.com + (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) + by smtp.metronet.co.uk (MetroNet Mail) with ESMTP + id 0A7724186A2; Wed, 14 Sep 2005 10:15:13 +0100 (BST) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mainbox.archonet.com (Postfix) with ESMTP id 11A2015F1D; + Wed, 14 Sep 2005 10:14:03 +0100 (BST) +Received: from mainbox.archonet.com ([127.0.0.1]) + by localhost (mainbox [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 16461-03; Wed, 14 Sep 2005 10:13:58 +0100 (BST) +Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP id 9877E15F1C; + Wed, 14 Sep 2005 10:13:58 +0100 (BST) +Message-ID: <4327E9D6.5020203@archonet.com> +Date: Wed, 14 Sep 2005 10:13:58 +0100 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Chris Kratz +Cc: pgsql-performance@postgresql.org +Subject: Re: Help with performance on current status column +References: <200509131708.26638.chris.kratz@vistashare.com> +In-Reply-To: <200509131708.26638.chris.kratz@vistashare.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.057 required=5 tests=[AWL=0.007, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/185 +X-Sequence-Number: 14493 + +Chris Kratz wrote: +> Hello All, +> +> We are struggling with a specific query that is killing us. When doing +> explain analyze on the entire query, we *seem* to be getting killed by the +> estimated number of rows on a case statement calculation. +> +> I've included a snippet from the explain analyze of the much larger query. The +> line in question, (cost=0.00..106.52 rows=1 width=16) (actual +> time=0.048..67.728 rows=4725 loops=1) shows that it returned 4700 rows +> instead of 1 which when coupled with a later join causes the statement to run +> over 3 minutes.[1] +> +> It seems that it thinks that the scan on role_id is going to return 1 row, but +> in reality returns 4725 rows. The case statement causing the problem uses +> todays date to see if a particular row is still active. Here is a test case +> showing how far off the estimate is from the reality. [2] + +> [2] A much simpler statement triggers the incorrect row counts here. +> +> explain analyze +> select * +> from roles rol +> where +> +> CASE +> WHEN rol.role_id IS NULL +> THEN NULL +> WHEN rol."begin" IS NOT NULL and rol."end" IS NOT NULL +> THEN +> CASE WHEN TIMESTAMP 'now'>=rol."begin" and TIMESTAMP +> 'now'<=rol."end" +> THEN 'Active' +> ELSE 'Inactive' END +> WHEN rol."begin" IS NOT NULL +> THEN +> CASE WHEN TIMESTAMP 'now'>=rol."begin" +> THEN 'Active' +> ELSE 'Inactive' END +> WHEN rol."end" IS NOT NULL +> THEN +> CASE WHEN TIMESTAMP 'now'<=rol."end" +> THEN 'Active' +> ELSE 'Inactive' END +> ELSE 'Active' +> END = 'Active' + +Aside #1 - I'm not entirely clear how role_id can be null since you +seemed to be joining against it in the real query. + +Aside #2 - You're probably better off with CURRENT_DATE since begin/end +seem to be dates, rather than TIMESTAMP 'now' - and in any case you +wanted "timestamp with time zone" + +OK, I think the root of your problem is your use of null to mean "not +ended" or "not started" (whatever 'not started' means). PostgreSQL has +the handy timestamptz value "infinity", but only for timestamps and not +for dates. I'd probably cheat a little and use an end date of +'9999-12-31' or similar to simulate "infinity". Then your test is simply: + +WHERE + ... + AND (rol.begin <= CURRENT_DATE AND rol.end >= CURRENT_DATE) + +That should estimate simply enough. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Wed Sep 14 10:02:37 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BECD8D8D8C + for ; + Wed, 14 Sep 2005 10:02:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 98910-06 + for ; + Wed, 14 Sep 2005 13:02:31 +0000 (GMT) +Received: from www.epot.cz (sramek.casablanca.cz [81.0.254.161]) + by svr1.postgresql.org (Postfix) with ESMTP id C80B1D8D71 + for ; + Wed, 14 Sep 2005 10:02:30 -0300 (ADT) +Received: from www.epot.cz (localhost [127.0.0.1]) + by www.epot.cz (8.13.3/8.12.10) with ESMTP id j8ED2QDd019952; + Wed, 14 Sep 2005 15:02:26 +0200 (CEST) (envelope-from dali@insula.cz) +Received: (from xsramek01@localhost) + by www.epot.cz (8.13.3/8.12.10/Submit) id j8ED2MIY019950; + Wed, 14 Sep 2005 15:02:22 +0200 (CEST) (envelope-from dali@insula.cz) +X-Authentication-Warning: www.epot.cz: xsramek01 set sender to dali@insula.cz + using -f +Date: Wed, 14 Sep 2005 15:02:22 +0200 +From: Dalibor Sramek +To: Merlin Moncure +Cc: pgsql-performance@postgresql.org +Subject: Re: Low performance on Windows problem +Message-ID: <20050914130221.GA18466@www.epot.cz> +References: <6EE64EF3AB31D5448D0007DD34EEB3417DD31A@Herge.rcsinc.local> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB3417DD31A@Herge.rcsinc.local> +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned-By: Clam AntiVirus - OK +X-Scanned-By: MIMEDefang 2.52 on 81.0.254.161 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 required=5 tests=[FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/186 +X-Sequence-Number: 14494 + +On Tue, Sep 13, 2005 at 11:05:00AM -0400, Merlin Moncure wrote: +> 5. do select array_accum(q::text) from generate_series(1,10000) q; + +I made the tests you suggested and the pattern is clear. The difference +between local and remote command execution is caused by moving data over +the network. E.g. the command above takes 700 ms locally and 1500 ms +remotely. Remote explain analyze takes exactly the 700 ms. + +I downloaded PCATTCP - http://www.pcausa.com/Utilities/pcattcp.htm +and the measured throughput between the two machines is over 10000 kB/s. +PCATTCP allows setting TCP_NODELAY but it had no effect on the transfer +speed. So the difference between local and remote execution should IMHO stay +in the 10 ms range. Definitely not 800 ms. The 8.1 has the same problem. + +Just for the record: the server PC is Dell Precision 330 with 3Com 3C920 +integrated network card. OS MS Windows Professional 2002 with service pack +2. There is Symantec Antivirus installed - which I have (hopefully) +completely disabled. + +Thanks for any help + +Dalibor Sramek + +-- +Dalibor Sramek http://www.insula.cz/dali \ In the eyes of cats + / dalibor.sramek@insula.cz \ all things +/ >H blog http://www.transhumanismus.cz/blog.php \ belong to cats. + +From pgsql-performance-owner@postgresql.org Wed Sep 14 10:35:10 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2619BD709A + for ; + Wed, 14 Sep 2005 10:35:09 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 04989-06 + for ; + Wed, 14 Sep 2005 13:35:04 +0000 (GMT) +Received: from greywolf.vistashare.net (65-116-16-98.dia.cust.qwest.net + [65.116.16.98]) + by svr1.postgresql.org (Postfix) with ESMTP id 615C2D8E8B + for ; + Wed, 14 Sep 2005 10:34:57 -0300 (ADT) +Received: from phoenix.vistashare.net (phoenix.vistashare.net [10.100.2.210]) + by greywolf.vistashare.net (Postfix) with ESMTP id 0B2A7D258; + Wed, 14 Sep 2005 09:35:02 -0400 (EDT) +From: Chris Kratz +Organization: VistaShare +To: pgsql-performance@postgresql.org +Subject: Re: Help with performance on current status column +Date: Wed, 14 Sep 2005 09:35:00 -0400 +User-Agent: KMail/1.8 +Cc: Richard Huxton +References: <200509131708.26638.chris.kratz@vistashare.com> + <4327E9D6.5020203@archonet.com> +In-Reply-To: <4327E9D6.5020203@archonet.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200509140935.01029.chris.kratz@vistashare.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 required=5 tests=[FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/187 +X-Sequence-Number: 14495 + +Hello Richard, + +Thank you for the response. I did forget to mention that the columns have the +following meanings. + +One, if a begin or end date is null, it means that the role is open ended in +that direction. For example, if there is no end date, that means currently +the role will go on forever beginning with the start date. Your idea of +using minimal and maximum dates is an interesting one and not one that I had +considered. I will do some testing later today and see if that makes a +difference. + +The other option I am toying with is simply having a status column which is +updated nightly via a cron job. This will probably be the most efficient and +can be indexed. + +I also forgot to say that we have seen this behavior on 2 boxes both on Linux +(Red Hat ES & Mandrake) and both are running Postgres 8.0 (8.0.1 and 8.0.3). +Strangely, after playing with statistics some yesterday (setting from 10 to +100 to 1000 and back to 10 and analyzing), the 8.0.1 machine picks a +different plan and runs in a 101.104ms. The larger machine (dual proc Opt, 6 +disk raid 10, etc) with 8.0.3 still takes 3-5minutes to run the same query +with the same data set even after playing with statistics and repeated +analyze on the same table. It just seems odd. It seems it is picking the +incorrect plan based off of an overly optimistic estimate of rows returned +from the calculation. + +The other frustration with this is that this sql is machine generated which is +why we have some of the awkwardness in the calculation. That calc gets used +for a lot of different things including column definitions when people want +to see the column on screen. + +Thanks, + +-Chris + +On Wednesday 14 September 2005 05:13 am, Richard Huxton wrote: +> Chris Kratz wrote: +> > Hello All, +> > +> > We are struggling with a specific query that is killing us. When doing +> > explain analyze on the entire query, we *seem* to be getting killed by +> > the estimated number of rows on a case statement calculation. +> > +> > I've included a snippet from the explain analyze of the much larger +> > query. The line in question, (cost=0.00..106.52 rows=1 width=16) (actual +> > time=0.048..67.728 rows=4725 loops=1) shows that it returned 4700 rows +> > instead of 1 which when coupled with a later join causes the statement to +> > run over 3 minutes.[1] +> > +> > It seems that it thinks that the scan on role_id is going to return 1 +> > row, but in reality returns 4725 rows. The case statement causing the +> > problem uses todays date to see if a particular row is still active. +> > Here is a test case showing how far off the estimate is from the reality. +> > [2] +> > +> > [2] A much simpler statement triggers the incorrect row counts here. +> > +> > explain analyze +> > select * +> > from roles rol +> > where +> > +> > CASE +> > WHEN rol.role_id IS NULL +> > THEN NULL +> > WHEN rol."begin" IS NOT NULL and rol."end" IS NOT NULL +> > THEN +> > CASE WHEN TIMESTAMP 'now'>=rol."begin" and TIMESTAMP +> > 'now'<=rol."end" +> > THEN 'Active' +> > ELSE 'Inactive' END +> > WHEN rol."begin" IS NOT NULL +> > THEN +> > CASE WHEN TIMESTAMP 'now'>=rol."begin" +> > THEN 'Active' +> > ELSE 'Inactive' END +> > WHEN rol."end" IS NOT NULL +> > THEN +> > CASE WHEN TIMESTAMP 'now'<=rol."end" +> > THEN 'Active' +> > ELSE 'Inactive' END +> > ELSE 'Active' +> > END = 'Active' +> +> Aside #1 - I'm not entirely clear how role_id can be null since you +> seemed to be joining against it in the real query. +> +> Aside #2 - You're probably better off with CURRENT_DATE since begin/end +> seem to be dates, rather than TIMESTAMP 'now' - and in any case you +> wanted "timestamp with time zone" +> +> OK, I think the root of your problem is your use of null to mean "not +> ended" or "not started" (whatever 'not started' means). PostgreSQL has +> the handy timestamptz value "infinity", but only for timestamps and not +> for dates. I'd probably cheat a little and use an end date of +> '9999-12-31' or similar to simulate "infinity". Then your test is simply: +> +> WHERE +> ... +> AND (rol.begin <= CURRENT_DATE AND rol.end >= CURRENT_DATE) +> +> That should estimate simply enough. +> +> -- +> Richard Huxton +> Archonet Ltd +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 3: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faq + +-- +Chris Kratz + +From pgsql-performance-owner@postgresql.org Wed Sep 14 11:44:02 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 59284D8BA7 + for ; + Wed, 14 Sep 2005 11:23:49 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 72843-02 + for ; + Wed, 14 Sep 2005 14:23:39 +0000 (GMT) +Received: from gwmta.wicourts.gov (gwmta.wicourts.gov [165.219.244.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 5175BD709A + for ; + Wed, 14 Sep 2005 11:23:36 -0300 (ADT) +Received: from Courts-MTA by gwmta.wicourts.gov + with Novell_GroupWise; Wed, 14 Sep 2005 09:23:41 -0500 +Message-Id: +X-Mailer: Novell GroupWise Internet Agent 6.5.4 +Date: Wed, 14 Sep 2005 09:23:22 -0500 +From: "Kevin Grittner" +To: , +Cc: +Subject: Re: Low performance on Windows problem +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.004 required=5 tests=[AWL=0.004] +X-Spam-Level: +X-Archive-Number: 200509/188 +X-Sequence-Number: 14496 + +(1) Latency and throughput don't necessarily correlate well. When = +blasting +quantities of data to test throughput, TCP_NODELAY might not matter +much -- a full buffer will be sent without a delay anyway. What do you = +get +on a ping while running the throughput test? +=20 +(2) Besides the TCP_NODELAY issue, another issue which has caused +similar problems is a mismatch between half duplex and full duplex in the +configuration of the switch and the server. Sometimes auto-negotiate +doesn't work as advertised; you might want to try setting the configuration= + +explicitly, if you aren't already doing so. +=20 +-Kevin +=20 +=20 +>>> Dalibor Sramek 09/14/05 8:02 AM >>> +On Tue, Sep 13, 2005 at 11:05:00AM -0400, Merlin Moncure wrote: +> 5. do select array_accum(q::text) from generate_series(1,10000) q; + +I made the tests you suggested and the pattern is clear. The difference +between local and remote command execution is caused by moving data over +the network. E.g. the command above takes 700 ms locally and 1500 ms +remotely. Remote explain analyze takes exactly the 700 ms. + +I downloaded PCATTCP - http://www.pcausa.com/Utilities/pcattcp.htm +and the measured throughput between the two machines is over 10000 kB/s. +PCATTCP allows setting TCP_NODELAY but it had no effect on the transfer +speed. So the difference between local and remote execution should IMHO = +stay +in the 10 ms range. Definitely not 800 ms. The 8.1 has the same problem. + +Just for the record: the server PC is Dell Precision 330 with 3Com 3C920 +integrated network card. OS MS Windows Professional 2002 with service pack +2. There is Symantec Antivirus installed - which I have (hopefully) +completely disabled. + +Thanks for any help + +Dalibor Sramek + + +From pgsql-hackers-owner@postgresql.org Wed Sep 14 12:42:56 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4088BD8E81 + for ; + Wed, 14 Sep 2005 12:42:55 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 53740-07 + for ; + Wed, 14 Sep 2005 15:42:52 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 68FDED8E7F + for ; + Wed, 14 Sep 2005 12:42:51 -0300 (ADT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 8093860; Wed, 14 Sep 2005 08:45:10 -0700 +From: Josh Berkus +Organization: Aglio Database Solutions +To: pgsql-hackers@postgresql.org, jonah.harris@gmail.com +Subject: Re: About method of PostgreSQL's Optimizer +Date: Wed, 14 Sep 2005 08:44:02 -0700 +User-Agent: KMail/1.8 +Cc: pryscila.lista@gmail.com +References: + + <36e6829205091320085993ceba@mail.gmail.com> +In-Reply-To: <36e6829205091320085993ceba@mail.gmail.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200509140844.03449.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.011 required=5 tests=[AWL=0.011] +X-Spam-Level: +X-Archive-Number: 200509/661 +X-Sequence-Number: 73058 + +Pryscila, + +> > There are other methods for query optimization, one of them is based on +> > plan transformations (for example, using A-Star algorithm) instead of +> > plan constructions used by PostgreSQL. + +We do certainly need a specific optimization for large star-schema joins. I'm +not certain that A* is suitable for our cost model, though; I think we might +need to work up something more particular to Postgres. + +> > Does anyone know why this method was choosen? Are there any papers or +> > researches about it? + +There probably are on ACM but I've not read them. Ours is a pretty +straightforward implementation of a cost-based optimizer. You can always +read the code ;-) + +Mark Kirkwood put together this nice paper on planner statistics: +http://www.powerpostgresql.com/PlanStats + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-hackers-owner@postgresql.org Wed Sep 14 12:52:59 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3A8E6D8E9B + for ; + Wed, 14 Sep 2005 12:52:57 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 53952-05 + for ; + Wed, 14 Sep 2005 15:52:54 +0000 (GMT) +Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.194]) + by svr1.postgresql.org (Postfix) with ESMTP id 26B8CD8E83 + for ; + Wed, 14 Sep 2005 12:52:51 -0300 (ADT) +Received: by xproxy.gmail.com with SMTP id i28so27691wxd + for ; + Wed, 14 Sep 2005 08:52:51 -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=VSUuXya/hIb5dywlDzC9uJajAHXwfyHh4Ul+a+poSxJACkDYkub8acbzG2YIMkJAYPcay6JPj6EKTtJaHllxNXY9Ukox1pz2hiCTRrcK+xwd/QJ9QTEm6QH2hU6qFhaw2RUMG4REVHMzP6HRcFtoKEo75y3Ox268cI1O/ybCQH0= +Received: by 10.70.132.9 with SMTP id f9mr303513wxd; + Wed, 14 Sep 2005 08:52:50 -0700 (PDT) +Received: by 10.70.18.3 with HTTP; Wed, 14 Sep 2005 08:52:50 -0700 (PDT) +Message-ID: +Date: Wed, 14 Sep 2005 12:52:50 -0300 +From: Pryscila B Guttoski +Reply-To: pryscila.lista@gmail.com +To: jonah.harris@gmail.com +Subject: Re: About method of PostgreSQL's Optimizer +Cc: pgsql-hackers@postgresql.org +In-Reply-To: <36e6829205091320085993ceba@mail.gmail.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: + + <36e6829205091320085993ceba@mail.gmail.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.587 required=5 tests=[AWL=0.563, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200509/662 +X-Sequence-Number: 73059 + +Hi Jonah, + +Thank's for your email, I really appreciate your opinions. + +Is it interesting to use both techniques? For example: +Given a query, an optimizer: +1. Generates one of the possible execution plans. +2. Does transformations on the original plan, based on rules and +heuristics, resulting in new alternative plans. +3. Evaluates the cost of generated plans by using statistics. +4. Keeps plans that have lower cost than the original plan +5. Repeat 2-4 over the new alternative plans. +What do you think about it? Are there any restrictions that I haven't seen? + +About other method... +Have you heard about using PDDL ("Planning Domain Definition +Language") for query optimization? + +[]'s +Pryscila + + +On 9/14/05, Jonah H. Harris wrote: +> Pryscila, +> =20 +> While I haven't been too involved in the open source PostgreSQL optimize= +r, +> I have done some work on it and optimizers in other database systems. +> =20 +> Based on my work, it is my opinion that PostgreSQL, as-well-as other +> databases which use a cost-based optimizer, prefer a breadth-first algori= +thm +> because one cannot determine the "real" cost of each node at run-time +> without systematically examining all possibilities through calculation.= +=20 +> This is the opposite of a rule-based optimizer which defines heuristics +> which can be evaulated by a best-first algorithm such as A*. +> =20 +> In a cost-based optimizer, the system must calculate the "cost" of each +> path based on data that changes during run-time including indexing, +> cardinality, tuple size, available memory, CPU usage, disk access times, +> etc. To a cost-based optimizer, every query is unique and therefore cann= +ot +> follow a weighted path in the same fashion. I can certainly see A* being +> used in a rule-based optimizer but not in a real-time cost-based optimize= +r. +> =20 +> Perhaps Tom, Bruce, et al have more specifics on PostgreSQL's +> implementation. +> =20 +> -Jonah +>=20 +> =20 +> =20 +> =20 +> On 9/13/05, Pryscila B Guttoski wrote: +> > Hello all! +> >=20 +> > On my master course, I'm studying the PostgreSQL's optimizer. +> > I don't know if anyone in this list have been participated from the +> PostgreSQL's Optimizer development, but maybe someone can help me on this +> question. +> > PostgreSQL generates all possible plans of executing the query (using a= +n +> almost exhaustive search), then gives a cost to each plan and finally the +> cheapest one is selected for execution. +> > There are other methods for query optimization, one of them is based on +> plan transformations (for example, using A-Star algorithm) instead of pla= +n +> constructions used by PostgreSQL.=20 +> > Does anyone know why this method was choosen? Are there any papers or +> researches about it? +> >=20 +> > Thank's a lot, +> > Pryscila. +> >=20 +>=20 +>=20 +>=20 +> --=20 +> Respectfully, +>=20 +> Jonah H. Harris, Database Internals Architect +> EnterpriseDB Corporation +> http://www.enterprisedb.com/=20 +> + +From pgsql-hackers-owner@postgresql.org Wed Sep 14 13:43:17 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6CA8ED8EF1 + for ; + Wed, 14 Sep 2005 13:36:46 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 68268-07 + for ; + Wed, 14 Sep 2005 16:36:42 +0000 (GMT) +Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.194]) + by svr1.postgresql.org (Postfix) with ESMTP id 66CC7D8EA6 + for ; + Wed, 14 Sep 2005 13:36:37 -0300 (ADT) +Received: by rproxy.gmail.com with SMTP id 1so14873rny + for ; + Wed, 14 Sep 2005 09:36:37 -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=B/kQ6IcHTwQ6tJiV8S6IIYbMM5m+HGEa7XOf0q8X55UUtIVSF0JSMB2X940K1T+clt9jgmQLjzQq/L3kBcSpiHuoigM+V0MuEpgkDyoVmw06KPqAONuMI/H+Vs2CXHLjdgtVXhN53AhVGgsT9G+gw8+3Ygk5nxI3tTiB0llEQl4= +Received: by 10.11.119.68 with SMTP id r68mr17678cwc; + Wed, 14 Sep 2005 09:36:37 -0700 (PDT) +Received: by 10.11.119.38 with HTTP; Wed, 14 Sep 2005 09:36:37 -0700 (PDT) +Message-ID: <36e6829205091409361035d32a@mail.gmail.com> +Date: Wed, 14 Sep 2005 12:36:37 -0400 +From: "Jonah H. Harris" +Reply-To: jonah.harris@gmail.com +To: pryscila.lista@gmail.com +Subject: Re: About method of PostgreSQL's Optimizer +Cc: pgsql-hackers@postgresql.org +In-Reply-To: +Mime-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_6261_6026987.1126715797508" +References: + + <36e6829205091320085993ceba@mail.gmail.com> + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.442 required=5 tests=[AWL=0.122, HTML_10_20=0.295, + HTML_MESSAGE=0.001, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200509/664 +X-Sequence-Number: 73061 + +------=_Part_6261_6026987.1126715797508 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Pryscila, + +Step 2 is basically where you find the difference between a cost-based=20 +optimizer (CBO) and a rule-based optimizer (RBO). A CBO is based on the=20 +computed execution cost of the query whereas an RBO uses more generalized= +=20 +heuristics. + +Let's get an example of what you're proposing and see if we can work it out= +=20 +from there. + +Say we have the following (this is a generalized CBO approach, not=20 +PostgreSQL specific): + +Oracle's SCOTT.EMP table with cardinality of 1 million and an index on empn= +o=20 +and ename. For storage purposes say that the empno index takes up 3600=20 +blocks, the ename index takes up 7800 blocks, and the table itself takes up= +=20 +17000 blocks. We'll also say that we have a 256 megabyte buffer cache of=20 +which we have cached 50% of the empno index, 10% of the ename index, and 5%= +=20 +of the emp table data. + +A user then issues the following query: + +SELECT empno, ename FROM emp; + +A cost-based optimizer will see the following: +1. See that the query is a full table scan (FTS) and calculate the cost of= +=20 +retrieving all 17000 blocks from disk. +2. See that the query is a FTS and that it can retrieve all data from the= +=20 +indexes (11400 blocks) and join the data (which join algorithm?) + +Without performing a breadth-first algorithm, how can one evaluate both=20 +options in a way that would allow you to perform heuristic transformations= +=20 +dynamically? What transformation/heuristic/rule can you use? A CBO=20 +implementation has to calculate the amount of I/O needed on each plan based= +=20 +on several statistics such as what's *potentially* in the cache, what's the= +=20 +access time for block I/O (including prefetching if the storage manager has= +=20 +it), and other factors. If you could name a database that uses a best-first= +=20 +algorithm, such as A*, please send me the link to their docs; I'd be=20 +interested in reading the implementation. + +As for using both in the same optimizer, I could only see an algorithm such= +=20 +as a customized-A* being used to planning *some* large queries. The reason = +I=20 +say this is because the cost calculation, which would still need to be=20 +breadth-first, could calculate and cache the cost of most nodes thereby=20 +allowing you to possibly perform transformations at the tail of calculation= +. + +As for references to query optimization possibly using best-first=20 +algorithms, I think I saw several types of algorithms used in work from a= +=20 +university query optimization engine. I can't remember if it was Cornell,= +=20 +Stanford, or Wisconsin... I'll try and get you a link to their info. + +-Jonah + +On 9/14/05, Pryscila B Guttoski wrote: +>=20 +> Hi Jonah, +>=20 +> Thank's for your email, I really appreciate your opinions. +>=20 +> Is it interesting to use both techniques? For example: +> Given a query, an optimizer: +> 1. Generates one of the possible execution plans. +> 2. Does transformations on the original plan, based on rules and +> heuristics, resulting in new alternative plans. +> 3. Evaluates the cost of generated plans by using statistics. +> 4. Keeps plans that have lower cost than the original plan +> 5. Repeat 2-4 over the new alternative plans. +> What do you think about it? Are there any restrictions that I haven't=20 +> seen? +>=20 +> About other method... +> Have you heard about using PDDL ("Planning Domain Definition +> Language") for query optimization? +>=20 +> []'s +> Pryscila +>=20 +>=20 +> On 9/14/05, Jonah H. Harris wrote: +> > Pryscila, +> > +> > While I haven't been too involved in the open source PostgreSQL=20 +> optimizer, +> > I have done some work on it and optimizers in other database systems. +> > +> > Based on my work, it is my opinion that PostgreSQL, as-well-as other +> > databases which use a cost-based optimizer, prefer a breadth-first=20 +> algorithm +> > because one cannot determine the "real" cost of each node at run-time +> > without systematically examining all possibilities through calculation. +> > This is the opposite of a rule-based optimizer which defines heuristics +> > which can be evaulated by a best-first algorithm such as A*. +> > +> > In a cost-based optimizer, the system must calculate the "cost" of each +> > path based on data that changes during run-time including indexing, +> > cardinality, tuple size, available memory, CPU usage, disk access times= +, +> > etc. To a cost-based optimizer, every query is unique and therefore=20 +> cannot +> > follow a weighted path in the same fashion. I can certainly see A* bein= +g +> > used in a rule-based optimizer but not in a real-time cost-based=20 +> optimizer. +> > +> > Perhaps Tom, Bruce, et al have more specifics on PostgreSQL's +> > implementation. +> > +> > -Jonah +> > +> > +> > +> > +> > On 9/13/05, Pryscila B Guttoski wrote: +> > > Hello all! +> > > +> > > On my master course, I'm studying the PostgreSQL's optimizer. +> > > I don't know if anyone in this list have been participated from the +> > PostgreSQL's Optimizer development, but maybe someone can help me on=20 +> this +> > question. +> > > PostgreSQL generates all possible plans of executing the query (using= +=20 +> an +> > almost exhaustive search), then gives a cost to each plan and finally= +=20 +> the +> > cheapest one is selected for execution. +> > > There are other methods for query optimization, one of them is based= +=20 +> on +> > plan transformations (for example, using A-Star algorithm) instead of= +=20 +> plan +> > constructions used by PostgreSQL. +> > > Does anyone know why this method was choosen? Are there any papers or +> > researches about it? +> > > +> > > Thank's a lot, +> > > Pryscila. +> > > +> > +> > +> > +> > -- +> > Respectfully, +> > +> > Jonah H. Harris, Database Internals Architect +> > EnterpriseDB Corporation +> > http://www.enterprisedb.com/ +> > +>=20 + + + +--=20 +Respectfully, + +Jonah H. Harris, Database Internals Architect +EnterpriseDB Corporation +http://www.enterprisedb.com/ + +------=_Part_6261_6026987.1126715797508 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Pryscila,
+
+Step 2 is basically where you find the difference between a cost-based +optimizer (CBO) and a rule-based optimizer (RBO).  A CBO is based +on the computed execution cost of the query whereas an RBO uses more +generalized heuristics.
+
+Let's get an example of what you're proposing and see if we can work it out= + from there.
+
+Say we have the following (this is a generalized CBO approach, not PostgreS= +QL specific):
+
+Oracle's SCOTT.EMP table with cardinality of 1 million and an index on +empno and ename.  For storage purposes say that the empno index +takes up 3600 blocks, the ename index takes up 7800 blocks, and the +table itself takes up 17000 blocks.  We'll also say that we have a +256 megabyte buffer cache of which we have cached 50% of the empno +index, 10% of the ename index, and 5% of the emp table data.
+
+A user then issues the following query:
+
+SELECT empno, ename FROM emp;
+
+A cost-based optimizer will see the following:
+1. See that the query is a full table scan (FTS) and calculate the cost of = +retrieving all 17000 blocks from disk.
+2. See that the query is a FTS and that it can retrieve all data from +the indexes (11400 blocks) and join the data (which join algorithm?)
+
+Without performing a breadth-first algorithm, how can one evaluate both +options in a way that would allow you to perform heuristic +transformations dynamically?  What transformation/heuristic/rule +can you use?  A CBO implementation has to calculate the amount of +I/O needed on each plan based on several statistics such as what's +*potentially* in the cache, what's the access time for block I/O +(including prefetching if the storage manager has it), and other +factors.  If you could name a database that uses a best-first +algorithm, such as A*, please send me the link to their docs; I'd be +interested in reading the implementation.
+
+As for using both in the same optimizer, I could only see an algorithm +such as a customized-A* being used to planning *some* large +queries.  The reason I say this is because the cost calculation, +which would still need to be breadth-first, could calculate and cache +the cost of most nodes thereby allowing you to possibly perform +transformations at the tail of calculation.
+
+As for references to query optimization possibly using best-first +algorithms, I think I saw several types of algorithms used in work from +a university query optimization engine.  I can't remember if it +was Cornell, Stanford, or Wisconsin... I'll try and get you a link to +their info.
+
+-Jonah

On 9/14/05, Pryscila B Guttoski <pryscila.lista@gmail.com> wrote:
+Hi Jonah,

Thank's for your email, I really appreciate your opinions.= +

Is it interesting to use both techniques? For example:
Given a q= +uery, an optimizer:
1. Generates one of the possible execution plans. +
2. Does transformations on the original plan, based on rules and
heu= +ristics, resulting in new alternative plans.
3. Evaluates the cost of ge= +nerated plans by using statistics.
4. Keeps plans that have lower cost t= +han the original plan +
5. Repeat 2-4 over the new alternative plans.
What do you think abou= +t it? Are there any restrictions that I haven't seen?

About other me= +thod...
Have you heard about using PDDL ("Planning Domain Definitio= +n +
Language") for query optimization?

[]'s
Pryscila

= +
On 9/14/05, Jonah H. Harris <jonah.harris@gmail.com> wrote:
> Pryscila,
>
>&= +nbsp; While I haven't been too involved in the open source PostgreSQL = +optimizer, +
> I have done some work on it and optimizers in other database syste= +ms.
>
>  Based on my work, it is my opinion that Post= +greSQL, as-well-as other
> databases which use a cost-based optimizer= +, prefer a breadth-first algorithm +
> because one cannot determine the "real" cost of each nod= +e at run-time
> without systematically examining all possibilities th= +rough calculation.
> This is the opposite of a rule-based optimizer w= +hich defines heuristics +
> which can be evaulated by a best-first algorithm such as A*.
&g= +t;
>  In a cost-based optimizer, the system must calculate = +the "cost" of each
> path based on data that changes during= + run-time including indexing, +
> cardinality, tuple size, available memory, CPU usage, disk access = +times,
> etc.  To a cost-based optimizer, every query is un= +ique and therefore cannot
> follow a weighted path in the same fashio= +n.  I can certainly see A* being +
> used in a rule-based optimizer but not in a real-time cost-based o= +ptimizer.
>
>  Perhaps Tom, Bruce, et al have more sp= +ecifics on PostgreSQL's
> implementation.
>
>  = +-Jonah
>
+>
>
>
> On 9/13/05, Pryscila B Guttoski <pryscila.lista@gmail.com> wrote:> > Hello all!
> >
> > On my master course, I'm s= +tudying the PostgreSQL's optimizer. +
> > I don't know if anyone in this list have been participated fr= +om the
> PostgreSQL's Optimizer development, but maybe someone can he= +lp me on this
> question.
> > PostgreSQL generates all possi= +ble plans of executing the query (using an +
> almost exhaustive search), then gives a cost to each plan and fina= +lly the
> cheapest one is selected for execution.
> > There = +are other methods for query optimization, one of them is based on
> p= +lan transformations (for example, using A-Star algorithm) instead of plan +
> constructions used by PostgreSQL.
> > Does anyone know wh= +y this method was choosen? Are there any papers or
> researches about= + it?
> >
> > Thank's a lot,
> > Pryscila.
+> >
>
>
>
> --
> Respectfully,
><= +br>> Jonah H. Harris, Database Internals Architect
> EnterpriseDB = +Corporation
> http://www.ent= +erprisedb.com/ +
>



--
Respect= +fully,

Jonah H. Harris, Database Internals Architect
EnterpriseDB= + Corporation
http://www.enterpr= +isedb.com/ +
+ +------=_Part_6261_6026987.1126715797508-- + +From pgsql-performance-owner@postgresql.org Wed Sep 14 14:10:44 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0D3ACD8241 + for ; + Wed, 14 Sep 2005 14:10:42 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 95675-03 + for ; + Wed, 14 Sep 2005 17:10:38 +0000 (GMT) +Received: from Herge.rcsinc.local (unknown [70.89.208.142]) + by svr1.postgresql.org (Postfix) with ESMTP id D1CCAD7DAB + for ; + Wed, 14 Sep 2005 14:10:35 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Subject: Re: Low performance on Windows problem +Date: Wed, 14 Sep 2005 13:10:32 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3417DD337@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Low performance on Windows problem +Thread-Index: AcW5LJZchBYePj/iRs2RREjpDjudSQAIgj9Q +From: "Merlin Moncure" +To: "Dalibor Sramek" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.036 required=5 tests=[AWL=-0.014, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/189 +X-Sequence-Number: 14497 + +> in the 10 ms range. Definitely not 800 ms. The 8.1 has the same +problem. +>=20 +> Just for the record: the server PC is Dell Precision 330 with 3Com +3C920 +> integrated network card. OS MS Windows Professional 2002 with service +pack +> 2. There is Symantec Antivirus installed - which I have (hopefully) +> completely disabled. + +Try throwing in another network card and see if it helps. Next step is +to try twinking tcp settings +(http://support.microsoft.com/default.aspx?scid=3Dkb;en-us;314053) and = +see +if that helps. Beyond that, try playing the update driver game. If you +are still having problems, try receiving bigger and bigger results to +see where problem occurs. 1-2k range suggests mtu problem, 4-8k range +suggests tcp receive window problem. + +Beyond that, I'm stumped, uh, buy Opteron? :) + +Merlin + + +From pgsql-hackers-owner@postgresql.org Wed Sep 14 14:54:56 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B1D2CD8EEF + for ; + Wed, 14 Sep 2005 14:54:55 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 04131-04 + for ; + Wed, 14 Sep 2005 17:54:50 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id E3BB1D8EE6 + for ; + Wed, 14 Sep 2005 14:54:50 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j8EHsk2Q006128; + Wed, 14 Sep 2005 13:54:47 -0400 (EDT) +To: jonah.harris@gmail.com +Cc: pryscila.lista@gmail.com, pgsql-hackers@postgresql.org +Subject: Re: About method of PostgreSQL's Optimizer +In-reply-to: <36e6829205091409361035d32a@mail.gmail.com> +References: + + <36e6829205091320085993ceba@mail.gmail.com> + + <36e6829205091409361035d32a@mail.gmail.com> +Comments: In-reply-to "Jonah H. Harris" + message dated "Wed, 14 Sep 2005 12:36:37 -0400" +Date: Wed, 14 Sep 2005 13:54:46 -0400 +Message-ID: <6127.1126720486@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/668 +X-Sequence-Number: 73065 + +"Jonah H. Harris" writes: +> As for using both in the same optimizer, I could only see an algorithm such +> as a customized-A* being used to planning *some* large queries. The reason I +> say this is because the cost calculation, which would still need to be +> breadth-first, could calculate and cache the cost of most nodes thereby +> allowing you to possibly perform transformations at the tail of calculation. + +We do already have two different plan search algorithms: the strict +bottom-up dynamic programming approach (System R style) and the GEQO +optimizer, which we switch to when there are too many joins needed to +allow exhaustive search. The GEQO code still depends on the normal +plan cost estimation code, but it doesn't consider every possible plan. + +I've never been very happy with the GEQO code: the random component of +the algorithm means you get unpredictable (and sometimes awful) plans, +and the particular variant that we are using is really designed to solve +traveling-salesman problems. It's at best a poor fit to the join +planning problem. + +So it seems interesting to me to think about replacing GEQO with a +rule-based optimizer for large join search spaces. + +There are previous discussions about this in the archives, I believe. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Sep 14 15:22:24 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 59F76D7E55 + for ; + Wed, 14 Sep 2005 15:22:18 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 12540-03 + for ; + Wed, 14 Sep 2005 18:22:12 +0000 (GMT) +Received: from mail24.sea5.speakeasy.net (mail24.sea5.speakeasy.net + [69.17.117.26]) + by svr1.postgresql.org (Postfix) with ESMTP id A7A89D6FD1 + for ; + Wed, 14 Sep 2005 15:22:11 -0300 (ADT) +Received: (qmail 13314 invoked from network); 14 Sep 2005 18:22:12 -0000 +Received: from mail.kinesis-cem.com (HELO pdarley) (kinesis@[64.81.9.230]) + (envelope-sender ) + by mail24.sea5.speakeasy.net (qmail-ldap-1.03) with SMTP + for ; 14 Sep 2005 18:22:12 -0000 +From: "Peter Darley" +To: "Pgsql-Performance" +Subject: Battery Backed Cache for RAID +Date: Wed, 14 Sep 2005 11:25:38 -0700 +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) +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506 +Importance: Normal +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/190 +X-Sequence-Number: 14498 + +Folks, + I'm getting a new server for our database, and I have a quick question +about RAID controllers with a battery backed cache. I understand that the +cache will allow the cache to be written out if the power fails to the box, +which allows it to report a write as committed safely when it's not actually +committed. + My question is, if the power goes off, and the drives stop, how does the +battery backed cache save things out to the dead drives? Is there another +component that is implied that will provide power to the drives that I +should be looking into as well? +Thanks, +Peter Darley + + +From pgsql-performance-owner@postgresql.org Wed Sep 14 15:28:55 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id ED8E3D8E94 + for ; + Wed, 14 Sep 2005 15:28:52 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 11639-06 + for ; + Wed, 14 Sep 2005 18:28:49 +0000 (GMT) +Received: from gghcwest.com (adsl-71-128-90-172.dsl.pltn13.pacbell.net + [71.128.90.172]) + by svr1.postgresql.org (Postfix) with ESMTP id 3C765D81F7 + for ; + Wed, 14 Sep 2005 15:28:48 -0300 (ADT) +Received: from toonses.gghcwest.com (toonses.gghcwest.com [192.168.168.115]) + by gghcwest.com (8.12.10/8.12.9) with ESMTP id j8EISgmd018948; + Wed, 14 Sep 2005 11:28:43 -0700 +Received: from jwb by toonses.gghcwest.com with local (Exim 4.52) + id 1EFbzv-0007Jg-SA; Wed, 14 Sep 2005 11:28:43 -0700 +Subject: Re: Battery Backed Cache for RAID +From: "Jeffrey W. Baker" +To: Peter Darley +Cc: Pgsql-Performance +In-Reply-To: +References: +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Date: Wed, 14 Sep 2005 11:28:43 -0700 +Message-Id: <1126722523.27650.6.camel@toonses.gghcwest.com> +Mime-Version: 1.0 +X-Mailer: Evolution 2.4.0 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=-0.618 required=5 tests=[AWL=-0.668, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/191 +X-Sequence-Number: 14499 + +On Wed, 2005-09-14 at 11:25 -0700, Peter Darley wrote: +> I'm getting a new server for our database, and I have a quick question +> about RAID controllers with a battery backed cache. I understand that the +> cache will allow the cache to be written out if the power fails to the box, +> which allows it to report a write as committed safely when it's not actually +> committed. + +Actually the cache will just hold its contents while the power is out. +When the power is restored, the RAID controller will complete the writes +to disk. If the battery does not last through the outage, the data is +lost. + +> My question is, if the power goes off, and the drives stop, how does the +> battery backed cache save things out to the dead drives? Is there another +> component that is implied that will provide power to the drives that I +> should be looking into as well? + +A UPS would allow you to do an orderly shutdown and write contents to +disk during a power failure. However a UPS can be an extra point of +failure. + +-jwb + +From pgsql-performance-owner@postgresql.org Wed Sep 14 17:02:13 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BFAA4D8E7D + for ; + Wed, 14 Sep 2005 17:02:10 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 32846-02 + for ; + Wed, 14 Sep 2005 20:02:02 +0000 (GMT) +Received: from mx1.surnet.cl (mx1.surnet.cl [216.155.73.180]) + by svr1.postgresql.org (Postfix) with ESMTP id DB861D81F7 + for ; + Wed, 14 Sep 2005 17:02:01 -0300 (ADT) +Received: from unknown (HELO cluster.surnet.cl) ([216.155.73.165]) + by mx1.surnet.cl with ESMTP; 14 Sep 2005 16:02:57 -0400 +X-IronPort-AV: i="3.97,110,1125892800"; d="scan'208"; a="8299397:sNHT30388438" +Received: from alvh.no-ip.org (216.155.86.232) by cluster.surnet.cl (7.0.043) + (authenticated as alvherre@surnet.cl) + id 4327E85F00012952; Wed, 14 Sep 2005 16:02:03 -0400 +Received: by alvh.no-ip.org (Postfix, from userid 1000) + id B0B91C2DC1A; Wed, 14 Sep 2005 16:03:24 -0400 (CLT) +Date: Wed, 14 Sep 2005 16:03:24 -0400 +From: Alvaro Herrera +To: "Jeffrey W. Baker" +Cc: Peter Darley , + Pgsql-Performance +Subject: Re: Battery Backed Cache for RAID +Message-ID: <20050914200324.GB26714@surnet.cl> +Mail-Followup-To: "Jeffrey W. Baker" , + Peter Darley , + Pgsql-Performance +References: + <1126722523.27650.6.camel@toonses.gghcwest.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1126722523.27650.6.camel@toonses.gghcwest.com> +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=2.65 required=5 tests=[AWL=-0.697, + DNS_FROM_RFC_ABUSE=0.374, DNS_FROM_RFC_POST=1.376, + RCVD_IN_SORBS_MISC=1.597] +X-Spam-Level: ** +X-Archive-Number: 200509/192 +X-Sequence-Number: 14500 + +On Wed, Sep 14, 2005 at 11:28:43AM -0700, Jeffrey W. Baker wrote: +> On Wed, 2005-09-14 at 11:25 -0700, Peter Darley wrote: +> > I'm getting a new server for our database, and I have a quick question +> > about RAID controllers with a battery backed cache. I understand that the +> > cache will allow the cache to be written out if the power fails to the box, +> > which allows it to report a write as committed safely when it's not actually +> > committed. +> +> Actually the cache will just hold its contents while the power is out. +> When the power is restored, the RAID controller will complete the writes +> to disk. If the battery does not last through the outage, the data is +> lost. + +Just curious: how long are the batteries supposed to last? + +-- +Alvaro Herrera -- Valdivia, Chile Architect, www.EnterpriseDB.com +Hi! I'm a .signature virus! +cp me into your .signature file to help me spread! + +From pgsql-performance-owner@postgresql.org Wed Sep 14 17:17:12 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 52250D8EFB + for ; + Wed, 14 Sep 2005 17:17:10 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37416-01 + for ; + Wed, 14 Sep 2005 20:17:04 +0000 (GMT) +Received: from Herge.rcsinc.local (unknown [70.89.208.142]) + by svr1.postgresql.org (Postfix) with ESMTP id BA020D8EF4 + for ; + Wed, 14 Sep 2005 17:17:05 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Subject: Re: Battery Backed Cache for RAID +Date: Wed, 14 Sep 2005 16:17:06 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3417DD346@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Battery Backed Cache for RAID +Thread-Index: AcW5aFDWzxA6KzyBS8WrIiJs+WMThQAAGGxA +From: "Merlin Moncure" +To: "Alvaro Herrera" +Cc: "Pgsql-Performance" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.037 required=5 tests=[AWL=-0.013, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/193 +X-Sequence-Number: 14501 + +> On Wed, Sep 14, 2005 at 11:28:43AM -0700, Jeffrey W. Baker wrote: +> > On Wed, 2005-09-14 at 11:25 -0700, Peter Darley wrote: +> > > I'm getting a new server for our database, and I have a quick +> question +> > > about RAID controllers with a battery backed cache. I understand +that +> the +> > > cache will allow the cache to be written out if the power fails to +the +> box, +> > > which allows it to report a write as committed safely when it's +not +> actually +> > > committed. +> > +> > Actually the cache will just hold its contents while the power is +out. +> > When the power is restored, the RAID controller will complete the +writes +> > to disk. If the battery does not last through the outage, the data +is +> > lost. +>=20 +> Just curious: how long are the batteries supposed to last? +=20 +For the length of time it will take for you to get fired for not getting +the server running plus one hour :). + +Merlin + +From pgsql-performance-owner@postgresql.org Wed Sep 14 17:40:36 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C9527D8F06 + for ; + Wed, 14 Sep 2005 17:40:34 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 38093-08 + for ; + Wed, 14 Sep 2005 20:40:26 +0000 (GMT) +Received: from ionian.i-clic.uihc.uiowa.edu (ionian.i-clic.uihc.uiowa.edu + [129.255.211.20]) + by svr1.postgresql.org (Postfix) with ESMTP id 7EC7CD8F05 + for ; + Wed, 14 Sep 2005 17:40:26 -0300 (ADT) +Received: by ionian.i-clic.uihc.uiowa.edu (Postfix, from userid 76) + id F172361DAE; Wed, 14 Sep 2005 14:30:07 -0500 (CDT) +Received: from [209.101.126.78] (unknown [209.101.126.78]) + by ionian.i-clic.uihc.uiowa.edu (Postfix) with ESMTP + id A36FE61DAD; Wed, 14 Sep 2005 14:30:06 -0500 (CDT) +Message-ID: <43288AB9.4000204@arbash-meinel.com> +Date: Wed, 14 Sep 2005 16:40:25 -0400 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Alvaro Herrera +Cc: "Jeffrey W. Baker" , + Peter Darley , + Pgsql-Performance +Subject: Re: Battery Backed Cache for RAID +References: + <1126722523.27650.6.camel@toonses.gghcwest.com> + <20050914200324.GB26714@surnet.cl> +In-Reply-To: <20050914200324.GB26714@surnet.cl> +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enigCB24377D1936EBF5BE704C07" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.012 required=5 tests=[AWL=0.012] +X-Spam-Level: +X-Archive-Number: 200509/194 +X-Sequence-Number: 14502 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enigCB24377D1936EBF5BE704C07 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 7bit + +Alvaro Herrera wrote: +> On Wed, Sep 14, 2005 at 11:28:43AM -0700, Jeffrey W. Baker wrote: +> +>>On Wed, 2005-09-14 at 11:25 -0700, Peter Darley wrote: +>> +>>> I'm getting a new server for our database, and I have a quick question +>>>about RAID controllers with a battery backed cache. I understand that the +>>>cache will allow the cache to be written out if the power fails to the box, +>>>which allows it to report a write as committed safely when it's not actually +>>>committed. +>> +>>Actually the cache will just hold its contents while the power is out. +>>When the power is restored, the RAID controller will complete the writes +>>to disk. If the battery does not last through the outage, the data is +>>lost. +> +> +> Just curious: how long are the batteries supposed to last? +> + +The recent *cheap* version of a ramdisk had battery backup for 16 hours. +(Very expensive ramdisks actually have enough battery power to power a +small hard-drive to dump the contents into). + +I'm guessing for a RAID controller, the time would be in the max 1 day +range. + +John +=:-> + + +--------------enigCB24377D1936EBF5BE704C07 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFDKIq5JdeBCYSNAAMRAq1FAKCmgrBueViWwac9+x7QgA5ANHsrRwCfZ0ZS +440kj2BgXv8wwVDzTjCjlwc= +=zCG9 +-----END PGP SIGNATURE----- + +--------------enigCB24377D1936EBF5BE704C07-- + +From pgsql-performance-owner@postgresql.org Wed Sep 14 17:47:03 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7A71BD8EFD + for ; + Wed, 14 Sep 2005 17:47:00 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 42304-03 + for ; + Wed, 14 Sep 2005 20:46:57 +0000 (GMT) +Received: from vadmzmailmx02.bankofamerica.com (vamx02.bankofamerica.com + [171.159.192.79]) + by svr1.postgresql.org (Postfix) with ESMTP id 43C7FD8EDA + for ; + Wed, 14 Sep 2005 17:46:57 -0300 (ADT) +Received: from vadmzmailmx03.bankofamerica.com ([171.182.200.79]) + by vadmzmailmx02.bankofamerica.com (8.12.11/8.12.11) with ESMTP id + j8EKklbc022967; Wed, 14 Sep 2005 20:46:47 GMT +Received: from memscmpl4. (varchvp01s209.bankofamerica.com [171.177.163.14]) + by vadmzmailmx03.bankofamerica.com (8.12.11/8.12.11) with SMTP id + j8EKiQeN000396; Wed, 14 Sep 2005 20:46:47 GMT +Received: from memmta0301 (171.186.140.73) + by memscmpl4. (Sigaba Gateway v3.6.1) + with ESMTP id 275386080; Wed, 14 Sep 2005 16:46:47 -0400 +Date: Wed, 14 Sep 2005 16:46:47 -0400 +From: "Welty, Richard" +Subject: Re: Battery Backed Cache for RAID +To: John A Meinel +Cc: Pgsql-Performance +Message-id: +MIME-version: 1.0 +X-MIMEOLE: Produced By Microsoft Exchange V6.5.7226.0 +Content-type: text/plain; charset=UTF-8 +Content-transfer-encoding: 7BIT +Content-class: urn:content-classes:message +Thread-topic: [PERFORM] Battery Backed Cache for RAID +Thread-index: AcW5bQq80CAYg+/MSIGaSMyOdk9IUwAAO3Ww +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +X-OriginalArrivalTime: 14 Sep 2005 20:46:47.0624 (UTC) + FILETIME=[6CB40C80:01C5B96D] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.097 required=5 tests=[AWL=0.097] +X-Spam-Level: +X-Archive-Number: 200509/195 +X-Sequence-Number: 14503 + + +John A Meinel wrote: +>The recent *cheap* version of a ramdisk had battery backup for 16 hours. +>(Very expensive ramdisks actually have enough battery power to power a +>small hard-drive to dump the contents into). + +>I'm guessing for a RAID controller, the time would be in the max 1 day +>range. + +i think some will go a bit longer. i have seen an IBM ServeRaid (rebranded +mylex in this particular case) keep its memory after being pulled for a +remarkably long period of time. + +no guarantees, though, so i'm not actually going to say how long so that nobody +gets unreasonable expectations. + +richard + +From pgsql-performance-owner@postgresql.org Wed Sep 14 17:47:50 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9EB23D8F08 + for ; + Wed, 14 Sep 2005 17:47:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 43395-01 + for ; + Wed, 14 Sep 2005 20:47:29 +0000 (GMT) +Received: from olive.qinip.net (olive.qinip.net [62.100.30.40]) + by svr1.postgresql.org (Postfix) with ESMTP id D174CD8EF2 + for ; + Wed, 14 Sep 2005 17:47:29 -0300 (ADT) +Received: from [10.0.0.2] (h8441139206.dsl.speedlinq.nl [84.41.139.206]) + by olive.qinip.net (Postfix) with ESMTP + id 9565E181D6; Wed, 14 Sep 2005 22:47:26 +0200 (MEST) +Message-ID: <43288C67.3000209@tweakers.net> +Date: Wed, 14 Sep 2005 22:47:35 +0200 +From: Arjen van der Meijden +User-Agent: Mozilla Thunderbird 1.0RC1 (Windows/20041201) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Alvaro Herrera +Cc: "Jeffrey W. Baker" , + Peter Darley , + Pgsql-Performance +Subject: Re: Battery Backed Cache for RAID +References: + <1126722523.27650.6.camel@toonses.gghcwest.com> + <20050914200324.GB26714@surnet.cl> +In-Reply-To: <20050914200324.GB26714@surnet.cl> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/196 +X-Sequence-Number: 14504 + +On 14-9-2005 22:03, Alvaro Herrera wrote: +> On Wed, Sep 14, 2005 at 11:28:43AM -0700, Jeffrey W. Baker wrote: +> +>>On Wed, 2005-09-14 at 11:25 -0700, Peter Darley wrote: +>> +>>Actually the cache will just hold its contents while the power is out. +>>When the power is restored, the RAID controller will complete the writes +>>to disk. If the battery does not last through the outage, the data is +>>lost. +> +> +> Just curious: how long are the batteries supposed to last? + +For the LSI-Logic MegaRaid 320-2e its about 72 hours for the standard +128MB version. Their SATA2-solution offers 32 and 72 hour-options. So I +assume its "in the order of days" for most RAID controllers. + +Best regards, + +Arjen van der Meijden + +From pgsql-performance-owner@postgresql.org Wed Sep 14 19:03:37 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CE849D8F11 + for ; + Wed, 14 Sep 2005 18:58:31 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 54722-05 + for ; + Wed, 14 Sep 2005 21:58:25 +0000 (GMT) +Received: from mail0.rawbw.com (mail0.rawbw.com [198.144.192.41]) + by svr1.postgresql.org (Postfix) with ESMTP id 384A2D8AB2 + for ; + Wed, 14 Sep 2005 18:58:25 -0300 (ADT) +Received: (from www@localhost) + by mail0.rawbw.com (8.11.6p2/8.11.6) id j8ELwS117329 + for pgsql-performance@postgresql.org; + Wed, 14 Sep 2005 14:58:28 -0700 (PDT) +Received: from cybs-gw.ic3.com (cybs-gw.ic3.com [66.185.177.10]) + by webmail.rawbw.com (IMP) with HTTP + for ; Wed, 14 Sep 2005 14:58:28 -0700 +Message-ID: <1126735108.43289d040898d@webmail.rawbw.com> +Date: Wed, 14 Sep 2005 14:58:28 -0700 +From: mudfoot@rawbw.com +To: pgsql-performance@postgresql.org +Subject: Re: Battery Backed Cache for RAID +References: + <1126722523.27650.6.camel@toonses.gghcwest.com> + <20050914200324.GB26714@surnet.cl> <43288C67.3000209@tweakers.net> +In-Reply-To: <43288C67.3000209@tweakers.net> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 8bit +User-Agent: Internet Messaging Program (IMP) 3.2.1 +X-Originating-IP: 66.185.177.10 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.178 required=5 tests=[AWL=0.000, NO_REAL_NAME=0.178] +X-Spam-Level: +X-Archive-Number: 200509/197 +X-Sequence-Number: 14505 + +Bear in mind you will lose data if the raid controller itself fails (or the +cache memory module). Many solutions have mirrored cache for this reason. But +that's more $$, depending on the risks you want to take. + +Quoting Arjen van der Meijden : + +> On 14-9-2005 22:03, Alvaro Herrera wrote: +> > On Wed, Sep 14, 2005 at 11:28:43AM -0700, Jeffrey W. Baker wrote: +> > +> >>On Wed, 2005-09-14 at 11:25 -0700, Peter Darley wrote: +> >> +> >>Actually the cache will just hold its contents while the power is out. +> >>When the power is restored, the RAID controller will complete the writes +> >>to disk. If the battery does not last through the outage, the data is +> >>lost. +> > +> > +> > Just curious: how long are the batteries supposed to last? +> +> For the LSI-Logic MegaRaid 320-2e its about 72 hours for the standard +> 128MB version. Their SATA2-solution offers 32 and 72 hour-options. So I +> assume its "in the order of days" for most RAID controllers. +> +> Best regards, +> +> Arjen van der Meijden +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 6: explain analyze is your friend +> + + + +From pgsql-performance-owner@postgresql.org Wed Sep 14 19:49:18 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DBCEED8E03 + for ; + Wed, 14 Sep 2005 19:49:16 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 67907-04 + for ; + Wed, 14 Sep 2005 22:49:12 +0000 (GMT) +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6C13ED8D5E + for ; + Wed, 14 Sep 2005 19:49:12 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 8CCF731F81; Thu, 15 Sep 2005 00:49:14 +0200 (MET DST) +From: "Qingqing Zhou" +X-Newsgroups: pgsql.performance +Subject: Re: How many tables is too many tables? +Date: Wed, 14 Sep 2005 18:49:06 -0700 +Organization: Hub.Org Networking Services +Lines: 34 +Message-ID: +References: <1126643032.787041.127400@z14g2000cwz.googlegroups.com> +X-Complaints-To: usenet@news.hub.org +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +X-RFC2646: Format=Flowed; Original +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.195 required=5 tests=[AWL=0.010, + PRIORITY_NO_NAME=1.185] +X-Spam-Level: * +X-Archive-Number: 200509/198 +X-Sequence-Number: 14506 + + + wrote +> +> One machine is simply not going to be able to scale with the quantities +> of links we hope to store information about and we want to move to some +> kind of cluster. Because of the quantities of data, it seems to make +> sense to go for a cluster setup such that in a 4 machine cluster, each +> machine has a quarter of the data (is this "Share nothing," or, "Share +> everything"?). To that end, we figured a good first step was to +> partition the data on one machine into multiple tables defining the +> logic which would find the appropriate table given a piece of data. +> Then, we assumed, adding the logic to find the appropriate machine and +> database in our cluster would only be an incremental upgrade. +> + +So you set up 4 separate copies of PG in 4 machines? This is neither SN or +SE. + +The partition is good for performance if you distribute IOs and CPUs. In +your design, I believe IO is distributed (to 4 machines), but since you +sliced data into too small pieces, you will get penality from other places. +For example, each table has to maintain separate indices (index becomes an +useless burden when table is too small), so there will be so many Btree root +... System tables (pg_class/pg_attribute, etc) has to contains many rows to +record your tables ... though we cached system table rows, but the memory +space is limited ... + +In short, too many tables. To design your new partition method, jsut keep in +mind that database access data in a page-wise IO. + +Regards, +Qingqing + + + +From pgsql-hackers-owner@postgresql.org Thu Sep 15 01:40:04 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4C8C0D869A + for ; + Thu, 15 Sep 2005 01:40:03 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 54738-05 + for ; + Thu, 15 Sep 2005 04:39:56 +0000 (GMT) +Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.197]) + by svr1.postgresql.org (Postfix) with ESMTP id A8381D8625 + for ; + Thu, 15 Sep 2005 01:39:55 -0300 (ADT) +Received: by rproxy.gmail.com with SMTP id 40so32121rnz + for ; + Wed, 14 Sep 2005 21:39:55 -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=Nfo6lZbZ+wtpBrpMPAQcFZXPDwCXOaqHAM1FBVsPw2z+SgpyDk4mX96G4ZYKxYPYtzrrXXKpJvIeZ2rA4JeHwAIp6xbXN8kWypu6hKZVOV46QcKXCClkwGVvV1FNWDjqhBokIdI/0PgIia5W4+bICqEri39gIeNn+pq0cYWNH2Y= +Received: by 10.11.119.31 with SMTP id r31mr282cwc; + Wed, 14 Sep 2005 21:39:55 -0700 (PDT) +Received: by 10.11.119.38 with HTTP; Wed, 14 Sep 2005 21:39:55 -0700 (PDT) +Message-ID: <36e6829205091421394fbb062a@mail.gmail.com> +Date: Thu, 15 Sep 2005 00:39:55 -0400 +From: "Jonah H. Harris" +Reply-To: jonah.harris@gmail.com +To: Tom Lane +Subject: Re: About method of PostgreSQL's Optimizer +Cc: pryscila.lista@gmail.com, pgsql-hackers@postgresql.org +In-Reply-To: <6127.1126720486@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_7343_20490035.1126759195608" +References: + + <36e6829205091320085993ceba@mail.gmail.com> + + <36e6829205091409361035d32a@mail.gmail.com> + <6127.1126720486@sss.pgh.pa.us> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.533 required=5 tests=[AWL=0.004, HTML_20_30=0.504, + HTML_MESSAGE=0.001, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200509/682 +X-Sequence-Number: 73079 + +------=_Part_7343_20490035.1126759195608 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Tom, + +I agree. There have been several occasions where GEQO has performed poorly= +=20 +for me. I'll search the archives for the past discussions. + +sorry for sending this to you twice Tom... forgot to hit reply all :( + +On 9/14/05, Tom Lane wrote: +>=20 +> "Jonah H. Harris" writes: +> > As for using both in the same optimizer, I could only see an algorithm= +=20 +> such +> > as a customized-A* being used to planning *some* large queries. The=20 +> reason I +> > say this is because the cost calculation, which would still need to be +> > breadth-first, could calculate and cache the cost of most nodes thereby +> > allowing you to possibly perform transformations at the tail of=20 +> calculation. +>=20 +> We do already have two different plan search algorithms: the strict +> bottom-up dynamic programming approach (System R style) and the GEQO +> optimizer, which we switch to when there are too many joins needed to +> allow exhaustive search. The GEQO code still depends on the normal +> plan cost estimation code, but it doesn't consider every possible plan. +>=20 +> I've never been very happy with the GEQO code: the random component of +> the algorithm means you get unpredictable (and sometimes awful) plans, +> and the particular variant that we are using is really designed to solve +> traveling-salesman problems. It's at best a poor fit to the join +> planning problem. +>=20 +> So it seems interesting to me to think about replacing GEQO with a +> rule-based optimizer for large join search spaces. +>=20 +> There are previous discussions about this in the archives, I believe. +>=20 +> regards, tom lane +>=20 + + + +--=20 +Respectfully, + +Jonah H. Harris, Database Internals Architect +EnterpriseDB Corporation +http://www.enterprisedb.com/ + +------=_Part_7343_20490035.1126759195608 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Tom,
+ +
+ +I agree.  There have been several occasions where GEQO has +performed poorly for me.  I'll search the archives for the past +discussions.
+
+sorry for sending this to you twice Tom... forgot to hit reply all :(
On 9/14/05, Tom Lane <tgl@sss.pgh.pa.us +> wrote:
"Jonah H. Harris" <= +jonah.harris@gmail.com +> writes:
> As for using both in the same optimizer, I could o= +nly see an algorithm such
> as a customized-A* being used to planning= + *some* large queries. The reason I
> say this is because the cost ca= +lculation, which would still need to be +
> breadth-first, could calculate and cache the cost of most nodes th= +ereby
> allowing you to possibly perform transformations at the tail = +of calculation.

We do already have two different plan search algorit= +hms: the strict +
bottom-up dynamic programming approach (System R style) and the GEQOoptimizer, which we switch to when there are too many joins needed to
a= +llow exhaustive search.  The GEQO code still depends on the norma= +l
plan cost estimation code, but it doesn't consider every possible plan= +. +

I've never been very happy with the GEQO code: the random component= + of
the algorithm means you get unpredictable (and sometimes awful) plan= +s,
and the particular variant that we are using is really designed to so= +lve +
traveling-salesman problems.  It's at best a poor fit to the = +join
planning problem.

So it seems interesting to me to think abo= +ut replacing GEQO with a
rule-based optimizer for large join search spac= +es.
+
There are previous discussions about this in the archives, I believe.
           &nb= +sp;            = +regards, +tom lane



--
Respectfull= +y,

Jonah H. Harris, Database Internals Architect
EnterpriseDB Cor= +poration
http://www.enterprised= +b.com/ +
+ +------=_Part_7343_20490035.1126759195608-- + +From pgsql-hackers-owner@postgresql.org Thu Sep 15 02:29:33 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C8EAAD8CD8 + for ; + Thu, 15 Sep 2005 02:29:23 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 01880-04 + for ; + Thu, 15 Sep 2005 05:29:19 +0000 (GMT) +Received: by svr1.postgresql.org (Postfix, from userid 1001) + id 2A467D9104; Thu, 15 Sep 2005 03:38:53 -0300 (ADT) +Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.202]) + by svr1.postgresql.org (Postfix) with ESMTP id 60652D816D + for ; + Thu, 15 Sep 2005 02:08:47 -0300 (ADT) +Received: by rproxy.gmail.com with SMTP id 40so32616rnz + for ; + Wed, 14 Sep 2005 22:08:47 -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=gw10thneX43j+nsj3w9dz8yuIXhEIhKlEz9NdoCW0izgsawj0O6E//KCkJn9prsc1I5I4LL3ghlM4dTkkTWaQFCP6a1ErVK+QKleQit5sSDmFOxKlrnEDOUKIJdpCnX4qYZ5s8HwSSR08Qf7g0PhsbtXIMTisdjODrpQnC2SAlU= +Received: by 10.11.117.77 with SMTP id p77mr617cwc; + Wed, 14 Sep 2005 22:08:47 -0700 (PDT) +Received: by 10.11.119.38 with HTTP; Wed, 14 Sep 2005 22:08:47 -0700 (PDT) +Message-ID: <36e682920509142208211344d5@mail.gmail.com> +Date: Thu, 15 Sep 2005 01:08:47 -0400 +From: "Jonah H. Harris" +Reply-To: jonah.harris@gmail.com +To: Tom Lane +Subject: Re: About method of PostgreSQL's Optimizer +Cc: pryscila.lista@gmail.com, pgsql-hackers@postgresql.org +In-Reply-To: <36e6829205091421394fbb062a@mail.gmail.com> +Mime-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_7375_13909730.1126760927459" +References: + + <36e6829205091320085993ceba@mail.gmail.com> + + <36e6829205091409361035d32a@mail.gmail.com> + <6127.1126720486@sss.pgh.pa.us> + <36e6829205091421394fbb062a@mail.gmail.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.309 required=5 tests=[AWL=0.228, HTML_30_40=0.056, + HTML_MESSAGE=0.001, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200509/683 +X-Sequence-Number: 73080 + +------=_Part_7375_13909730.1126760927459 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Pryscila, + +For research reference, you may want to look at the work done on the=20 +Columbia Query Optimization Framework. As I recall, I think it (or its=20 +predecessors) had both cost and rule-based optimization. If you need the=20 +code to it, I can dig it up on one of my old systems. + +Albeit dated, another good reference for optimizer implementation is the=20 +cascades query optimization framework. + + +On 9/15/05, Jonah H. Harris wrote: +>=20 +> Tom, +>=20 +> I agree. There have been several occasions where GEQO has performed poorl= +y=20 +> for me. I'll search the archives for the past discussions. +>=20 +> sorry for sending this to you twice Tom... forgot to hit reply all :( +>=20 +> On 9/14/05, Tom Lane wrote: +> >=20 +> > "Jonah H. Harris" writes: +> > > As for using both in the same optimizer, I could only see an algorith= +m=20 +> > such +> > > as a customized-A* being used to planning *some* large queries. The= +=20 +> > reason I +> > > say this is because the cost calculation, which would still need to b= +e=20 +> >=20 +> > > breadth-first, could calculate and cache the cost of most nodes=20 +> > thereby +> > > allowing you to possibly perform transformations at the tail of=20 +> > calculation. +> >=20 +> > We do already have two different plan search algorithms: the strict=20 +> > bottom-up dynamic programming approach (System R style) and the GEQO +> > optimizer, which we switch to when there are too many joins needed to +> > allow exhaustive search. The GEQO code still depends on the normal +> > plan cost estimation code, but it doesn't consider every possible plan.= +=20 +> >=20 +> > I've never been very happy with the GEQO code: the random component of +> > the algorithm means you get unpredictable (and sometimes awful) plans, +> > and the particular variant that we are using is really designed to solv= +e=20 +> >=20 +> > traveling-salesman problems. It's at best a poor fit to the join +> > planning problem. +> >=20 +> > So it seems interesting to me to think about replacing GEQO with a +> > rule-based optimizer for large join search spaces. +> >=20 +> > There are previous discussions about this in the archives, I believe. +> >=20 +> > regards, tom lane +> >=20 +>=20 +>=20 +>=20 +> --=20 +> Respectfully, +>=20 +> Jonah H. Harris, Database Internals Architect +> EnterpriseDB Corporation +> http://www.enterprisedb.com/=20 +>=20 + + + +--=20 +Respectfully, + +Jonah H. Harris, Database Internals Architect +EnterpriseDB Corporation +http://www.enterprisedb.com/ + +------=_Part_7375_13909730.1126760927459 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Pryscila,
+
+For research reference, you may want to look at the work done on the +Columbia Query Optimization Framework.  As I recall, I think it +(or its predecessors) had both cost and rule-based optimization.  +If you need the code to it, I can dig it up on one of my old systems.
+
+Albeit dated, another good reference for optimizer implementation is the ca= +scades query optimization framework.
+
+
On 9/15/05, Jonah H. Harris <jonah= +.harris@gmail.com> wrote:
+Tom,
+ +
+ +I agree.  There have been several occasions where GEQO has +performed poorly for me.  I'll search the archives for the past +discussions.
+
+sorry for sending this to you twice Tom... forgot to hit reply all :(
On 9/14/05, Tom Lane < +tgl@sss.pgh.pa.us +> wrote:
"Jonah H. H= +arris" < +jonah.harris@gmail.com +> writes:
> As for using both in the same optimizer, I could o= +nly see an algorithm such
> as a customized-A* being used to planning= + *some* large queries. The reason I
> say this is because the cost ca= +lculation, which would still need to be +
> breadth-first, could calculate and cache the cost of most nodes th= +ereby
> allowing you to possibly perform transformations at the tail = +of calculation.

We do already have two different plan search algorit= +hms: the strict +
bottom-up dynamic programming approach (System R style) and the GEQOoptimizer, which we switch to when there are too many joins needed to
a= +llow exhaustive search.  The GEQO code still depends on the norma= +l
+plan cost estimation code, but it doesn't consider every possible plan. +

I've never been very happy with the GEQO code: the random component= + of
the algorithm means you get unpredictable (and sometimes awful) plan= +s,
and the particular variant that we are using is really designed to so= +lve +
traveling-salesman problems.  It's at best a poor fit to the = +join
planning problem.

So it seems interesting to me to think abo= +ut replacing GEQO with a
rule-based optimizer for large join search spac= +es.
+ +
There are previous discussions about this in the archives, I believe.
           &nb= +sp;            = +regards, +tom lane



--
Respectfully,

J= +onah H. Harris, Database Internals Architect
EnterpriseDB Corporation +http://www.enterprisedb.com/ +
+ +



--
Respectful= +ly,

Jonah H. Harris, Database Internals Architect
EnterpriseDB Co= +rporation
http://www.enterprise= +db.com/ +
+ +------=_Part_7375_13909730.1126760927459-- + +From pgsql-performance-owner@postgresql.org Thu Sep 15 11:01:17 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E26FBD86B2 + for ; + Thu, 15 Sep 2005 11:01:15 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 31284-10 + for ; + Thu, 15 Sep 2005 14:01:09 +0000 (GMT) +Received: from Herge.rcsinc.local (unknown [70.89.208.142]) + by svr1.postgresql.org (Postfix) with ESMTP id BA679D8541 + for ; + Thu, 15 Sep 2005 11:01:08 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C5B9FD.EEB0F3DA" +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Subject: Re: [ODBC] ODBC Driver on Windows 64 bit +Date: Thu, 15 Sep 2005 10:01:12 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3417DD352@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [ODBC] ODBC Driver on Windows 64 bit +Thread-Index: AcW596LPFirXxdBFTfezQx48D6J6xQAACZnQAABHZjAAAF/54AAAk1nA +From: "Merlin Moncure" +To: "Dave Page" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.037 required=5 tests=[AWL=-0.014, + FORGED_RCVD_HELO=0.05, HTML_MESSAGE=0.001] +X-Spam-Level: +X-Archive-Number: 200509/199 +X-Sequence-Number: 14507 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C5B9FD.EEB0F3DA +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + +Well, pg being a multi-process architecture, on a 64 bit system you get +the advantages of extra memory for cache all day long. I don't thing a +2gb mem limit/backend is not a wall people are hitting very often even +on high end systems. Performance wise, 32 vs. 64 bit is a tug of war +between extra registers & faster 64 bit ops on one side vs. smaller +pointers and better memory footprint on the other. +=20 +Note I am assuming Opteron here where the 32/64 performance is basically +the same. +=20 +Merlin +=20 + =20 + That being said, from what I'm hearing it may be moot because +it's probably best to run postgres as 32 bit on a 64 bit operating +system performance wise. + =20 + =20 +Oh? why's that then? +=20 +/D + +------_=_NextPart_001_01C5B9FD.EEB0F3DA +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + + + + + +
+ +

Well, pg being a multi-process +architecture, on a 64 bit system you get the advantages of extra memory = +for +cache all day long.  I = +don’t +thing a 2gb mem +limit/backend is not a wall people are hitting very often even on high = +end +systems.  Performance wise, = +32 vs. +64 bit is a tug of war between extra registers & faster 64 bit ops = +on one +side vs. smaller pointers and better memory footprint on the = +other.

+ +

 

+ +

Note I am assuming Opteron here = +where the +32/64 performance is basically the same.

+ +

 

+ +

Merlin

+ +

 

+ +
+ +
+ +

 

+ +

That being said, from what = +I’m +hearing it may be moot because it’s probably best to run postgres = +as 32 +bit on a 64 bit operating system performance = +wise.

+ +

 

+ +

 

+ +
+ +

Oh? why's that = +then?

+ +

 

+ +

/D

+ +
+ +
+ + + + + +------_=_NextPart_001_01C5B9FD.EEB0F3DA-- + +From pgsql-performance-owner@postgresql.org Mon Sep 19 19:46:24 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 36888D9142 + for ; + Fri, 16 Sep 2005 08:51:53 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 35787-08 + for ; + Fri, 16 Sep 2005 11:51:48 +0000 (GMT) +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 06905D9132 + for ; + Fri, 16 Sep 2005 08:51:47 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id C358731059; Fri, 16 Sep 2005 13:51:49 +0200 (MET DST) +From: "bm\\mbn" +X-Newsgroups: pgsql.performance +Subject: RAID Stripe size +Date: 16 Sep 2005 04:51:43 -0700 +Organization: http://groups.google.com +Lines: 17 +Message-ID: <1126871503.157442.314670@g49g2000cwa.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/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.7.10) Gecko/20050716 Firefox/1.0.6,gzip(gfe),gzip(gfe) +Complaints-To: groups-abuse@google.com +Injection-Info: g49g2000cwa.googlegroups.com; posting-host=194.90.15.25; + posting-account=cuZ6ZQwAAACyYqV8Ja_6O6NoOzN-TUCZ +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/202 +X-Sequence-Number: 14510 + +Hi Everyone + +The machine is IBM x345 with ServeRAID 6i 128mb cache and 6 SCSI 15k +disks. + +2 disks are in RAID1 and hold the OS, SWAP & pg_xlog +4 disks are in RAID10 and hold the Cluster itself. + +the DB will have two major tables 1 with 10 million rows and one with +100 million rows. +All the activities against this tables will be SELECT. + +Currently the strip size is 8k. I read in many place this is a poor +setting. + +Am i right ? + + +From pgsql-performance-owner@postgresql.org Mon Sep 19 19:47:43 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DEF18D91F0 + for ; + Fri, 16 Sep 2005 22:28:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37524-03 + for ; + Sat, 17 Sep 2005 01:28:13 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id CA400D8F77 + for ; + Fri, 16 Sep 2005 22:28:15 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.13.1/8.13.1) with ESMTP id j8H1SCd7040751 + for ; Sat, 17 Sep 2005 01:28:12 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.13.1/8.13.1/Submit) id j8H1SBAN040748 + for pgsql-performance@postgresql.org; Sat, 17 Sep 2005 01:28:11 GMT + (envelope-from news) +From: Martin Nickel +X-Newsgroups: pgsql.performance +Subject: How can this be? +Date: Fri, 16 Sep 2005 20:34:14 -0500 +Organization: Hub.Org Networking Services +Lines: 51 +Message-ID: +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 8bit +X-Complaints-To: usenet@news.hub.org +To: pgsql.performance@postgresql.org +User-Agent: Pan/0.14.2 (This is not a psychotic episode. It's a cleansing + moment of clarity.) +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=-2.82 required=5 tests=[ALL_TRUSTED=-2.82] +X-Spam-Level: +X-Archive-Number: 200509/203 +X-Sequence-Number: 14511 + +Hello all, +Mostly Postgres makes sense to me. But now and then it does something +that boggles my brain. Take the statements below. I have a table +(agent) with 5300 rows. The primary key is agent_id. I can do SELECT +agent_id FROM agent and it returns all PK values in less than half a +second (dual Opteron box, 4G ram, SATA Raid 10 drive system). + +But when I do a DELETE on two rows with an IN statement, using the primary +key index (as stated by EXPLAIN) it take almost 4 minutes. +pg_stat_activity shows nine other connections, all idle. + +If someone can explain this to me it will help restore my general faith in +order and consistancy in the universe. + +Martin + + +-- Executing query: +SELECT count(*) from agent; +Total query runtime: 54 ms. +Data retrieval runtime: 31 ms. +1 rows retrieved. +Result: 5353 + +-- Executing query: +VACUUM ANALYZE agent; + +-- Executing query: +DELETE FROM agent WHERE agent_id IN (15395, 15394); +Query returned successfully: 2 rows affected, 224092 ms execution time. + +-- Executing query: +EXPLAIN DELETE FROM agent WHERE agent_id IN (15395, 15394); +Index Scan using agent2_pkey, agent2_pkey on agent (cost=0.00..7.27 +rows=2 width=6) +Index Cond: ((agent_id = 15395) OR (agent_id = 15394)) + +Here's my table +CREATE TABLE agent +( + agent_id int4 NOT NULL DEFAULT nextval('agent_id_seq'::text), + office_id int4 NOT NULL, + lastname varchar(25), + firstname varchar(25), +...other columns... + CONSTRAINT agent2_pkey PRIMARY KEY (agent_id), + CONSTRAINT agent_office_fk FOREIGN KEY (office_id) REFERENCES office (office_id) ON UPDATE RESTRICT ON DELETE RESTRICT +) +WITHOUT OIDS; + + + +From pgsql-performance-owner@postgresql.org Sat Sep 17 12:47:36 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F3FCDD7FAA + for ; + Sat, 17 Sep 2005 12:47:34 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 53708-09 + for ; + Sat, 17 Sep 2005 15:47:32 +0000 (GMT) +Received: from pentium2.antoine (m119.net81-67-244.noos.fr [81.67.244.119]) + by svr1.postgresql.org (Postfix) with ESMTP id 1FFE1D6EC0 + for ; + Sat, 17 Sep 2005 12:47:31 -0300 (ADT) +Received: from [192.168.1.11] (pentium4.antoine [192.168.1.11]) + by pentium2.antoine (Postfix) with ESMTP id 07E10C7A49 + for ; + Sat, 17 Sep 2005 17:47:18 +0200 (CEST) +Message-ID: <432C3A86.5010000@free.fr> +Date: Sat, 17 Sep 2005 17:47:18 +0200 +From: Antoine Bajolet +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; fr-FR; + rv:1.7.11) Gecko/20050728 +X-Accept-Language: fr, en, en-us +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Nested Loop trouble : Execution time increases more 1000 time (long) +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.842 required=5 tests=[FORGED_RCVD_HELO=0.05, + RCVD_IN_NJABL_DUL=1.655, RCVD_IN_SORBS_DUL=0.137] +X-Spam-Level: * +X-Archive-Number: 200509/200 +X-Sequence-Number: 14508 + +Hello, + +We are using postgresql in a search engine on an intranet handling +throusand of documents. +But we ave a big problem when users use more than two search key. + +There are more tables around, but the heart of the search engine is +made of three tables : + +fiches (f_id int4, f_title varchar) 52445 rows +engine (f_id int4, k_id int4, weight ) 11761700 rows +keywords(k_id, keyword) 1072600 rows + +A "fiche" is linked to any kind of document. +The engine table counts how many times a keyword appears in a document. + +A query to search on one or two keywords is quick to execute (the +front-end creates thoses queries): + +--------------------------------------------------------------------- +select count (distinct f.f_id) as results +FROM +fiches f + INNER JOIN engine e1 INNER JOIN keywords k1 USING (k_id) USING (f_id) + INNER JOIN engine e2 INNER JOIN keywords k2 USING (k_id) USING (f_id) + +WHERE TRUE +AND k1.keyword like 'maintenance%' +AND k2.keyword like 'exploitation%' +; + +QUERY PLAN +Aggregate (cost=3953.00..3953.00 rows=1 width=4) (actual +time=525.243..525.243 rows=1 loops=1) + -> Nested Loop (cost=1974.79..3952.99 rows=1 width=4) (actual +time=211.570..513.758 rows=6879 loops=1) + -> Hash Join (cost=1974.79..3949.62 rows=1 width=8) (actual +time=211.483..389.340 rows=6879 loops=1) + Hash Cond: ("outer".f_id = "inner".f_id) + -> Nested Loop (cost=0.00..1974.76 rows=11 width=4) +(actual time=0.132..155.499 rows=9520 loops=1) + -> Index Scan using keyword_pattern_key on keywords +k2 (cost=0.00..3.51 rows=1 width=4) (actual time=0.078..1.887 rows=75 +loops=1) + Index Cond: (((keyword)::text ~>=~ +'exploitation'::character varying) AND ((keyword)::text ~<~ +'exploitatioo'::character varying)) + Filter: ((keyword)::text ~~ 'exploitation%'::text) + -> Index Scan using k_id_key on engine e2 +(cost=0.00..1954.93 rows=1306 width=8) (actual time=0.049..1.842 +rows=127 loops=75) + Index Cond: (e2.k_id = "outer".k_id) + -> Hash (cost=1974.76..1974.76 rows=11 width=4) (actual +time=211.203..211.203 rows=0 loops=1) + -> Nested Loop (cost=0.00..1974.76 rows=11 +width=4) (actual time=0.296..197.590 rows=11183 loops=1) + -> Index Scan using keyword_pattern_key on +keywords k1 (cost=0.00..3.51 rows=1 width=4) (actual time=0.189..1.351 +rows=73 loops=1) + Index Cond: (((keyword)::text ~>=~ +'maintenance'::character varying) AND ((keyword)::text ~<~ +'maintenancf'::character varying)) + Filter: ((keyword)::text ~~ +'maintenance%'::text) + -> Index Scan using k_id_key on engine e1 +(cost=0.00..1954.93 rows=1306 width=8) (actual time=0.029..2.406 +rows=153 loops=73) + Index Cond: (e1.k_id = "outer".k_id) + -> Index Scan using fiches_pkey on fiches f (cost=0.00..3.36 +rows=1 width=4) (actual time=0.013..0.014 rows=1 loops=6879) + Index Cond: (f.f_id = "outer".f_id) +Total runtime: 525.511 ms +-------------------------------------------------------------------------- + + +But when there are three keywords or more, the planner chooses to +perform a very costly nested loop : + +-------------------------------------------------------------------------- +select count (distinct f.f_id) as results +FROM +fiches f + INNER JOIN engine e1 INNER JOIN keywords k1 USING (k_id) USING (f_id) + INNER JOIN engine e2 INNER JOIN keywords k2 USING (k_id) USING (f_id) + INNER JOIN engine e3 INNER JOIN keywords k3 USING (k_id) USING (f_id) + +WHERE TRUE +AND k1.keyword like 'maintenance%' +AND k2.keyword like 'exploitation%' +AND k3.keyword like 'numerique%' +; + +QUERY PLAN +Aggregate (cost=5927.90..5927.90 rows=1 width=4) (actual +time=673048.168..673048.169 rows=1 loops=1) + -> Nested Loop (cost=1974.79..5927.90 rows=1 width=4) (actual +time=1853.789..673038.065 rows=2929 loops=1) + -> Nested Loop (cost=1974.79..5924.52 rows=1 width=12) (actual +time=1853.719..672881.725 rows=2929 loops=1) + Join Filter: ("inner".f_id = "outer".f_id) + -> Hash Join (cost=1974.79..3949.62 rows=1 width=8) +(actual time=198.845..441.947 rows=6879 loops=1) + Hash Cond: ("outer".f_id = "inner".f_id) + -> Nested Loop (cost=0.00..1974.76 rows=11 +width=4) (actual time=0.129..199.895 rows=9520 loops=1) + -> Index Scan using keyword_pattern_key on +keywords k2 (cost=0.00..3.51 rows=1 width=4) (actual time=0.077..1.918 +rows=75 loops=1) + Index Cond: (((keyword)::text ~>=~ +'exploitation'::character varying) AND ((keyword)::text ~<~ +'exploitatioo'::character varying)) + Filter: ((keyword)::text ~~ +'exploitation%'::text) + -> Index Scan using k_id_key on engine e2 +(cost=0.00..1954.93 rows=1306 width=8) (actual time=0.035..2.342 +rows=127 loops=75) + Index Cond: (e2.k_id = "outer".k_id) + -> Hash (cost=1974.76..1974.76 rows=11 width=4) +(actual time=198.650..198.650 rows=0 loops=1) + -> Nested Loop (cost=0.00..1974.76 rows=11 +width=4) (actual time=0.174..187.216 rows=11183 loops=1) + -> Index Scan using keyword_pattern_key +on keywords k1 (cost=0.00..3.51 rows=1 width=4) (actual +time=0.113..1.222 rows=73 loops=1) + Index Cond: (((keyword)::text ~>=~ +'maintenance'::character varying) AND ((keyword)::text ~<~ +'maintenancf'::character varying)) + Filter: ((keyword)::text ~~ +'maintenance%'::text) + -> Index Scan using k_id_key on engine +e1 (cost=0.00..1954.93 rows=1306 width=8) (actual time=0.029..2.311 +rows=153 loops=73) + Index Cond: (e1.k_id = "outer".k_id) + -> Nested Loop (cost=0.00..1974.76 rows=11 width=4) +(actual time=0.087..90.165 rows=9553 loops=6879) + -> Index Scan using keyword_pattern_key on keywords +k3 (cost=0.00..3.51 rows=1 width=4) (actual time=0.049..0.628 rows=49 +loops=6879) + Index Cond: (((keyword)::text ~>=~ +'numerique'::character varying) AND ((keyword)::text ~<~ +'numeriquf'::character varying)) + Filter: ((keyword)::text ~~ 'numerique%'::text) + -> Index Scan using k_id_key on engine e3 +(cost=0.00..1954.93 rows=1306 width=8) (actual time=0.023..1.544 +rows=195 loops=337071) + Index Cond: (e3.k_id = "outer".k_id) + -> Index Scan using fiches_pkey on fiches f (cost=0.00..3.36 +rows=1 width=4) (actual time=0.041..0.043 rows=1 loops=2929) + Index Cond: (f.f_id = "outer".f_id) +Total runtime: 673048.405 ms +---------------------------------------------------------------------- +More than 10 minutes ! + +Is there a specific reason the planner chooses this way ? +Can whe do something on the postgresql configuration to avoid this ? +Can whe force the planner to use a hash join as it does for the first +joins ? + +Regards, +Antoine Bajolet + + + +From pgsql-performance-owner@postgresql.org Mon Sep 19 20:00:47 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EA445D8C44 + for ; + Mon, 19 Sep 2005 20:00:44 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 41787-05 + for ; + Mon, 19 Sep 2005 23:00:36 +0000 (GMT) +Received: from window.monsterlabs.com (window.monsterlabs.com + [216.183.105.176]) + by svr1.postgresql.org (Postfix) with SMTP id 4E2D8D8B43 + for ; + Mon, 19 Sep 2005 20:00:35 -0300 (ADT) +Received: (qmail 15786 invoked from network); 19 Sep 2005 22:58:31 -0000 +Received: from pcp0012204803pcs.blairblvd.tn.nash.comcast.net (HELO + ?192.168.15.106?) (69.245.49.69) + by 0 with SMTP; 19 Sep 2005 22:58:31 -0000 +Mime-Version: 1.0 (Apple Message framework v734) +Content-Transfer-Encoding: quoted-printable +Message-Id: <5DDEAB6E-36F9-422C-A44F-56E190B9FF55@sitening.com> +Content-Type: text/plain; charset=WINDOWS-1252; delsp=yes; format=flowed +To: PgSQL Performance +From: "Thomas F. O'Connell" +Subject: Index Selection: ORDER BY vs. PRIMARY KEY +Date: Mon, 19 Sep 2005 18:00:33 -0500 +X-Mailer: Apple Mail (2.734) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.021 required=5 tests=[AWL=0.021] +X-Spam-Level: +X-Archive-Number: 200509/204 +X-Sequence-Number: 14512 + +I have a query that looks roughly like this (I've removed irrelevant =20 +SELECT clause material and obfuscated names, trying to keep them =20 +consistent where altered in EXPLAIN output): + +SELECT u.emma_member_id, h.action_ts +FROM user as u, history as h +WHERE u.user_id =3D h.user_id +AND h.action_id =3D '$constant_data' +ORDER BY h.action_ts DESC LIMIT 100 OFFSET 0 + +The user table has ~25,000 rows. The history table has ~750,000 rows. =20= + +Currently, there is an index on history.action_ts and a separate one =20 +on history.action_id. There's also a PRIMARY KEY on user.user_id. If =20 +I run the query as such, I get a plan like this: + + QUERY PLAN +------------------------------------------------------------------------=20= + +------------------------------------------------------------------------=20= + +-------------------------------------------------------- +Limit (cost=3D0.00..2196.30 rows=3D100 width=3D925) (actual =20 +time=3D947.208..3178.775 rows=3D3 loops=3D1) + -> Nested Loop (cost=3D0.00..83898.65 rows=3D3820 width=3D925) =20 +(actual time=3D947.201..3178.759 rows=3D3 loops=3D1) + -> Index Scan Backward using h_action_ts_idx on history h =20= + +(cost=3D0.00..60823.53 rows=3D3820 width=3D480) (actual =20 +time=3D946.730..3177.953 rows=3D3 loops=3D1) + Filter: (action_id =3D $constant_data::bigint) + -> Index Scan using user_pkey on user u (cost=3D0.00..6.01 =20= + +rows=3D1 width=3D445) (actual time=3D0.156..0.161 rows=3D1 loops=3D3) + Index Cond: (u.user_id =3D "outer".user_id) +Total runtime: 3179.143 ms +(7 rows) + +If I drop the index on the timestamp field, I get a plan like this: + + QUERY PLAN +------------------------------------------------------------------------=20= + +------------------------------------------------------------------------=20= + +------------------------------------------------- +Limit (cost=3D17041.41..17041.66 rows=3D100 width=3D925) (actual =20 +time=3D201.725..201.735 rows=3D3 loops=3D1) + -> Sort (cost=3D17041.41..17050.96 rows=3D3820 width=3D925) = +(actual =20 +time=3D201.719..201.722 rows=3D3 loops=3D1) + Sort Key: h.action_ts + -> Merge Join (cost=3D13488.15..16814.13 rows=3D3820 =20 +width=3D925) (actual time=3D7.306..201.666 rows=3D3 loops=3D1) + Merge Cond: ("outer".user_id =3D "inner".user_id) + -> Index Scan using user_pkey on user u =20 +(cost=3D0.00..3134.82 rows=3D26802 width=3D445) (actual = +time=3D0.204..151.351 =20 +rows=3D24220 loops=3D1) + -> Sort (cost=3D13488.15..13497.70 rows=3D3820 =20 +width=3D480) (actual time=3D0.226..0.234 rows=3D3 loops=3D1) + Sort Key: h.user_id + -> Index Scan using h_action_id_idx on history =20= + +h (cost=3D0.00..13260.87 rows=3D3820 width=3D480) (actual =20 +time=3D0.184..0.195 rows=3D3 loops=3D1) + Index Cond: (action_id =3D =20 +$constant_data::bigint) +Total runtime: 202.089 ms +(11 rows) + +Clearly, if the index on the timestamp field is there, postgres wants =20= + +to use it for the ORDER BY, even though the performance is worse. How =20= + +is this preference made internally? If both indexes exist, will =20 +postgres always prefer the index on an ordered column? If I need the =20 +index on the timestamp field for other queries, is my best bet just =20 +to increase sort_mem for this query? + +Here's my version string: +PostgreSQL 8.0.3 on i686-pc-linux-gnu, compiled by GCC 2.95.4 + +-- +Thomas F. O'Connell +Co-Founder, Information Architect +Sitening, LLC + +Strategic Open Source: Open Your i=99 + +http://www.sitening.com/ +110 30th Avenue North, Suite 6 +Nashville, TN 37203-6320 +615-469-5150 +615-469-5151 (fax) + + +From pgsql-performance-owner@postgresql.org Mon Sep 19 20:04:25 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5A10BD8B43 + for ; + Mon, 19 Sep 2005 20:04:22 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 43522-04 + for ; + Mon, 19 Sep 2005 23:04:15 +0000 (GMT) +Received: from gp.word-to-the-wise.com (gp.word-to-the-wise.com + [64.71.176.18]) + by svr1.postgresql.org (Postfix) with ESMTP id 87390D88C4 + for ; + Mon, 19 Sep 2005 20:04:16 -0300 (ADT) +Received: by gp.word-to-the-wise.com (Postfix, from userid 500) + id 9393E8FC095; Mon, 19 Sep 2005 16:02:09 -0700 (PDT) +Date: Mon, 19 Sep 2005 16:02:09 -0700 +From: Steve Atkins +To: pgsql-performance@postgresql.org +Subject: Re: How can this be? +Message-ID: <20050919230209.GA22764@gp.word-to-the-wise.com> +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +User-Agent: Mutt/1.4.1i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.88 required=5 tests=[AWL=-0.496, + DNS_FROM_RFC_POST=1.376] +X-Spam-Level: +X-Archive-Number: 200509/205 +X-Sequence-Number: 14513 + +On Fri, Sep 16, 2005 at 08:34:14PM -0500, Martin Nickel wrote: + +> Hello all, +> Mostly Postgres makes sense to me. But now and then it does something +> that boggles my brain. Take the statements below. I have a table +> (agent) with 5300 rows. The primary key is agent_id. I can do SELECT +> agent_id FROM agent and it returns all PK values in less than half a +> second (dual Opteron box, 4G ram, SATA Raid 10 drive system). +> +> But when I do a DELETE on two rows with an IN statement, using the primary +> key index (as stated by EXPLAIN) it take almost 4 minutes. +> pg_stat_activity shows nine other connections, all idle. +> +> If someone can explain this to me it will help restore my general faith in +> order and consistancy in the universe. + +When you delete a row from agent PG needs to find any matching rows in +office. Is office large? Is office(office_id) indexed? + +> -- Executing query: +> DELETE FROM agent WHERE agent_id IN (15395, 15394); +> Query returned successfully: 2 rows affected, 224092 ms execution time. +> +> -- Executing query: +> EXPLAIN DELETE FROM agent WHERE agent_id IN (15395, 15394); +> Index Scan using agent2_pkey, agent2_pkey on agent (cost=0.00..7.27 +> rows=2 width=6) +> Index Cond: ((agent_id = 15395) OR (agent_id = 15394)) +> +> Here's my table +> CREATE TABLE agent +> ( +> agent_id int4 NOT NULL DEFAULT nextval('agent_id_seq'::text), +> office_id int4 NOT NULL, +> lastname varchar(25), +> firstname varchar(25), +> ...other columns... +> CONSTRAINT agent2_pkey PRIMARY KEY (agent_id), +> CONSTRAINT agent_office_fk FOREIGN KEY (office_id) REFERENCES office (office_id) ON UPDATE RESTRICT ON DELETE RESTRICT +> ) +> WITHOUT OIDS; + +Cheers, + Steve + +From pgsql-performance-owner@postgresql.org Mon Sep 19 20:08:39 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7509ED7D51 + for ; + Mon, 19 Sep 2005 20:08:37 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 40666-09 + for ; + Mon, 19 Sep 2005 23:08:31 +0000 (GMT) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id 75604D71EA + for ; + Mon, 19 Sep 2005 20:08:32 -0300 (ADT) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id 98CB4355BB; Mon, 19 Sep 2005 16:07:44 -0700 (PDT) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id 974A6355B8; Mon, 19 Sep 2005 16:07:44 -0700 (PDT) +Date: Mon, 19 Sep 2005 16:07:44 -0700 (PDT) +From: Stephan Szabo +To: Martin Nickel +Cc: pgsql-performance@postgresql.org +Subject: Re: How can this be? +In-Reply-To: +Message-ID: <20050919160622.F99507@megazone.bigpanda.com> +References: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/206 +X-Sequence-Number: 14514 + +On Fri, 16 Sep 2005, Martin Nickel wrote: + +> Hello all, +> Mostly Postgres makes sense to me. But now and then it does something +> that boggles my brain. Take the statements below. I have a table +> (agent) with 5300 rows. The primary key is agent_id. I can do SELECT +> agent_id FROM agent and it returns all PK values in less than half a +> second (dual Opteron box, 4G ram, SATA Raid 10 drive system). +> +> But when I do a DELETE on two rows with an IN statement, using the primary +> key index (as stated by EXPLAIN) it take almost 4 minutes. +> pg_stat_activity shows nine other connections, all idle. + +Are there any tables that reference agent or other triggers? My first +guess would be that there's a foreign key check for something else that's +referencing agent.agent_id for which an index scan isn't being used. + +From pgsql-performance-owner@postgresql.org Tue Sep 20 00:05:52 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A8F7FD7957 + for ; + Tue, 20 Sep 2005 00:05:47 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 09305-01 + for ; + Tue, 20 Sep 2005 03:05:43 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 20A22D926B + for ; + Tue, 20 Sep 2005 00:05:42 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j8K35f2B001649; + Mon, 19 Sep 2005 23:05:41 -0400 (EDT) +To: "Thomas F. O'Connell" +Cc: PgSQL Performance +Subject: Re: Index Selection: ORDER BY vs. PRIMARY KEY +In-reply-to: <5DDEAB6E-36F9-422C-A44F-56E190B9FF55@sitening.com> +References: <5DDEAB6E-36F9-422C-A44F-56E190B9FF55@sitening.com> +Comments: In-reply-to "Thomas F. O'Connell" + message dated "Mon, 19 Sep 2005 18:00:33 -0500" +Date: Mon, 19 Sep 2005 23:05:41 -0400 +Message-ID: <1648.1127185541@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/207 +X-Sequence-Number: 14515 + +"Thomas F. O'Connell" writes: +> Clearly, if the index on the timestamp field is there, postgres wants +> to use it for the ORDER BY, even though the performance is worse. How +> is this preference made internally? If both indexes exist, will +> postgres always prefer the index on an ordered column? If I need the +> index on the timestamp field for other queries, is my best bet just +> to increase sort_mem for this query? + +If you suppose that Postgres has a "preference" for one index over +another, you're already fatally off track. It's all about estimated +costs. In this case, the plan with h_action_ts_idx is preferred because +it has a lower estimated cost (2196.30) than the other plan (17041.66). +The way to think about this is not that Postgres "prefers" one index +over another, but that the estimated costs aren't in line with reality. + +It looks from the plans that there are a number of estimation errors +giving you trouble, but the one that seems most easily fixable is +here: + + -> Index Scan using h_action_id_idx on history h (cost=0.00..13260.87 rows=3820 width=480) (actual time=0.184..0.195 rows=3 loops=1) + Index Cond: (action_id = $constant_data::bigint) + +Estimating 3820 rows matching $constant_data when there are really only +3 is a pretty serious estimation error :-( ... certainly more than +enough to explain a factor-of-100 error in the total estimated costs. + +How recently did you last ANALYZE the history file? If the ANALYZE +stats are up-to-date and it's still blowing the rowcount estimate by +a factor of 1000, maybe you need to increase the statistics target for +this column. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Sep 20 00:21:38 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 123ABD8975 + for ; + Tue, 20 Sep 2005 00:21:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 12158-04 + for ; + Tue, 20 Sep 2005 03:21:28 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id AABADD7ECE + for ; + Tue, 20 Sep 2005 00:21:26 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j8K3LNUa001833; + Mon, 19 Sep 2005 23:21:23 -0400 (EDT) +To: "cydatamatt@gmail.com" +Cc: pgsql-performance@postgresql.org +Subject: Re: How many tables is too many tables? +In-reply-to: <1126643032.787041.127400@z14g2000cwz.googlegroups.com> +References: <1126643032.787041.127400@z14g2000cwz.googlegroups.com> +Comments: In-reply-to "cydatamatt@gmail.com" + message dated "13 Sep 2005 13:23:52 -0700" +Date: Mon, 19 Sep 2005 23:21:23 -0400 +Message-ID: <1832.1127186483@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.241 required=5 tests=[AWL=-0.229, + TO_ADDRESS_EQ_REAL=0.47] +X-Spam-Level: +X-Archive-Number: 200509/208 +X-Sequence-Number: 14516 + +"cydatamatt@gmail.com" writes: +> We currently have around 400,000 tables +> and I would estimate that the vast majority of these tables are +> relatively small (less than 200 rows). + +Stop right there, and go redesign your schema. This is unbelievably +wrong :-( + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Sep 20 01:22:35 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D4775D7A0A + for ; + Tue, 20 Sep 2005 01:22:32 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25730-04 + for ; + Tue, 20 Sep 2005 04:22:29 +0000 (GMT) +Received: from ionian.i-clic.uihc.uiowa.edu (ionian.i-clic.uihc.uiowa.edu + [129.255.211.20]) + by svr1.postgresql.org (Postfix) with ESMTP id 5E3F5D7780 + for ; + Tue, 20 Sep 2005 01:22:25 -0300 (ADT) +Received: by ionian.i-clic.uihc.uiowa.edu (Postfix, from userid 76) + id D5B5F61DAF; Mon, 19 Sep 2005 22:11:50 -0500 (CDT) +Received: from [192.168.1.12] (12-214-18-81.client.mchsi.com [12.214.18.81]) + by ionian.i-clic.uihc.uiowa.edu (Postfix) with ESMTP + id 503A761DAD; Mon, 19 Sep 2005 22:11:49 -0500 (CDT) +Message-ID: <432F8E7C.4080704@arbash-meinel.com> +Date: Tue, 20 Sep 2005 00:22:20 -0400 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "cydatamatt@gmail.com" +Cc: pgsql-performance@postgresql.org +Subject: Re: How many tables is too many tables? +References: <1126643032.787041.127400@z14g2000cwz.googlegroups.com> +In-Reply-To: <1126643032.787041.127400@z14g2000cwz.googlegroups.com> +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enigF3EC9859E225F28A2EDB2A54" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.252 required=5 tests=[AWL=-0.218, + TO_ADDRESS_EQ_REAL=0.47] +X-Spam-Level: +X-Archive-Number: 200509/209 +X-Sequence-Number: 14517 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enigF3EC9859E225F28A2EDB2A54 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 7bit + +cydatamatt@gmail.com wrote: +> I have a database of hundreds of millions of web links (between sites) +> in Postgres. For each link, we record the url, the referer, and the +> most recent date the link exists. I'm having some serious performance +> issues when it comes to writing new data into the database. +> +> One machine is simply not going to be able to scale with the quantities +> of links we hope to store information about and we want to move to some +> kind of cluster. Because of the quantities of data, it seems to make +> sense to go for a cluster setup such that in a 4 machine cluster, each +> machine has a quarter of the data (is this "Share nothing," or, "Share +> everything"?). To that end, we figured a good first step was to +> partition the data on one machine into multiple tables defining the +> logic which would find the appropriate table given a piece of data. +> Then, we assumed, adding the logic to find the appropriate machine and +> database in our cluster would only be an incremental upgrade. + +In a database app, you generally don't win by going to a cluster, +because you are almost always bound by your I/O. Which means that a +single machine, just with more disks, is going to outperform a group of +machines. + +As Tom mentioned, your schema is not very good. So lets discuss what a +better schema would be, and also how you might be able to get decent +performance with a cluster. + +First, 200rows * 400,000 tables = 80M rows. Postgres can handle this in +a single table without too much difficulty. It all depends on the +selectivity of your indexes, etc. + +I'm not sure how you are trying to normalize your data, but it sounds +like having a url table so that each entry can be a simple integer, +rather than the full path, considering that you are likely to have a +bunch of repeated information. + +This makes your main table something like 2 integers, plus the +interesting stuff (from url, to url, data). + +If you are finding you are running into I/O problems, you probably could +use this layout to move your indexes off onto their own spindles, and +maybe separate the main table from the url tables. + +What is your hardware? What are you trying to do that you don't think +will scale? + +If you were SELECT bound, then maybe a cluster would help you, because +you could off-load the SELECTs onto slave machines, and leave your +primary machine available for INSERTs and replication. + +> +... + +> +> At this point, the primary performance bottleneck is in adding +> additional data to the database. Our loader program (we load text +> files of link information) is currently getting about 40 rows a second, +> which is nowhere near the performance we need to be seeing. In theory, +> we want to be able to re-write our entire archive of data within on a +> 1-2 month cycle, so this is a very heavy write application (though +> we're also constantly generating reports from the data, so its not +> write only). + +Are you VACUUMing enough? If you are rewriting all of the data, postgres +needs you to clean up afterwards. It is pessimistic, and leaves old rows +in their place. + +> +> Is the total number of tables prohibitively affecting our write speed +> or is that an IO problem that can only be addressed by better drive +> partitioning (all data is on one drive, which I've already read is a +> problem)? Is this approach to data partitioning one which makes any +> sense for performance, or should we move to a more normal distribution +> of links across fewer tables which house more rows each? + +If all data is on a single drive, you are nowhere near needing a cluster +to improve your database. What you need is a 14-drive RAID array. It's +probably cheaper than 4x powerful machines, and will provide you with +much better performance. And put all of your tables back into one. + +John +=:-> + +> +> Thanks in advance for your advice. +> +> -matt +> +> +> ---------------------------(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 +> + + +--------------enigF3EC9859E225F28A2EDB2A54 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFDL458JdeBCYSNAAMRAoXhAKC4BRdx5796GLeqOALdkc+7E3ChSgCfRO27 +8kl25uc2G5inTOWcDILSTZ0= +=m2ll +-----END PGP SIGNATURE----- + +--------------enigF3EC9859E225F28A2EDB2A54-- + +From pgsql-performance-owner@postgresql.org Tue Sep 20 01:25:06 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id ECA07D7083 + for ; + Tue, 20 Sep 2005 01:25:05 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 26420-04 + for ; + Tue, 20 Sep 2005 04:25:02 +0000 (GMT) +Received: from ionian.i-clic.uihc.uiowa.edu (ionian.i-clic.uihc.uiowa.edu + [129.255.211.20]) + by svr1.postgresql.org (Postfix) with ESMTP id E4795D6F9A + for ; + Tue, 20 Sep 2005 01:25:02 -0300 (ADT) +Received: by ionian.i-clic.uihc.uiowa.edu (Postfix, from userid 76) + id 9E9A361DAF; Mon, 19 Sep 2005 22:14:29 -0500 (CDT) +Received: from [192.168.1.12] (12-214-18-81.client.mchsi.com [12.214.18.81]) + by ionian.i-clic.uihc.uiowa.edu (Postfix) with ESMTP + id 4BED661DAD; Mon, 19 Sep 2005 22:14:28 -0500 (CDT) +Message-ID: <432F8F1B.7030901@arbash-meinel.com> +Date: Tue, 20 Sep 2005 00:24:59 -0400 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "bm\\mbn" +Cc: pgsql-performance@postgresql.org +Subject: Re: RAID Stripe size +References: <1126871503.157442.314670@g49g2000cwa.googlegroups.com> +In-Reply-To: <1126871503.157442.314670@g49g2000cwa.googlegroups.com> +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enigBED3454481BF187A190F69A9" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.019 required=5 tests=[AWL=0.019] +X-Spam-Level: +X-Archive-Number: 200509/210 +X-Sequence-Number: 14518 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enigBED3454481BF187A190F69A9 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 7bit + +bm\mbn wrote: +> Hi Everyone +> +> The machine is IBM x345 with ServeRAID 6i 128mb cache and 6 SCSI 15k +> disks. +> +> 2 disks are in RAID1 and hold the OS, SWAP & pg_xlog +> 4 disks are in RAID10 and hold the Cluster itself. +> +> the DB will have two major tables 1 with 10 million rows and one with +> 100 million rows. +> All the activities against this tables will be SELECT. + +What type of SELECTs will you be doing? Mostly sequential reads of a +bunch of data, or indexed lookups of random pieces? + +> +> Currently the strip size is 8k. I read in many place this is a poor +> setting. + +>From what I've heard of RAID, if you are doing large sequential +transfers, larger stripe sizes (128k, 256k) generally perform better. +For postgres, though, when you are writing, having the stripe size be +around the same size as your page size (8k) could be advantageous, as +when postgres reads a page, it only reads a single stripe. So if it were +reading a series of pages, each one would come from a different disk. + +I may be wrong about that, though. + +John +=:-> + +> +> Am i right ? + + +--------------enigBED3454481BF187A190F69A9 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFDL48bJdeBCYSNAAMRAs40AJsGKRxP1Kof/DliHwldecMXkx2rvACdEtvd +w3WWrbrsu8zOfexGpuelkAE= +=0ucd +-----END PGP SIGNATURE----- + +--------------enigBED3454481BF187A190F69A9-- + +From pgsql-performance-owner@postgresql.org Tue Sep 20 02:37:11 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8874AD80D3 + for ; + Tue, 20 Sep 2005 02:37:10 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 40048-10 + for ; + Tue, 20 Sep 2005 05:37:03 +0000 (GMT) +Received: from window.monsterlabs.com (window.monsterlabs.com + [216.183.105.176]) + by svr1.postgresql.org (Postfix) with SMTP id 3C733D72AA + for ; + Tue, 20 Sep 2005 02:37:02 -0300 (ADT) +Received: (qmail 21554 invoked from network); 20 Sep 2005 05:34:53 -0000 +Received: from pcp0012204803pcs.blairblvd.tn.nash.comcast.net (HELO + ?192.168.15.106?) (69.245.49.69) + by 0 with SMTP; 20 Sep 2005 05:34:53 -0000 +In-Reply-To: <1648.1127185541@sss.pgh.pa.us> +References: <5DDEAB6E-36F9-422C-A44F-56E190B9FF55@sitening.com> + <1648.1127185541@sss.pgh.pa.us> +Mime-Version: 1.0 (Apple Message framework v734) +Content-Type: text/plain; charset=WINDOWS-1252; delsp=yes; format=flowed +Message-Id: +Cc: PgSQL Performance +Content-Transfer-Encoding: quoted-printable +From: "Thomas F. O'Connell" +Subject: Re: Index Selection: ORDER BY vs. PRIMARY KEY +Date: Tue, 20 Sep 2005 00:36:51 -0500 +To: Tom Lane +X-Mailer: Apple Mail (2.734) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.02 required=5 tests=[AWL=0.020] +X-Spam-Level: +X-Archive-Number: 200509/211 +X-Sequence-Number: 14519 + + +On Sep 19, 2005, at 10:05 PM, Tom Lane wrote: + +> "Thomas F. O'Connell" writes: +> +>> Clearly, if the index on the timestamp field is there, postgres wants +>> to use it for the ORDER BY, even though the performance is worse. How +>> is this preference made internally? If both indexes exist, will +>> postgres always prefer the index on an ordered column? If I need the +>> index on the timestamp field for other queries, is my best bet just +>> to increase sort_mem for this query? +> +> If you suppose that Postgres has a "preference" for one index over +> another, you're already fatally off track. It's all about estimated +> costs. In this case, the plan with h_action_ts_idx is preferred =20 +> because +> it has a lower estimated cost (2196.30) than the other plan =20 +> (17041.66). +> The way to think about this is not that Postgres "prefers" one index +> over another, but that the estimated costs aren't in line with =20 +> reality. +> +> It looks from the plans that there are a number of estimation errors +> giving you trouble, but the one that seems most easily fixable is +> here: +> +> -> Index Scan using h_action_id_idx on history h =20 +> (cost=3D0.00..13260.87 rows=3D3820 width=3D480) (actual = +time=3D0.184..0.195 =20 +> rows=3D3 loops=3D1) +> Index Cond: (action_id =3D $constant_data::bigint) +> +> Estimating 3820 rows matching $constant_data when there are really =20 +> only +> 3 is a pretty serious estimation error :-( ... certainly more than +> enough to explain a factor-of-100 error in the total estimated costs. +> +> How recently did you last ANALYZE the history file? If the ANALYZE +> stats are up-to-date and it's still blowing the rowcount estimate by +> a factor of 1000, maybe you need to increase the statistics target for +> this column. +> +> regards, tom lane + +Thanks for the guidance, Tom. I don't know why I was "fatally off =20 +track" on this one. It was indeed statistics related. pg_autovacuum =20 +hadn't visited this table for a long enough window to have an impact =20 +on the estimates. A sad case of the should've-known-betters... + +-- +Thomas F. O'Connell +Co-Founder, Information Architect +Sitening, LLC + +Strategic Open Source: Open Your i=99 + +http://www.sitening.com/ +110 30th Avenue North, Suite 6 +Nashville, TN 37203-6320 +615-469-5150 +615-469-5151 (fax) + + +From pgsql-performance-owner@postgresql.org Tue Sep 20 04:50:25 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F289ED825F + for ; + Tue, 20 Sep 2005 04:50:21 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 71121-05 + for ; + Tue, 20 Sep 2005 07:50:14 +0000 (GMT) +Received: from mxout5.netvision.net.il (mxout5.netvision.net.il [194.90.9.29]) + by svr1.postgresql.org (Postfix) with ESMTP id 883B4D80E4 + for ; + Tue, 20 Sep 2005 04:50:14 -0300 (ADT) +Received: from [192.168.0.50] ([194.90.15.25]) by mxout5.netvision.net.il + (Sun Java System Messaging Server 6.1 HotFix 0.11 (built Jan 28 2005)) + with ESMTP id <0IN3005IGV3P5P60@mxout5.netvision.net.il> for + pgsql-performance@postgresql.org; Tue, 20 Sep 2005 10:50:14 +0300 (IDT) +Date: Tue, 20 Sep 2005 10:51:41 +0300 +From: Michael Ben-Nes +Subject: Re: RAID Stripe size +In-reply-to: <432F8F1B.7030901@arbash-meinel.com> +To: John A Meinel +Cc: pgsql-performance@postgresql.org +Message-id: <432FBF8D.5010501@canaan.co.il> +Organization: Canaan Surfing Ltd +MIME-version: 1.0 +Content-type: text/plain; charset=UTF-8; format=flowed +Content-transfer-encoding: 7BIT +X-Accept-Language: en-us, en +References: <1126871503.157442.314670@g49g2000cwa.googlegroups.com> + <432F8F1B.7030901@arbash-meinel.com> +User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.091 required=5 tests=[AWL=0.091] +X-Spam-Level: +X-Archive-Number: 200509/212 +X-Sequence-Number: 14520 + +Hi + + +John A Meinel wrote: + +>bm\mbn wrote: +> +> +>>Hi Everyone +>> +>>The machine is IBM x345 with ServeRAID 6i 128mb cache and 6 SCSI 15k +>>disks. +>> +>>2 disks are in RAID1 and hold the OS, SWAP & pg_xlog +>>4 disks are in RAID10 and hold the Cluster itself. +>> +>>the DB will have two major tables 1 with 10 million rows and one with +>>100 million rows. +>>All the activities against this tables will be SELECT. +>> +>> +> +>What type of SELECTs will you be doing? Mostly sequential reads of a +>bunch of data, or indexed lookups of random pieces? +> +> +All of them. some Rtree some btree some without using indexes. + +> +> +>>Currently the strip size is 8k. I read in many place this is a poor +>>setting. +>> +>> +> +>>From what I've heard of RAID, if you are doing large sequential +>transfers, larger stripe sizes (128k, 256k) generally perform better. +>For postgres, though, when you are writing, having the stripe size be +>around the same size as your page size (8k) could be advantageous, as +>when postgres reads a page, it only reads a single stripe. So if it were +>reading a series of pages, each one would come from a different disk. +> +>I may be wrong about that, though. +> +> +I must admit im a bit amazed how such important parameter is so +ambiguous. an optimal strip size can improve the performance of the db +significantly. I bet that the difference in performance between a poor +stripe setting to an optimal one is more important then how much RAM or +CPU you have. +I hope to run some tests soon thugh i have limited time on the +production server to do such tests. + +>John +>=:-> +> +> +> +>>Am i right ? +>> +>> +> +> +> + +-- +-------------------------- +Canaan Surfing Ltd. +Internet Service Providers +Ben-Nes Michael - Manager +Tel: 972-4-6991122 +Cel: 972-52-8555757 +Fax: 972-4-6990098 +http://www.canaan.net.il +-------------------------- + + +From pgsql-performance-owner@postgresql.org Tue Sep 20 06:41:16 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E55EDD7E7A + for ; + Tue, 20 Sep 2005 06:41:15 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 97534-03 + for ; + Tue, 20 Sep 2005 09:41:10 +0000 (GMT) +Received: from vms040pub.verizon.net (vms040pub.verizon.net [206.46.252.40]) + by svr1.postgresql.org (Postfix) with ESMTP id E160ED72E9 + for ; + Tue, 20 Sep 2005 06:41:08 -0300 (ADT) +Received: from osgiliath.mathom.us ([151.200.14.55]) + by vms040.mailsrvcs.net (Sun Java System Messaging Server 6.2 HotFix + 0.04 (built Dec 24 2004)) with ESMTPA id + <0IN400IYG08LM1HG@vms040.mailsrvcs.net> for + pgsql-performance@postgresql.org; Tue, 20 Sep 2005 04:41:10 -0500 (CDT) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id ACC2C600605 for + ; + Tue, 20 Sep 2005 05:41:09 -0400 (EDT) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 15390-01 for ; Tue, + 20 Sep 2005 05:41:09 -0400 (EDT) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id 510D6600489; Tue, 20 Sep 2005 05:41:09 -0400 (EDT) +Date: Tue, 20 Sep 2005 05:41:09 -0400 +From: Michael Stone +Subject: Re: RAID Stripe size +In-reply-to: <432FBF8D.5010501@canaan.co.il> +To: pgsql-performance@postgresql.org +Mail-Followup-To: pgsql-performance@postgresql.org +Message-id: <20050920094109.GZ14918@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: by amavisd-new-20030616-p10 (Debian) at mathom.us +References: <1126871503.157442.314670@g49g2000cwa.googlegroups.com> + <432F8F1B.7030901@arbash-meinel.com> <432FBF8D.5010501@canaan.co.il> +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.039 required=5 tests=[AWL=-0.011, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/213 +X-Sequence-Number: 14521 + +On Tue, Sep 20, 2005 at 10:51:41AM +0300, Michael Ben-Nes wrote: +>I must admit im a bit amazed how such important parameter is so +>ambiguous. an optimal strip size can improve the performance of the db +>significantly. + +It's configuration dependent. IME, it has an insignificant effect. If +anything, changing it from the vendor default may make performance worse +(maybe the firmware on the array is tuned for a particular size?) + +>I bet that the difference in performance between a poor stripe setting +>to an optimal one is more important then how much RAM or CPU you have. + +I'll take that bet, because I've benched it. If something so trivial +(and completely free) was the single biggest factor in performance, do +you really think it would be an undiscovered secret? + +>I hope to run some tests soon thugh i have limited time on the +>production server to do such tests. + +Well, benchmarking your data on your hardware is the first thing you +should do, not something you should try to cram in late in the game. You +can't get a valid answer to a "what's the best configuration" question +until you've tested some configurations. + +Mike Stone + +From pgsql-performance-owner@postgresql.org Tue Sep 20 07:52:02 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A5838D72E9 + for ; + Tue, 20 Sep 2005 07:52:01 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 11767-04 + for ; + Tue, 20 Sep 2005 10:51:57 +0000 (GMT) +Received: from i-free.spb.ru (i-free.spb.ru [194.105.194.152]) + by svr1.postgresql.org (Postfix) with ESMTP id 23D10D7271 + for ; + Tue, 20 Sep 2005 07:51:55 -0300 (ADT) +Received: from localhost (localhost [127.0.0.1]) + by i-free.spb.ru (Postfix) with ESMTP id A7A6A33E91; + Tue, 20 Sep 2005 14:51:56 +0400 (MSD) +Received: from i-free.spb.ru ([127.0.0.1]) + by localhost (i-free [127.0.0.1]) (amavisd-new, port 10024) with LMTP + id 30208-01-6; Tue, 20 Sep 2005 14:51:56 +0400 (MSD) +Received: from office1.i-free.ru (office1.i-free.ru [81.222.216.82]) + by i-free.spb.ru (Postfix) with ESMTP id 126FD2F308; + Tue, 20 Sep 2005 14:51:55 +0400 (MSD) +Received: from [192.168.0.250] (helo=deepcore) + by office1.i-free.ru with smtp (Exim 3.36 #1 (Debian)) + id 1EHfj9-00011m-00; Tue, 20 Sep 2005 14:51:55 +0400 +Date: Tue, 20 Sep 2005 14:53:07 +0400 +From: evgeny gridasov +To: "bm\\mbn" +Cc: pgsql-performance@postgresql.org +Subject: Re: RAID Stripe size +Message-Id: <20050920145307.1a111595.eugrid@fpm.kubsu.ru> +In-Reply-To: <1126871503.157442.314670@g49g2000cwa.googlegroups.com> +References: <1126871503.157442.314670@g49g2000cwa.googlegroups.com> +X-Mailer: Sylpheed version 2.0.0 (GTK+ 2.6.2; i486-pc-linux-gnu) +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at i-free.spb.ru +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/214 +X-Sequence-Number: 14522 + +Hi Everybody! + +I've got a spare machine which is 2xXEON 3.2GHz, 4Gb RAM +14x140Gb SCSI 10k (LSI MegaRaid 320U). It is going into production in 3-5months. +I do have free time to run tests on this machine, and I could test different stripe sizes +if somebody prepares a test script and data for that. + +I could also test different RAID modes 0,1,5 and 10 for this script. + +I guess the community needs these results. + +On 16 Sep 2005 04:51:43 -0700 +"bm\\mbn" wrote: + +> Hi Everyone +> +> The machine is IBM x345 with ServeRAID 6i 128mb cache and 6 SCSI 15k +> disks. +> +> 2 disks are in RAID1 and hold the OS, SWAP & pg_xlog +> 4 disks are in RAID10 and hold the Cluster itself. +> +> the DB will have two major tables 1 with 10 million rows and one with +> 100 million rows. +> All the activities against this tables will be SELECT. +> +> Currently the strip size is 8k. I read in many place this is a poor +> setting. +> +> Am i right ? + +-- +Evgeny Gridasov +Software Developer +I-Free, Russia + +From pgsql-performance-owner@postgresql.org Tue Sep 20 10:50:43 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 299ABD915C + for ; + Tue, 20 Sep 2005 10:50:41 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 53545-05 + for ; + Tue, 20 Sep 2005 13:50:28 +0000 (GMT) +Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.201]) + by svr1.postgresql.org (Postfix) with ESMTP id D94ABD919E + for ; + Tue, 20 Sep 2005 10:50:25 -0300 (ADT) +Received: by zproxy.gmail.com with SMTP id z31so190320nzd + for ; + Tue, 20 Sep 2005 06:50:29 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:mime-version:content-transfer-encoding:message-id:content-type:to:from:subject:date:x-mailer; + b=kjioXustleM+JDmfORdCynvM8I1PL1PWTJkd/QaEjSW35j8l63rA1Zci1fLic1mnloPanwTjznlVbn6j1Fr7wbrgT+teNnUIUKVmbavL9sCqqv0lveZZ6DZcXAaZ8OXPDlo7npAWn88D0zlj62JRFGr14sWQV8Bee7gvT+DpsvQ= +Received: by 10.36.146.10 with SMTP id t10mr3958985nzd; + Tue, 20 Sep 2005 06:50:29 -0700 (PDT) +Received: from ?192.168.100.103? ( [218.79.107.209]) + by mx.gmail.com with ESMTP id 22sm5239358nzn.2005.09.20.06.50.28; + Tue, 20 Sep 2005 06:50:29 -0700 (PDT) +Mime-Version: 1.0 (Apple Message framework v622) +Content-Transfer-Encoding: 7bit +Message-Id: +Content-Type: text/plain; charset=US-ASCII; format=flowed +To: pgsql-performance@postgresql.org +From: Richard Woo +Subject: unsubscribe +Date: Tue, 20 Sep 2005 21:50:24 +0800 +X-Mailer: Apple Mail (2.622) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.024 required=5 tests=[RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200509/215 +X-Sequence-Number: 14523 + +unsubscribe + + +From pgsql-performance-owner@postgresql.org Tue Sep 20 11:05:18 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 79A4FD92F6 + for ; + Tue, 20 Sep 2005 11:05:16 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 55403-07 + for ; + Tue, 20 Sep 2005 14:05:00 +0000 (GMT) +Received: from nwkea-mail-1.sun.com (nwkea-mail-1.sun.com [192.18.42.13]) + by svr1.postgresql.org (Postfix) with ESMTP id 0A67FD8DC3 + for ; + Tue, 20 Sep 2005 11:04:58 -0300 (ADT) +Received: from phys-bur-1 ([129.148.9.72]) + by nwkea-mail-1.sun.com (8.12.10/8.12.9) with ESMTP id j8KE4t2N016763 + for ; + Tue, 20 Sep 2005 07:05:03 -0700 (PDT) +Received: from conversion-daemon.bur-mail1.east.sun.com by + bur-mail1.east.sun.com + (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) + id <0IN400901C9LOB@bur-mail1.east.sun.com> + (original mail from J.K.Shah@Sun.COM) for + pgsql-performance@postgresql.org; + Tue, 20 Sep 2005 10:04:57 -0400 (EDT) +Received: from [129.148.168.2] (tinkerer.East.Sun.COM [129.148.168.2]) + by bur-mail1.east.sun.com + (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) + with ESMTPA id <0IN400IY8CG5AK@bur-mail1.east.sun.com>; Tue, + 20 Sep 2005 10:04:56 -0400 (EDT) +Date: Tue, 20 Sep 2005 10:01:44 -0400 +From: "Jignesh K. Shah" +Subject: Re: RAID Stripe size +In-reply-to: <20050920145307.1a111595.eugrid@fpm.kubsu.ru> +To: evgeny gridasov +Cc: "bm\\mbn" , pgsql-performance@postgresql.org +Message-id: <43301648.2040104@sun.com> +Organization: Sun Microsystems +MIME-version: 1.0 +Content-type: text/plain; charset=ISO-8859-1; format=flowed +Content-transfer-encoding: 7BIT +X-Accept-Language: en-us, en +User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050322) +References: <1126871503.157442.314670@g49g2000cwa.googlegroups.com> + <20050920145307.1a111595.eugrid@fpm.kubsu.ru> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.114 required=5 tests=[AWL=0.114] +X-Spam-Level: +X-Archive-Number: 200509/216 +X-Sequence-Number: 14524 + +Typically your stripe size impacts read and write. + +In Solaris, the trick is to match it with your maxcontig parameter. If +you set maxcontig to 128 pages which is 128* 8 = 1024k (1M) then your +optimal stripe size is 128 * 8 / (number of spindles in LUN).. Assuming +number of spindles is 6 then you get an odd number. In such cases either +your current io or the next sequential io is going to be little bit +inefficient depending on what you select (as a rule of thumb however +just take the closest stripe size). However if your number of spindles +matches 8 then you get a perfect 128 and hence makes sense to select +128K. (Maxcontig is a paramter in Solaris which defines the max +contiguous space allocated to a block which really helps in case of +sequential io operations). + +But as you see this was maxcontig dependent in my case. What if your +maxcontig is way off track. This can happen if your io pattern is more +and more random. In such cases maxcontig is better at lower numbers to +reduce space wastage and in effect reducing your stripe size reduces +your responde time. + +This means now it is Workload dependent... Random IOs or Sequential IOs +(atleast where IOs can be clubbed together). + +As you can see stripe size in Solaris is eventually dependent on your +Workload. Typically my guess is on any other platform, the stripe size +is dependent on your Workload and how it will access the data. Lower +stripe size helps smaller IOs perform better but lack total throughtput +efficiency. While larger stripe size increases throughput efficiency at +the cost of response time of your small IO requirements. + +Don't forget many file systems will buffer your IOs and can club them +together if it finds them sequential from its point of view. Hence in +such cases the effective IO size is what matters for raid sizes. + +If you effective IO sizes are big then go for higher raid size. +If your effective IO sizes are small and response time is critical go +for smaller raid sizes + +Regards, +Jignesh + +evgeny gridasov wrote: + +>Hi Everybody! +> +>I've got a spare machine which is 2xXEON 3.2GHz, 4Gb RAM +>14x140Gb SCSI 10k (LSI MegaRaid 320U). It is going into production in 3-5months. +>I do have free time to run tests on this machine, and I could test different stripe sizes +>if somebody prepares a test script and data for that. +> +>I could also test different RAID modes 0,1,5 and 10 for this script. +> +>I guess the community needs these results. +> +>On 16 Sep 2005 04:51:43 -0700 +>"bm\\mbn" wrote: +> +> +> +>>Hi Everyone +>> +>>The machine is IBM x345 with ServeRAID 6i 128mb cache and 6 SCSI 15k +>>disks. +>> +>>2 disks are in RAID1 and hold the OS, SWAP & pg_xlog +>>4 disks are in RAID10 and hold the Cluster itself. +>> +>>the DB will have two major tables 1 with 10 million rows and one with +>>100 million rows. +>>All the activities against this tables will be SELECT. +>> +>>Currently the strip size is 8k. I read in many place this is a poor +>>setting. +>> +>>Am i right ? +>> +>> +> +> +> + +-- +______________________________ + +Jignesh K. Shah +MTS Software Engineer, +MDE - Horizontal Technologies +Sun Microsystems, Inc +Phone: (781) 442 3052 +Email: J.K.Shah@sun.com +______________________________ + + + +From pgsql-performance-owner@postgresql.org Tue Sep 20 12:13:27 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4863BD8C5E + for ; + Tue, 20 Sep 2005 12:13:24 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 73246-08 + for ; + Tue, 20 Sep 2005 15:13:20 +0000 (GMT) +Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.205]) + by svr1.postgresql.org (Postfix) with ESMTP id 26C7ED88B7 + for ; + Tue, 20 Sep 2005 12:13:16 -0300 (ADT) +Received: by zproxy.gmail.com with SMTP id 40so276377nzk + for ; + Tue, 20 Sep 2005 08:13: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:references; + b=DUhlpqOHzgdfPpTQysTYjzPuXtwizpn+zLatUoPGfh1lY4bH/1e9L54sbmByg6ZobCDYQCspY1dui6xTNFalF8/Wk/oO94mWkx1O6GE/UtmOvNTyQbtRq15qitMYXgCWv/ygSoOqlHBwOABA/mbb/9LxSRe84VoaLlUV3oprp5k= +Received: by 10.54.36.79 with SMTP id j79mr1820780wrj; + Tue, 20 Sep 2005 08:13:15 -0700 (PDT) +Received: by 10.54.83.10 with HTTP; Tue, 20 Sep 2005 08:13:15 -0700 (PDT) +Message-ID: <33c6269f050920081371bf3909@mail.gmail.com> +Date: Tue, 20 Sep 2005 11:13:15 -0400 +From: Alex Turner +Reply-To: armtuk@gmail.com +To: bmmbn +Subject: Re: RAID Stripe size +Cc: pgsql-performance@postgresql.org +In-Reply-To: <1126871503.157442.314670@g49g2000cwa.googlegroups.com> +Mime-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_3277_149750.1127229195559" +References: <1126871503.157442.314670@g49g2000cwa.googlegroups.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.249 required=5 tests=[AWL=-0.071, HTML_10_20=0.295, + HTML_MESSAGE=0.001, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200509/217 +X-Sequence-Number: 14525 + +------=_Part_3277_149750.1127229195559 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +I have benched different sripe sizes with different file systems, and the= +=20 +perfmance differences can be quite dramatic. + +Theoreticaly a smaller stripe is better for OLTP as you can write more smal= +l=20 +transactions independantly to more different disks more often than not, but= +=20 +a large stripe size is good for Data warehousing as you are often doing ver= +y=20 +large sequential reads, and a larger stripe size is going to exploit the=20 +on-drive cache as you request larger single chunks from the disk at a time. + +It also seems that different controllers are partial to different defaults= +=20 +that can affect their performance, so I would suggest that testing this on= +=20 +two different controller cards man be less than optimal. + +I would also recommend looking at file system. For us JFS worked=20 +signifcantly faster than resier for large read loads and large write loads,= +=20 +so we chose JFS over ext3 and reiser. + +I found that lower stripe sizes impacted performance badly as did overly=20 +large stripe sizes. + +Alex Turner +NetEconomist + +On 16 Sep 2005 04:51:43 -0700, bmmbn wrote: +>=20 +> Hi Everyone +>=20 +> The machine is IBM x345 with ServeRAID 6i 128mb cache and 6 SCSI 15k +> disks. +>=20 +> 2 disks are in RAID1 and hold the OS, SWAP & pg_xlog +> 4 disks are in RAID10 and hold the Cluster itself. +>=20 +> the DB will have two major tables 1 with 10 million rows and one with +> 100 million rows. +> All the activities against this tables will be SELECT. +>=20 +> Currently the strip size is 8k. I read in many place this is a poor +> setting. +>=20 +> Am i right ? +>=20 +>=20 +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: Don't 'kill -9' the postmaster +> + +------=_Part_3277_149750.1127229195559 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +I have benched different sripe sizes with different file systems, and the p= +erfmance differences can be quite dramatic.
+
+Theoreticaly a smaller stripe is better for OLTP as you can write more +small transactions independantly to more different disks more often +than not, but a large stripe size is good for Data warehousing as you +are often doing very large sequential reads, and a larger stripe size +is going to exploit the on-drive cache as you request larger single +chunks from the disk at a time.
+
+It also seems that different controllers are partial to different +defaults that can affect their performance, so I would suggest that +testing this on two different controller cards man be less than optimal. +
+I would also recommend looking at file system.  For us JFS worked +signifcantly faster than resier for large read loads and large write +loads, so we chose JFS over ext3 and reiser.
+
+I found that lower stripe sizes impacted performance badly as did overly la= +rge stripe sizes.
+
+Alex Turner
+NetEconomist

On 16 Sep 2005 04:51:4= +3 -0700, bmmbn <miki@canaan.co.il> wrote:
+Hi Everyone

The machine is IBM x345 with ServeRAID 6i 128mb cache an= +d 6 SCSI 15k
disks.

2 disks are in RAID1 and hold the OS, SWAP &a= +mp; pg_xlog
4 disks are in RAID10 and hold the Cluster itself.

+the DB will have two major tables 1 with 10 million rows and one with
10= +0 million rows.
All the activities against this tables will be SELECT.
Currently the strip size is 8k. I read in many place this is a poor +
setting.

Am i right ?


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

+ +------=_Part_3277_149750.1127229195559-- + +From pgsql-performance-owner@postgresql.org Tue Sep 20 12:22:19 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 82BD0D9210 + for ; + Tue, 20 Sep 2005 12:21:54 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 73709-08 + for ; + Tue, 20 Sep 2005 15:21:47 +0000 (GMT) +Received: from vadmzmailmx02.bankofamerica.com (vamx02.bankofamerica.com + [171.159.192.79]) + by svr1.postgresql.org (Postfix) with ESMTP id 1E66CD8FD4 + for ; + Tue, 20 Sep 2005 12:21:46 -0300 (ADT) +Received: from vadmzmailmx01.bankofamerica.com ([171.182.200.78]) + by vadmzmailmx02.bankofamerica.com (8.12.11/8.12.11) with ESMTP id + j8KFLjCf026153 + for ; Tue, 20 Sep 2005 15:21:45 GMT +Received: from memscmpl4. (varchvp01s209.bankofamerica.com [171.177.163.14]) + by vadmzmailmx01.bankofamerica.com (8.12.11/8.12.11) with SMTP id + j8KFLS9W000912 + for ; Tue, 20 Sep 2005 15:21:45 GMT +Received: from memmta0302 (171.186.140.77) + by memscmpl4. (Sigaba Gateway v3.6.1) + with ESMTP id 277429858; Tue, 20 Sep 2005 11:21:45 -0400 +Date: Tue, 20 Sep 2005 11:21:44 -0400 +From: "Welty, Richard" +Subject: Re: RAID Stripe size +To: pgsql-performance@postgresql.org +Message-id: +MIME-version: 1.0 +X-MIMEOLE: Produced By Microsoft Exchange V6.5.7226.0 +Content-type: text/plain; charset=iso-8859-1 +Content-transfer-encoding: 7BIT +Content-class: urn:content-classes:message +Thread-topic: [PERFORM] RAID Stripe size +Thread-index: AcW99mLRWiRjIar0Sx2zb6zDQVgREQAAOvxw +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +X-OriginalArrivalTime: 20 Sep 2005 15:21:45.0080 (UTC) + FILETIME=[02C27F80:01C5BDF7] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.088 required=5 tests=[AWL=0.088] +X-Spam-Level: +X-Archive-Number: 200509/218 +X-Sequence-Number: 14526 + +Alex Turner wrote: + +> I would also recommend looking at file system. For us JFS worked signifcantly +> faster than resier for large read loads and large write loads, so we chose JFS +> over ext3 and reiser. + +has jfs been reliable for you? there seems to be a lot of conjecture about instability, +but i find jfs a potentially attractive alternative for a number of reasons. + +richard + +From pgsql-performance-owner@postgresql.org Tue Sep 20 12:33:46 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5ED81D70A7 + for ; + Tue, 20 Sep 2005 12:33:44 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 75929-10 + for ; + Tue, 20 Sep 2005 15:33:37 +0000 (GMT) +Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.200]) + by svr1.postgresql.org (Postfix) with ESMTP id 99B03D91AD + for ; + Tue, 20 Sep 2005 12:33:29 -0300 (ADT) +Received: by zproxy.gmail.com with SMTP id 40so282475nzk + for ; + Tue, 20 Sep 2005 08:33:29 -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=HqaTgbVwkLu8BLFxof90UbWLDheBXOpl/guQf96IQ/zrEUb+Sy4HhdfQeKVpQ+ZQWA30WrLacZKv7JRDNo3YaHFdD5hErkbeUbKdU6BY7Dq5q2ZnZiCQ1EKU4A60sNGsPxeEA/KUY97qDtQwVnu4gJPAnGPVcniLe7ETIhaBTos= +Received: by 10.54.36.79 with SMTP id j79mr1831918wrj; + Tue, 20 Sep 2005 08:33:29 -0700 (PDT) +Received: by 10.54.83.10 with HTTP; Tue, 20 Sep 2005 08:33:28 -0700 (PDT) +Message-ID: <33c6269f050920083334b131bc@mail.gmail.com> +Date: Tue, 20 Sep 2005 11:33:29 -0400 +From: Alex Turner +Reply-To: armtuk@gmail.com +To: "Welty, Richard" +Subject: Re: RAID Stripe size +Cc: pgsql-performance@postgresql.org +In-Reply-To: +Mime-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_3427_28665120.1127230409008" +References: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.354 required=5 tests=[AWL=-0.175, HTML_20_30=0.504, + HTML_MESSAGE=0.001, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200509/219 +X-Sequence-Number: 14527 + +------=_Part_3427_28665120.1127230409008 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +I have found JFS to be just fine. We have been running a medium load on thi= +s=20 +server for 9 months with no unscheduled down time. Datbase is about 30gig o= +n=20 +disk, and we get about 3-4 requests per second that generate results sets i= +n=20 +the thousands from about 8am to about 11pm. + +I have foudn that JFS barfs if you put a million files in a directory and= +=20 +try to do an 'ls', but then so did reiser, only Ext3 handled this test=20 +succesfully. Fortunately with a database, this is an atypical situation, so= +=20 +JFS has been fine for DB for us so far. + +We have had severe problems with Ext3 when file systems hit 100% usage, the= +y=20 +get all kinds of unhappy, we haven't had the same problem with JFS. + +Alex Turner +NetEconomist + +On 9/20/05, Welty, Richard wrote: +>=20 +> Alex Turner wrote: +>=20 +> > I would also recommend looking at file system. For us JFS worked=20 +> signifcantly +> > faster than resier for large read loads and large write loads, so we=20 +> chose JFS +> > over ext3 and reiser. +>=20 +> has jfs been reliable for you? there seems to be a lot of conjecture abou= +t=20 +> instability, +> but i find jfs a potentially attractive alternative for a number of=20 +> reasons. +>=20 +> richard +>=20 +> ---------------------------(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 +> + +------=_Part_3427_28665120.1127230409008 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +I have found JFS to be just fine.  We have been running a medium +load on this server for 9 months with no unscheduled down time.  +Datbase is about 30gig on disk, and we get about 3-4 requests per +second that generate results sets in the thousands from about 8am to +about 11pm.
+
+I have foudn that JFS barfs if you put a million files in a directory +and try to do an 'ls', but then so did reiser, only Ext3 handled this +test succesfully.  Fortunately with a database, this is an +atypical situation, so JFS has been fine for DB for us so far.
+
+We have had severe problems with Ext3 when file systems hit 100% usage, +they get all kinds of unhappy, we haven't had the same problem with JFS. +
+Alex Turner
+NetEconomist

On 9/20/05, Welty, Richard <richard.welty@bankofamerica.com> wrote:<= +blockquote class=3D"gmail_quote" style=3D"border-left: 1px solid rgb(204, 2= +04, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> +Alex Turner  wrote:

> I would also recommend looking at= + file system.  For us JFS worked signifcantly
>  = +faster than resier for large read loads and large write loads, so we chose = +JFS
>  over ext3 and reiser. +

has jfs been reliable for you? there seems to be a lot of conjectur= +e about instability,
but i find jfs a potentially attractive alternative= + for a number of reasons.

richard

---------------------------= +(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
= +

+ +------=_Part_3427_28665120.1127230409008-- + +From pgsql-performance-owner@postgresql.org Tue Sep 20 12:36:14 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CCEA8D9142 + for ; + Tue, 20 Sep 2005 12:36:11 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 77218-09 + for ; + Tue, 20 Sep 2005 15:36:02 +0000 (GMT) +Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.198]) + by svr1.postgresql.org (Postfix) with ESMTP id D1FAED8FD4 + for ; + Tue, 20 Sep 2005 12:35:59 -0300 (ADT) +Received: by zproxy.gmail.com with SMTP id 40so283195nzk + for ; + Tue, 20 Sep 2005 08:35:58 -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=SDze8RgzW1MLCshJg/NyOt2XtktWJM8+5diaqiZGs4cIpKtNG4Q+dWiCkbqrILytnX0/BThTHTqLVP41Qt1iFk9ssag9voek5yHzRg31jq/yQyhoAxX0dGtQc7r+7nhcMDNJA5CBkHSBea9Qdd7xz4y19NCBaZs84KBJn2+viL8= +Received: by 10.54.71.20 with SMTP id t20mr1836815wra; + Tue, 20 Sep 2005 08:35:58 -0700 (PDT) +Received: by 10.54.83.10 with HTTP; Tue, 20 Sep 2005 08:35:58 -0700 (PDT) +Message-ID: <33c6269f05092008357973a651@mail.gmail.com> +Date: Tue, 20 Sep 2005 11:35:58 -0400 +From: Alex Turner +Reply-To: armtuk@gmail.com +To: Kelly Burkhart +Subject: Re: Need for speed 2 +Cc: Ron , pgsql-performance@postgresql.org +In-Reply-To: <1124996422.6969.47.camel@krb06.tradebot.com> +Mime-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_3447_32575630.1127230558130" +References: <6.2.3.4.0.20050817140116.05d317b0@pop.earthlink.net> + + <430D6EED.10603@relevanttraffic.se> + <6.2.3.4.0.20050825094630.05e6b160@pop.earthlink.net> + <1124996422.6969.47.camel@krb06.tradebot.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.146 required=5 tests=[AWL=0.035, HTML_40_50=0.086, + HTML_MESSAGE=0.001, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200509/220 +X-Sequence-Number: 14528 + +------=_Part_3447_32575630.1127230558130 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +I have found that while the OS may flush to the controller fast with=20 +fsync=3Dtrue, the controller does as it pleases (it has BBU, so I'm not too= +=20 +worried), so you get great performance because your controller is determine= +=20 +read/write sequence outside of what is being demanded by an fsync. + +Alex Turner +NetEconomist + +On 8/25/05, Kelly Burkhart wrote: +>=20 +> On Thu, 2005-08-25 at 11:16 -0400, Ron wrote: +> > ># - Settings - +> > > +> > >fsync =3D false # turns forced synchronization on or off +> > >#wal_sync_method =3D fsync # the default varies across platforms: +> > > # fsync, fdatasync, open_sync, or +> > +> > I hope you have a battery backed write buffer! +>=20 +> Battery backed write buffer will do nothing here, because the OS is +> taking it's sweet time flushing to the controller's battery backed write +> buffer! +>=20 +> Isn't the reason for batter backed controller cache to make fsync()s +> fast? +>=20 +> -K +>=20 +> ---------------------------(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 +> + +------=_Part_3447_32575630.1127230558130 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +I have found that while the OS may flush to the controller fast with +fsync=3Dtrue, the controller does as it pleases (it has BBU, so I'm not +too worried), so you get great performance because your controller is +determine read/write sequence outside of what is being demanded by an +fsync.
+
+Alex Turner
+NetEconomist

On 8/25/05, Kelly Burkhart <kelly@tradebotsystems.com> wrote:
+On Thu, 2005-08-25 at 11:16 -0400, Ron wrote:
> ># - Settings -> >
> +>fsync =3D +false           &nbs= +p;       +# turns forced synchronization on or off
> >#wal_sync_method =3D f= +sync        # the default varies ac= +ross platforms:
> +>            = +;            &n= +bsp;        +# fsync, fdatasync, open_sync, or
>
> I hope you have a battery= + backed write buffer!

Battery backed write buffer will do nothing he= +re, because the OS is
taking it's sweet time flushing to the controller'= +s battery backed write +
buffer!

Isn't the reason for batter backed controller cache to m= +ake fsync()s
fast?

-K

---------------------------(end of b= +roadcast)---------------------------
TIP 9: In versions below 8.0, the p= +lanner will ignore your desire to +
       choose an index scan if your joini= +ng column's datatypes do not
       match<= +br>

+ +------=_Part_3447_32575630.1127230558130-- + +From pgsql-performance-owner@postgresql.org Tue Sep 20 13:01:17 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3FE3AD922A + for ; + Tue, 20 Sep 2005 13:01:16 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 85744-04 + for ; + Tue, 20 Sep 2005 16:01:07 +0000 (GMT) +Received: from i-free.spb.ru (i-free.spb.ru [194.105.194.152]) + by svr1.postgresql.org (Postfix) with ESMTP id E0E1CD91E0 + for ; + Tue, 20 Sep 2005 13:01:01 -0300 (ADT) +Received: from localhost (localhost [127.0.0.1]) + by i-free.spb.ru (Postfix) with ESMTP id E48AB33B86 + for ; + Tue, 20 Sep 2005 20:01:00 +0400 (MSD) +Received: from i-free.spb.ru ([127.0.0.1]) + by localhost (i-free [127.0.0.1]) (amavisd-new, port 10024) with LMTP + id 06363-02-10 for ; + Tue, 20 Sep 2005 20:01:00 +0400 (MSD) +Received: from office1.i-free.ru (office1.i-free.ru [81.222.216.82]) + by i-free.spb.ru (Postfix) with ESMTP id 6E7A033A05 + for ; + Tue, 20 Sep 2005 20:00:58 +0400 (MSD) +Received: from [192.168.0.250] (helo=deepcore) + by office1.i-free.ru with smtp (Exim 3.36 #1 (Debian)) + id 1EHkYD-0000p5-00 + for ; Tue, 20 Sep 2005 20:00:57 +0400 +Date: Tue, 20 Sep 2005 20:02:10 +0400 +From: evgeny gridasov +To: pgsql-performance@postgresql.org +Subject: Re: RAID Stripe size +Message-Id: <20050920200210.27ad75cf.eugrid@fpm.kubsu.ru> +In-Reply-To: +References: +X-Mailer: Sylpheed version 2.0.0 (GTK+ 2.6.2; i486-pc-linux-gnu) +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at i-free.spb.ru +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/221 +X-Sequence-Number: 14529 + +We have a production server(8.0.2) running 24x7, 300k+ transactions per day. +Linux 2.6.11 / JFS file system. +No problems. It works faster than ext3. + +> Alex Turner wrote: +> +> > I would also recommend looking at file system. For us JFS worked signifcantly +> > faster than resier for large read loads and large write loads, so we chose JFS +> > over ext3 and reiser. +> +> has jfs been reliable for you? there seems to be a lot of conjecture about instability, +> but i find jfs a potentially attractive alternative for a number of reasons. +> +> richard +> +> ---------------------------(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 + + +-- +Evgeny Gridasov +Software Developer +I-Free, Russia + +From pgsql-performance-owner@postgresql.org Tue Sep 20 15:11:55 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0BAEFD9294 + for ; + Tue, 20 Sep 2005 15:11:49 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 20693-01 + for ; + Tue, 20 Sep 2005 18:11:42 +0000 (GMT) +Received: from i-free.spb.ru (i-free.spb.ru [194.105.194.152]) + by svr1.postgresql.org (Postfix) with ESMTP id 15A03D8E94 + for ; + Tue, 20 Sep 2005 15:11:42 -0300 (ADT) +Received: from localhost (localhost [127.0.0.1]) + by i-free.spb.ru (Postfix) with ESMTP id B52D43413B + for ; + Tue, 20 Sep 2005 22:11:42 +0400 (MSD) +Received: from i-free.spb.ru ([127.0.0.1]) + by localhost (i-free [127.0.0.1]) (amavisd-new, port 10024) with LMTP + id 24443-01-4 for ; + Tue, 20 Sep 2005 22:11:42 +0400 (MSD) +Received: from office1.i-free.ru (office1.i-free.ru [81.222.216.82]) + by i-free.spb.ru (Postfix) with ESMTP id 90CE434050 + for ; + Tue, 20 Sep 2005 22:11:42 +0400 (MSD) +Received: from [192.168.0.250] (helo=deepcore) + by office1.i-free.ru with smtp (Exim 3.36 #1 (Debian)) + id 1EHmak-0003Xw-00 + for ; Tue, 20 Sep 2005 22:11:42 +0400 +Date: Tue, 20 Sep 2005 22:12:55 +0400 +From: evgeny gridasov +To: pgsql-performance@postgresql.org +Subject: Planner statistics vs. count(*) +Message-Id: <20050920221255.2c32b87b.eugrid@fpm.kubsu.ru> +In-Reply-To: <20050920200210.27ad75cf.eugrid@fpm.kubsu.ru> +References: + <20050920200210.27ad75cf.eugrid@fpm.kubsu.ru> +X-Mailer: Sylpheed version 2.0.0 (GTK+ 2.6.2; i486-pc-linux-gnu) +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at i-free.spb.ru +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/222 +X-Sequence-Number: 14530 + +Hi Everybody. + +I am going to replace some 'select count(*) from ... where ...' queries +which run on large tables (10M+ rows) with something like +'explain select * from ... where ....' and parse planner output after that +to find out its forecast about number of rows the query is going to retrieve. + +Since my users do not need exact row count for large tables, this will +boost performance for my application. I ran some queries with explain and +explain analyze then. If i set statistics number for the table about 200-300 +the planner forecast seems to be working very fine. + +My questions are: +1. Is there a way to interact with postgresql planner, other than 'explain ...'? An aggregate query like 'select estimate_count(*) from ...' would really help =)) +2. How precise is the planner row count forecast given for a complex query (select with 3-5 joint tables,aggregates,subselects, etc...)? + + +-- +Evgeny Gridasov +Software Developer +I-Free, Russia + +From pgsql-performance-owner@postgresql.org Tue Sep 20 15:29:44 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2DDC3D9388 + for ; + Tue, 20 Sep 2005 15:29:43 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 22271-08 + for ; + Tue, 20 Sep 2005 18:29:33 +0000 (GMT) +Received: from presinet.com (presinet.com [209.53.156.1]) + by svr1.postgresql.org (Postfix) with ESMTP id A734BD9312 + for ; + Tue, 20 Sep 2005 15:29:32 -0300 (ADT) +Received: from [10.10.1.151] ([10.10.1.151]) by presinet.com with Microsoft + SMTPSVC(6.0.3790.1830); Tue, 20 Sep 2005 11:28:09 -0700 +Message-ID: <4330550B.80600@PresiNET.com> +Date: Tue, 20 Sep 2005 11:29:31 -0700 +From: Bricklen Anderson +User-Agent: Debian Thunderbird 1.0.6 (X11/20050802) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: evgeny gridasov +Cc: pgsql-performance@postgresql.org +Subject: Re: Planner statistics vs. count(*) +References: + <20050920200210.27ad75cf.eugrid@fpm.kubsu.ru> + <20050920221255.2c32b87b.eugrid@fpm.kubsu.ru> +In-Reply-To: <20050920221255.2c32b87b.eugrid@fpm.kubsu.ru> +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-OriginalArrivalTime: 20 Sep 2005 18:28:09.0312 (UTC) + FILETIME=[0D14DE00:01C5BE11] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.01 required=5 tests=[AWL=0.010] +X-Spam-Level: +X-Archive-Number: 200509/223 +X-Sequence-Number: 14531 + +evgeny gridasov wrote: +> Hi Everybody. +> +> I am going to replace some 'select count(*) from ... where ...' queries +> which run on large tables (10M+ rows) with something like +> 'explain select * from ... where ....' and parse planner output after that +> to find out its forecast about number of rows the query is going to retrieve. +> +> Since my users do not need exact row count for large tables, this will +> boost performance for my application. I ran some queries with explain and +> explain analyze then. If i set statistics number for the table about 200-300 +> the planner forecast seems to be working very fine. +> +> My questions are: +> 1. Is there a way to interact with postgresql planner, other than 'explain ...'? An aggregate query like 'select estimate_count(*) from ...' would really help =)) +> 2. How precise is the planner row count forecast given for a complex query (select with 3-5 joint tables,aggregates,subselects, etc...)? +> +> +I think that this has been done before. Check the list archives (I believe it +may have been Michael Fuhr?) + +ah, check this: + +http://archives.postgresql.org/pgsql-sql/2005-08/msg00046.php + +-- +_______________________________ + +This e-mail may be privileged and/or confidential, and the sender does +not waive any related rights and obligations. Any distribution, use or +copying of this e-mail or the information it contains by other than an +intended recipient is unauthorized. If you received this e-mail in +error, please advise me (by return e-mail or otherwise) immediately. +_______________________________ + +From pgsql-performance-owner@postgresql.org Tue Sep 20 15:41:53 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A8782D942B + for ; + Tue, 20 Sep 2005 15:41:51 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 23339-08 + for ; + Tue, 20 Sep 2005 18:41:45 +0000 (GMT) +Received: from smtp.puc.cl (tarahuin.puc.cl [146.155.99.13]) + by svr1.postgresql.org (Postfix) with ESMTP id 5770BD9406 + for ; + Tue, 20 Sep 2005 15:41:40 -0300 (ADT) +Received: (qmail 36844 invoked from network); 20 Sep 2005 18:41:38 -0000 +Received: from nnsanche.stg.puc.cl (HELO nnsanche.puc.cl) + (nnsanche@[146.155.199.92]) (envelope-sender ) + by tarahuin-smtp.puc.cl (qmail-ldap-1.03) with SMTP + for ; 20 Sep 2005 18:41:38 -0000 +Message-Id: <5.2.0.9.1.20050920144041.0287c300@pop.puc.cl> +X-Sender: nnsanche@pop.puc.cl +X-Mailer: QUALCOMM Windows Eudora Version 5.2.0.9 +Date: Tue, 20 Sep 2005 14:41:30 -0400 +To: pgsql-performance@postgresql.org +From: Nelba =?iso-8859-1?Q?S=E1nchez?= Rojas +Subject: unsubscribe +Mime-Version: 1.0 +Content-Type: text/plain; charset="iso-8859-1"; format=flowed +Content-Transfer-Encoding: quoted-printable +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 required=5 tests=[FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/224 +X-Sequence-Number: 14532 + +unsubscribe + + +---------------------------(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 +Nelba S=E1nchez R. +Servicios Tecnol=F3gicos de Gesti=F3n (STG) +Pontificia Universidad Cat=F3lica de Chile +fono : (56-2) 686 2316 +fax : (56-2) 222 9487 +mailto:nnsanche@uc.cl + + +From pgsql-performance-owner@postgresql.org Fri Sep 23 02:18:11 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 64E6FD9330 + for ; + Tue, 20 Sep 2005 15:53:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28345-05 + for ; + Tue, 20 Sep 2005 18:53:22 +0000 (GMT) +Received: from smtp107.mail.sc5.yahoo.com (smtp107.mail.sc5.yahoo.com + [66.163.169.227]) + by svr1.postgresql.org (Postfix) with SMTP id 12786D920A + for ; + Tue, 20 Sep 2005 15:53:21 -0300 (ADT) +Received: (qmail 28818 invoked from network); 20 Sep 2005 18:53:21 -0000 +Received: from unknown (HELO host-140.engineering.n-able.com) + (wander9@209.217.70.195 with plain) + by smtp107.mail.sc5.yahoo.com with SMTP; 20 Sep 2005 18:53:21 -0000 +Subject: VACUUM FULL vs CLUSTER +From: Markus Benne +To: pgsql-performance@postgresql.org +In-Reply-To: <5.2.0.9.1.20050920144041.0287c300@pop.puc.cl> +References: <5.2.0.9.1.20050920144041.0287c300@pop.puc.cl> +Content-Type: text/plain +Date: Tue, 20 Sep 2005 14:53:19 -0400 +Message-Id: <1127242399.26562.15.camel@host-140.engineering.n-able.com> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.3-1.2.101mdk +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/272 +X-Sequence-Number: 14580 + +I have a table that is purged by 25% each night. I'd like to do a +vacuum nightly after the purge to reclaim the space, but I think I'll +still need to do a vacuum full weekly. + +Would there be any benefit to doing a cluster instead of the vacuum? + + +From pgsql-performance-owner@postgresql.org Tue Sep 20 22:44:03 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7B4FDD9039 + for ; + Tue, 20 Sep 2005 22:44:00 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 16472-05 + for ; + Wed, 21 Sep 2005 01:43:53 +0000 (GMT) +Received: from mailout2.pacific.net.au (mailout2.pacific.net.au [61.8.0.115]) + by svr1.postgresql.org (Postfix) with ESMTP id B2A7CD9488 + for ; + Tue, 20 Sep 2005 22:43:50 -0300 (ADT) +Received: from mailproxy1.pacific.net.au (mailproxy1.pacific.net.au + [61.8.0.86]) + by mailout2.pacific.net.au (8.13.4/8.13.4/Debian-3) with ESMTP id + j8L1hqJK019479 + for ; Wed, 21 Sep 2005 11:43:52 +1000 +Received: from rws-exch01.rapidweb.com.au (b0FE2.static.pacific.net.au + [202.7.84.226]) + by mailproxy1.pacific.net.au (8.13.4/8.13.4/Debian-3) with ESMTP id + j8L1hqAN004694 + for ; Wed, 21 Sep 2005 11:43:52 +1000 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: multipart/mixed; + boundary="----_=_NextPart_001_01C5BE4E.148DF21A" +Subject: Deadlock Issue with PostgreSQL +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Date: Wed, 21 Sep 2005 11:44:54 +1000 +Message-ID: + <684E37D19BEFA148B453F5C4FB466B6223A3E9@rws-exch01.rapidweb.com.au> +X-MS-Has-Attach: yes +X-MS-TNEF-Correlator: +Thread-Topic: Deadlock Issue with PostgreSQL +Thread-Index: AcW+ThCeOlfWj6iJQCq5Q/1qARA3uA== +From: "Anu Kucharlapati" +To: +Cc: "Owen Blizzard" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.051 required=5 tests=[FORGED_RCVD_HELO=0.05, + HTML_MESSAGE=0.001] +X-Spam-Level: +X-Archive-Number: 200509/225 +X-Sequence-Number: 14533 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C5BE4E.148DF21A +Content-Type: multipart/alternative; + boundary="----_=_NextPart_002_01C5BE4E.148DF21A" + + +------_=_NextPart_002_01C5BE4E.148DF21A +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + +Background: We are running a web application on apache with database +server as PostgreSQL. The application is a expense claim application +with workflow. The software versions are specified below: + +=20 + +Red Hat Linux release 7.3 + +Apache 1.3.20 + +PostgreSQL 7.1.3 + +=20 + +Problem: When the application is accessed by many users like say 40, the +PostgreSQL database freezes.=20 + +=20 + +Description of Process happening behind: The application mainly puts +load on one table (worklist) where the steps were created for each +expense claim initiated. While creating each step for claim there is +exclusive row lock and at the end inserts a new step. Both these +statements are in one transaction. When the apache hangs in between the +deadlock remains. In this way there are many deadlocks created which +makes the database to finally freeze. To resolve this we were restarting +the PostgreSQl db. Sometime the apache also hangs. Then we were +restarting the apache. There is no log created in postgreSQL. Whereas +our application records an error log: 'Failed to gain exclusive table +row lock' + +=20 + +We were guessing that the database hanging is due to deadlock issue. But +not sure of it. + +=20 + +I have attached the postgreSQL.conf file for your reference to check the +settings. + +=20 + +Please let me know what might be the reason and how to check and resolve +it. + +=20 + +Thanks and Best Regards, + +Anu + +=20 + +=20 + +=20 + + +------_=_NextPart_002_01C5BE4E.148DF21A +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + +
+ +

Background: We are = +running a +web application on apache with database server as PostgreSQL. The = +application +is a expense claim application with workflow.  The software = +versions are +specified below:

+ +

 

+ +

Red Hat Linux release = +7.3

+ +

Apache = +1.3.20

+ +

PostgreSQL = +7.1.3

+ +

 

+ +

Problem: When = +the +application is accessed by many users like say 40, the PostgreSQL = +database freezes. +

+ +

 

+ +

Description of Process happening = +behind: The +application mainly puts load on one table (worklist) where the steps = +were +created for each expense claim initiated. While creating each step for = +claim +there is exclusive row lock and at the end inserts a new step. Both = +these +statements are in one transaction. When the apache hangs in between the +deadlock remains. In this way there are many deadlocks created which = +makes the +database to finally freeze. To resolve this we were restarting the = +PostgreSQl +db. Sometime the apache also hangs. Then we were restarting the apache. = +There +is no log created in postgreSQL. Whereas our application records an = +error log: ‘Failed +to gain exclusive table row lock’

+ +

 

+ +

We were guessing that the database hanging is due to +deadlock issue. But not sure of it.

+ +

 

+ +

I have attached the postgreSQL.conf file for your = +reference +to check the settings.

+ +

 

+ +

Please let me know what might be the reason and how = +to check +and resolve it.

+ +

 

+ +

Thanks and Best Regards,

+ +

Anu

+ +

 

+ +

 

+ +

 

+ +
+ + + + + +------_=_NextPart_002_01C5BE4E.148DF21A-- + +------_=_NextPart_001_01C5BE4E.148DF21A +Content-Type: application/octet-stream; + name="postgresql.conf" +Content-Transfer-Encoding: base64 +Content-Description: postgresql.conf +Content-Disposition: attachment; + filename="postgresql.conf" + +IwojIFBvc3RncmVTUUwgY29uZmlndXJhdGlvbiBmaWxlCiMgLS0tLS0tLS0tLS0tLS0tLS0tLS0t +LS0tLS0tLS0KIwojIFRoaXMgZmlsZSBjb25zaXN0cyBvZiBsaW5lcyBvZiB0aGUgZm9ybQojCiMg +ICBuYW1lID0gdmFsdWUKIwojIChUaGUgYD0nIGlzIG9wdGlvbmFsLikgV2hpdGUgc3BhY2UgaXMg +Y29sbGFwc2VkLCBjb21tZW50cyBhcmUKIyBpbnRyb2R1Y2VkIGJ5IGAjJyBhbnl3aGVyZSBvbiBh +IGxpbmUuIFRoZSBjb21wbGV0ZSBsaXN0IG9mIG9wdGlvbgojIG5hbWVzIGFuZCBhbGxvd2VkIHZh +bHVlcyBjYW4gYmUgZm91bmQgaW4gdGhlIFBvc3RncmVTUUwKIyBkb2N1bWVudGF0aW9uLiBFeGFt +cGxlcyBhcmU6CgojbG9nX2Nvbm5lY3Rpb25zID0gb24KI2ZzeW5jID0gb2ZmCiNtYXhfY29ubmVj +dGlvbnMgPSA2NAoKIyBBbnkgb3B0aW9uIGNhbiBhbHNvIGJlIGdpdmVuIGFzIGEgY29tbWFuZCBs +aW5lIHN3aXRjaCB0byB0aGUKIyBwb3N0bWFzdGVyLCBlLmcuLCAncG9zdG1hc3RlciAtYyBsb2df +Y29ubmVjdGlvbnM9b24nLiBTb21lIG9wdGlvbnMKIyBjYW4gYmUgc2V0IGF0IHJ1bi10aW1lIHdp +dGggdGhlICdTRVQnIFNRTCBjb21tYW5kLgoKIz09PT09PT09PT09PT09PT09PT09PT09PT09PT09 +PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQojIENoYW5nZWQgY29u +ZmlndXJhdGlvbjogMTUgRGVjIDIwMDMKCiNtYXhfY29ubmVjdGlvbnMgPSA2NAojc2hhcmVkX2J1 +ZmZlcnMgPSAyNTYKCiMgZW5kIGNoYW5nZTogMTUgRGVjIDIwMDMKCiM9PT09PT09PT09PT09PT09 +PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0K +IyMgMjAwNDEyMjIgQ1kKI21heF9jb25uZWN0aW9ucyA9IDgwCiNzaGFyZWRfYnVmZmVycyA9IDE2 +MAojIyMKCiM9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 +PT09PT09PT09PT09PT09PT09PT09PT0KIyMgMjAwNTAxMjAgQ1kKbWF4X2Nvbm5lY3Rpb25zID0g +MTAwCnNoYXJlZF9idWZmZXJzID0gMjAwCiMjIwoKIz09PT09PT09PT09PT09PT09PT09PT09PT09 +PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQojIENoYW5nZWQg +Y29uZmlndXJhdGlvbjogMTUgTm92IDIwMDQKCiNtYXhfY29ubmVjdGlvbnMgPSA2NAojc2hhcmVk +X2J1ZmZlcnMgPSAxMjgKCiM9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 +PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KCgojCiMJQ29ubmVjdGlvbiBQYXJhbWV0 +ZXJzCiMKI3RjcGlwX3NvY2tldCA9IGZhbHNlCiNzc2wgPSBmYWxzZQoKI21heF9jb25uZWN0aW9u +cyA9IDMyICMgMS0xMDI0CgojcG9ydCA9IDU0MzIgCiNob3N0bmFtZV9sb29rdXAgPSBmYWxzZQoj +c2hvd19zb3VyY2VfcG9ydCA9IGZhbHNlCgojdW5peF9zb2NrZXRfZGlyZWN0b3J5ID0gJycKI3Vu +aXhfc29ja2V0X2dyb3VwID0gJycKI3VuaXhfc29ja2V0X3Blcm1pc3Npb25zID0gMDc3NwoKI3Zp +cnR1YWxfaG9zdCA9ICcnCgoja3JiX3NlcnZlcl9rZXlmaWxlID0gJycKCgojCiMJUGVyZm9ybWFu +Y2UKIwojc29ydF9tZW0gPSA1MTIKIyMgMjAwNDEyMjEgQ1kKI3NvcnRfbWVtID0gMjA0OAojIwoj +IyAyMDA0MTIyMSBDWQpzb3J0X21lbSA9IDQwOTYKIyMKI3NoYXJlZF9idWZmZXJzID0gMiptYXhf +Y29ubmVjdGlvbnMgIyBtaW4gMTYKI2ZzeW5jID0gdHJ1ZQoKCiMKIwlPcHRpbWl6ZXIgUGFyYW1l +dGVycwojCiNlbmFibGVfc2Vxc2NhbiA9IHRydWUKI2VuYWJsZV9pbmRleHNjYW4gPSB0cnVlCiNl +bmFibGVfdGlkc2NhbiA9IHRydWUKI2VuYWJsZV9zb3J0ID0gdHJ1ZQojZW5hYmxlX25lc3Rsb29w +ID0gdHJ1ZQojZW5hYmxlX21lcmdlam9pbiA9IHRydWUKI2VuYWJsZV9oYXNoam9pbiA9IHRydWUK +CiNrc3FvID0gZmFsc2UKI2dlcW8gPSB0cnVlCgojZWZmZWN0aXZlX2NhY2hlX3NpemUgPSAxMDAw +ICAjIGRlZmF1bHQgaW4gOGsgcGFnZXMKIyMgMjAwNDEyMjIgQ1kKI2VmZmVjdGl2ZV9jYWNoZV9z +aXplID0gNjAwMCAgIyBkZWZhdWx0IGluIDhrIHBhZ2VzCiMjIwojIyAyMDA0MTIyMiBDWQplZmZl +Y3RpdmVfY2FjaGVfc2l6ZSA9IDEyMDAwICAjIGRlZmF1bHQgaW4gOGsgcGFnZXMKIyMjCiNyYW5k +b21fcGFnZV9jb3N0ID0gNAojY3B1X3R1cGxlX2Nvc3QgPSAwLjAxCiNjcHVfaW5kZXhfdHVwbGVf +Y29zdCA9IDAuMDAxCiNjcHVfb3BlcmF0b3JfY29zdCA9IDAuMDAyNQojZ2Vxb19zZWxlY3Rpb25f +YmlhcyA9IDIuMCAjIHJhbmdlIDEuNS0yLjAKCgojCiMJR0VRTyBPcHRpbWl6ZXIgUGFyYW1ldGVy +cwojCiNnZXFvX3RocmVzaG9sZCA9IDExCiNnZXFvX3Bvb2xfc2l6ZSA9IDAgICNkZWZhdWx0IGJh +c2VkIGluIHRhYmxlcywgcmFuZ2UgMTI4LTEwMjQKI2dlcW9fZWZmb3J0ID0gMQojZ2Vxb19nZW5l +cmF0aW9ucyA9IDAKI2dlcW9fcmFuZG9tX3NlZWQgPSAtMSAjIGF1dG8tY29tcHV0ZSBzZWVkCgoK +IwojCUluaGVyaXRhbmNlCiMKI3NxbF9pbmhlcml0YW5jZSA9IHRydWUKCgojCiMJRGVhZGxvY2sK +IwojZGVhZGxvY2tfdGltZW91dCA9IDEwMDAKCgojCiMJRXhwcmVzc2lvbiBEZXB0aCBMaW1pdGF0 +aW9uCiMKI21heF9leHByX2RlcHRoID0gMTAwMDAgIyBtaW4gMTAKCgojCiMJV3JpdGUtYWhlYWQg +bG9nIChXQUwpCiMKI3dhbF9idWZmZXJzID0gOCAjIG1pbiA0CiN3YWxfZmlsZXMgPSAwICMgcmFu +Z2UgMC02NAojd2FsX3N5bmNfbWV0aG9kID0gZnN5bmMgIyBmc3luYyBvciBmZGF0YXN5bmMgb3Ig +b3Blbl9zeW5jIG9yIG9wZW5fZGF0YXN5bmMKIyBOb3RlOiBkZWZhdWx0IHdhbF9zeW5jX21ldGhv +ZCB2YXJpZXMgYWNyb3NzIHBsYXRmb3Jtcwojd2FsX2RlYnVnID0gMCAjIHJhbmdlIDAtMTYKI2Nv +bW1pdF9kZWxheSA9IDAgIyByYW5nZSAwLTEwMDAwMAojY29tbWl0X3NpYmxpbmdzID0gNSAjIHJh +bmdlIDEtMTAwMAojY2hlY2twb2ludF9zZWdtZW50cyA9IDMgIyBpbiBsb2dmaWxlIHNlZ21lbnRz +ICgxNk1CIGVhY2gpLCBtaW4gMQojY2hlY2twb2ludF90aW1lb3V0ID0gMzAwICMgaW4gc2Vjb25k +cywgcmFuZ2UgMzAtMzYwMAoKCiMKIwlEZWJ1ZyBkaXNwbGF5CiMKI3NpbGVudF9tb2RlID0gZmFs +c2UKCiNsb2dfY29ubmVjdGlvbnMgPSBmYWxzZQojbG9nX3RpbWVzdGFtcCA9IGZhbHNlCiNsb2df +cGlkID0gZmFsc2UKCiM9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 +PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KIyBDaGFuZ2VkIGNvbmZpZ3VyYXRpb246IDE1 +IE5vdiAyMDA0Cgpsb2dfdGltZXN0YW1wID0gdHJ1ZQoKIz09PT09PT09PT09PT09PT09PT09PT09 +PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQoKI2RlYnVn +X2xldmVsID0gMCAjIHJhbmdlIDAtMTYKCiNkZWJ1Z19wcmludF9xdWVyeSA9IGZhbHNlCiNkZWJ1 +Z19wcmludF9wYXJzZSA9IGZhbHNlCiNkZWJ1Z19wcmludF9yZXdyaXR0ZW4gPSBmYWxzZQojZGVi +dWdfcHJpbnRfcGxhbiA9IGZhbHNlCiNkZWJ1Z19wcmV0dHlfcHJpbnQgPSBmYWxzZQoKI2lmZGVm +IFVTRV9BU1NFUlRfQ0hFQ0tJTkcKI2RlYnVnX2Fzc2VydGlvbnMgPSB0cnVlCiNlbmRpZgoKCiMK +IwlTeXNsb2cKIwojaWZkZWYgRU5BQkxFX1NZU0xPRwojc3lzbG9nID0gMCAjIHJhbmdlIDAtMgoj +c3lzbG9nX2ZhY2lsaXR5ID0gJ0xPQ0FMMCcKI3N5c2xvZ19pZGVudCA9ICdwb3N0Z3JlcycKI2Vu +ZGlmCgoKIwojCVN0YXRpc3RpY3MKIwojc2hvd19wYXJzZXJfc3RhdHMgPSBmYWxzZQojc2hvd19w +bGFubmVyX3N0YXRzID0gZmFsc2UKI3Nob3dfZXhlY3V0b3Jfc3RhdHMgPSBmYWxzZQojc2hvd19x +dWVyeV9zdGF0cyA9IGZhbHNlCiNpZmRlZiBCVFJFRV9CVUlMRF9TVEFUUwojc2hvd19idHJlZV9i +dWlsZF9zdGF0cyA9IGZhbHNlCiNlbmRpZgoKCiMKIwlMb2NrIFRyYWNpbmcKIwojdHJhY2Vfbm90 +aWZ5ID0gZmFsc2UKI2lmZGVmIExPQ0tfREVCVUcKI3RyYWNlX2xvY2tzID0gZmFsc2UKI3RyYWNl +X3VzZXJsb2NrcyA9IGZhbHNlCiN0cmFjZV9zcGlubG9ja3MgPSBmYWxzZQojZGVidWdfZGVhZGxv +Y2tzID0gZmFsc2UKI3RyYWNlX2xvY2tfb2lkbWluID0gMTYzODQKI3RyYWNlX2xvY2tfdGFibGUg +PSAwCiNlbmRpZgo= + +------_=_NextPart_001_01C5BE4E.148DF21A-- + +From pgsql-performance-owner@postgresql.org Tue Sep 20 23:15:42 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B0C1FD949E + for ; + Tue, 20 Sep 2005 23:15:39 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28039-06 + for ; + Wed, 21 Sep 2005 02:15:19 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id CED6FD94B9 + for ; + Tue, 20 Sep 2005 23:15:19 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j8L2FOxf009863; + Tue, 20 Sep 2005 22:15:24 -0400 (EDT) +To: "Anu Kucharlapati" +Cc: pgsql-performance@postgresql.org, "Owen Blizzard" +Subject: Re: Deadlock Issue with PostgreSQL +In-reply-to: + <684E37D19BEFA148B453F5C4FB466B6223A3E9@rws-exch01.rapidweb.com.au> +References: + <684E37D19BEFA148B453F5C4FB466B6223A3E9@rws-exch01.rapidweb.com.au> +Comments: In-reply-to "Anu Kucharlapati" + message dated "Wed, 21 Sep 2005 11:44:54 +1000" +Date: Tue, 20 Sep 2005 22:15:24 -0400 +Message-ID: <9862.1127268924@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/226 +X-Sequence-Number: 14534 + +"Anu Kucharlapati" writes: +> Red Hat Linux release 7.3 +> Apache 1.3.20 +> PostgreSQL 7.1.3 + +I'm not sure about Apache, but both the RHL and Postgres versions +you are using are stone age --- *please* update. Red Hat stopped +supporting that release years ago, and the PG community isn't +supporting 7.1.* anymore either. There are too many known problems +in 7.1.* that are unfixable without a major-version upgrade. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Sep 21 12:35:34 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9A744D995C + for ; + Wed, 21 Sep 2005 12:35:15 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 11772-08 + for ; + Wed, 21 Sep 2005 15:35:08 +0000 (GMT) +Received: from yertle.kcilink.com (yertle.kcilink.com [65.205.34.180]) + by svr1.postgresql.org (Postfix) with ESMTP id 4DAEAD98E3 + for ; + Wed, 21 Sep 2005 12:35:04 -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 766C2B80C + for ; + Wed, 21 Sep 2005 11:35:03 -0400 (EDT) +Mime-Version: 1.0 (Apple Message framework v734) +In-Reply-To: <20050910001821.E1170@ganymede.hub.org> +References: <20050910001821.E1170@ganymede.hub.org> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <4CF7BD03-26BB-4883-9DCA-F7CB39100BC2@khera.org> +Content-Transfer-Encoding: 7bit +From: Vivek Khera +Subject: Re: CHECK vs REFERENCES +Date: Wed, 21 Sep 2005 11:35:02 -0400 +To: Postgresql Performance +X-Mailer: Apple Mail (2.734) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.025 required=5 tests=[AWL=0.025] +X-Spam-Level: +X-Archive-Number: 200509/227 +X-Sequence-Number: 14535 + + +On Sep 9, 2005, at 11:23 PM, Marc G. Fournier wrote: + +> The case is where I just want to check that a value being inserted +> is one of a few possible values, with that list of values rarely +> (if ever) changing, so havng a 'flexible list' REFERENCED seems +> relatively overkill ... +> + +That's what I thought until the first time that list needed to be +altered. At this point, it becomes a royal pain. + +point to take: do it right the first time, or you have to do it over, +and over, and over... + +Vivek Khera, Ph.D. ++1-301-869-4449 x806 + + + +From pgsql-performance-owner@postgresql.org Wed Sep 21 13:33:43 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E29EFD98D4 + for ; + Wed, 21 Sep 2005 12:57:56 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 16127-03 + for ; + Wed, 21 Sep 2005 15:57:49 +0000 (GMT) +Received: from yertle.kcilink.com (yertle.kcilink.com [65.205.34.180]) + by svr1.postgresql.org (Postfix) with ESMTP id 517EED9662 + for ; + Wed, 21 Sep 2005 12:57:43 -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 CC4F0B80C + for ; + Wed, 21 Sep 2005 11:57:43 -0400 (EDT) +Mime-Version: 1.0 (Apple Message framework v734) +In-Reply-To: <84621a60509121502603bd56c@mail.gmail.com> +References: <84621a6050912140464c380c3@mail.gmail.com> + + <84621a60509121502603bd56c@mail.gmail.com> +Content-Type: multipart/alternative; boundary=Apple-Mail-5-834691309 +Message-Id: <241EAFA1-B76D-46C1-9536-69B3B05AA64C@khera.org> +From: Vivek Khera +Subject: Re: Performance considerations for very heavy INSERT traffic +Date: Wed, 21 Sep 2005 11:57:42 -0400 +To: Postgresql Performance +X-Mailer: Apple Mail (2.734) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.193 required=5 tests=[AWL=-0.135, HTML_50_60=0.095, + HTML_FONT_BIG=0.232, HTML_MESSAGE=0.001] +X-Spam-Level: +X-Archive-Number: 200509/229 +X-Sequence-Number: 14537 + + +--Apple-Mail-5-834691309 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset=US-ASCII; + delsp=yes; + format=flowed + + +On Sep 12, 2005, at 6:02 PM, Brandon Black wrote: + +> - splitting the xlog and the data on distinct physical +> drives or arrays +> +> That would almost definitely help, I haven't tried it yet. +> Speaking of the xlog, anyone know anything specific about the WAL +> tuning parameters for heavy concurrent write traffic? What little +> I could dig up on WAL tuning was contradictory, and testing some +> random changes to the parameters hasn't been very conclusive yet. +> I would imagine the WAL buffers stuff could potentially have a +> large effect for us. +> + +you will want to make your pg_xlog RAID volume BIG, and then tell +postgres to use that space: bump up checkpoint_segments (and suitably +the checkpoint timeouts). I run with 256 segments and a timeout of 5 +minutes. The timeout refletcs your expected crash recovery time, so +adjust it wisely.... + +Also, you should consider how you split your drives across your RAID +data channels on your test machine: I put each pair of the RAID10 +mirrors on opposite channels, so both channels of my RAID controller +are pretty evenly loaded during write. + +Vivek Khera, Ph.D. ++1-301-869-4449 x806 + + + +--Apple-Mail-5-834691309 +Content-Transfer-Encoding: quoted-printable +Content-Type: text/html; + charset=ISO-8859-1 + +
On Sep 12, 2005, = +at 6:02 PM, Brandon Black wrote:

=A0=A0=A0=A0=A0=A0=A0= +=A0- splitting the xlog and the data on distinct physical drives or = +arrays

That would almost definitely help, I haven't = +tried it yet.=A0 Speaking of the xlog, anyone know anything specific = +about the WAL tuning parameters for heavy concurrent write traffic?=A0 = +What little I could dig up on WAL tuning was contradictory, and testing = +some random changes to the parameters hasn't been very conclusive yet.=A0 = +I would imagine the WAL buffers stuff could potentially have a large = +effect for us.


you= + will want to make your pg_xlog RAID volume BIG, and then tell postgres = +to use that space: bump up checkpoint_segments (and suitably the = +checkpoint timeouts).=A0 I run with 256 segments and a timeout of 5 = +minutes.=A0 The timeout refletcs your=A0 expected crash recovery time, = +so adjust it wisely....

Also, you should consider = +how you split your drives across your RAID data channels on your test = +machine: I put each pair of the RAID10 mirrors on opposite channels, so = +both channels of my RAID controller are pretty evenly loaded during = +write.

Vivek Khera, = +Ph.D.

+1-301-869-4449 x806



= + +--Apple-Mail-5-834691309-- + +From pgsql-performance-owner@postgresql.org Wed Sep 21 13:29:07 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 27E45D9932 + for ; + Wed, 21 Sep 2005 13:02:01 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 16447-04 + for ; + Wed, 21 Sep 2005 16:01:49 +0000 (GMT) +Received: from yertle.kcilink.com (yertle.kcilink.com [65.205.34.180]) + by svr1.postgresql.org (Postfix) with ESMTP id 552F6D9895 + for ; + Wed, 21 Sep 2005 13:01:49 -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 26CFBB80C + for ; + Wed, 21 Sep 2005 12:01:49 -0400 (EDT) +Mime-Version: 1.0 (Apple Message framework v734) +In-Reply-To: <84621a60509121502603bd56c@mail.gmail.com> +References: <84621a6050912140464c380c3@mail.gmail.com> + + <84621a60509121502603bd56c@mail.gmail.com> +Content-Type: multipart/alternative; boundary=Apple-Mail-6-834936406 +Message-Id: <0C638D58-7AA9-4668-BE41-A9CC05DA3DA8@khera.org> +From: Vivek Khera +Subject: Re: Performance considerations for very heavy INSERT traffic +Date: Wed, 21 Sep 2005 12:01:48 -0400 +To: Postgresql Performance +X-Mailer: Apple Mail (2.734) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.194 required=5 tests=[AWL=-0.134, HTML_50_60=0.095, + HTML_FONT_BIG=0.232, HTML_MESSAGE=0.001] +X-Spam-Level: +X-Archive-Number: 200509/228 +X-Sequence-Number: 14536 + + +--Apple-Mail-6-834936406 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset=US-ASCII; + delsp=yes; + format=flowed + + +On Sep 12, 2005, at 6:02 PM, Brandon Black wrote: + +> - using COPY instead of INSERT ? +> (should be easy to do from the aggregators) +> +> Possibly, although it would kill the current design of returning +> the database transaction status for a single client packet back to +> the client on transaction success/failure. The aggregator could +> put several clients' data into a series of delayed multi-row copy +> statements. +> + +buffer through the file system on your aggregator. once you "commit" +to local disk file, return back to your client that you got the +data. then insert into the actual postgres DB in large batches of +inserts inside a single Postgres transaction. + +we have our web server log certain tracking requests to a local +file. with file locks and append mode, it is extremely quick and has +little contention delays. then every so often, we lock the file, +rename it, release the lock, then process it at our leisure to do +the inserts to Pg in one big transaction. + +Vivek Khera, Ph.D. ++1-301-869-4449 x806 + + + +--Apple-Mail-6-834936406 +Content-Transfer-Encoding: quoted-printable +Content-Type: text/html; + charset=ISO-8859-1 + +
On Sep 12, 2005, = +at 6:02 PM, Brandon Black wrote:

=A0=A0=A0=A0=A0=A0=A0= +=A0- using COPY instead of INSERT ?
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= +=A0=A0=A0=A0(should be easy to do from the = +aggregators)

Possibly, although it would kill the = +current design of returning the database transaction status for a single = +client packet back to the client on transaction success/failure. =A0 The = +aggregator could put several clients' data into a series of delayed = +multi-row copy statements.


buf= +fer through the file system on your aggregator.=A0 once you "commit" to = +local disk file, return back to your client that you got the data.=A0 = +then insert into the actual postgres DB in large batches of inserts = +inside a single Postgres transaction.

we have our web server log = +certain tracking requests to a local file.=A0 with file locks and append = +mode, it is extremely quick and has little contention delays. then every = +so often, we lock the file, rename=A0 it, release the lock, then process = +it at our leisure to do the inserts to Pg in one big = +transaction.

Vivek Khera, Ph.D.

+1-301-869-4449 x806



= + +--Apple-Mail-6-834936406-- + +From pgsql-performance-owner@postgresql.org Wed Sep 21 16:39:21 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2A3E7D9CC7 + for ; + Wed, 21 Sep 2005 16:38:29 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 82712-03 + for ; + Wed, 21 Sep 2005 19:38:22 +0000 (GMT) +Received: from ecmailer.ecmarket.com (ecmailer.ecmarket.com [216.187.109.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E8523D9CA4 + for ; + Wed, 21 Sep 2005 16:38:19 -0300 (ADT) +Received: from hummer.enterprise.ecmarket.com (hummer.enterprise.ecmarket.com + [10.0.7.2]) + by ecmailer.ecmarket.com (Postfix) with ESMTP id B4E1FB81B6 + for ; + Wed, 21 Sep 2005 12:38:20 -0700 (PDT) +Received: from gurpreet2 (gaulakh2.devel.ecmarket.com [10.0.5.33]) + by hummer.enterprise.ecmarket.com (Postfix) with SMTP id C047E24121 + for ; + Wed, 21 Sep 2005 12:36:27 -0700 (PDT) +From: "Gurpreet Aulakh" +To: +Subject: Query slower on 8.0.3 (Windows) vs 7.3 (cygwin) +Date: Wed, 21 Sep 2005 12:38:20 -0700 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) +Importance: Normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/230 +X-Sequence-Number: 14538 + +I currently have a Postgres 7.3 database running under WIN2K using cygwin +and want to move to Postgres 8.0.3 (native windows version). +I am finding most simple queries are significantly faster on the native +windows version compared to 7.3 (under cygwin). +However, for a complex query, that involve multiple JOINs, the 7.3 version +is actually faster (about 2X faster). + +The query that I am running was optimized to run under 7.3. It was +specifically modified to control the planner with explicit JOINs. +When I run the same query on the 8.0.3 version with the join_collapse_limit +set to 1 the query is slower. + +Can someone tell me why setting the join_collapse_limit to 1 in the 8.0 +version does not produce similar results to the 7.3 version? +Does anyone have any suggestions on what I can do? Do I have to rewrite the +query? + + +Here are the results of an explain analyze on the query. + +Explain analyze Postgres 7.3 running on WIN2K using cygwin. + +Hash Join (cost=21808.27..1946264.80 rows=2982 width=1598) (actual +time=2186.00..2320.00 rows=50 loops=1) + Hash Cond: ("outer".doc_internalparentomxref = "inner".doc_documentid) + -> Hash Join (cost=20948.78..1945323.29 rows=2982 width=1534) (actual +time=2110.00..2227.00 rows=50 loops=1) + Hash Cond: ("outer".doc_internalrootxref = "inner".doc_documentid) + -> Hash Join (cost=20089.29..1944381.79 rows=2982 width=1484) +(actual time=2067.00..2179.00 rows=50 loops=1) + Hash Cond: ("outer".doc_documentid = "inner".doc_documentid) + Join Filter: ("inner".dc_doccontacttype = 'FROM'::character +varying) + -> Hash Join (cost=7455.14..1928613.59 rows=2982 +width=1138) (actual time=1216.00..1539.00 rows=50 loops=1) + Hash Cond: ("outer".doc_documentid = +"inner".doc_documentid) + Join Filter: ("inner".dc_doccontacttype = +'TO'::character varying) + -> Hash Join (cost=183.49..1918519.06 rows=2860 +width=792) (actual time=64.00..301.00 rows=50 loops=1) + Hash Cond: ("outer".doc_documentid = +"inner".doc_documentid) + -> Seq Scan on document finaldoc +(cost=0.00..1918256.94 rows=2860 width=717) (actual time=13.00..254.00 +rows=50 loops=1) + Filter: (subplan) + SubPlan + -> Materialize (cost=335.27..335.27 +rows=50 width=160) (actual time=0.00..0.01 rows=50 loops=5719) + -> Limit (cost=0.00..335.27 +rows=50 width=160) (actual time=3.00..8.00 rows=50 loops=1) + -> Nested Loop +(cost=0.00..38347.95 rows=5719 width=160) (actual time=3.00..8.00 rows=51 +loops=1) + -> Merge Join +(cost=0.00..3910.14 rows=5719 width=120) (actual time=3.00..3.00 rows=51 +loops=1) + Merge Cond: +("outer".doc_documentid = "inner".doc_documentid) + -> Index Scan +using pk_document on document doc (cost=0.00..3256.48 rows=5719 width=80) +(actual time=1.00..1.00 rows=51 loops=1) + -> Index Scan +using pk_folder_document on folder_document (cost=0.00..553.91 rows=5719 +width=40) (actual time=2.00..2.00 rows=51 loops=1) + -> Index Scan using +pk_document on document root (cost=0.00..6.01 rows=1 width=40) (actual +time=0.10..0.10 rows=1 loops=51) + Index Cond: +("outer".doc_internalrootxref = root.doc_documentid) + -> Hash (cost=169.19..169.19 rows=5719 +width=75) (actual time=31.00..31.00 rows=0 loops=1) + -> Seq Scan on folder_document +(cost=0.00..169.19 rows=5719 width=75) (actual time=0.00..11.00 rows=5719 +loops=1) + -> Hash (cost=1328.80..1328.80 rows=34280 width=346) +(actual time=846.00..846.00 rows=0 loops=1) + -> Seq Scan on doccontact dcto +(cost=0.00..1328.80 rows=34280 width=346) (actual time=0.00..175.00 +rows=34280 loops=1) + -> Hash (cost=1328.80..1328.80 rows=34280 width=346) +(actual time=445.00..445.00 rows=0 loops=1) + -> Seq Scan on doccontact dcfrom (cost=0.00..1328.80 +rows=34280 width=346) (actual time=0.00..223.00 rows=34280 loops=1) + -> Hash (cost=845.19..845.19 rows=5719 width=50) (actual +time=42.00..42.00 rows=0 loops=1) + -> Seq Scan on document root (cost=0.00..845.19 rows=5719 +width=50) (actual time=0.00..2.00 rows=5719 loops=1) + -> Hash (cost=845.19..845.19 rows=5719 width=64) (actual +time=73.00..73.00 rows=0 loops=1) + -> Seq Scan on document parentom (cost=0.00..845.19 rows=5719 +width=64) (actual time=0.00..30.00 rows=5719 loops=1) + SubPlan + -> Limit (cost=0.00..5.56 rows=1 width=40) (actual time=0.06..0.06 +rows=0 loops=50) + -> Result (cost=0.00..7.20 rows=1 width=40) (actual +time=0.06..0.06 rows=0 loops=50) + One-Time Filter: ($0 = true) + -> Index Scan using documentevent_index on documentevent +de (cost=0.00..7.20 rows=1 width=40) (actual time=0.07..0.07 rows=0 +loops=44) + Index Cond: (($1 = doc_documentid) AND +(de_processedflag = false) AND (de_documenteventstatus = 'ERROR'::character +varying)) + -> Limit (cost=0.00..3.86 rows=1 width=40) (actual time=0.10..0.10 +rows=0 loops=50) + +Explain analyze Postgres 8.0.3 running natively under WIN2K. + +Hash IN Join (cost=5293.09..7121.89 rows=50 width=1369) (actual +time=1062.000..5558.000 rows=50 loops=1) + Hash Cond: (("outer".doc_documentid)::text = +("inner".doc_documentid)::text) + -> Hash Left Join (cost=4798.24..6199.29 rows=5741 width=1369) (actual +time=751.000..4236.000 rows=5719 loops=1) + Hash Cond: (("outer".doc_internalparentomxref)::text = +("inner".doc_documentid)::text) + -> Hash Left Join (cost=3956.48..5271.41 rows=5741 width=1345) +(actual time=541.000..3105.000 rows=5719 loops=1) + Hash Cond: (("outer".doc_internalrootxref)::text = +("inner".doc_documentid)::text) + -> Hash Left Join (cost=3114.72..4343.53 rows=5741 +width=1335) (actual time=501.000..2313.000 rows=5719 loops=1) + Hash Cond: (("outer".doc_documentid)::text = +("inner".doc_documentid)::text) + -> Hash Left Join (cost=1649.92..2721.09 rows=5741 +width=1039) (actual time=180.000..1342.000 rows=5719 loops=1) + Hash Cond: (("outer".doc_documentid)::text = +("inner".doc_documentid)::text) + -> Hash Left Join (cost=185.13..1098.65 +rows=5741 width=743) (actual time=40.000..592.000 rows=5719 loops=1) + Hash Cond: (("outer".doc_documentid)::text += ("inner".doc_documentid)::text) + -> Seq Scan on document finaldoc +(cost=0.00..827.41 rows=5741 width=708) (actual time=0.000..41.000 rows=5719 +loops=1) + -> Hash (cost=170.70..170.70 rows=5770 +width=75) (actual time=40.000..40.000 rows=0 loops=1) + -> Seq Scan on folder_document +(cost=0.00..170.70 rows=5770 width=75) (actual time=0.000..10.000 rows=5719 +loops=1) + -> Hash (cost=1450.50..1450.50 rows=5718 +width=336) (actual time=140.000..140.000 rows=0 loops=1) + -> Seq Scan on doccontact dcto +(cost=0.00..1450.50 rows=5718 width=336) (actual time=0.000..130.000 +rows=5718 loops=1) + Filter: ((dc_doccontacttype)::text = +'TO'::text) + -> Hash (cost=1450.50..1450.50 rows=5718 width=336) +(actual time=321.000..321.000 rows=0 loops=1) + -> Seq Scan on doccontact dcfrom +(cost=0.00..1450.50 rows=5718 width=336) (actual time=10.000..291.000 +rows=5718 loops=1) + Filter: ((dc_doccontacttype)::text = +'FROM'::text) + -> Hash (cost=827.41..827.41 rows=5741 width=50) (actual +time=40.000..40.000 rows=0 loops=1) + -> Seq Scan on document root (cost=0.00..827.41 +rows=5741 width=50) (actual time=0.000..30.000 rows=5719 loops=1) + -> Hash (cost=827.41..827.41 rows=5741 width=64) (actual +time=210.000..210.000 rows=0 loops=1) + -> Seq Scan on document parentom (cost=0.00..827.41 +rows=5741 width=64) (actual time=0.000..160.000 rows=5719 loops=1) + -> Hash (cost=494.73..494.73 rows=50 width=42) (actual +time=261.000..261.000 rows=0 loops=1) + -> Subquery Scan "IN_subquery" (cost=185.13..494.73 rows=50 +width=42) (actual time=101.000..261.000 rows=50 loops=1) + -> Limit (cost=185.13..494.23 rows=50 width=40) (actual +time=101.000..261.000 rows=50 loops=1) + -> Nested Loop Left Join (cost=185.13..35676.18 +rows=5741 width=40) (actual time=101.000..261.000 rows=50 loops=1) + -> Hash Left Join (cost=185.13..1098.65 +rows=5741 width=80) (actual time=91.000..91.000 rows=50 loops=1) + Hash Cond: (("outer".doc_documentid)::text += ("inner".doc_documentid)::text) + -> Seq Scan on document doc +(cost=0.00..827.41 rows=5741 width=80) (actual time=10.000..10.000 rows=50 +loops=1) + -> Hash (cost=170.70..170.70 rows=5770 +width=40) (actual time=81.000..81.000 rows=0 loops=1) + -> Seq Scan on folder_document +(cost=0.00..170.70 rows=5770 width=40) (actual time=10.000..61.000 rows=5719 +loops=1) + -> Index Scan using pk_document on document root +(cost=0.00..6.01 rows=1 width=40) (actual time=3.400..3.400 rows=1 loops=50) + Index Cond: +(("outer".doc_internalrootxref)::text = (root.doc_documentid)::text) + SubPlan + -> Limit (cost=0.00..1.96 rows=1 width=40) (actual time=0.400..0.400 +rows=0 loops=50) + -> Seq Scan on followup_document fd (cost=0.00..3.91 rows=2 +width=40) (actual time=0.400..0.400 rows=0 loops=50) + Filter: (($1)::text = (doc_documentid)::text) + -> Limit (cost=0.00..6.01 rows=1 width=40) (actual +time=17.620..17.620 rows=0 loops=50) + -> Result (cost=0.00..6.01 rows=1 width=40) (actual +time=17.620..17.620 rows=0 loops=50) + One-Time Filter: ($0 = true) + -> Index Scan using documentevent_index on documentevent +de (cost=0.00..6.01 rows=1 width=40) (actual time=28.419..28.419 rows=0 +loops=31) + Index Cond: ((($1)::text = (doc_documentid)::text) +AND (de_processedflag = false) AND ((de_documenteventstatus)::text = +'ERROR'::text)) + Total runtime: 5558.000 ms + + +From pgsql-performance-owner@postgresql.org Fri Sep 23 02:34:47 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E4687D9E6C + for ; + Wed, 21 Sep 2005 19:04:02 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 13377-08 + for ; + Wed, 21 Sep 2005 22:03:56 +0000 (GMT) +Received: from ki-communication.com (unknown [202.147.194.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 5B6E9D9E65 + for ; + Wed, 21 Sep 2005 19:03:50 -0300 (ADT) +Received: from iacn01wks ([192.168.0.128]) by ki-communication.com with + Microsoft SMTPSVC(6.0.3790.1830); Thu, 22 Sep 2005 05:08:11 +0700 +From: "Ahmad Fajar" +To: +Subject: tsearch2 seem very slow +Date: Thu, 22 Sep 2005 05:08:12 +0700 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0000_01C5BF33.A16E12B0" +X-Mailer: Microsoft Office Outlook, Build 11.0.6353 +Thread-Index: AcW++PT0wRKS88YrQZGbHiQZ6k4XsQ== +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +Message-ID: +X-OriginalArrivalTime: 21 Sep 2005 22:08:11.0656 (UTC) + FILETIME=[F4B47080:01C5BEF8] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.001 required=5 tests=[HTML_MESSAGE=0.001] +X-Spam-Level: +X-Archive-Number: 200509/273 +X-Sequence-Number: 14581 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0000_01C5BF33.A16E12B0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit + +I have about 419804 rows in my article table. I have installed tsearch2 and +its gist index correctly. + +My table structure is: + +CREATE TABLE tbarticles + +( + + articleid int4 NOT NULL, + + title varchar(250), + + mediaid int4, + + datee date, + + content text, + + contentvar text, + + mmcol float4 NOT NULL, + + sirkulasi float4, + + page varchar(10), + + tglisidata date, + + namapc varchar(12), + + usere varchar(12), + + file_pdf varchar(255), + + file_pdf2 varchar(50), + + kolom int4, + + size_jpeg int4, + + journalist varchar(120), + + ratebw float4, + + ratefc float4, + + fti tsvector, + + CONSTRAINT pk_tbarticles PRIMARY KEY (articleid) + +) WITHOUT OIDS; + +Create index fti_idx1 on tbarticles using gist (fti); + +Create index fti_idx2 on tbarticles using gist (datee, fti); + + + +But when I search something like: + +Select articleid, title, datee from tbarticles where fti @@ +to_tsquery('susilo&bambang&yudhoyono&jusuf&kalla'); + +It takes about 30 sec. I run explain analyze and the index is used +correctly. + + + +Then I try multi column index to filter by date, and my query something +like: + +Select articleid, title, datee from tbarticles where fti @@ +to_tsquery('susilo&bambang&yudhoyono&jusuf&kalla') and datee >= '2002-01-01' +and datee <= current_date + +An it still run about 25 sec. I do run explain analyze and my multicolumn +index is used correctly. + +This is not acceptable if want to publish my website if the search took very +longer. + + + +I have run vacuum full analyze before doing such query. What going wrong +with my query?? Is there any way to make this faster? + +I have try to tune my postgres configuration, but it seem helpless. My linux +box is Redhat 4 AS, and + +the hardware: 2 GB RAM DDR 400, 2x200 GB Serial ATA 7200RPM and configure as +RAID0 (just for postgres data), my sistem run at EIDE 80GB 7200 RPM. + + + +Please.help.help. + + +------=_NextPart_000_0000_01C5BF33.A16E12B0 +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + +
+ +

I have about 419804 rows in my article table. I have +installed tsearch2 and its gist index correctly. = +

+ +

My table structure is:

+ +

CREATE TABLE tbarticles

+ +

(

+ +

  articleid int4 NOT = +NULL,

+ +

  title = +varchar(250),

+ +

  mediaid int4,

+ +

  datee date,

+ +

  content text,

+ +

  contentvar text,

+ +

  mmcol float4 NOT = +NULL,

+ +

  sirkulasi float4,

+ +

  page varchar(10),

+ +

  tglisidata date,

+ +

  namapc = +varchar(12),

+ +

  usere = +varchar(12),

+ +

  file_pdf = +varchar(255),

+ +

  file_pdf2 = +varchar(50),

+ +

  kolom int4,

+ +

  size_jpeg int4,

+ +

  journalist = +varchar(120),

+ +

  ratebw float4,

+ +

  ratefc float4,

+ +

  fti tsvector,

+ +

  CONSTRAINT pk_tbarticles PRIMARY KEY = +(articleid)

+ +

) WITHOUT OIDS;

+ +

Create index fti_idx1 on tbarticles using gist = +(fti);

+ +

Create index fti_idx2 on tbarticles using gist = +(datee, fti);

+ +

 

+ +

But when I search something = +like:

+ +

Select articleid, title, datee from tbarticles where = +fti @@ +to_tsquery(‘susilo&bambang&yudhoyono&jusuf&kalla= +217;);

+ +

It takes about 30 sec. I run explain analyze and the = +index +is used correctly.

+ +

 

+ +

Then I try multi column index to filter by date, and = +my +query something like:

+ +

Select articleid, title, datee from tbarticles where = +fti @@ +to_tsquery(‘susilo&bambang&yudhoyono&jusuf&kalla= +217;) +and datee >=3D '2002-01-01' and datee <=3D = +current_date

+ +

An it still run about 25 sec. I do run explain = +analyze and +my multicolumn index is used correctly.

+ +

This is not acceptable if want to publish my website = +if the +search took very longer.

+ +

 

+ +

I have run vacuum full analyze before doing such = +query. What +going wrong with my query?? Is there any way to make this = +faster?

+ +

I have try to tune my postgres configuration, but it = +seem +helpless. My linux box is Redhat 4 AS, and

+ +

the hardware: 2 GB RAM DDR 400, 2x200 GB Serial ATA = +7200RPM and +configure as RAID0 (just for postgres data), my sistem run at EIDE 80GB = +7200 +RPM.

+ +

 

+ +

Please…help…help…<= +/font>

+ +
+ + + + + +------=_NextPart_000_0000_01C5BF33.A16E12B0-- + + +From pgsql-performance-owner@postgresql.org Wed Sep 21 21:11:44 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4F483D9FB2 + for ; + Wed, 21 Sep 2005 21:11:20 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 49845-01 + for ; + Thu, 22 Sep 2005 00:11:15 +0000 (GMT) +Received: from ecmailer.ecmarket.com (ecmailer.ecmarket.com [216.187.109.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D2432D9FAE + for ; + Wed, 21 Sep 2005 21:11:14 -0300 (ADT) +Received: from hummer.enterprise.ecmarket.com (hummer.enterprise.ecmarket.com + [10.0.7.2]) + by ecmailer.ecmarket.com (Postfix) with ESMTP id CC52EB81B5; + Wed, 21 Sep 2005 17:11:17 -0700 (PDT) +Received: from gurpreet2 (gaulakh2.devel.ecmarket.com [10.0.5.33]) + by hummer.enterprise.ecmarket.com (Postfix) with SMTP + id 0ED1724121; Wed, 21 Sep 2005 17:11:17 -0700 (PDT) +From: "Gurpreet Aulakh" +To: "Gurpreet Aulakh" , + +Subject: Re: Query slower on 8.0.3 (Windows) vs 7.3 (cygwin) +Date: Wed, 21 Sep 2005 17:11:17 -0700 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) +Importance: Normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506 +In-Reply-To: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/231 +X-Sequence-Number: 14539 + +I have started to break my query down and analyze each piece. +What I have discovered is very interesting. + +First here is a small piece of my query. + +EXPLAIN ANALYZE SELECT doc.doc_documentid FROM document AS doc + LEFT JOIN document as root ON doc.doc_internalRootXref = +root.doc_documentId + LEFT JOIN folder_document ON doc.doc_documentid = +folder_document.doc_documentId LIMIT 500 OFFSET 0 + +When I run this on Postgres 8.0.3 running under windows this is the result + +QUERY PLAN +Limit (cost=183.49..753.41 rows=500 width=40) (actual time=47.000..79.000 +rows=500 loops=1) + -> Hash Left Join (cost=183.49..6702.23 rows=5719 width=40) (actual +time=47.000..79.000 rows=500 loops=1) + Hash Cond: (("outer".doc_documentid)::text = +("inner".doc_documentid)::text) + -> Merge Left Join (cost=0.00..6432.96 rows=5719 width=40) (actual +time=0.000..16.000 rows=500 loops=1) + Merge Cond: (("outer".doc_internalrootxref)::text = +("inner".doc_documentid)::text) + -> Index Scan using doc_internalrootxref_index on document +doc (cost=0.00..3172.64 rows=5719 width=80) (actual time=0.000..0.000 +rows=500 loops=1) + -> Index Scan using pk_document on document root +(cost=0.00..3174.53 rows=5719 width=40) (actual time=0.000..0.000 rows=863 +loops=1) + -> Hash (cost=169.19..169.19 rows=5719 width=40) (actual +time=47.000..47.000 rows=0 loops=1) + -> Seq Scan on folder_document (cost=0.00..169.19 rows=5719 +width=40) (actual time=0.000..16.000 rows=5719 loops=1) +Total runtime: 79.000 ms + +Here is the result of running the same query on the Postgres 7.3 running +under Cygwin + +QUERY PLAN +Limit (cost=183.49..775.31 rows=500 width=160) (actual time=13.00..44.00 +rows=500 loops=1) + -> Hash Join (cost=183.49..6952.79 rows=5719 width=160) (actual +time=13.00..44.00 rows=501 loops=1) + Hash Cond: ("outer".doc_documentid = "inner".doc_documentid) + -> Merge Join (cost=0.00..6612.03 rows=5719 width=120) (actual +time=0.00..29.00 rows=775 loops=1) + Merge Cond: ("outer".doc_internalrootxref = +"inner".doc_documentid) + -> Index Scan using doc_internalrootxref_index on document +doc (cost=0.00..3254.39 rows=5719 width=80) (actual time=0.00..7.00 +rows=775 loops=1) + -> Index Scan using pk_document on document root +(cost=0.00..3257.88 rows=5719 width=40) (actual time=0.00..15.00 rows=1265 +loops=1) + -> Hash (cost=169.19..169.19 rows=5719 width=40) (actual +time=12.00..12.00 rows=0 loops=1) + -> Seq Scan on folder_document (cost=0.00..169.19 rows=5719 +width=40) (actual time=0.00..9.00 rows=5719 loops=1) +Total runtime: 45.00 msec + +What is really interesting is the time it takes for the Hash to occur. For +the first hash, on the 7.3 it takes only 12ms while on the 8.0 it takes +47ms. +Now the databases are created from the same data and I have run +vacuumdb -f -z on the databases. + +Now I have read something on the archives that stated that perhaps the data +is in the filesystem (not database) cache. Would this be the case?. If so +how would I improve the performance under WIN2K? + +Anyone have any ideas? + + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org]On Behalf Of Gurpreet +Aulakh +Sent: September 21, 2005 12:38 PM +To: pgsql-performance@postgresql.org +Subject: [PERFORM] Query slower on 8.0.3 (Windows) vs 7.3 (cygwin) + + +I currently have a Postgres 7.3 database running under WIN2K using cygwin +and want to move to Postgres 8.0.3 (native windows version). +I am finding most simple queries are significantly faster on the native +windows version compared to 7.3 (under cygwin). +However, for a complex query, that involve multiple JOINs, the 7.3 version +is actually faster (about 2X faster). + +The query that I am running was optimized to run under 7.3. It was +specifically modified to control the planner with explicit JOINs. +When I run the same query on the 8.0.3 version with the join_collapse_limit +set to 1 the query is slower. + +Can someone tell me why setting the join_collapse_limit to 1 in the 8.0 +version does not produce similar results to the 7.3 version? +Does anyone have any suggestions on what I can do? Do I have to rewrite the +query? + + +Here are the results of an explain analyze on the query. + +Explain analyze Postgres 7.3 running on WIN2K using cygwin. + +Hash Join (cost=21808.27..1946264.80 rows=2982 width=1598) (actual +time=2186.00..2320.00 rows=50 loops=1) + Hash Cond: ("outer".doc_internalparentomxref = "inner".doc_documentid) + -> Hash Join (cost=20948.78..1945323.29 rows=2982 width=1534) (actual +time=2110.00..2227.00 rows=50 loops=1) + Hash Cond: ("outer".doc_internalrootxref = "inner".doc_documentid) + -> Hash Join (cost=20089.29..1944381.79 rows=2982 width=1484) +(actual time=2067.00..2179.00 rows=50 loops=1) + Hash Cond: ("outer".doc_documentid = "inner".doc_documentid) + Join Filter: ("inner".dc_doccontacttype = 'FROM'::character +varying) + -> Hash Join (cost=7455.14..1928613.59 rows=2982 +width=1138) (actual time=1216.00..1539.00 rows=50 loops=1) + Hash Cond: ("outer".doc_documentid = +"inner".doc_documentid) + Join Filter: ("inner".dc_doccontacttype = +'TO'::character varying) + -> Hash Join (cost=183.49..1918519.06 rows=2860 +width=792) (actual time=64.00..301.00 rows=50 loops=1) + Hash Cond: ("outer".doc_documentid = +"inner".doc_documentid) + -> Seq Scan on document finaldoc +(cost=0.00..1918256.94 rows=2860 width=717) (actual time=13.00..254.00 +rows=50 loops=1) + Filter: (subplan) + SubPlan + -> Materialize (cost=335.27..335.27 +rows=50 width=160) (actual time=0.00..0.01 rows=50 loops=5719) + -> Limit (cost=0.00..335.27 +rows=50 width=160) (actual time=3.00..8.00 rows=50 loops=1) + -> Nested Loop +(cost=0.00..38347.95 rows=5719 width=160) (actual time=3.00..8.00 rows=51 +loops=1) + -> Merge Join +(cost=0.00..3910.14 rows=5719 width=120) (actual time=3.00..3.00 rows=51 +loops=1) + Merge Cond: +("outer".doc_documentid = "inner".doc_documentid) + -> Index Scan +using pk_document on document doc (cost=0.00..3256.48 rows=5719 width=80) +(actual time=1.00..1.00 rows=51 loops=1) + -> Index Scan +using pk_folder_document on folder_document (cost=0.00..553.91 rows=5719 +width=40) (actual time=2.00..2.00 rows=51 loops=1) + -> Index Scan using +pk_document on document root (cost=0.00..6.01 rows=1 width=40) (actual +time=0.10..0.10 rows=1 loops=51) + Index Cond: +("outer".doc_internalrootxref = root.doc_documentid) + -> Hash (cost=169.19..169.19 rows=5719 +width=75) (actual time=31.00..31.00 rows=0 loops=1) + -> Seq Scan on folder_document +(cost=0.00..169.19 rows=5719 width=75) (actual time=0.00..11.00 rows=5719 +loops=1) + -> Hash (cost=1328.80..1328.80 rows=34280 width=346) +(actual time=846.00..846.00 rows=0 loops=1) + -> Seq Scan on doccontact dcto +(cost=0.00..1328.80 rows=34280 width=346) (actual time=0.00..175.00 +rows=34280 loops=1) + -> Hash (cost=1328.80..1328.80 rows=34280 width=346) +(actual time=445.00..445.00 rows=0 loops=1) + -> Seq Scan on doccontact dcfrom (cost=0.00..1328.80 +rows=34280 width=346) (actual time=0.00..223.00 rows=34280 loops=1) + -> Hash (cost=845.19..845.19 rows=5719 width=50) (actual +time=42.00..42.00 rows=0 loops=1) + -> Seq Scan on document root (cost=0.00..845.19 rows=5719 +width=50) (actual time=0.00..2.00 rows=5719 loops=1) + -> Hash (cost=845.19..845.19 rows=5719 width=64) (actual +time=73.00..73.00 rows=0 loops=1) + -> Seq Scan on document parentom (cost=0.00..845.19 rows=5719 +width=64) (actual time=0.00..30.00 rows=5719 loops=1) + SubPlan + -> Limit (cost=0.00..5.56 rows=1 width=40) (actual time=0.06..0.06 +rows=0 loops=50) + -> Result (cost=0.00..7.20 rows=1 width=40) (actual +time=0.06..0.06 rows=0 loops=50) + One-Time Filter: ($0 = true) + -> Index Scan using documentevent_index on documentevent +de (cost=0.00..7.20 rows=1 width=40) (actual time=0.07..0.07 rows=0 +loops=44) + Index Cond: (($1 = doc_documentid) AND +(de_processedflag = false) AND (de_documenteventstatus = 'ERROR'::character +varying)) + -> Limit (cost=0.00..3.86 rows=1 width=40) (actual time=0.10..0.10 +rows=0 loops=50) + +Explain analyze Postgres 8.0.3 running natively under WIN2K. + +Hash IN Join (cost=5293.09..7121.89 rows=50 width=1369) (actual +time=1062.000..5558.000 rows=50 loops=1) + Hash Cond: (("outer".doc_documentid)::text = +("inner".doc_documentid)::text) + -> Hash Left Join (cost=4798.24..6199.29 rows=5741 width=1369) (actual +time=751.000..4236.000 rows=5719 loops=1) + Hash Cond: (("outer".doc_internalparentomxref)::text = +("inner".doc_documentid)::text) + -> Hash Left Join (cost=3956.48..5271.41 rows=5741 width=1345) +(actual time=541.000..3105.000 rows=5719 loops=1) + Hash Cond: (("outer".doc_internalrootxref)::text = +("inner".doc_documentid)::text) + -> Hash Left Join (cost=3114.72..4343.53 rows=5741 +width=1335) (actual time=501.000..2313.000 rows=5719 loops=1) + Hash Cond: (("outer".doc_documentid)::text = +("inner".doc_documentid)::text) + -> Hash Left Join (cost=1649.92..2721.09 rows=5741 +width=1039) (actual time=180.000..1342.000 rows=5719 loops=1) + Hash Cond: (("outer".doc_documentid)::text = +("inner".doc_documentid)::text) + -> Hash Left Join (cost=185.13..1098.65 +rows=5741 width=743) (actual time=40.000..592.000 rows=5719 loops=1) + Hash Cond: (("outer".doc_documentid)::text += ("inner".doc_documentid)::text) + -> Seq Scan on document finaldoc +(cost=0.00..827.41 rows=5741 width=708) (actual time=0.000..41.000 rows=5719 +loops=1) + -> Hash (cost=170.70..170.70 rows=5770 +width=75) (actual time=40.000..40.000 rows=0 loops=1) + -> Seq Scan on folder_document +(cost=0.00..170.70 rows=5770 width=75) (actual time=0.000..10.000 rows=5719 +loops=1) + -> Hash (cost=1450.50..1450.50 rows=5718 +width=336) (actual time=140.000..140.000 rows=0 loops=1) + -> Seq Scan on doccontact dcto +(cost=0.00..1450.50 rows=5718 width=336) (actual time=0.000..130.000 +rows=5718 loops=1) + Filter: ((dc_doccontacttype)::text = +'TO'::text) + -> Hash (cost=1450.50..1450.50 rows=5718 width=336) +(actual time=321.000..321.000 rows=0 loops=1) + -> Seq Scan on doccontact dcfrom +(cost=0.00..1450.50 rows=5718 width=336) (actual time=10.000..291.000 +rows=5718 loops=1) + Filter: ((dc_doccontacttype)::text = +'FROM'::text) + -> Hash (cost=827.41..827.41 rows=5741 width=50) (actual +time=40.000..40.000 rows=0 loops=1) + -> Seq Scan on document root (cost=0.00..827.41 +rows=5741 width=50) (actual time=0.000..30.000 rows=5719 loops=1) + -> Hash (cost=827.41..827.41 rows=5741 width=64) (actual +time=210.000..210.000 rows=0 loops=1) + -> Seq Scan on document parentom (cost=0.00..827.41 +rows=5741 width=64) (actual time=0.000..160.000 rows=5719 loops=1) + -> Hash (cost=494.73..494.73 rows=50 width=42) (actual +time=261.000..261.000 rows=0 loops=1) + -> Subquery Scan "IN_subquery" (cost=185.13..494.73 rows=50 +width=42) (actual time=101.000..261.000 rows=50 loops=1) + -> Limit (cost=185.13..494.23 rows=50 width=40) (actual +time=101.000..261.000 rows=50 loops=1) + -> Nested Loop Left Join (cost=185.13..35676.18 +rows=5741 width=40) (actual time=101.000..261.000 rows=50 loops=1) + -> Hash Left Join (cost=185.13..1098.65 +rows=5741 width=80) (actual time=91.000..91.000 rows=50 loops=1) + Hash Cond: (("outer".doc_documentid)::text += ("inner".doc_documentid)::text) + -> Seq Scan on document doc +(cost=0.00..827.41 rows=5741 width=80) (actual time=10.000..10.000 rows=50 +loops=1) + -> Hash (cost=170.70..170.70 rows=5770 +width=40) (actual time=81.000..81.000 rows=0 loops=1) + -> Seq Scan on folder_document +(cost=0.00..170.70 rows=5770 width=40) (actual time=10.000..61.000 rows=5719 +loops=1) + -> Index Scan using pk_document on document root +(cost=0.00..6.01 rows=1 width=40) (actual time=3.400..3.400 rows=1 loops=50) + Index Cond: +(("outer".doc_internalrootxref)::text = (root.doc_documentid)::text) + SubPlan + -> Limit (cost=0.00..1.96 rows=1 width=40) (actual time=0.400..0.400 +rows=0 loops=50) + -> Seq Scan on followup_document fd (cost=0.00..3.91 rows=2 +width=40) (actual time=0.400..0.400 rows=0 loops=50) + Filter: (($1)::text = (doc_documentid)::text) + -> Limit (cost=0.00..6.01 rows=1 width=40) (actual +time=17.620..17.620 rows=0 loops=50) + -> Result (cost=0.00..6.01 rows=1 width=40) (actual +time=17.620..17.620 rows=0 loops=50) + One-Time Filter: ($0 = true) + -> Index Scan using documentevent_index on documentevent +de (cost=0.00..6.01 rows=1 width=40) (actual time=28.419..28.419 rows=0 +loops=31) + Index Cond: ((($1)::text = (doc_documentid)::text) +AND (de_processedflag = false) AND ((de_documenteventstatus)::text = +'ERROR'::text)) + Total runtime: 5558.000 ms + + +---------------------------(end of broadcast)--------------------------- +TIP 5: don't forget to increase your free space map settings + + + + +From pgsql-performance-owner@postgresql.org Thu Sep 22 00:13:27 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 671F1D6D8D + for ; + Thu, 22 Sep 2005 00:13:14 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 06757-04 + for ; + Thu, 22 Sep 2005 03:13:12 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id B4815DA141 + for ; + Thu, 22 Sep 2005 00:13:11 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j8M3CvbH024009; + Wed, 21 Sep 2005 23:12:57 -0400 (EDT) +To: "Gurpreet Aulakh" +Cc: pgsql-performance@postgresql.org +Subject: Re: Query slower on 8.0.3 (Windows) vs 7.3 (cygwin) +In-reply-to: +References: +Comments: In-reply-to "Gurpreet Aulakh" + message dated "Wed, 21 Sep 2005 17:11:17 -0700" +Date: Wed, 21 Sep 2005 23:12:57 -0400 +Message-ID: <24008.1127358777@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/232 +X-Sequence-Number: 14540 + +"Gurpreet Aulakh" writes: +> What is really interesting is the time it takes for the Hash to occur. For +> the first hash, on the 7.3 it takes only 12ms while on the 8.0 it takes +> 47ms. + +You haven't told us a thing about the column datatypes involved (much +less what the query actually is) ... but I wonder if this is a textual +datatype and the 8.0 installation is using a non-C locale where the 7.3 +installation is using C locale. That could account for a considerable +slowdown in text comparison speeds. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Sep 22 01:21:56 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4A46BDA1E5 + for ; + Thu, 22 Sep 2005 01:21:56 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 22285-09 + for ; + Thu, 22 Sep 2005 04:21:52 +0000 (GMT) +Received: from wmail05dat.netvigator.com (unknown [218.102.48.220]) + by svr1.postgresql.org (Postfix) with ESMTP id 1E6B2DA1D5 + for ; + Thu, 22 Sep 2005 01:21:50 -0300 (ADT) +Received: from n2.netvigator.com ([218.102.147.167]) + by wmail05dat.netvigator.com + (InterMail vM.6.01.05.02 201-2131-123-102-20050715) with ESMTP id + <20050922042146.XKPE18019.wmail05dat.netvigator.com@n2.netvigator.com> + for ; + Thu, 22 Sep 2005 12:21:46 +0800 +Message-Id: <6.2.1.2.0.20050922102035.07bcf2e0@localhost> +X-Mailer: QUALCOMM Windows Eudora Version 6.2.1.2 +Date: Thu, 22 Sep 2005 12:21:18 +0800 +To: pgsql-performance@postgresql.org +From: K C Lau +Subject: Re: SELECT LIMIT 1 VIEW Performance Issue +In-Reply-To: <6.2.1.2.0.20050615100524.04f9d6a8@localhost> +References: <6.2.1.2.0.20050615100524.04f9d6a8@localhost> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.517 required=5 tests=[AWL=-0.375, + DNS_FROM_RFC_POST=1.376, FROM_ENDS_IN_NUMS=0.516] +X-Spam-Level: * +X-Archive-Number: 200509/233 +X-Sequence-Number: 14541 + +Hi All, + +Investigating further on this problem I brought up in June, the following +query with pg 8.0.3 on Windows scans all 1743 data records for a player: + +esdt=> explain analyze select PlayerID,AtDate from Player a + where PlayerID='22220' and AtDate = (select b.AtDate from Player b + where b.PlayerID = a.PlayerID order by b.PlayerID desc, b.AtDate desc +LIMIT 1); + + Index Scan using pk_player on player a (cost=0.00..2789.07 rows=9 +width=23) (a +ctual time=51.046..51.049 rows=1 loops=1) + Index Cond: ((playerid)::text = '22220'::text) + Filter: ((atdate)::text = ((subplan))::text) + SubPlan + -> Limit (cost=0.00..0.83 rows=1 width=23) (actual +time=0.016..0.017 rows +=1 loops=1743) + -> Index Scan Backward using pk_player on player +b (cost=0.00..970. +53 rows=1166 width=23) (actual time=0.011..0.011 rows=1 loops=1743) + Index Cond: ((playerid)::text = ($0)::text) + Total runtime: 51.133 ms + +Using a static value in the subquery produces the desired result below, but +since we use views for our queries (see last part of this email), we cannot +push the static value into the subquery: + +esdt=> explain analyze select PlayerID,AtDate from Player a + where PlayerID='22220' and AtDate = (select b.AtDate from Player b + where b.PlayerID = '22220' order by b.PlayerID desc, b.AtDate desc LIMIT 1); + + Index Scan using pk_player on player a (cost=0.75..4.26 rows=1 width=23) +(actu +al time=0.054..0.058 rows=1 loops=1) + Index Cond: (((playerid)::text = '22220'::text) AND ((atdate)::text = +($0)::t +ext)) + InitPlan + -> Limit (cost=0.00..0.75 rows=1 width=23) (actual +time=0.028..0.029 rows +=1 loops=1) + -> Index Scan Backward using pk_player on player +b (cost=0.00..1323 +.05 rows=1756 width=23) (actual time=0.023..0.023 rows=1 loops=1) + Index Cond: ((playerid)::text = '22220'::text) + Total runtime: 0.149 ms + +The Player table has a primary key on PlayerID, AtDate. Is there a way to +stop the inner-most index scan looping all 1743 data records for that +player? Is that a bug or known issue? + +BTW, I tried using 8.1 beta2 on Windows and its performance is similar, I +have also tried other variants such as MAX and DISTINCT but with no success. + +Any help is most appreciated. + +Best regards, +KC. + + +At 10:46 05/06/15, K C Lau wrote: +>Hi All, +> +>I previously posted the following as a sequel to my SELECT DISTINCT +>Performance Issue question. We would most appreciate any clue or +>suggestions on how to overcome this show-stopping issue. We are using +>8.0.3 on Windows. +> +>Is it a known limitation when using a view with SELECT ... LIMIT 1? +> +>Would the forthcoming performance enhancement with MAX help when used +>within a view, as in: +> +>create or replace view VCurPlayer as select * from Player a +>where a.AtDate = (select Max(b.AtDate) from Player b where a.PlayerID = +>b.PlayerID); +> +>select PlayerID,AtDate from VCurPlayer where PlayerID='22220'; +> +>Thanks and regards, +>KC. +> +>--------- +> +>Actually the problem with LIMIT 1 query is when we use views with the +>LIMIT 1 construct. The direct SQL is ok: +> +>esdt=> explain analyze select PlayerID,AtDate from Player where +>PlayerID='22220' +> order by PlayerID desc, AtDate desc LIMIT 1; +> +> Limit (cost=0.00..1.37 rows=1 width=23) (actual time=0.000..0.000 +> rows=1 loops=1) +> -> Index Scan Backward using pk_player on +> player (cost=0.00..16074.23 rows=11770 width=23) (actual +> time=0.000..0.000 rows=1 loops=1) +> Index Cond: ((playerid)::text = '22220'::text) +> Total runtime: 0.000 ms +> +>esdt=> create or replace view VCurPlayer3 as select * from Player a +>where AtDate = (select b.AtDate from Player b where a.PlayerID = b.PlayerID +>order by b.PlayerID desc, b.AtDate desc LIMIT 1); +> +>esdt=> explain analyze select PlayerID,AtDate,version from VCurPlayer3 +>where PlayerID='22220'; +> Index Scan using pk_player on player a (cost=0.00..33072.78 rows=59 +> width=27) +>(actual time=235.000..235.000 rows=1 loops=1) +> Index Cond: ((playerid)::text = '22220'::text) +> Filter: ((atdate)::text = ((subplan))::text) +> SubPlan +> -> Limit (cost=0.00..1.44 rows=1 width=23) (actual +> time=0.117..0.117 rows=1 loops=1743) +> -> Index Scan Backward using pk_player on player +> b (cost=0.00..14023.67 rows=9727 width=23) (actual time=0.108..0.108 +> rows=1 loops=1743) +> Index Cond: (($0)::text = (playerid)::text) +> Total runtime: 235.000 ms + + +From pgsql-performance-owner@postgresql.org Thu Sep 22 05:24:13 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CAD2ADA4DC + for ; + Thu, 22 Sep 2005 05:24:11 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 84829-04 + for ; + Thu, 22 Sep 2005 08:24:09 +0000 (GMT) +Received: from smtp1.freeserve.com (smtp1.wanadoo.co.uk [193.252.22.158]) + by svr1.postgresql.org (Postfix) with ESMTP id F296CDA4DB + for ; + Thu, 22 Sep 2005 05:24:08 -0300 (ADT) +Received: from me-wanadoo.net (localhost [127.0.0.1]) + by mwinf3014.me.freeserve.com (SMTP Server) with ESMTP id C1FE28800085; + Thu, 22 Sep 2005 10:24:08 +0200 (CEST) +Received: from 192.168.0.102 (modem-2050.leopard.dialup.pol.co.uk + [217.135.152.2]) + by mwinf3014.me.freeserve.com (SMTP Server) with ESMTP id 5F0A88800081; + Thu, 22 Sep 2005 10:24:08 +0200 (CEST) +X-ME-UUID: 20050922082408389.5F0A88800081@mwinf3014.me.freeserve.com +Subject: Re: Nested Loop trouble : Execution time increases more +From: Simon Riggs +To: Antoine Bajolet +Cc: pgsql-performance@postgresql.org +In-Reply-To: <432C3A86.5010000@free.fr> +References: <432C3A86.5010000@free.fr> +Content-Type: text/plain +Organization: 2nd Quadrant +Date: Thu, 22 Sep 2005 09:24:10 +0100 +Message-Id: <1127377450.4145.68.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-3) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.052 required=5 tests=[AWL=0.002, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/234 +X-Sequence-Number: 14542 + +On Sat, 2005-09-17 at 17:47 +0200, Antoine Bajolet wrote: + +> There are more tables around, but the heart of the search engine is +> made of three tables : +> +> fiches (f_id int4, f_title varchar) 52445 rows +> engine (f_id int4, k_id int4, weight ) 11761700 rows +> keywords(k_id, keyword) 1072600 rows +> +> A "fiche" is linked to any kind of document. +> The engine table counts how many times a keyword appears in a document. +> +> A query to search on one or two keywords is quick to execute (the +> front-end creates thoses queries): +> + +> Is there a specific reason the planner chooses this way ? + +Yes, you have an additional join for each new keyword, so there is more +work to do. + +Recode your SQL with an IN subselect that retrieves all possible +keywords before it accesses the larger table. + +That way you should have only one join for each new keyword. + +> Can whe do something on the postgresql configuration to avoid this ? +> Can whe force the planner to use a hash join as it does for the first +> joins ? + +Not required, IMHO. + +Best Regards, Simon Riggs + + + +From pgsql-performance-owner@postgresql.org Thu Sep 22 05:41:10 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 01B1BDA4A8 + for ; + Thu, 22 Sep 2005 05:41:09 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 90401-02 + for ; + Thu, 22 Sep 2005 08:40:48 +0000 (GMT) +Received: from smtp1.freeserve.com (smtp1.wanadoo.co.uk [193.252.22.158]) + by svr1.postgresql.org (Postfix) with ESMTP id 831D8DA512 + for ; + Thu, 22 Sep 2005 05:40:48 -0300 (ADT) +Received: from me-wanadoo.net (localhost [127.0.0.1]) + by mwinf3007.me.freeserve.com (SMTP Server) with ESMTP id 444D21C0008B; + Thu, 22 Sep 2005 10:40:50 +0200 (CEST) +Received: from 192.168.0.102 (modem-2050.leopard.dialup.pol.co.uk + [217.135.152.2]) + by mwinf3007.me.freeserve.com (SMTP Server) with ESMTP id C328A1C00088; + Thu, 22 Sep 2005 10:40:49 +0200 (CEST) +X-ME-UUID: 20050922084049799.C328A1C00088@mwinf3007.me.freeserve.com +Subject: Re: SELECT LIMIT 1 VIEW Performance Issue +From: Simon Riggs +To: K C Lau +Cc: pgsql-performance@postgresql.org +In-Reply-To: <6.2.1.2.0.20050922102035.07bcf2e0@localhost> +References: <6.2.1.2.0.20050615100524.04f9d6a8@localhost> + <6.2.1.2.0.20050922102035.07bcf2e0@localhost> +Content-Type: text/plain +Organization: 2nd Quadrant +Date: Thu, 22 Sep 2005 09:40:56 +0100 +Message-Id: <1127378456.4145.76.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-3) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.052 required=5 tests=[AWL=0.002, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/235 +X-Sequence-Number: 14543 + +On Thu, 2005-09-22 at 12:21 +0800, K C Lau wrote: + +> Investigating further on this problem I brought up in June, the following +> query with pg 8.0.3 on Windows scans all 1743 data records for a player: +> +> esdt=> explain analyze select PlayerID,AtDate from Player a +> where PlayerID='22220' and AtDate = (select b.AtDate from Player b +> where b.PlayerID = a.PlayerID order by b.PlayerID desc, b.AtDate desc +> LIMIT 1); +> + +> Total runtime: 51.133 ms +> +> Using a static value in the subquery produces the desired result below, but +> since we use views for our queries (see last part of this email), we cannot +> push the static value into the subquery: +> +> esdt=> explain analyze select PlayerID,AtDate from Player a +> where PlayerID='22220' and AtDate = (select b.AtDate from Player b +> where b.PlayerID = '22220' order by b.PlayerID desc, b.AtDate desc LIMIT 1); + +> Total runtime: 0.149 ms +> +> The Player table has a primary key on PlayerID, AtDate. Is there a way to +> stop the inner-most index scan looping all 1743 data records for that +> player? Is that a bug or known issue? + +Currently the planner can't tell whether a subquery is correlated or not +until it has planned the query. So it is unable to push down the +qualification automatically in the way you have achieved manually. The +new min() optimisation doesn't yet work with GROUP BY which is what you +would use to reformulate the query that way, so no luck that way either. + +If you don't want to do this in a view, calculate the values for all +players at once and store the values in a summary table for when you +need them. + +Best Regards, Simon Riggs + + + +From pgsql-performance-owner@postgresql.org Thu Sep 22 07:42:08 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 44064D93AB + for ; + Thu, 22 Sep 2005 07:42:06 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 20093-02 + for ; + Thu, 22 Sep 2005 10:42:02 +0000 (GMT) +Received: from imsm057dat.netvigator.com (imsm057.netvigator.com + [218.102.48.210]) + by svr1.postgresql.org (Postfix) with ESMTP id 5076AD93F2 + for ; + Thu, 22 Sep 2005 07:42:02 -0300 (ADT) +Received: from n2.netvigator.com ([218.102.147.167]) + by imsm057dat.netvigator.com + (InterMail vM.6.01.05.02 201-2131-123-102-20050715) with ESMTP id + <20050922104203.XOW10762.imsm057dat.netvigator.com@n2.netvigator.com>; + Thu, 22 Sep 2005 18:42:03 +0800 +Message-Id: <6.2.1.2.0.20050922181009.02c36ca8@localhost> +X-Mailer: QUALCOMM Windows Eudora Version 6.2.1.2 +Date: Thu, 22 Sep 2005 18:40:46 +0800 +To: Simon Riggs +From: K C Lau +Subject: Re: SELECT LIMIT 1 VIEW Performance Issue +Cc: pgsql-performance@postgresql.org +In-Reply-To: <1127378456.4145.76.camel@localhost.localdomain> +References: <6.2.1.2.0.20050615100524.04f9d6a8@localhost> + <6.2.1.2.0.20050922102035.07bcf2e0@localhost> + <1127378456.4145.76.camel@localhost.localdomain> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.522 required=5 tests=[AWL=-0.370, + DNS_FROM_RFC_POST=1.376, FROM_ENDS_IN_NUMS=0.516] +X-Spam-Level: * +X-Archive-Number: 200509/236 +X-Sequence-Number: 14544 + +We use similar views as base views throughout our OLTP system to get the +latest time-based record(s). So it is quite impossible to use summary +tables etc. Are there other ways to do it? + +The subquery would pinpoint the record(s) with the composite primary key. +Both MS Sql and Oracle do not have such performance problem. So this +problem is effectively stopping us from migrating to PostgreSQL. + +Any suggestions would be most appreciated. + +Best regards, +KC. + +At 16:40 05/09/22, Simon Riggs wrote: +>On Thu, 2005-09-22 at 12:21 +0800, K C Lau wrote: +> +> > Investigating further on this problem I brought up in June, the following +> > query with pg 8.0.3 on Windows scans all 1743 data records for a player: +> > +> > esdt=> explain analyze select PlayerID,AtDate from Player a +> > where PlayerID='22220' and AtDate = (select b.AtDate from Player b +> > where b.PlayerID = a.PlayerID order by b.PlayerID desc, b.AtDate desc +> > LIMIT 1); +> > +> +> > Total runtime: 51.133 ms +> > +> > Using a static value in the subquery produces the desired result below, +> but +> > since we use views for our queries (see last part of this email), we +> cannot +> > push the static value into the subquery: +> > +> > esdt=> explain analyze select PlayerID,AtDate from Player a +> > where PlayerID='22220' and AtDate = (select b.AtDate from Player b +> > where b.PlayerID = '22220' order by b.PlayerID desc, b.AtDate desc +> LIMIT 1); +> +> > Total runtime: 0.149 ms +> > +> > The Player table has a primary key on PlayerID, AtDate. Is there a way to +> > stop the inner-most index scan looping all 1743 data records for that +> > player? Is that a bug or known issue? +> +>Currently the planner can't tell whether a subquery is correlated or not +>until it has planned the query. So it is unable to push down the +>qualification automatically in the way you have achieved manually. The +>new min() optimisation doesn't yet work with GROUP BY which is what you +>would use to reformulate the query that way, so no luck that way either. +> +>If you don't want to do this in a view, calculate the values for all +>players at once and store the values in a summary table for when you +>need them. +> +>Best Regards, Simon Riggs +> +> +> +>---------------------------(end of broadcast)--------------------------- +>TIP 6: explain analyze is your friend + + +From pgsql-performance-owner@postgresql.org Thu Sep 22 09:48:01 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id ED591DA6B2 + for ; + Thu, 22 Sep 2005 09:47:59 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 54939-02 + for ; + Thu, 22 Sep 2005 12:47:56 +0000 (GMT) +Received: from smtp1.freeserve.com (smtp1.wanadoo.co.uk [193.252.22.158]) + by svr1.postgresql.org (Postfix) with ESMTP id 552BCDA6B0 + for ; + Thu, 22 Sep 2005 09:47:56 -0300 (ADT) +Received: from me-wanadoo.net (nullmx.civet.com [127.0.0.1]) + by mwinf3016.me.freeserve.com (SMTP Server) with ESMTP id BE88CC400086; + Thu, 22 Sep 2005 14:47:58 +0200 (CEST) +Received: from 192.168.0.102 (modem-3521.llama.dialup.pol.co.uk + [217.135.189.193]) + by mwinf3016.me.freeserve.com (SMTP Server) with ESMTP id 59ECFC400082; + Thu, 22 Sep 2005 14:47:58 +0200 (CEST) +X-ME-UUID: 20050922124758368.59ECFC400082@mwinf3016.me.freeserve.com +Subject: Re: SELECT LIMIT 1 VIEW Performance Issue +From: Simon Riggs +To: K C Lau +Cc: pgsql-performance@postgresql.org +In-Reply-To: <6.2.1.2.0.20050922181009.02c36ca8@localhost> +References: <6.2.1.2.0.20050615100524.04f9d6a8@localhost> + <6.2.1.2.0.20050922102035.07bcf2e0@localhost> + <1127378456.4145.76.camel@localhost.localdomain> + <6.2.1.2.0.20050922181009.02c36ca8@localhost> +Content-Type: text/plain +Organization: 2nd Quadrant +Date: Thu, 22 Sep 2005 13:48:04 +0100 +Message-Id: <1127393284.4145.109.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-3) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.052 required=5 tests=[AWL=0.002, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/237 +X-Sequence-Number: 14545 + +On Thu, 2005-09-22 at 18:40 +0800, K C Lau wrote: +> We use similar views as base views throughout our OLTP system to get the +> latest time-based record(s). So it is quite impossible to use summary +> tables etc. Are there other ways to do it? +> +> The subquery would pinpoint the record(s) with the composite primary key. +> Both MS Sql and Oracle do not have such performance problem. So this +> problem is effectively stopping us from migrating to PostgreSQL. +> +> Any suggestions would be most appreciated. + +Even if this were fixed for 8.1, which seems unlikely, would you be able +to move to that release immediately? + +ISTM you have two choices, in priority, complexity and time/cost order +1) custom mods to your app +2) custom mods to PostgreSQL + +Maybe its possible to reconstruct your query with sub-sub-selects so +that you have a correlated query with manually pushed down clauses, +which also references a more constant base view? + +Is a 51ms query really such a problem for you? + +Best Regards, Simon Riggs + + + +From pgsql-performance-owner@postgresql.org Thu Sep 22 11:37:16 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 24A8BDA7EC + for ; + Thu, 22 Sep 2005 11:37:14 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 85637-05 + for ; + Thu, 22 Sep 2005 14:37:08 +0000 (GMT) +Received: from Herge.rcsinc.local (unknown [70.89.208.142]) + by svr1.postgresql.org (Postfix) with ESMTP id 6271ADA7E9 + for ; + Thu, 22 Sep 2005 11:37:09 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Subject: Re: SELECT LIMIT 1 VIEW Performance Issue +Date: Thu, 22 Sep 2005 10:37:08 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3417DD3FF@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] SELECT LIMIT 1 VIEW Performance Issue +Thread-Index: AcW/Lot73JGeYA6TQOCRru9yGoax8gAU42KA +From: "Merlin Moncure" +To: "K C Lau" +Cc: "Simon Riggs" , +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.039 required=5 tests=[AWL=-0.011, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/238 +X-Sequence-Number: 14546 + +> >I previously posted the following as a sequel to my SELECT DISTINCT +> >Performance Issue question. We would most appreciate any clue or +> >suggestions on how to overcome this show-stopping issue. We are using +> >8.0.3 on Windows. +> > +> >Is it a known limitation when using a view with SELECT ... LIMIT 1? +> > +> >Would the forthcoming performance enhancement with MAX help when used +> >within a view, as in: +> > +> >create or replace view VCurPlayer as select * from Player a +> >where a.AtDate =3D (select Max(b.AtDate) from Player b where = +a.PlayerID +=3D +> >b.PlayerID); + +Here is a trick I use sometimes with views, etc. This may or may not be +effective to solve your problem but it's worth a shot. Create one small +SQL function taking date, etc. and returning the values and define it +immutable. Now in-query it is treated like a constant. + +Another useful application for this feature is when you have nested +views (view 1 queries view 2) and you need to filter records based on +fields from view 2 which are not returned in view 1. Impossible?=20 + +in view 2 add clause where v2.f between f_min() and f_max(), them being +immutable functions which can grab filter criteria based on inputs or +values from a table. + +Merlin + +From pgsql-performance-owner@postgresql.org Thu Sep 22 11:40:27 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4299DDA7D0 + for ; + Thu, 22 Sep 2005 11:40:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 84291-08 + for ; + Thu, 22 Sep 2005 14:40:20 +0000 (GMT) +Received: from wmail05dat.netvigator.com (unknown [218.102.48.220]) + by svr1.postgresql.org (Postfix) with ESMTP id A6294DA7C7 + for ; + Thu, 22 Sep 2005 11:40:20 -0300 (ADT) +Received: from n2.netvigator.com ([218.102.147.167]) + by wmail05dat.netvigator.com + (InterMail vM.6.01.05.02 201-2131-123-102-20050715) with ESMTP id + <20050922144024.YHBC18019.wmail05dat.netvigator.com@n2.netvigator.com>; + Thu, 22 Sep 2005 22:40:24 +0800 +Message-Id: <6.2.1.2.0.20050922221846.02c45fb8@localhost> +X-Mailer: QUALCOMM Windows Eudora Version 6.2.1.2 +Date: Thu, 22 Sep 2005 22:39:29 +0800 +To: Simon Riggs +From: K C Lau +Subject: Re: SELECT LIMIT 1 VIEW Performance Issue +Cc: pgsql-performance@postgresql.org +In-Reply-To: <1127393284.4145.109.camel@localhost.localdomain> +References: <6.2.1.2.0.20050615100524.04f9d6a8@localhost> + <6.2.1.2.0.20050922102035.07bcf2e0@localhost> + <1127378456.4145.76.camel@localhost.localdomain> + <6.2.1.2.0.20050922181009.02c36ca8@localhost> + <1127393284.4145.109.camel@localhost.localdomain> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.525 required=5 tests=[AWL=-0.367, + DNS_FROM_RFC_POST=1.376, FROM_ENDS_IN_NUMS=0.516] +X-Spam-Level: * +X-Archive-Number: 200509/239 +X-Sequence-Number: 14547 + +At 20:48 05/09/22, Simon Riggs wrote: +>On Thu, 2005-09-22 at 18:40 +0800, K C Lau wrote: +> > We use similar views as base views throughout our OLTP system to get the +> > latest time-based record(s). So it is quite impossible to use summary +> > tables etc. Are there other ways to do it? +> > +> > The subquery would pinpoint the record(s) with the composite primary key. +> > Both MS Sql and Oracle do not have such performance problem. So this +> > problem is effectively stopping us from migrating to PostgreSQL. +> > +> > Any suggestions would be most appreciated. +> +>Even if this were fixed for 8.1, which seems unlikely, would you be able +>to move to that release immediately? + +Yes. In fact when we first developed our system a few years ago, we tested +on MS7.0, Oracle 8 and PG 7.1.1 and we did not hit that problem. When we +try again with PG 8.0, the performance becomes unbearable, but other areas +appear ok and other queries are often faster than MS Sql2k. + +>Maybe its possible to reconstruct your query with sub-sub-selects so +>that you have a correlated query with manually pushed down clauses, +>which also references a more constant base view? + +We would be most happy to try them if we have some example views or pointers. + +>Is a 51ms query really such a problem for you? + +Unfortunately yes, as our target performance is in the high hundreds of +transactions per sec. And 51 ms is already the best case for a single +select, with everything cached in memory immediately after the same select +which took 390 ms on a quiet system. + +>Best Regards, Simon Riggs + +Best regards, +KC. + + +From pgsql-performance-owner@postgresql.org Thu Sep 22 11:57:04 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BF644DA826 + for ; + Thu, 22 Sep 2005 11:57:02 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 92256-04 + for ; + Thu, 22 Sep 2005 14:56:58 +0000 (GMT) +Received: from wmail05dat.netvigator.com (unknown [218.102.48.220]) + by svr1.postgresql.org (Postfix) with ESMTP id DF68CD902F + for ; + Thu, 22 Sep 2005 11:56:59 -0300 (ADT) +Received: from n2.netvigator.com ([218.102.147.167]) + by wmail05dat.netvigator.com + (InterMail vM.6.01.05.02 201-2131-123-102-20050715) with ESMTP id + <20050922145703.YHZT18019.wmail05dat.netvigator.com@n2.netvigator.com>; + Thu, 22 Sep 2005 22:57:03 +0800 +Message-Id: <6.2.1.2.0.20050922224720.02c365f8@localhost> +X-Mailer: QUALCOMM Windows Eudora Version 6.2.1.2 +Date: Thu, 22 Sep 2005 22:56:47 +0800 +To: "Merlin Moncure" +From: K C Lau +Subject: Re: SELECT LIMIT 1 VIEW Performance Issue +Cc: +In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB3417DD3FF@Herge.rcsinc.local> +References: <6EE64EF3AB31D5448D0007DD34EEB3417DD3FF@Herge.rcsinc.local> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.528 required=5 tests=[AWL=-0.364, + DNS_FROM_RFC_POST=1.376, FROM_ENDS_IN_NUMS=0.516] +X-Spam-Level: * +X-Archive-Number: 200509/240 +X-Sequence-Number: 14548 + +At 22:37 05/09/22, Merlin Moncure wrote: + +> > >create or replace view VCurPlayer as select * from Player a +> > >where a.AtDate = (select Max(b.AtDate) from Player b where a.PlayerID= +> > >b.PlayerID); +> +>Here is a trick I use sometimes with views, etc. This may or may not be +>effective to solve your problem but it's worth a shot. Create one small +>SQL function taking date, etc. and returning the values and define it +>immutable. Now in-query it is treated like a constant. + +We don't use functions as a rule, but I would be glad to give it a try. +I would most appreciate if you could define a sample function and rewrite +the VCurPlayer view above. Both PlayerID and AtDate are varchar fields. + +>Another useful application for this feature is when you have nested +>views (view 1 queries view 2) and you need to filter records based on +>fields from view 2 which are not returned in view 1. Impossible? +> +>in view 2 add clause where v2.f between f_min() and f_max(), them being +>immutable functions which can grab filter criteria based on inputs or +>values from a table. +> +>Merlin + +Best regards, +KC. + + +From pgsql-performance-owner@postgresql.org Thu Sep 22 12:48:31 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 25181DA8E0 + for ; + Thu, 22 Sep 2005 12:41:24 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 03210-05 + for ; + Thu, 22 Sep 2005 15:41:22 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 0410CDA8D0 + for ; + Thu, 22 Sep 2005 12:41:21 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j8MFfE4a029337; + Thu, 22 Sep 2005 11:41:14 -0400 (EDT) +To: K C Lau +Cc: Simon Riggs , + pgsql-performance@postgresql.org +Subject: Re: SELECT LIMIT 1 VIEW Performance Issue +In-reply-to: <6.2.1.2.0.20050922221846.02c45fb8@localhost> +References: <6.2.1.2.0.20050615100524.04f9d6a8@localhost> + <6.2.1.2.0.20050922102035.07bcf2e0@localhost> + <1127378456.4145.76.camel@localhost.localdomain> + <6.2.1.2.0.20050922181009.02c36ca8@localhost> + <1127393284.4145.109.camel@localhost.localdomain> + <6.2.1.2.0.20050922221846.02c45fb8@localhost> +Comments: In-reply-to K C Lau + message dated "Thu, 22 Sep 2005 22:39:29 +0800" +Date: Thu, 22 Sep 2005 11:41:14 -0400 +Message-ID: <29336.1127403674@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/241 +X-Sequence-Number: 14549 + +K C Lau writes: +> At 20:48 05/09/22, Simon Riggs wrote: +>> Even if this were fixed for 8.1, which seems unlikely, would you be able +>> to move to that release immediately? + +> Yes. In fact when we first developed our system a few years ago, we tested +> on MS7.0, Oracle 8 and PG 7.1.1 and we did not hit that problem. + +It's really not credible that PG 7.1 did any better with this than +current sources do. The subplan mechanism hasn't changed materially +since about 6.5. It could be that 7.1's performance was simply so +bad across the board that you didn't notice ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Sep 22 13:16:26 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8A624DA981 + for ; + Thu, 22 Sep 2005 13:16:24 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 12572-08 + for ; + Thu, 22 Sep 2005 16:16:22 +0000 (GMT) +Received: from smtp3.freeserve.com (smtp3.wanadoo.co.uk [193.252.22.156]) + by svr1.postgresql.org (Postfix) with ESMTP id 98F1FDA9A8 + for ; + Thu, 22 Sep 2005 13:16:21 -0300 (ADT) +Received: from me-wanadoo.net (localhost [127.0.0.1]) + by mwinf3208.me.freeserve.com (SMTP Server) with ESMTP id 99D0D740008E; + Thu, 22 Sep 2005 18:16:18 +0200 (CEST) +Received: from 192.168.0.102 (modem-1130.llama.dialup.pol.co.uk + [217.135.180.106]) + by mwinf3208.me.freeserve.com (SMTP Server) with ESMTP id 2EF26740008D; + Thu, 22 Sep 2005 18:16:18 +0200 (CEST) +X-ME-UUID: 20050922161618192.2EF26740008D@mwinf3208.me.freeserve.com +Subject: Re: SELECT LIMIT 1 VIEW Performance Issue +From: Simon Riggs +To: K C Lau +Cc: pgsql-performance@postgresql.org +In-Reply-To: <6.2.1.2.0.20050922221846.02c45fb8@localhost> +References: <6.2.1.2.0.20050615100524.04f9d6a8@localhost> + <6.2.1.2.0.20050922102035.07bcf2e0@localhost> + <1127378456.4145.76.camel@localhost.localdomain> + <6.2.1.2.0.20050922181009.02c36ca8@localhost> + <1127393284.4145.109.camel@localhost.localdomain> + <6.2.1.2.0.20050922221846.02c45fb8@localhost> +Content-Type: text/plain +Organization: 2nd Quadrant +Date: Thu, 22 Sep 2005 17:16:23 +0100 +Message-Id: <1127405783.4145.113.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-3) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.052 required=5 tests=[AWL=0.002, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/242 +X-Sequence-Number: 14550 + +On Thu, 2005-09-22 at 22:39 +0800, K C Lau wrote: +> >Is a 51ms query really such a problem for you? +> +> Unfortunately yes, as our target performance is in the high hundreds of +> transactions per sec. And 51 ms is already the best case for a single +> select, with everything cached in memory immediately after the same select +> which took 390 ms on a quiet system. + +If the current value is used so often, use two tables - one with a +current view only of the row maintained using UPDATE. Different +performance issues maybe, but at least not correlated subquery ones. + +Best Regards, Simon Riggs + + + +From pgsql-performance-owner@postgresql.org Thu Sep 22 13:17:43 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2D1E9DA9BE + for ; + Thu, 22 Sep 2005 13:17:41 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 20677-05 + for ; + Thu, 22 Sep 2005 16:17:37 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id EFFE0DA9BD + for ; + Thu, 22 Sep 2005 13:17:34 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j8MGHW5u029638; + Thu, 22 Sep 2005 12:17:32 -0400 (EDT) +To: Antoine Bajolet +Cc: pgsql-performance@postgresql.org +Subject: Re: Nested Loop trouble : Execution time increases more 1000 time + (long) +In-reply-to: <432C3A86.5010000@free.fr> +References: <432C3A86.5010000@free.fr> +Comments: In-reply-to Antoine Bajolet + message dated "Sat, 17 Sep 2005 17:47:18 +0200" +Date: Thu, 22 Sep 2005 12:17:32 -0400 +Message-ID: <29637.1127405852@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/243 +X-Sequence-Number: 14551 + +Antoine Bajolet writes: +> We are using postgresql in a search engine on an intranet handling +> throusand of documents. +> But we ave a big problem when users use more than two search key. + +I think you need to increase the statistics targets for your keywords +table --- the estimates of numbers of matching rows are much too small: + +> -> Index Scan using keyword_pattern_key on keywords +> k2 (cost=0.00..3.51 rows=1 width=4) (actual time=0.078..1.887 rows=75 +> loops=1) +> Index Cond: (((keyword)::text ~>=~ +> 'exploitation'::character varying) AND ((keyword)::text ~<~ +> 'exploitatioo'::character varying)) +> Filter: ((keyword)::text ~~ 'exploitation%'::text) + +A factor-of-75 error is quite likely to mislead the planner into +choosing a bad join plan. + +BTW, have you looked into using a real full-text-search engine (eg, +tsearch2) instead of rolling your own like this? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Sep 22 14:13:03 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id ECFD2DAA11 + for ; + Thu, 22 Sep 2005 14:12:54 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 66697-06 + for ; + Thu, 22 Sep 2005 17:12:52 +0000 (GMT) +Received: from pentium2.antoine (m119.net81-67-244.noos.fr [81.67.244.119]) + by svr1.postgresql.org (Postfix) with ESMTP id 20A22DAA51 + for ; + Thu, 22 Sep 2005 14:12:50 -0300 (ADT) +Received: from [192.168.1.11] (pentium4.antoine [192.168.1.11]) + by pentium2.antoine (Postfix) with ESMTP + id 0C3D8C7A49; Thu, 22 Sep 2005 19:12:37 +0200 (CEST) +Message-ID: <4332E604.9020709@free.fr> +Date: Thu, 22 Sep 2005 19:12:36 +0200 +From: Antoine Bajolet +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; fr-FR; + rv:1.7.11) Gecko/20050728 +X-Accept-Language: fr, en, en-us +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Cc: Tom Lane +Subject: Re: Nested Loop trouble : Execution time increases more +References: <432C3A86.5010000@free.fr> <29637.1127405852@sss.pgh.pa.us> +In-Reply-To: <29637.1127405852@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.394 required=5 tests=[AWL=-0.448, + FORGED_RCVD_HELO=0.05, RCVD_IN_NJABL_DUL=1.655, RCVD_IN_SORBS_DUL=0.137] +X-Spam-Level: * +X-Archive-Number: 200509/244 +X-Sequence-Number: 14552 + +Hello, + +Tom Lane a �crit : + +>Antoine Bajolet writes: +> +> +>>We are using postgresql in a search engine on an intranet handling +>>throusand of documents. +>>But we ave a big problem when users use more than two search key. +>> +>> +> +>I think you need to increase the statistics targets for your keywords +>table --- the estimates of numbers of matching rows are much too small: +> +> +What value you think i could put into a ALTER TABLE SET STATISTICS +statment ? + +Also, the solution given by Simon Riggs works well. + + +Recode your SQL with an IN subselect that retrieves all possible +keywords before it accesses the larger table. + + +But i will try the old ones increasing the statistics parameter and compare performance. + + +> +> +>> -> Index Scan using keyword_pattern_key on keywords +>>k2 (cost=0.00..3.51 rows=1 width=4) (actual time=0.078..1.887 rows=75 +>>loops=1) +>> Index Cond: (((keyword)::text ~>=~ +>>'exploitation'::character varying) AND ((keyword)::text ~<~ +>>'exploitatioo'::character varying)) +>> Filter: ((keyword)::text ~~ 'exploitation%'::text) +>> +>> +> +>A factor-of-75 error is quite likely to mislead the planner into +>choosing a bad join plan. +> +>BTW, have you looked into using a real full-text-search engine (eg, +>tsearch2) instead of rolling your own like this? +> +> +It seems a quite good contrib, but... +The first version of this search engine was developped in 2000... +tsearch2 nor tsearch existed at this time. +Also, there are some developpement works around this search engine +(pertinence algorithm, filtering with users rights, ponderating keywords +with specific rules to each type of document, etc.) and adapting all to +work in the similar way with tsearch2 seems to be a bit heavy. +At the end, each document indexed are quite big and the choosen method +reduces disk storage : 1 Go of text content traduces to ~100 Mo of table +space. + +Best Regards, +Antoine Bajolet + + + +From pgsql-performance-owner@postgresql.org Thu Sep 22 14:53:12 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3AEDEDAAAB + for ; + Thu, 22 Sep 2005 14:53:10 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 86496-08 + for ; + Thu, 22 Sep 2005 17:53:07 +0000 (GMT) +Received: from pentium2.antoine (m119.net81-67-244.noos.fr [81.67.244.119]) + by svr1.postgresql.org (Postfix) with ESMTP id 9B27FDAAC1 + for ; + Thu, 22 Sep 2005 14:53:06 -0300 (ADT) +Received: from [192.168.1.11] (pentium4.antoine [192.168.1.11]) + by pentium2.antoine (Postfix) with ESMTP id 50B34C7A49 + for ; + Thu, 22 Sep 2005 19:52:54 +0200 (CEST) +Message-ID: <4332EF76.1060101@free.fr> +Date: Thu, 22 Sep 2005 19:52:54 +0200 +From: Antoine Bajolet +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; fr-FR; + rv:1.7.11) Gecko/20050728 +X-Accept-Language: fr, en, en-us +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Nested Loop trouble : Execution time increases more +References: <432C3A86.5010000@free.fr> <29637.1127405852@sss.pgh.pa.us> + <4332E604.9020709@free.fr> +In-Reply-To: <4332E604.9020709@free.fr> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.394 required=5 tests=[AWL=-0.448, + FORGED_RCVD_HELO=0.05, RCVD_IN_NJABL_DUL=1.655, RCVD_IN_SORBS_DUL=0.137] +X-Spam-Level: * +X-Archive-Number: 200509/245 +X-Sequence-Number: 14553 + +Re, + +With modifing parameters like this : + +ALTER TABLE keywords ALTER keyword SET STATISTICS 100; +ALTER TABLE keywords ALTER k_id SET STATISTICS 100; +ALTER TABLE engine ALTER k_id SET STATISTICS 100; +ALTER TABLE engine ALTER f_id SET STATISTICS 100; + +vacuuming both tables +and rewriting the queries using sub-selects : + +select count (distinct f.f_id) as results +FROM +fiches f +INNER JOIN (SELECT distinct f_id FROM keywords,engine WHERE engine.k_id += keywords.k_id AND keyword like 'exploitation%') as e1 USING(f_id) +INNER JOIN (SELECT distinct f_id FROM keywords,engine WHERE engine.k_id += keywords.k_id AND keyword like 'maintenance%') as e2 USING(f_id) +INNER JOIN (SELECT distinct f_id FROM keywords,engine WHERE engine.k_id += keywords.k_id AND keyword like 'numerique%') as e3 USING(f_id) + +The query time is less than 600 ms, and increases only a little adding +more keywords. + +Thanks to Tom Lane and Simon Riggs. + +Best regards, +Antoine Bajolet + +Antoine Bajolet a �crit : + +> Hello, +> +> Tom Lane a �crit : +> +>> Antoine Bajolet writes: +>> +>> +>>> We are using postgresql in a search engine on an intranet handling +>>> throusand of documents. +>>> But we ave a big problem when users use more than two search key. +>>> +>> +>> +>> I think you need to increase the statistics targets for your keywords +>> table --- the estimates of numbers of matching rows are much too small: +>> +>> +> What value you think i could put into a ALTER TABLE SET STATISTICS +> statment ? +> +> Also, the solution given by Simon Riggs works well. +> +> +> Recode your SQL with an IN subselect that retrieves all possible +> keywords before it accesses the larger table. +> +> +> But i will try the old ones increasing the statistics parameter and +> compare performance. +> + + +From pgsql-performance-owner@postgresql.org Thu Sep 22 15:07:46 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5702DDAAEC + for ; + Thu, 22 Sep 2005 15:07:45 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 12561-05 + for ; + Thu, 22 Sep 2005 18:07:41 +0000 (GMT) +Received: from Herge.rcsinc.local (unknown [70.89.208.142]) + by svr1.postgresql.org (Postfix) with ESMTP id 6EEF3DA864 + for ; + Thu, 22 Sep 2005 15:07:40 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Subject: Re: SELECT LIMIT 1 VIEW Performance Issue +Date: Thu, 22 Sep 2005 14:07:38 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3417DD406@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] SELECT LIMIT 1 VIEW Performance Issue +Thread-Index: AcW/heZ3xEvsoqiJS7SWf7oV8j849wAFZtlg +From: "Merlin Moncure" +To: "K C Lau" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.039 required=5 tests=[AWL=-0.011, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/246 +X-Sequence-Number: 14554 + +> >Here is a trick I use sometimes with views, etc. This may or may not +be +> >effective to solve your problem but it's worth a shot. Create one +small +> >SQL function taking date, etc. and returning the values and define it +> >immutable. Now in-query it is treated like a constant. +>=20 +> We don't use functions as a rule, but I would be glad to give it a +try. +> I would most appreciate if you could define a sample function and +rewrite +> the VCurPlayer view above. Both PlayerID and AtDate are varchar +fields. + +> esdt=3D> explain analyze select PlayerID,AtDate from Player a +> where PlayerID=3D'22220' and AtDate =3D (select b.AtDate from Player = +b +> where b.PlayerID =3D '22220' order by b.PlayerID desc, b.AtDate desc +LIMIT 1 +try: + +create function player_max_at_date (varchar) returns date as=20 +$$ + select atdate from player where playerid =3D $1 order by playerid +desc, AtDate desc limit 1; +$$ language sql immutable; + +create view v as select playerid, player_max_at_date(playerid) from +player; +select * from v where playerid =3D 'x'; --etc + +note: this function is not really immutable. try with both 'immutable' +and 'stable' if performance is same, do stable. + +You're welcome in advance, ;) +Merlin + + + +From pgsql-performance-owner@postgresql.org Thu Sep 22 15:20:12 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E09E1DAB16 + for ; + Thu, 22 Sep 2005 15:20:09 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 11768-08 + for ; + Thu, 22 Sep 2005 18:20:06 +0000 (GMT) +Received: from gwmta.wicourts.gov (gwmta.wicourts.gov [165.219.244.91]) + by svr1.postgresql.org (Postfix) with ESMTP id B337DDAB2B + for ; + Thu, 22 Sep 2005 15:20:05 -0300 (ADT) +Received: from Courts-MTA by gwmta.wicourts.gov + with Novell_GroupWise; Thu, 22 Sep 2005 13:20:03 -0500 +Message-Id: +X-Mailer: Novell GroupWise Internet Agent 6.5.4 +Date: Thu, 22 Sep 2005 13:19:56 -0500 +From: "Kevin Grittner" +To: , +Subject: Re: SELECT LIMIT 1 VIEW Performance Issue +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.004 required=5 tests=[AWL=0.004] +X-Spam-Level: +X-Archive-Number: 200509/247 +X-Sequence-Number: 14555 + +Have you tried the "best choice" pattern -- where you select the set of +candidate rows and then exclude those for which a better choice +exists within the set? I often get better results with this pattern than +with the alternatives. Transmuting your query to use this patter gives: +=20 +select PlayerID,AtDate from Player a where PlayerID=3D'22220' + and not exists + (select * from Player b + where b.PlayerID =3D a.PlayerID and b.AtDate > a.AtDate); +=20 +>>> K C Lau 09/21/05 11:21 PM >>> + +select PlayerID,AtDate from Player a + where PlayerID=3D'22220' and AtDate =3D (select b.AtDate from Player b + where b.PlayerID =3D a.PlayerID order by b.PlayerID desc, b.AtDate = +desc=20 +LIMIT 1); + + +From pgsql-performance-owner@postgresql.org Thu Sep 22 15:54:15 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DED73DAA63 + for ; + Thu, 22 Sep 2005 15:54:13 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 46347-05 + for ; + Thu, 22 Sep 2005 18:54:11 +0000 (GMT) +Received: from ecmailer.ecmarket.com (ecmailer.ecmarket.com [216.187.109.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9F117DAA5F + for ; + Thu, 22 Sep 2005 15:54:10 -0300 (ADT) +Received: from hummer.enterprise.ecmarket.com (hummer.enterprise.ecmarket.com + [10.0.7.2]) + by ecmailer.ecmarket.com (Postfix) with ESMTP id C27EDB81B8 + for ; + Thu, 22 Sep 2005 11:54:11 -0700 (PDT) +Received: from gurpreet2 (gaulakh2.devel.ecmarket.com [10.0.5.33]) + by hummer.enterprise.ecmarket.com (Postfix) with SMTP id 5999012B236 + for ; + Thu, 22 Sep 2005 11:54:10 -0700 (PDT) +From: "Gurpreet Aulakh" +To: +Subject: Re: Query slower on 8.0.3 (Windows) vs 7.3 (cygwin) +Date: Thu, 22 Sep 2005 11:54:11 -0700 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) +Importance: Normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506 +In-Reply-To: <24008.1127358777@sss.pgh.pa.us> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/248 +X-Sequence-Number: 14556 + +Hi, + +Here is the information that you requested. + +The sub query that I am using is + +EXPLAIN ANALYZE SELECT doc.doc_documentid FROM document AS doc + LEFT JOIN document as root + ON doc.doc_internalRootXref = root.doc_documentId + LEFT JOIN folder_document ON doc.doc_documentid = +folder_document.doc_documentId +LIMIT 500 OFFSET 0 + + +The column doc_documentid is character varying(48) on both tables (document, +folder_document). +The column doc_internalRootXref is also character varying(48) +doc_documentid and doc_internalRootXref are UUIDs that is 36 chars long. + +The document table has 58 columns. + 31 columns are varchar ranging from size 8 to 80 + 7 booleans + 4 numeric(12,2) + 8 timestamp with time zone + 1 integer + 1 bigint + 5 text + +The folder_documen table has 6 columns + 4 varchar (2 of length 16 2 of length 48) + +The following indexes are on the document table + pk_document primary key btree (doc_documentid), + document_pk unique btree (doc_documentid), + doc_deliverydate_index btree (doc_deliverydate), + doc_externalxref_index btree (doc_externalxref), + doc_internalparentomxref_index btree (doc_internalparentomxref), + doc_internalrootxref_index btree (doc_internalrootxref) +The following indexes are on the folder_document table + pk_folder_document primary key btree (doc_documentid) + fk_folder_document1 FOREIGN KEY (fld_folderid) REFERENCES +folder(fld_folderid) + ON UPDATE RESTRICT ON DELETE CASCADE, + fk_folder_document2 FOREIGN KEY (doc_documentid) REFERENCES +document(doc_documentid) + ON UPDATE RESTRICT ON DELETE CASCADE + +After reading your hint about locale settings, I reinstalled postgres and +made sure the locale was set +to C and that the encoding was SQL_ASCII. (these are the settings on the +cygwin installation). + +I still get the same results in the last post. + + +-----Original Message----- +From: Tom Lane [mailto:tgl@sss.pgh.pa.us] +Sent: September 21, 2005 8:13 PM +To: Gurpreet Aulakh +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Query slower on 8.0.3 (Windows) vs 7.3 (cygwin) + + +"Gurpreet Aulakh" writes: +> What is really interesting is the time it takes for the Hash to occur. For +> the first hash, on the 7.3 it takes only 12ms while on the 8.0 it takes +> 47ms. + +You haven't told us a thing about the column datatypes involved (much +less what the query actually is) ... but I wonder if this is a textual +datatype and the 8.0 installation is using a non-C locale where the 7.3 +installation is using C locale. That could account for a considerable +slowdown in text comparison speeds. + + regards, tom lane + + + + +From pgsql-performance-owner@postgresql.org Thu Sep 22 18:20:14 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1AE79D807E + for ; + Thu, 22 Sep 2005 18:20:11 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 14804-07 + for ; + Thu, 22 Sep 2005 21:20:04 +0000 (GMT) +Received: from BAYC1-PASMTP01.BAYC1.HOTMAIL.COM + (bayc1-pasmtp01.bayc1.hotmail.com [65.54.191.161]) + by svr1.postgresql.org (Postfix) with ESMTP id 92029D7C4A + for ; + Thu, 22 Sep 2005 18:20:03 -0300 (ADT) +Message-ID: +X-Originating-IP: [70.50.100.93] +X-Originating-Email: [pelletier_32@sympatico.ca] +Received: from JP ([70.50.100.93]) by BAYC1-PASMTP01.BAYC1.HOTMAIL.COM over + TLS secured channel with Microsoft SMTPSVC(6.0.3790.1830); + Thu, 22 Sep 2005 14:19:32 -0700 +Message-ID: <004201c5bfbb$6745bba0$6501a8c0@JP> +From: "Jean-Pierre Pelletier" +To: +Subject: Queries 15 times slower on 8.1 beta 2 than on 8.0 +Date: Thu, 22 Sep 2005 17:20:04 -0400 +MIME-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="iso-8859-1"; + reply-type=original +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2900.2670 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670 +X-OriginalArrivalTime: 22 Sep 2005 21:19:32.0145 (UTC) + FILETIME=[52F42A10:01C5BFBB] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.516 required=5 tests=[FROM_ENDS_IN_NUMS=0.516, + MSGID_FROM_MTA_HEADER=0] +X-Spam-Level: +X-Archive-Number: 200509/249 +X-Sequence-Number: 14557 + +Hi, + +I've got many queries running much slower on 8.1 beta2 than on 8.0.1 +Here is a simplified one that takes 484 ms on 8.1 and 32 ms on 8.0.1. + +select + 0 +from + Content C + + left outer join Supplier S + on C.SupplierId = S.SupplierId + + left outer join Price P + on C.PriceId = P.PriceId; + +Any ideas why it's slower? + +Thanks +Jean-Pierre Pelletier +e-djuster + +====================================================== + +create table Price ( + PriceId INTEGER NOT NULL DEFAULT NEXTVAL('PriceId'), + ItemId INTEGER NOT NULL, + SupplierId INTEGER NOT NULL, + LocationId SMALLINT NULL, + FromDate DATE NOT NULL DEFAULT CURRENT_DATE, + UnitValue DECIMAL NOT NULL, + InsertedByPersonId INTEGER NOT NULL, + LastUpdatedByPersonId INTEGER NULL, + InsertTimestamp TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP, + LastUpdateTimeStamp TIMESTAMP(0) NULL +); + +alter table price add primary key (priceid); + +create table Supplier ( + SupplierId INTEGER NOT NULL DEFAULT NEXTVAL('SupplierId'), + SupplierDescription VARCHAR(50) NOT NULL, + InsertTimestamp TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP, + ApprovalDate DATE NULL +); + +alter table supplier add primary key (supplierid); + +-- I've only put one row in table Content because it was sufficient to +produce +-- the slowdown + +create table content (contentid integer not null, supplierid integer, +priceid integer); +insert into content VALUES (148325, 12699, 388026); + +vacuum analyze content; -- 1 row +vacuum analyze price; -- 581475 rows +vacuum analyze supplier; -- 10139 rows + +====================================================== +Here are the query plans: + +On "PostgreSQL 8.1beta2 on i686-pc-mingw32, compiled by GCC gcc.exe (GCC) +3.4.2 (mingw-special)" + +explain select 0 from Content C LEFT OUTER JOIN Supplier S ON +C.SupplierId = S.SupplierId LEFT OUTER JOIN Price P ON C.PriceId = +P.PriceId; + QUERY PLAN +-------------------------------------------------------------------------------------------- + Nested Loop Left Join (cost=0.00..18591.77 rows=1 width=0) + Join Filter: ("outer".priceid = "inner".priceid) + -> Nested Loop Left Join (cost=0.00..5.59 rows=1 width=4) + -> Seq Scan on content c (cost=0.00..1.01 rows=1 width=8) + -> Index Scan using "Supplier Id" on supplier s (cost=0.00..4.56 +rows=1 width=4) + Index Cond: ("outer".supplierid = s.supplierid) + -> Seq Scan on price p (cost=0.00..11317.75 rows=581475 width=4) + + +"PostgreSQL 8.0.1 on i686-pc-mingw32, compiled by GCC gcc.exe (GCC) 3.4.2 +(mingw-special)" + +explain select 0 from Content C LEFT OUTER JOIN Supplier S ON +C.SupplierId = S.SupplierId LEFT OUTER JOIN Price P ON C.PriceId = +P.PriceId; + QUERY PLAN +-------------------------------------------------------------------------------------------- + Nested Loop Left Join (cost=0.00..11.08 rows=1 width=0) + -> Nested Loop Left Join (cost=0.00..5.53 rows=1 width=4) + -> Seq Scan on content c (cost=0.00..1.01 rows=1 width=8) + -> Index Scan using "Supplier Id" on supplier s (cost=0.00..4.51 +rows=1 width=4) + Index Cond: ("outer".supplierid = s.supplierid) + -> Index Scan using price_pkey on price p (cost=0.00..5.53 rows=1 +width=4) + Index Cond: ("outer".priceid = p.priceid) + + +From pgsql-performance-owner@postgresql.org Thu Sep 22 18:32:38 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 26C28D8F9D + for ; + Thu, 22 Sep 2005 18:32:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 20496-05 + for ; + Thu, 22 Sep 2005 21:32:28 +0000 (GMT) +Received: from tetra.ehpg.net (tetra2.ehpg.net [65.19.161.8]) + by svr1.postgresql.org (Postfix) with ESMTP id 548DFD8E5D + for ; + Thu, 22 Sep 2005 18:32:24 -0300 (ADT) +Received: from dsl081-087-203.lax1.dsl.speakeasy.net ([64.81.87.203]) + by tetra.ehpg.net with esmtpa (Exim 4.50) + id 1EIYg2-0001HY-KW; Thu, 22 Sep 2005 14:32:22 -0700 +In-Reply-To: +References: +Mime-Version: 1.0 (Apple Message framework v734) +X-Priority: 3 +Content-Type: multipart/alternative; boundary=Apple-Mail-15-941169757 +Message-Id: +Cc: +From: "Gavin M. Roy" +Subject: Re: Queries 15 times slower on 8.1 beta 2 than on 8.0 +Date: Thu, 22 Sep 2005 14:32:21 -0700 +To: "Jean-Pierre Pelletier" +X-Mailer: Apple Mail (2.734) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.014 required=5 tests=[AWL=-0.014, HTML_60_70=0.027, + HTML_MESSAGE=0.001] +X-Spam-Level: +X-Archive-Number: 200509/250 +X-Sequence-Number: 14558 + + +--Apple-Mail-15-941169757 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset=US-ASCII; + delsp=yes; + format=flowed + +What stood out to me the most was: + +On Sep 22, 2005, at 2:20 PM, Jean-Pierre Pelletier wrote: + +> -> Seq Scan on price p (cost=0.00..11317.75 rows=581475 width=4) + +a) is the index there, b) have you analyzed, c) perhaps the planners +have different default values for when to use an index vrs a +seqscan... if you turn off seqscan, are the timings similar? + +Gavin M. Roy +800 Pound Gorilla +gmr@ehpg.net + + + +--Apple-Mail-15-941169757 +Content-Transfer-Encoding: quoted-printable +Content-Type: text/html; + charset=ISO-8859-1 + +What stood out to me the most = +was:

On Sep 22, 2005, at 2:20 PM, Jean-Pierre = +Pelletier wrote:

=A0 ->=A0 Seq Scan on price p=A0 (cost=3D0.00..11317.75 = +rows=3D581475 width=3D4)


a) is = +the index there, b) have you analyzed, c) perhaps the planners have = +different default values for when to use an index vrs a seqscan...=A0 if = +you turn off seqscan, are the timings similar?

Gavin = +M. Roy
800 Pound Gorilla


= + +--Apple-Mail-15-941169757-- + +From pgsql-performance-owner@postgresql.org Thu Sep 22 18:38:58 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 64507D79B6 + for ; + Thu, 22 Sep 2005 18:38:49 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 24668-03 + for ; + Thu, 22 Sep 2005 21:38:44 +0000 (GMT) +Received: from BAYC1-PASMTP04.bayc1.hotmail.com + (bayc1-pasmtp04.bayc1.hotmail.com [65.54.191.164]) + by svr1.postgresql.org (Postfix) with ESMTP id DD566D6FDB + for ; + Thu, 22 Sep 2005 18:38:37 -0300 (ADT) +Message-ID: +X-Originating-IP: [70.50.100.93] +X-Originating-Email: [pelletier_32@sympatico.ca] +Received: from JP ([70.50.100.93]) by BAYC1-PASMTP04.bayc1.hotmail.com over + TLS secured channel with Microsoft SMTPSVC(6.0.3790.1830); + Thu, 22 Sep 2005 14:38:07 -0700 +Message-ID: <007b01c5bfbe$00140290$6501a8c0@JP> +From: "Jean-Pierre Pelletier" +To: "Gavin M. Roy" +Cc: +References: + +Subject: Re: Queries 15 times slower on 8.1 beta 2 than on 8.0 +Date: Thu, 22 Sep 2005 17:38:40 -0400 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0076_01C5BF9C.781FF1D0" +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2900.2670 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670 +X-OriginalArrivalTime: 22 Sep 2005 21:38:07.0790 (UTC) + FILETIME=[EBEE14E0:01C5BFBD] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.53 required=5 tests=[AWL=-0.014, + FROM_ENDS_IN_NUMS=0.516, HTML_60_70=0.027, HTML_MESSAGE=0.001, + MSGID_FROM_MTA_HEADER=0] +X-Spam-Level: +X-Archive-Number: 200509/251 +X-Sequence-Number: 14559 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0076_01C5BF9C.781FF1D0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +All indexes are there, and I've analyzed the three tables. + +I turned off seq scan, the query plans became identical but the = +performance +was not better. + +----- Original Message -----=20 + From: Gavin M. Roy=20 + To: Jean-Pierre Pelletier=20 + Cc: pgsql-performance@postgresql.org=20 + Sent: Thursday, September 22, 2005 5:32 PM + Subject: Re: [PERFORM] Queries 15 times slower on 8.1 beta 2 than on = +8.0 + + + What stood out to me the most was: + + + On Sep 22, 2005, at 2:20 PM, Jean-Pierre Pelletier wrote: + + + -> Seq Scan on price p (cost=3D0.00..11317.75 rows=3D581475 = +width=3D4) + + + + a) is the index there, b) have you analyzed, c) perhaps the planners = +have different default values for when to use an index vrs a seqscan... = +if you turn off seqscan, are the timings similar? + + + Gavin M. Roy + 800 Pound Gorilla + gmr@ehpg.net + + + + +------=_NextPart_000_0076_01C5BF9C.781FF1D0 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
All indexes are there, and I've = +analyzed the three=20 +tables.
+
 
+
I turned off seq scan, the query plans = +became=20 +identical but the performance
+
was not better.
+
 
+
----- Original Message -----
+
+ From:=20 + Gavin M. Roy = + + +
Cc: pgsql-performance@postgr= +esql.org=20 +
+
Sent: Thursday, September 22, = +2005 5:32=20 + PM
+
Subject: Re: [PERFORM] Queries = +15 times=20 + slower on 8.1 beta 2 than on 8.0
+

What stood out to me the most was: +

+
+
On Sep 22, 2005, at 2:20 PM, Jean-Pierre Pelletier = +wrote:
+
+

  = +->  Seq Scan on price p  (cost=3D0.00..11317.75 = +rows=3D581475=20 + width=3D4)


+
a) is the index there, b) have you analyzed, c) perhaps the = +planners have=20 + different default values for when to use an index vrs a = +seqscan...  if=20 + you turn off seqscan, are the timings similar?

+
+
Gavin M. Roy
+
800 Pound Gorilla
+ +

+ +------=_NextPart_000_0076_01C5BF9C.781FF1D0-- + + +From pgsql-performance-owner@postgresql.org Thu Sep 22 18:48:34 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8641DD8D80 + for ; + Thu, 22 Sep 2005 18:48:32 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 24328-08 + for ; + Thu, 22 Sep 2005 21:48:28 +0000 (GMT) +Received: from sccmmhc91.asp.att.net (sccmmhc91.asp.att.net [204.127.203.211]) + by svr1.postgresql.org (Postfix) with ESMTP id 1E9B5D8D74 + for ; + Thu, 22 Sep 2005 18:48:24 -0300 (ADT) +Received: from juju.arbash-meinel.com ([12.214.18.81]) + by sccmmhc91.asp.att.net (sccmmhc91) with ESMTP + id <20050922214825m9100psmpde>; Thu, 22 Sep 2005 21:48:26 +0000 +Received: by juju.arbash-meinel.com (Postfix, from userid 505) + id 8C79D55FF0; Thu, 22 Sep 2005 16:48:25 -0500 (CDT) +Received: from [192.168.1.11] (liliana.arbash-meinel.com [192.168.1.11]) + by juju.arbash-meinel.com (Postfix) with ESMTP id E98CF55FA4; + Thu, 22 Sep 2005 16:48:22 -0500 (CDT) +Message-ID: <433326A6.8010708@arbash-meinel.com> +Date: Thu, 22 Sep 2005 16:48:22 -0500 +From: John Arbash Meinel +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050727) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Jean-Pierre Pelletier +Cc: pgsql-performance@postgresql.org +Subject: Re: Queries 15 times slower on 8.1 beta 2 than on 8.0 +References: +In-Reply-To: +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enigC8079ADE35788585F32912F2" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.045 required=5 tests=[AWL=-0.005, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/252 +X-Sequence-Number: 14560 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enigC8079ADE35788585F32912F2 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit + +Jean-Pierre Pelletier wrote: +> Hi, +> +> I've got many queries running much slower on 8.1 beta2 than on 8.0.1 +> Here is a simplified one that takes 484 ms on 8.1 and 32 ms on 8.0.1. +> +> select +> 0 +> from +> Content C +> +> left outer join Supplier S +> on C.SupplierId = S.SupplierId +> +> left outer join Price P +> on C.PriceId = P.PriceId; +> +> Any ideas why it's slower? + +You really have to post the results of "EXPLAIN ANALYZE" not just +explain. So that we can tell what the planner is expecting, versus what +really happened. + +John +=:-> + +> +> Thanks +> Jean-Pierre Pelletier +> e-djuster +> + +--------------enigC8079ADE35788585F32912F2 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.5 (GNU/Linux) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFDMyamJdeBCYSNAAMRAomXAJ9Pe/jFwz3tAH7mWpeBw3tUtPoSWQCdH3t1 +nd0YRSnI/FfkVKZoyaiz3fU= +=sJoX +-----END PGP SIGNATURE----- + +--------------enigC8079ADE35788585F32912F2-- + +From pgsql-performance-owner@postgresql.org Thu Sep 22 18:58:58 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 95C3AD90CA + for ; + Thu, 22 Sep 2005 18:58:55 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25111-09 + for ; + Thu, 22 Sep 2005 21:58:47 +0000 (GMT) +Received: from BAYC1-PASMTP02.BAYC1.HOTMAIL.COM + (bayc1-pasmtp02.bayc1.hotmail.com [65.54.191.162]) + by svr1.postgresql.org (Postfix) with ESMTP id 96E14D901E + for ; + Thu, 22 Sep 2005 18:58:47 -0300 (ADT) +Message-ID: +X-Originating-IP: [70.50.100.93] +X-Originating-Email: [pelletier_32@sympatico.ca] +Received: from JP ([70.50.100.93]) by BAYC1-PASMTP02.BAYC1.HOTMAIL.COM over + TLS secured channel with Microsoft SMTPSVC(6.0.3790.1830); + Thu, 22 Sep 2005 14:58:17 -0700 +Message-ID: <012501c5bfc0$d1122320$6501a8c0@JP> +From: "Jean-Pierre Pelletier" +To: "John Arbash Meinel" +Cc: +References: + <433326A6.8010708@arbash-meinel.com> +Subject: Re: Queries 15 times slower on 8.1 beta 2 than on 8.0 +Date: Thu, 22 Sep 2005 17:58:49 -0400 +MIME-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="iso-8859-1"; + reply-type=original +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2900.2670 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670 +X-OriginalArrivalTime: 22 Sep 2005 21:58:17.0408 (UTC) + FILETIME=[BCEB2400:01C5BFC0] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.523 required=5 tests=[AWL=0.007, + FROM_ENDS_IN_NUMS=0.516, MSGID_FROM_MTA_HEADER=0] +X-Spam-Level: +X-Archive-Number: 200509/253 +X-Sequence-Number: 14561 + +Here are the explain analyze: + +On 8.1 beta2: + +"Nested Loop Left Join (cost=0.00..18591.77 rows=1 width=0) (actual +time=1320.302..2439.066 rows=1 loops=1)" +" Join Filter: ("outer".priceid = "inner".priceid)" +" -> Nested Loop Left Join (cost=0.00..5.59 rows=1 width=4) (actual +time=0.044..0.058 rows=1 loops=1)" +" -> Seq Scan on content c (cost=0.00..1.01 rows=1 width=8) (actual +time=0.009..0.011 rows=1 loops=1)" +" -> Index Scan using "Supplier Id" on supplier s (cost=0.00..4.56 +rows=1 width=4) (actual time=0.016..0.022 rows=1 loops=1)" +" Index Cond: ("outer".supplierid = s.supplierid)" +" -> Seq Scan on price p (cost=0.00..11317.75 rows=581475 width=4) +(actual time=0.004..1143.720 rows=581475 loops=1)" +"Total runtime: 2439.211 ms" + +On 8.0.1: + +"Nested Loop Left Join (cost=0.00..11.02 rows=1 width=0) (actual +time=0.000..0.000 rows=1 loops=1)" +" -> Nested Loop Left Join (cost=0.00..5.48 rows=1 width=4) (actual +time=0.000..0.000 rows=1 loops=1)" +" -> Seq Scan on content c (cost=0.00..1.01 rows=1 width=8) (actual +time=0.000..0.000 rows=1 loops=1)" +" -> Index Scan using "Supplier Id" on supplier s (cost=0.00..4.46 +rows=1 width=4) (actual time=0.000..0.000 rows=1 loops=1)" +" Index Cond: ("outer".supplierid = s.supplierid)" +" -> Index Scan using "Price Id" on price p (cost=0.00..5.53 rows=1 +width=4) (actual time=0.000..0.000 rows=1 loops=1)" +" Index Cond: ("outer".priceid = p.priceid)" +"Total runtime: 0.000 ms" + +----- Original Message ----- +From: "John Arbash Meinel" +To: "Jean-Pierre Pelletier" +Cc: +Sent: Thursday, September 22, 2005 5:48 PM +Subject: Re: [PERFORM] Queries 15 times slower on 8.1 beta 2 than on 8.0 + + + +From pgsql-performance-owner@postgresql.org Thu Sep 22 19:10:15 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A5412D9117 + for ; + Thu, 22 Sep 2005 19:03:23 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 29126-04 + for ; + Thu, 22 Sep 2005 22:03:19 +0000 (GMT) +Received: from sccmmhc91.asp.att.net (sccmmhc91.asp.att.net [204.127.203.211]) + by svr1.postgresql.org (Postfix) with ESMTP id 96CC5D90C1 + for ; + Thu, 22 Sep 2005 19:03:16 -0300 (ADT) +Received: from juju.arbash-meinel.com ([12.214.18.81]) + by sccmmhc91.asp.att.net (sccmmhc91) with ESMTP + id <20050922220319m9100psr4se>; Thu, 22 Sep 2005 22:03:19 +0000 +Received: by juju.arbash-meinel.com (Postfix, from userid 505) + id 505CA55FF0; Thu, 22 Sep 2005 17:03:19 -0500 (CDT) +Received: from [192.168.1.11] (liliana.arbash-meinel.com [192.168.1.11]) + by juju.arbash-meinel.com (Postfix) with ESMTP id D462455FA4; + Thu, 22 Sep 2005 17:03:16 -0500 (CDT) +Message-ID: <43332A24.8000809@arbash-meinel.com> +Date: Thu, 22 Sep 2005 17:03:16 -0500 +From: John Arbash Meinel +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050727) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Jean-Pierre Pelletier +Cc: pgsql-performance@postgresql.org +Subject: Re: Queries 15 times slower on 8.1 beta 2 than on 8.0 +References: + <433326A6.8010708@arbash-meinel.com> + +In-Reply-To: +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig5B6AB798589056579FDCF7CE" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.045 required=5 tests=[AWL=-0.005, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/254 +X-Sequence-Number: 14562 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig5B6AB798589056579FDCF7CE +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit + +Jean-Pierre Pelletier wrote: +> Here are the explain analyze: + +What is the explain analyze if you use "set enable_seqscan to off"? + +Also, can you post the output of: +\d supplier +\d price +\d content + +Mostly I just want to see what the indexes are, in the case that you +don't want to show us your schema. + +John +=:-> + +--------------enig5B6AB798589056579FDCF7CE +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.5 (GNU/Linux) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFDMyokJdeBCYSNAAMRAhrEAJ49j8esl3O+garEmv6FzO0jHtipgQCgyzAs +AJJTkr9d0RCD2VMy8B1/SqQ= +=kd/z +-----END PGP SIGNATURE----- + +--------------enig5B6AB798589056579FDCF7CE-- + +From pgsql-performance-owner@postgresql.org Thu Sep 22 19:17:42 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 28E17D6EB0 + for ; + Thu, 22 Sep 2005 19:15:21 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28639-08 + for ; + Thu, 22 Sep 2005 22:15:17 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id B678DD90CA + for ; + Thu, 22 Sep 2005 19:15:18 -0300 (ADT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [64.81.245.111] (account josh@agliodbs.com HELO + temoku.sf.agliodbs.com) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 8136717; Thu, 22 Sep 2005 15:17:43 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: Queries 15 times slower on 8.1 beta 2 than on 8.0 +Date: Thu, 22 Sep 2005 15:19:05 -0700 +User-Agent: KMail/1.8 +Cc: "Jean-Pierre Pelletier" , + "John Arbash Meinel" +References: + <433326A6.8010708@arbash-meinel.com> + +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200509221519.05555.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.047 required=5 tests=[AWL=-0.003, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/255 +X-Sequence-Number: 14563 + +Jean-Pierre, + +First off, you're on Windows? + +> " -> Seq Scan on price p (cost=0.00..11317.75 rows=581475 width=4) +> (actual time=0.004..1143.720 rows=581475 loops=1)" + +Well, this is your pain point. Can we see the index scan plan on 8.1? +Given that it's *expecting* only one row, I can't understand why it's +using a seq scan ... + +> "Nested Loop Left Join (cost=0.00..11.02 rows=1 width=0) (actual +> time=0.000..0.000 rows=1 loops=1)" +> " -> Nested Loop Left Join (cost=0.00..5.48 rows=1 width=4) (actual +> time=0.000..0.000 rows=1 loops=1)" +> "Total runtime: 0.000 ms" + +Feh, this looks like the "windows does not report times" bug, which makes +it hard to compare ... + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Fri Sep 23 02:35:56 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4C0F8D922B + for ; + Thu, 22 Sep 2005 19:27:05 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37059-06 + for ; + Thu, 22 Sep 2005 22:27:00 +0000 (GMT) +Received: from el.volia.net (el.volia.net [82.144.192.38]) + by svr1.postgresql.org (Postfix) with ESMTP id 39A64D6EB0 + for ; + Thu, 22 Sep 2005 19:27:00 -0300 (ADT) +Received: from ip.85.202.198.223.dyn.pool-4.broadband.voliacable.com + ([85.202.198.223] helo=evl) + by el.volia.net with esmtp (Exim 4.43 (FreeBSD)) id 1EIZWw-0003At-6t + for pgsql-performance@postgresql.org; Fri, 23 Sep 2005 01:27:02 +0300 +Date: Fri, 23 Sep 2005 01:27:16 +0300 +From: eVl +X-Mailer: The Bat! (v3.0.1.33) Professional +Reply-To: eVl +Organization: eVl inc. +X-Priority: 3 (Normal) +Message-ID: <133614678.20050923012716@gmail.com> +To: pgsql-performance@postgresql.org +Subject: optimization downgrade perfomance? +MIME-Version: 1.0 +Content-Type: text/plain; charset=Windows-1251 +Content-Transfer-Encoding: quoted-printable +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.207 required=5 tests=[UPPERCASE_25_50=0.207] +X-Spam-Level: +X-Archive-Number: 200509/274 +X-Sequence-Number: 14582 + +Hello! + +=09Got a DB with traffic statictics stored. And a SELECT statement which sh= +ows traffic volume per days also divided by regions - local traffic and glo= +bal. + Thus SELECT statement returns about some (in about 10-20) rows paire= +d like this: + +ttype (text)| volume (int)| tdate (date) +---------------------------------------- +local | xxxxx | some-date +global | xxxxx | some-date + +=09When executing this SELECT (see SELECT.A above) it executes in about 700= + ms, but when I want wipe out all info about local traffic, with query like= + this: + SELECT * FROM ( SELECT.A ) a WHERE type =3D 'global'; +It executes about 10000 ms - more then 10 TIMES SLOWER! + + Why this could be? + + + +------------------------------------------------- +Initial Query - SELECT.A (executes about 700 ms) + +SELECT=20 + CASE is_local(aa.uaix) WHEN true THEN 'local'=20 + ELSE 'global' END AS TType,=20 + aa.cDate AS TDate, + SUM(aa.data) AS Value=20 +FROM ( + SELECT=20 + a.uaix AS uaix,=20 + cDate AS cDate,=20 + SUM(a.data) AS data=20 + FROM ( +=09 ( + SELECT toIP AS uaix,=20 + cDate AS cDate,=20 + SUM(packetSize) AS data +=09 FROM vw_stats + WHERE interface <> 'inet' + AND cdate =3D '01.09.2005' + AND fromIP << '192.168.0.0/16' + AND NOT (toIP << '192.168.0.0/16') + GROUP BY 1,2 +=09 ) + UNION=20 + ( + SELECT fromIP AS uaix,=20 + cDate AS cDate,=20 + SUM(packetSize) AS data + FROM vw_stats + WHERE interface <> 'inet' + AND cdate =3D '01.09.2005' + AND toIP << '192.168.0.0/16' + AND NOT (fromIP << '192.168.0.0/16') + GROUP BY 1,2 + ) + ) a + GROUP BY 1,2 +) aa +GROUP BY 1,2 +ORDER BY 1,2 + +----------------------------------------------------------- +Query with local info filtered (executes about 10000 ms) + +SELECT * FROM ( + +) aaa WHERE aaa.TType =3D 'global'; + + +----------------------------------------------------------- + +Running Postgresql 8.0.3 on FreeBSD 5.3 + + =20 + +--=20 +Best regards, + eVl mailto:evl.evl@gmail.com + + + +From pgsql-performance-owner@postgresql.org Thu Sep 22 19:28:33 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A20BFD7AF6 + for ; + Thu, 22 Sep 2005 19:28:29 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 36298-05 + for ; + Thu, 22 Sep 2005 22:28:25 +0000 (GMT) +Received: from BAYC1-PASMTP02.BAYC1.HOTMAIL.COM + (bayc1-pasmtp02.bayc1.hotmail.com [65.54.191.162]) + by svr1.postgresql.org (Postfix) with ESMTP id 49258D7AB7 + for ; + Thu, 22 Sep 2005 19:28:26 -0300 (ADT) +Message-ID: +X-Originating-IP: [70.50.100.93] +X-Originating-Email: [pelletier_32@sympatico.ca] +Received: from JP ([70.50.100.93]) by BAYC1-PASMTP02.BAYC1.HOTMAIL.COM over + TLS secured channel with Microsoft SMTPSVC(6.0.3790.1830); + Thu, 22 Sep 2005 15:27:56 -0700 +Message-ID: <017301c5bfc4$f5e75180$6501a8c0@JP> +From: "Jean-Pierre Pelletier" +To: "John Arbash Meinel" +Cc: +References: + <433326A6.8010708@arbash-meinel.com> + + <43332A24.8000809@arbash-meinel.com> +Subject: Re: Queries 15 times slower on 8.1 beta 2 than on 8.0 +Date: Thu, 22 Sep 2005 18:28:29 -0400 +MIME-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="iso-8859-1"; + reply-type=original +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2900.2670 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670 +X-OriginalArrivalTime: 22 Sep 2005 22:27:57.0049 (UTC) + FILETIME=[E1AACE90:01C5BFC4] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.521 required=5 tests=[AWL=0.005, + FROM_ENDS_IN_NUMS=0.516, MSGID_FROM_MTA_HEADER=0] +X-Spam-Level: +X-Archive-Number: 200509/256 +X-Sequence-Number: 14564 + +With enable-seq-scan = off, it runs in 350 ms so better than 484 ms +but still much slower than 32 ms in 8.0.1. + +============================================== + + Table "public.content" + Column | Type | Modifiers +------------+---------+----------- + contentid | integer | not null + supplierid | integer | + priceid | integer | + + Table "public.price" + Column | Type | Modifiers +-----------------------+--------------------------------+----------- + priceid | integer | not null + itemid | integer | + supplierid | integer | + locationid | smallint | + fromdate | date | + unitvalue | numeric | + insertedbypersonid | integer | + lastupdatedbypersonid | integer | + inserttimestamp | timestamp(0) without time zone | + lastupdatetimestamp | timestamp(0) without time zone | +Indexes: + "price_pkey" PRIMARY KEY, btree (priceid) + + Table "public.supplier" + Column | Type | +Modifie +rs +---------------------+--------------------------------+------------------------- +--------------------- + supplierid | integer | not null default +nextval +('SupplierId'::text) + supplierdescription | character varying(50) | not null + inserttimestamp | timestamp(0) without time zone | default now() + approvaldate | date | +Indexes: + "Supplier Id" PRIMARY KEY, btree (supplierid) + "Supplier Description" UNIQUE, btree (upper(supplierdescription::text)) + "Supplier.InsertTimestamp" btree (inserttimestamp) +Check constraints: + "Supplier Name cannot be empty" CHECK (btrim(supplierdescription::text) +<> ''::tex + +================================================================================ + + +Explan analyze with enable-seq-scan = off on 8.1 beta2 + QUERY PLAN + +-------------------------------------------------------------------------------- +------------------------------------------------------------ + Merge Left Join (cost=100000005.60..101607964.74 rows=1 width=0) (actual +time= +729.067..729.078 rows=1 loops=1) + Merge Cond: ("outer".priceid = "inner".priceid) + -> Sort (cost=100000005.60..100000005.60 rows=1 width=4) (actual +time=0.064 +..0.067 rows=1 loops=1) + Sort Key: c.priceid + -> Nested Loop Left Join (cost=100000000.00..100000005.59 rows=1 +widt +h=4) (actual time=0.038..0.049 rows=1 loops=1) + -> Seq Scan on content c (cost=100000000.00..100000001.01 +ro +ws=1 width=8) (actual time=0.008..0.011 rows=1 loops=1) + -> Index Scan using "Supplier Id" on supplier s +(cost=0.00..4.5 +6 rows=1 width=4) (actual time=0.016..0.019 rows=1 loops=1) + Index Cond: ("outer".supplierid = s.supplierid) + -> Index Scan using "Price Id" on price p (cost=0.00..1606505.44 +rows=58147 +5 width=4) (actual time=0.008..370.854 rows=164842 loops=1) + Total runtime: 729.192 ms + +----- Original Message ----- +From: "John Arbash Meinel" +To: "Jean-Pierre Pelletier" +Cc: +Sent: Thursday, September 22, 2005 6:03 PM +Subject: Re: [PERFORM] Queries 15 times slower on 8.1 beta 2 than on 8.0 + + + +From pgsql-performance-owner@postgresql.org Thu Sep 22 19:37:41 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9F618D7E26 + for ; + Thu, 22 Sep 2005 19:37:27 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 35562-10 + for ; + Thu, 22 Sep 2005 22:37:20 +0000 (GMT) +Received: from wsmailap01.firstam.com (outbound-smtp01.firstam.com + [208.246.101.197]) + by svr1.postgresql.org (Postfix) with ESMTP id E628ED7863 + for ; + Thu, 22 Sep 2005 19:37:21 -0300 (ADT) +Received: from 172.21.131.5 by wsmailap02.firstam.com with ESMTP ( + Tumbleweed MMS SMTP Relay (MMS v5.6.3)); Thu, 22 Sep 2005 15:37:14 + -0700 +X-Server-Uuid: 7F57BFB8-2F8F-44C6-8C75-DD639B93CEA6 +Received: from anammx01.ana.firstamdata.com ([192.168.173.35]) by + famarp01.firstam.com (MOS 3.5.6-GR) with SMTP id EXS69056; Thu, 22 Sep + 2005 15:37:15 -0700 (PDT) +Received: from pisgana01sxch21.ana.firstamdata.com (Not + Verified[192.168.173.71]) by mailgateway.firstam.com (post.office MTA + v5.0 0924 ) with ESMTP id ; Thu, 22 Sep 2005 15:37:14 -0700 +Received: from pisgana01sxch01.ana.firstamdata.com ([192.168.173.70]) by + pisgana01sxch21.ana.firstamdata.com with Microsoft SMTPSVC(6.0.3790.211 + ); Thu, 22 Sep 2005 15:37:15 -0700 +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Subject: Re: Queries 15 times slower on 8.1 beta 2 than on 8.0 +Date: Thu, 22 Sep 2005 15:37:14 -0700 +Message-ID: + +Thread-Topic: [PERFORM] Queries 15 times slower on 8.1 beta 2 than on + 8.0 +Thread-Index: AcW/xZdg0UhcXYJJR6ywPbpojxENQQAAFzEg +From: "Tomeh, Husam" +To: pgsql-performance@postgresql.org +X-OriginalArrivalTime: 22 Sep 2005 22:37:15.0045 (UTC) + FILETIME=[2E423D50:01C5BFC6] +X-WSS-ID: 6F2DED9022C76380-01-01 +Content-Type: text/plain; + charset=us-ascii +Content-Transfer-Encoding: quoted-printable +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.017 required=5 tests=[AWL=0.017] +X-Spam-Level: +X-Archive-Number: 200509/257 +X-Sequence-Number: 14565 + +=20 +Have tried adjusting the effective_cache_size so that you don't the +planner may produce a better explain plan for you and not needing to set +seqscan to off. + + +--=20 +=20Husam=20 + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Jean-Pierre +Pelletier +Sent: Thursday, September 22, 2005 3:28 PM +To: John Arbash Meinel +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Queries 15 times slower on 8.1 beta 2 than on 8.0 + +With enable-seq-scan =3D off, it runs in 350 ms so better than 484 ms +but still much slower than 32 ms in 8.0.1. + +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +=20 Table "public.content" +=20 Column | Type | Modifiers +------------+---------+----------- +=20contentid | integer | not null +=20supplierid | integer | +=20priceid | integer | + +=20 Table "public.price" +=20 Column | Type | Modifiers +-----------------------+--------------------------------+----------- +=20priceid | integer | not null +=20itemid | integer | +=20supplierid | integer | +=20locationid | smallint | +=20fromdate | date | +=20unitvalue | numeric | +=20insertedbypersonid | integer | +=20lastupdatedbypersonid | integer | +=20inserttimestamp | timestamp(0) without time zone | +=20lastupdatetimestamp | timestamp(0) without time zone | +Indexes: +=20 "price_pkey" PRIMARY KEY, btree (priceid) + +=20 Table "public.supplier" +=20 Column | Type |=20 +Modifie +rs +---------------------+--------------------------------+----------------- +-------- +--------------------- +=20supplierid | integer | not null defaul= +t + +nextval +('SupplierId'::text) +=20supplierdescription | character varying(50) | not null +=20inserttimestamp | timestamp(0) without time zone | default now() +=20approvaldate | date | +Indexes: +=20 "Supplier Id" PRIMARY KEY, btree (supplierid) +=20 "Supplier Description" UNIQUE, btree +(upper(supplierdescription::text)) +=20 "Supplier.InsertTimestamp" btree (inserttimestamp) +Check constraints: +=20 "Supplier Name cannot be empty" CHECK +(btrim(supplierdescription::text)=20 +<> ''::tex + +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +=3D=3D=3D=3D=3D=3D=3D=3D + + +Explan analyze with enable-seq-scan =3D off on 8.1 beta2 +=20 QUERY +PLAN + +------------------------------------------------------------------------ +-------- +------------------------------------------------------------ +=20Merge Left Join (cost=3D100000005.60..101607964.74 rows=3D1 width=3D0= +) +(actual=20 +time=3D +729.067..729.078 rows=3D1 loops=3D1) +=20 Merge Cond: ("outer".priceid =3D "inner".priceid) +=20 -> Sort (cost=3D100000005.60..100000005.60 rows=3D1 width=3D4) (ac= +tual=20 +time=3D0.064 +..0.067 rows=3D1 loops=3D1) +=20 Sort Key: c.priceid +=20 -> Nested Loop Left Join (cost=3D100000000.00..100000005.59 +rows=3D1=20 +widt +h=3D4) (actual time=3D0.038..0.049 rows=3D1 loops=3D1) +=20 -> Seq Scan on content c +(cost=3D100000000.00..100000001.01=20 +ro +ws=3D1 width=3D8) (actual time=3D0.008..0.011 rows=3D1 loops=3D1) +=20 -> Index Scan using "Supplier Id" on supplier s=20 +(cost=3D0.00..4.5 +6 rows=3D1 width=3D4) (actual time=3D0.016..0.019 rows=3D1 loops=3D1) +=20 Index Cond: ("outer".supplierid =3D s.supplierid) +=20 -> Index Scan using "Price Id" on price p (cost=3D0.00..1606505.44= +=20 +rows=3D58147 +5 width=3D4) (actual time=3D0.008..370.854 rows=3D164842 loops=3D1) +=20Total runtime: 729.192 ms + +----- Original Message -----=20 +From: "John Arbash Meinel" +To: "Jean-Pierre Pelletier" +Cc: +Sent: Thursday, September 22, 2005 6:03 PM +Subject: Re: [PERFORM] Queries 15 times slower on 8.1 beta 2 than on 8.0 + + + +---------------------------(end of broadcast)--------------------------- +TIP 1: if posting/reading through Usenet, please send an appropriate +=20 subscribe-nomail command to majordomo@postgresql.org so that you= +r +=20 message can get through to the mailing list cleanly + +********************************************************************** +This message contains confidential information intended only for the=20 +use of the addressee(s) named above and may contain information that=20 +is legally privileged. If you are not the addressee, or the person=20 +responsible for delivering it to the addressee, you are hereby=20 +notified that reading, disseminating, distributing or copying this=20 +message is strictly prohibited. If you have received this message by=20 +mistake, please immediately notify us by replying to the message and=20 +delete the original message immediately thereafter. + +Thank you. FADLD Tag +********************************************************************** + + +From pgsql-performance-owner@postgresql.org Thu Sep 22 19:43:41 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 827BDD6ECD + for ; + Thu, 22 Sep 2005 19:43:37 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 42046-01 + for ; + Thu, 22 Sep 2005 22:43:30 +0000 (GMT) +Received: from BAYC1-PASMTP03.bayc1.hotmail.com + (bayc1-pasmtp03.bayc1.hotmail.com [65.54.191.163]) + by svr1.postgresql.org (Postfix) with ESMTP id 69187D8B84 + for ; + Thu, 22 Sep 2005 19:43:28 -0300 (ADT) +Message-ID: +X-Originating-IP: [70.50.100.93] +X-Originating-Email: [pelletier_32@sympatico.ca] +Received: from JP ([70.50.100.93]) by BAYC1-PASMTP03.bayc1.hotmail.com over + TLS secured channel with Microsoft SMTPSVC(6.0.3790.1830); + Thu, 22 Sep 2005 15:42:58 -0700 +Message-ID: <01be01c5bfc7$0f682dd0$6501a8c0@JP> +From: "Jean-Pierre Pelletier" +To: +Subject: Fw: Queries 15 times slower on 8.1 beta 2 than on 8.0 +Date: Thu, 22 Sep 2005 18:43:31 -0400 +MIME-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="iso-8859-1"; + reply-type=response +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2900.2670 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670 +X-OriginalArrivalTime: 22 Sep 2005 22:42:58.0889 (UTC) + FILETIME=[FB34AB90:01C5BFC6] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.52 required=5 tests=[AWL=0.004, + FROM_ENDS_IN_NUMS=0.516, MSGID_FROM_MTA_HEADER=0] +X-Spam-Level: +X-Archive-Number: 200509/258 +X-Sequence-Number: 14566 + +----- Original Message ----- +From: "Jean-Pierre Pelletier" +To: +Sent: Thursday, September 22, 2005 6:37 PM +Subject: Re: [PERFORM] Queries 15 times slower on 8.1 beta 2 than on 8.0 + + +> How do I produce an "Index scan plan" ? +> +> ----- Original Message ----- +> From: "Josh Berkus" +> To: +> Cc: "Jean-Pierre Pelletier" ; "John Arbash +> Meinel" +> Sent: Thursday, September 22, 2005 6:19 PM +> Subject: Re: [PERFORM] Queries 15 times slower on 8.1 beta 2 than on 8.0 +> +> +>> Jean-Pierre, +>> +>> First off, you're on Windows? +>> +>>> " -> Seq Scan on price p (cost=0.00..11317.75 rows=581475 width=4) +>>> (actual time=0.004..1143.720 rows=581475 loops=1)" +>> +>> Well, this is your pain point. Can we see the index scan plan on 8.1? +>> Given that it's *expecting* only one row, I can't understand why it's +>> using a seq scan ... +>> +>>> "Nested Loop Left Join (cost=0.00..11.02 rows=1 width=0) (actual +>>> time=0.000..0.000 rows=1 loops=1)" +>>> " -> Nested Loop Left Join (cost=0.00..5.48 rows=1 width=4) (actual +>>> time=0.000..0.000 rows=1 loops=1)" +>>> "Total runtime: 0.000 ms" +>> +>> Feh, this looks like the "windows does not report times" bug, which makes +>> it hard to compare ... +>> +>> -- +>> --Josh +>> +>> Josh Berkus +>> Aglio Database Solutions +>> San Francisco +> + + +From pgsql-performance-owner@postgresql.org Thu Sep 22 19:54:53 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DDE55D6E69 + for ; + Thu, 22 Sep 2005 19:54:42 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 44407-01 + for ; + Thu, 22 Sep 2005 22:54:39 +0000 (GMT) +Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) + by svr1.postgresql.org (Postfix) with ESMTP id 430E6D76BA + for ; + Thu, 22 Sep 2005 19:54:39 -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 j8MMsXI2057410 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); + Thu, 22 Sep 2005 16:54:36 -0600 (MDT) + (envelope-from mfuhr@winnie.fuhr.org) +Received: from winnie.fuhr.org (localhost [127.0.0.1]) + by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j8MMsXiC025145; + Thu, 22 Sep 2005 16:54:33 -0600 (MDT) + (envelope-from mfuhr@winnie.fuhr.org) +Received: (from mfuhr@localhost) + by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j8MMsXoX025144; + Thu, 22 Sep 2005 16:54:33 -0600 (MDT) (envelope-from mfuhr) +Date: Thu, 22 Sep 2005 16:54:32 -0600 +From: Michael Fuhr +To: Josh Berkus +Cc: pgsql-performance@postgresql.org, + Jean-Pierre Pelletier , + John Arbash Meinel +Subject: Re: Queries 15 times slower on 8.1 beta 2 than on 8.0 +Message-ID: <20050922225432.GA25103@winnie.fuhr.org> +References: + <433326A6.8010708@arbash-meinel.com> + + <200509221519.05555.josh@agliodbs.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <200509221519.05555.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.005 required=5 tests=[AWL=0.005] +X-Spam-Level: +X-Archive-Number: 200509/259 +X-Sequence-Number: 14567 + +On Thu, Sep 22, 2005 at 03:19:05PM -0700, Josh Berkus wrote: +> > " -> Seq Scan on price p (cost=0.00..11317.75 rows=581475 width=4) +> > (actual time=0.004..1143.720 rows=581475 loops=1)" +> +> Well, this is your pain point. Can we see the index scan plan on 8.1? +> Given that it's *expecting* only one row, I can't understand why it's +> using a seq scan ... + +I've created a simplified, self-contained test case for this: + +CREATE TABLE price ( + priceid integer PRIMARY KEY +); + +CREATE TABLE supplier ( + supplierid integer PRIMARY KEY +); + +CREATE TABLE content ( + contentid integer PRIMARY KEY, + supplierid integer NOT NULL REFERENCES supplier, + priceid integer NOT NULL REFERENCES price +); + +INSERT INTO price (priceid) SELECT * FROM generate_series(1, 50000); +INSERT INTO supplier (supplierid) SELECT * FROM generate_series(1, 10000); +INSERT INTO content (contentid, supplierid, priceid) VALUES (1, 1, 50000); + +ANALYZE price; +ANALYZE supplier; +ANALYZE content; + +EXPLAIN ANALYZE +SELECT 0 +FROM content c +LEFT OUTER JOIN supplier s ON c.supplierid = s.supplierid +LEFT OUTER JOIN price p ON c.priceid = p.priceid; + +Here's the EXPLAIN ANALYZE from 8.0.3: + + Nested Loop Left Join (cost=0.00..7.06 rows=1 width=0) (actual time=0.180..0.232 rows=1 loops=1) + -> Nested Loop Left Join (cost=0.00..4.04 rows=1 width=4) (actual time=0.105..0.133 rows=1 loops=1) + -> Seq Scan on content c (cost=0.00..1.01 rows=1 width=8) (actual time=0.021..0.029 rows=1 loops=1) + -> Index Scan using supplier_pkey on supplier s (cost=0.00..3.01 rows=1 width=4) (actual time=0.052..0.059 rows=1 loops=1) + Index Cond: ("outer".supplierid = s.supplierid) + -> Index Scan using price_pkey on price p (cost=0.00..3.01 rows=1 width=4) (actual time=0.046..0.055 rows=1 loops=1) + Index Cond: ("outer".priceid = p.priceid) + Total runtime: 0.582 ms + +Here it is from 8.1beta2: + + Merge Right Join (cost=4.05..1054.06 rows=1 width=0) (actual time=676.863..676.895 rows=1 loops=1) + Merge Cond: ("outer".priceid = "inner".priceid) + -> Index Scan using price_pkey on price p (cost=0.00..925.00 rows=50000 width=4) (actual time=0.035..383.345 rows=50000 loops=1) + -> Sort (cost=4.05..4.05 rows=1 width=4) (actual time=0.152..0.159 rows=1 loops=1) + Sort Key: c.priceid + -> Nested Loop Left Join (cost=0.00..4.04 rows=1 width=4) (actual time=0.082..0.111 rows=1 loops=1) + -> Seq Scan on content c (cost=0.00..1.01 rows=1 width=8) (actual time=0.016..0.024 rows=1 loops=1) + -> Index Scan using supplier_pkey on supplier s (cost=0.00..3.01 rows=1 width=4) (actual time=0.039..0.047 rows=1 loops=1) + Index Cond: ("outer".supplierid = s.supplierid) + Total runtime: 677.563 ms + +If we change content's priceid then we get the same plan but faster results: + +UPDATE content SET priceid = 1; + + Merge Right Join (cost=4.05..1054.06 rows=1 width=0) (actual time=0.268..0.303 rows=1 loops=1) + Merge Cond: ("outer".priceid = "inner".priceid) + -> Index Scan using price_pkey on price p (cost=0.00..925.00 rows=50000 width=4) (actual time=0.049..0.061 rows=2 loops=1) + -> Sort (cost=4.05..4.05 rows=1 width=4) (actual time=0.187..0.192 rows=1 loops=1) + Sort Key: c.priceid + -> Nested Loop Left Join (cost=0.00..4.04 rows=1 width=4) (actual time=0.099..0.128 rows=1 loops=1) + -> Seq Scan on content c (cost=0.00..1.01 rows=1 width=8) (actual time=0.025..0.033 rows=1 loops=1) + -> Index Scan using supplier_pkey on supplier s (cost=0.00..3.01 rows=1 width=4) (actual time=0.046..0.053 rows=1 loops=1) + Index Cond: ("outer".supplierid = s.supplierid) + Total runtime: 0.703 ms + +-- +Michael Fuhr + +From pgsql-performance-owner@postgresql.org Thu Sep 22 20:08:32 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 41961D7318 + for ; + Thu, 22 Sep 2005 20:07:52 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 45703-05 + for ; + Thu, 22 Sep 2005 23:07:37 +0000 (GMT) +Received: from BAYC1-PASMTP04.bayc1.hotmail.com + (bayc1-pasmtp04.bayc1.hotmail.com [65.54.191.164]) + by svr1.postgresql.org (Postfix) with ESMTP id 4433BD7204 + for ; + Thu, 22 Sep 2005 20:07:38 -0300 (ADT) +Message-ID: +X-Originating-IP: [70.50.100.93] +X-Originating-Email: [pelletier_32@sympatico.ca] +Received: from JP ([70.50.100.93]) by BAYC1-PASMTP04.bayc1.hotmail.com over + TLS secured channel with Microsoft SMTPSVC(6.0.3790.1830); + Thu, 22 Sep 2005 16:07:09 -0700 +Message-ID: <021501c5bfca$6fe82130$6501a8c0@JP> +From: "Jean-Pierre Pelletier" +To: "Michael Fuhr" , "Josh Berkus" +Cc: , + "John Arbash Meinel" +References: + <433326A6.8010708@arbash-meinel.com> + + <200509221519.05555.josh@agliodbs.com> + <20050922225432.GA25103@winnie.fuhr.org> +Subject: Re: Queries 15 times slower on 8.1 beta 2 than on 8.0 +Date: Thu, 22 Sep 2005 19:07:41 -0400 +MIME-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="iso-8859-1"; + reply-type=original +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2900.2670 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670 +X-OriginalArrivalTime: 22 Sep 2005 23:07:09.0288 (UTC) + FILETIME=[5BB5FE80:01C5BFCA] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.519 required=5 tests=[AWL=0.003, + FROM_ENDS_IN_NUMS=0.516, MSGID_FROM_MTA_HEADER=0] +X-Spam-Level: +X-Archive-Number: 200509/260 +X-Sequence-Number: 14568 + +I don't know if it makes a difference but in my tables, +content.supplierid and content.priceid were nullable. + +----- Original Message ----- +From: "Michael Fuhr" +To: "Josh Berkus" +Cc: ; "Jean-Pierre Pelletier" +; "John Arbash Meinel" +Sent: Thursday, September 22, 2005 6:54 PM +Subject: Re: [PERFORM] Queries 15 times slower on 8.1 beta 2 than on 8.0 + + +> On Thu, Sep 22, 2005 at 03:19:05PM -0700, Josh Berkus wrote: +>> > " -> Seq Scan on price p (cost=0.00..11317.75 rows=581475 width=4) +>> > (actual time=0.004..1143.720 rows=581475 loops=1)" +>> +>> Well, this is your pain point. Can we see the index scan plan on 8.1? +>> Given that it's *expecting* only one row, I can't understand why it's +>> using a seq scan ... +> +> I've created a simplified, self-contained test case for this: +> +> CREATE TABLE price ( +> priceid integer PRIMARY KEY +> ); +> +> CREATE TABLE supplier ( +> supplierid integer PRIMARY KEY +> ); +> +> CREATE TABLE content ( +> contentid integer PRIMARY KEY, +> supplierid integer NOT NULL REFERENCES supplier, +> priceid integer NOT NULL REFERENCES price +> ); +> +> INSERT INTO price (priceid) SELECT * FROM generate_series(1, 50000); +> INSERT INTO supplier (supplierid) SELECT * FROM generate_series(1, 10000); +> INSERT INTO content (contentid, supplierid, priceid) VALUES (1, 1, 50000); +> +> ANALYZE price; +> ANALYZE supplier; +> ANALYZE content; +> +> EXPLAIN ANALYZE +> SELECT 0 +> FROM content c +> LEFT OUTER JOIN supplier s ON c.supplierid = s.supplierid +> LEFT OUTER JOIN price p ON c.priceid = p.priceid; +> +> Here's the EXPLAIN ANALYZE from 8.0.3: +> +> Nested Loop Left Join (cost=0.00..7.06 rows=1 width=0) (actual +> time=0.180..0.232 rows=1 loops=1) +> -> Nested Loop Left Join (cost=0.00..4.04 rows=1 width=4) (actual +> time=0.105..0.133 rows=1 loops=1) +> -> Seq Scan on content c (cost=0.00..1.01 rows=1 width=8) +> (actual time=0.021..0.029 rows=1 loops=1) +> -> Index Scan using supplier_pkey on supplier s (cost=0.00..3.01 +> rows=1 width=4) (actual time=0.052..0.059 rows=1 loops=1) +> Index Cond: ("outer".supplierid = s.supplierid) +> -> Index Scan using price_pkey on price p (cost=0.00..3.01 rows=1 +> width=4) (actual time=0.046..0.055 rows=1 loops=1) +> Index Cond: ("outer".priceid = p.priceid) +> Total runtime: 0.582 ms +> +> Here it is from 8.1beta2: +> +> Merge Right Join (cost=4.05..1054.06 rows=1 width=0) (actual +> time=676.863..676.895 rows=1 loops=1) +> Merge Cond: ("outer".priceid = "inner".priceid) +> -> Index Scan using price_pkey on price p (cost=0.00..925.00 +> rows=50000 width=4) (actual time=0.035..383.345 rows=50000 loops=1) +> -> Sort (cost=4.05..4.05 rows=1 width=4) (actual time=0.152..0.159 +> rows=1 loops=1) +> Sort Key: c.priceid +> -> Nested Loop Left Join (cost=0.00..4.04 rows=1 width=4) +> (actual time=0.082..0.111 rows=1 loops=1) +> -> Seq Scan on content c (cost=0.00..1.01 rows=1 width=8) +> (actual time=0.016..0.024 rows=1 loops=1) +> -> Index Scan using supplier_pkey on supplier s +> (cost=0.00..3.01 rows=1 width=4) (actual time=0.039..0.047 rows=1 loops=1) +> Index Cond: ("outer".supplierid = s.supplierid) +> Total runtime: 677.563 ms +> +> If we change content's priceid then we get the same plan but faster +> results: +> +> UPDATE content SET priceid = 1; +> +> Merge Right Join (cost=4.05..1054.06 rows=1 width=0) (actual +> time=0.268..0.303 rows=1 loops=1) +> Merge Cond: ("outer".priceid = "inner".priceid) +> -> Index Scan using price_pkey on price p (cost=0.00..925.00 +> rows=50000 width=4) (actual time=0.049..0.061 rows=2 loops=1) +> -> Sort (cost=4.05..4.05 rows=1 width=4) (actual time=0.187..0.192 +> rows=1 loops=1) +> Sort Key: c.priceid +> -> Nested Loop Left Join (cost=0.00..4.04 rows=1 width=4) +> (actual time=0.099..0.128 rows=1 loops=1) +> -> Seq Scan on content c (cost=0.00..1.01 rows=1 width=8) +> (actual time=0.025..0.033 rows=1 loops=1) +> -> Index Scan using supplier_pkey on supplier s +> (cost=0.00..3.01 rows=1 width=4) (actual time=0.046..0.053 rows=1 loops=1) +> Index Cond: ("outer".supplierid = s.supplierid) +> Total runtime: 0.703 ms +> +> -- +> Michael Fuhr + + +From pgsql-performance-owner@postgresql.org Thu Sep 22 20:10:29 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E4E39D6F4F + for ; + Thu, 22 Sep 2005 20:10:27 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 45633-09 + for ; + Thu, 22 Sep 2005 23:10:21 +0000 (GMT) +Received: from BAYC1-PASMTP04.bayc1.hotmail.com + (bayc1-pasmtp04.bayc1.hotmail.com [65.54.191.164]) + by svr1.postgresql.org (Postfix) with ESMTP id 18230D6E83 + for ; + Thu, 22 Sep 2005 20:10:22 -0300 (ADT) +Message-ID: +X-Originating-IP: [70.50.100.93] +X-Originating-Email: [pelletier_32@sympatico.ca] +Received: from JP ([70.50.100.93]) by BAYC1-PASMTP04.bayc1.hotmail.com over + TLS secured channel with Microsoft SMTPSVC(6.0.3790.1830); + Thu, 22 Sep 2005 16:09:53 -0700 +Message-ID: <022401c5bfca$d1bb9e00$6501a8c0@JP> +From: "Jean-Pierre Pelletier" +To: +Cc: +References: + <200509221519.05555.josh@agliodbs.com> + + <200509221558.44027.josh@agliodbs.com> +Subject: Re: Queries 15 times slower on 8.1 beta 2 than on 8.0 +Date: Thu, 22 Sep 2005 19:10:25 -0400 +MIME-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="iso-8859-1"; + reply-type=original +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2900.2670 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670 +X-OriginalArrivalTime: 22 Sep 2005 23:09:53.0344 (UTC) + FILETIME=[BD7EF400:01C5BFCA] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.519 required=5 tests=[AWL=0.003, + FROM_ENDS_IN_NUMS=0.516, MSGID_FROM_MTA_HEADER=0] +X-Spam-Level: +X-Archive-Number: 200509/261 +X-Sequence-Number: 14569 + +my settings are: + +effective_cache_size = 1000 +random_page_cost = 4 +work_mem = 20000 + +----- Original Message ----- +From: "Josh Berkus" +To: "Jean-Pierre Pelletier" +Sent: Thursday, September 22, 2005 6:58 PM +Subject: Re: [PERFORM] Queries 15 times slower on 8.1 beta 2 than on 8.0 + + +> Jean-Pierre, +> +>> How do I produce an "Index scan plan" ? +> +> You just did. What's your effective_cache_size set to? +> random_page_cost? work_mem? +> +> -- +> --Josh +> +> Josh Berkus +> Aglio Database Solutions +> San Francisco + +From pgsql-performance-owner@postgresql.org Thu Sep 22 20:12:29 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EB96CD71F1 + for ; + Thu, 22 Sep 2005 20:12:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 43240-08 + for ; + Thu, 22 Sep 2005 23:12:22 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id D64AAD6ECD + for ; + Thu, 22 Sep 2005 20:12:23 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j8MNCEqY016904; + Thu, 22 Sep 2005 19:12:15 -0400 (EDT) +To: Michael Fuhr +Cc: Josh Berkus , pgsql-performance@postgresql.org, + Jean-Pierre Pelletier , + John Arbash Meinel +Subject: Re: Queries 15 times slower on 8.1 beta 2 than on 8.0 +In-reply-to: <20050922225432.GA25103@winnie.fuhr.org> +References: + <433326A6.8010708@arbash-meinel.com> + + <200509221519.05555.josh@agliodbs.com> + <20050922225432.GA25103@winnie.fuhr.org> +Comments: In-reply-to Michael Fuhr + message dated "Thu, 22 Sep 2005 16:54:32 -0600" +Date: Thu, 22 Sep 2005 19:12:14 -0400 +Message-ID: <16903.1127430734@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/262 +X-Sequence-Number: 14570 + +Michael Fuhr writes: +> I've created a simplified, self-contained test case for this: + +I see the problem --- I broke best_inner_indexscan() for some cases +where the potential indexscan clause is an outer-join ON clause. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Sep 22 20:13:46 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C332FD7AB7 + for ; + Thu, 22 Sep 2005 20:12:44 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 47213-04 + for ; + Thu, 22 Sep 2005 23:12:37 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 94C75D7A16 + for ; + Thu, 22 Sep 2005 20:12:38 -0300 (ADT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [64.81.245.111] (account josh@agliodbs.com HELO + temoku.sf.agliodbs.com) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 8137005; Thu, 22 Sep 2005 16:15:04 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: "Jean-Pierre Pelletier" +Subject: Re: Queries 15 times slower on 8.1 beta 2 than on 8.0 +Date: Thu, 22 Sep 2005 16:16:25 -0700 +User-Agent: KMail/1.8 +Cc: pgsql-performance@postgresql.org +References: + <200509221558.44027.josh@agliodbs.com> + +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200509221616.25781.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.047 required=5 tests=[AWL=-0.003, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/263 +X-Sequence-Number: 14571 + +Jean-Pierre, + +> effective_cache_size = 1000 + +Try setting this to 16,384 as a test. + +> random_page_cost = 4 + +Try setting this to 2.5 as a test. + +> work_mem = 20000 + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Thu Sep 22 20:18:44 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 63539D6ECD + for ; + Thu, 22 Sep 2005 20:17:56 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 43403-08 + for ; + Thu, 22 Sep 2005 23:17:50 +0000 (GMT) +Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) + by svr1.postgresql.org (Postfix) with ESMTP id DCC8CD7115 + for ; + Thu, 22 Sep 2005 20:17:50 -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 j8MNHlgi057436 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); + Thu, 22 Sep 2005 17:17:49 -0600 (MDT) + (envelope-from mfuhr@winnie.fuhr.org) +Received: from winnie.fuhr.org (localhost [127.0.0.1]) + by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j8MNHkBp025334; + Thu, 22 Sep 2005 17:17:46 -0600 (MDT) + (envelope-from mfuhr@winnie.fuhr.org) +Received: (from mfuhr@localhost) + by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j8MNHkn1025333; + Thu, 22 Sep 2005 17:17:46 -0600 (MDT) (envelope-from mfuhr) +Date: Thu, 22 Sep 2005 17:17:46 -0600 +From: Michael Fuhr +To: Jean-Pierre Pelletier +Cc: Josh Berkus , pgsql-performance@postgresql.org, + John Arbash Meinel +Subject: Re: Queries 15 times slower on 8.1 beta 2 than on 8.0 +Message-ID: <20050922231746.GA25296@winnie.fuhr.org> +References: + <433326A6.8010708@arbash-meinel.com> + + <200509221519.05555.josh@agliodbs.com> + <20050922225432.GA25103@winnie.fuhr.org> + <021501c5bfca$6fe82130$6501a8c0@JP> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <021501c5bfca$6fe82130$6501a8c0@JP> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.005 required=5 tests=[AWL=0.005] +X-Spam-Level: +X-Archive-Number: 200509/264 +X-Sequence-Number: 14572 + +On Thu, Sep 22, 2005 at 07:07:41PM -0400, Jean-Pierre Pelletier wrote: +> I don't know if it makes a difference but in my tables, +> content.supplierid and content.priceid were nullable. + +That makes no difference in the tests I've done. + +Tom Lane says he's found the problem; I expect he'll be committing +a fix shortly. + +-- +Michael Fuhr + +From pgsql-performance-owner@postgresql.org Thu Sep 22 20:19:45 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E1718D7204 + for ; + Thu, 22 Sep 2005 20:19:10 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 49707-04 + for ; + Thu, 22 Sep 2005 23:19:05 +0000 (GMT) +Received: from wsmail05.firstam.com (unknown [208.246.100.41]) + by svr1.postgresql.org (Postfix) with ESMTP id 7C8ADD7115 + for ; + Thu, 22 Sep 2005 20:19:04 -0300 (ADT) +Received: from 172.21.131.5 by wsmailap01.firstam.com with ESMTP ( + Tumbleweed MMS SMTP Relay (MMS v5.6.3)); Thu, 22 Sep 2005 16:18:54 + -0700 +X-Server-Uuid: 2A3A6F04-3324-429D-9DE4-35238E3EA19C +Received: from anammx01.ana.firstamdata.com ([192.168.173.35]) by + famarp01.firstam.com (MOS 3.5.6-GR) with SMTP id EXS93704; Thu, 22 Sep + 2005 16:18:55 -0700 (PDT) +Received: from pisgana01sxch21.ana.firstamdata.com (Not + Verified[192.168.173.71]) by mailgateway.firstam.com (post.office MTA + v5.0 0924 ) with ESMTP id ; Thu, 22 Sep 2005 16:18:54 -0700 +Received: from pisgana01sxch01.ana.firstamdata.com ([192.168.173.70]) by + pisgana01sxch21.ana.firstamdata.com with Microsoft SMTPSVC(6.0.3790.211 + ); Thu, 22 Sep 2005 16:18:55 -0700 +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Subject: Re: Queries 15 times slower on 8.1 beta 2 than on 8.0 +Date: Thu, 22 Sep 2005 16:18:54 -0700 +Message-ID: + +Thread-Topic: [PERFORM] Queries 15 times slower on 8.1 beta 2 than on + 8.0 +Thread-Index: AcW/y0SpVapSnfRTQhyztBNslKY/jgAACT/A +From: "Tomeh, Husam" +To: pgsql-performance@postgresql.org +X-OriginalArrivalTime: 22 Sep 2005 23:18:55.0125 (UTC) + FILETIME=[006C2C50:01C5BFCC] +X-WSS-ID: 6F2DE4541KS107085-01-01 +Content-Type: text/plain; + charset=us-ascii +Content-Transfer-Encoding: quoted-printable +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.017 required=5 tests=[AWL=0.017] +X-Spam-Level: +X-Archive-Number: 200509/265 +X-Sequence-Number: 14573 + +=20 +The recommendation for effective_cache_size is about 2/3 of your +server's physical RAM (if the server is dedicated only for postgres). +This should have a significant impact on whether Postgres planner +chooses indexes over sequential scans.=20 + +--=20 +=20Husam=20 + + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Jean-Pierre +Pelletier +Sent: Thursday, September 22, 2005 4:10 PM +To: josh@agliodbs.com +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Queries 15 times slower on 8.1 beta 2 than on 8.0 + +my settings are: + +effective_cache_size =3D 1000 +random_page_cost =3D 4 +work_mem =3D 20000 + +----- Original Message -----=20 +From: "Josh Berkus" +To: "Jean-Pierre Pelletier" +Sent: Thursday, September 22, 2005 6:58 PM +Subject: Re: [PERFORM] Queries 15 times slower on 8.1 beta 2 than on 8.0 + + +> Jean-Pierre, +>=20 +>> How do I produce an "Index scan plan" ? +>=20 +> You just did. What's your effective_cache_size set to? =20 +> random_page_cost? work_mem? +>=20 +> --=20 +> --Josh +>=20 +> Josh Berkus +> Aglio Database Solutions +> San Francisco + +---------------------------(end of broadcast)--------------------------- +TIP 3: Have you checked our extensive FAQ? + +=20 http://www.postgresql.org/docs/faq + +********************************************************************** +This message contains confidential information intended only for the=20 +use of the addressee(s) named above and may contain information that=20 +is legally privileged. If you are not the addressee, or the person=20 +responsible for delivering it to the addressee, you are hereby=20 +notified that reading, disseminating, distributing or copying this=20 +message is strictly prohibited. If you have received this message by=20 +mistake, please immediately notify us by replying to the message and=20 +delete the original message immediately thereafter. + +Thank you. FADLD Tag +********************************************************************** + + +From pgsql-performance-owner@postgresql.org Thu Sep 22 20:28:41 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 14879D7BF9 + for ; + Thu, 22 Sep 2005 20:26:32 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 47858-07 + for ; + Thu, 22 Sep 2005 23:26:26 +0000 (GMT) +Received: from BAYC1-PASMTP03.bayc1.hotmail.com + (bayc1-pasmtp03.bayc1.hotmail.com [65.54.191.163]) + by svr1.postgresql.org (Postfix) with ESMTP id 4B394D7A0A + for ; + Thu, 22 Sep 2005 20:26:27 -0300 (ADT) +Message-ID: +X-Originating-IP: [70.50.100.93] +X-Originating-Email: [pelletier_32@sympatico.ca] +Received: from JP ([70.50.100.93]) by BAYC1-PASMTP03.bayc1.hotmail.com over + TLS secured channel with Microsoft SMTPSVC(6.0.3790.1830); + Thu, 22 Sep 2005 16:25:57 -0700 +Message-ID: <024b01c5bfcd$10df07a0$6501a8c0@JP> +From: "Jean-Pierre Pelletier" +To: "Michael Fuhr" +Cc: "Josh Berkus" , , + "John Arbash Meinel" +References: + <433326A6.8010708@arbash-meinel.com> + + <200509221519.05555.josh@agliodbs.com> + <20050922225432.GA25103@winnie.fuhr.org> + <021501c5bfca$6fe82130$6501a8c0@JP> + <20050922231746.GA25296@winnie.fuhr.org> +Subject: Re: Queries 15 times slower on 8.1 beta 2 than on 8.0 +Date: Thu, 22 Sep 2005 19:26:30 -0400 +MIME-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="iso-8859-1"; + reply-type=original +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2900.2670 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670 +X-OriginalArrivalTime: 22 Sep 2005 23:25:58.0163 (UTC) + FILETIME=[FC92A630:01C5BFCC] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.518 required=5 tests=[AWL=0.002, + FROM_ENDS_IN_NUMS=0.516, MSGID_FROM_MTA_HEADER=0] +X-Spam-Level: +X-Archive-Number: 200509/266 +X-Sequence-Number: 14574 + +Thanks everybody for your help, I'll be awaiting the fix. + +I've also noticed that pg_stat_activity is always empty even if +stats_start_collector = on + +----- Original Message ----- +From: "Michael Fuhr" +To: "Jean-Pierre Pelletier" +Cc: "Josh Berkus" ; ; +"John Arbash Meinel" +Sent: Thursday, September 22, 2005 7:17 PM +Subject: Re: [PERFORM] Queries 15 times slower on 8.1 beta 2 than on 8.0 + + +> On Thu, Sep 22, 2005 at 07:07:41PM -0400, Jean-Pierre Pelletier wrote: +>> I don't know if it makes a difference but in my tables, +>> content.supplierid and content.priceid were nullable. +> +> That makes no difference in the tests I've done. +> +> Tom Lane says he's found the problem; I expect he'll be committing +> a fix shortly. +> +> -- +> Michael Fuhr +> +> ---------------------------(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 + + +From pgsql-performance-owner@postgresql.org Thu Sep 22 20:31:28 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 02D7ED77E5 + for ; + Thu, 22 Sep 2005 20:31:24 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 51144-06 + for ; + Thu, 22 Sep 2005 23:31:18 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 808FED7204 + for ; + Thu, 22 Sep 2005 20:31:19 -0300 (ADT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [64.81.245.111] (account josh@agliodbs.com HELO + temoku.sf.agliodbs.com) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 8137129; Thu, 22 Sep 2005 16:33:44 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: "Jean-Pierre Pelletier" +Subject: Re: Queries 15 times slower on 8.1 beta 2 than on 8.0 +Date: Thu, 22 Sep 2005 16:35:06 -0700 +User-Agent: KMail/1.8 +Cc: "Michael Fuhr" , pgsql-performance@postgresql.org, + "John Arbash Meinel" +References: + <20050922231746.GA25296@winnie.fuhr.org> + +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200509221635.06716.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.047 required=5 tests=[AWL=-0.003, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/267 +X-Sequence-Number: 14575 + +Jean-Pierre, + +> Thanks everybody for your help, I'll be awaiting the fix. +> +> I've also noticed that pg_stat_activity is always empty even if +> stats_start_collector = on + +Yes, I believe that this is a know Windows issue. Not sure if it's fixed +in 8.1. + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Thu Sep 22 20:50:21 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DD50FD6E83 + for ; + Thu, 22 Sep 2005 20:50:16 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 54133-08 + for ; + Thu, 22 Sep 2005 23:50:08 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id F3020D7933 + for ; + Thu, 22 Sep 2005 20:50:09 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j8MNo2Lk018134; + Thu, 22 Sep 2005 19:50:02 -0400 (EDT) +To: Michael Fuhr +Cc: Jean-Pierre Pelletier , + Josh Berkus , pgsql-performance@postgresql.org, + John Arbash Meinel +Subject: Re: Queries 15 times slower on 8.1 beta 2 than on 8.0 +In-reply-to: <20050922231746.GA25296@winnie.fuhr.org> +References: + <433326A6.8010708@arbash-meinel.com> + + <200509221519.05555.josh@agliodbs.com> + <20050922225432.GA25103@winnie.fuhr.org> + <021501c5bfca$6fe82130$6501a8c0@JP> + <20050922231746.GA25296@winnie.fuhr.org> +Comments: In-reply-to Michael Fuhr + message dated "Thu, 22 Sep 2005 17:17:46 -0600" +Date: Thu, 22 Sep 2005 19:50:02 -0400 +Message-ID: <18133.1127433002@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/268 +X-Sequence-Number: 14576 + +Michael Fuhr writes: +> Tom Lane says he's found the problem; I expect he'll be committing +> a fix shortly. + +The attached patch allows it to generate the expected plan, at least +in the test case I tried. + + regards, tom lane + +*** src/backend/optimizer/path/indxpath.c.orig Sun Aug 28 18:47:20 2005 +--- src/backend/optimizer/path/indxpath.c Thu Sep 22 19:17:41 2005 +*************** +*** 955,969 **** + /* + * Examine each joinclause in the joininfo list to see if it matches any + * key of any index. If so, add the clause's other rels to the result. +- * (Note: we consider only actual participants, not extraneous rels +- * possibly mentioned in required_relids.) + */ + foreach(l, rel->joininfo) + { + RestrictInfo *joininfo = (RestrictInfo *) lfirst(l); + Relids other_rels; + +! other_rels = bms_difference(joininfo->clause_relids, rel->relids); + if (matches_any_index(joininfo, rel, other_rels)) + outer_relids = bms_join(outer_relids, other_rels); + else +--- 955,967 ---- + /* + * Examine each joinclause in the joininfo list to see if it matches any + * key of any index. If so, add the clause's other rels to the result. + */ + foreach(l, rel->joininfo) + { + RestrictInfo *joininfo = (RestrictInfo *) lfirst(l); + Relids other_rels; + +! other_rels = bms_difference(joininfo->required_relids, rel->relids); + if (matches_any_index(joininfo, rel, other_rels)) + outer_relids = bms_join(outer_relids, other_rels); + else + +From pgsql-performance-owner@postgresql.org Thu Sep 22 21:20:50 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2DBADD81D2 + for ; + Thu, 22 Sep 2005 21:20:44 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 66655-07 + for ; + Fri, 23 Sep 2005 00:20:36 +0000 (GMT) +Received: from mailout1.pacific.net.au (mailout1.pacific.net.au [61.8.0.84]) + by svr1.postgresql.org (Postfix) with ESMTP id E3835D80E4 + for ; + Thu, 22 Sep 2005 21:20:30 -0300 (ADT) +Received: from mailproxy2.pacific.net.au (mailproxy2.pacific.net.au + [61.8.0.87]) + by mailout1.pacific.net.au (8.13.4/8.13.4/Debian-3) with ESMTP id + j8N0KVA1026103; Fri, 23 Sep 2005 10:20:31 +1000 +Received: from rws-exch01.rapidweb.com.au (b0FE2.static.pacific.net.au + [202.7.84.226]) + by mailproxy2.pacific.net.au (8.13.4/8.13.4/Debian-3) with ESMTP id + j8N0KVn5008166; Fri, 23 Sep 2005 10:20:31 +1000 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C5BFD4.C4CAA56A" +Subject: FW: Deadlock Issue with PostgreSQL +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Date: Fri, 23 Sep 2005 10:21:33 +1000 +Message-ID: + <684E37D19BEFA148B453F5C4FB466B6223A4EF@rws-exch01.rapidweb.com.au> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: FW: [PERFORM] Deadlock Issue with PostgreSQL +Thread-Index: AcW/1MBuPhwwA7D0TI+EI5YJn+ggTA== +From: "Anu Kucharlapati" +To: +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.051 required=5 tests=[FORGED_RCVD_HELO=0.05, + HTML_MESSAGE=0.001] +X-Spam-Level: +X-Archive-Number: 200509/269 +X-Sequence-Number: 14577 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C5BFD4.C4CAA56A +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + +Hello Tom, + +=20 + +Thanks a lot for your quick response. Which version do you think is the +more stable one that we should upgrade to? + +=20 + +Please provide us with the Upgrade instructions/documentation to be +followed for both red hat and PostgreSQL.=20 + +=20 + +Thanks and Best Regards, + +Anu + +=20 + +=20 + +-----Original Message----- + +From: Tom Lane [mailto:tgl@sss.pgh.pa.us]=20 + +Sent: Wednesday, September 21, 2005 12:15 PM + +To: Anu Kucharlapati + +Cc: pgsql-performance@postgresql.org; Owen Blizzard + +Subject: Re: [PERFORM] Deadlock Issue with PostgreSQL=20 + +=20 + +"Anu Kucharlapati" writes: + +> Red Hat Linux release 7.3 + +> Apache 1.3.20 + +> PostgreSQL 7.1.3 + +=20 + +I'm not sure about Apache, but both the RHL and Postgres versions + +you are using are stone age --- *please* update. Red Hat stopped + +supporting that release years ago, and the PG community isn't + +supporting 7.1.* anymore either. There are too many known problems + +in 7.1.* that are unfixable without a major-version upgrade. + +=20 + + regards, tom lane + +=20 + + +------_=_NextPart_001_01C5BFD4.C4CAA56A +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + + + + +
+ +

Hello Tom,

+ +

 

+ +

Thanks a lot for your quick response. Which version do you think = +is the +more stable one that we should upgrade to?

+ +

 

+ +

Please provide us with the Upgrade instructions/documentation to = +be +followed for both red hat and PostgreSQL.

+ +

 

+ +

Thanks and Best Regards,

+ +

Anu

+ +

 

+ +

 

+ +

-----Original Message-----

+ +

From: Tom = +Lane +[mailto:tgl@sss.pgh.pa.us]

+ +

Sent: Wednesday, September 21, 2005 12:15 = +PM

+ +

To: Anu Kucharlapati

+ +

Cc: pgsql-performance@postgresql.org; Owen = +Blizzard

+ +

Subject: Re: [PERFORM] Deadlock Issue with PostgreSQL = +

+ +

 

+ +

"Anu Kucharlapati" <anuk@rapidweb.com.au> = +writes:

+ +

> Red Hat Linux release 7.3

+ +

> Apache 1.3.20

+ +

> PostgreSQL 7.1.3

+ +

 

+ +

I'm not sure about Apache, but both the RHL and Postgres = +versions

+ +

you are using are stone age --- *please* update.  Red Hat = +stopped

+ +

supporting that release years ago, and the PG community = +isn't

+ +

supporting 7.1.* anymore either.  There are too many known = +problems

+ +

in 7.1.* that are unfixable without a major-version = +upgrade.

+ +

 

+ +

           = +;       regards, tom = +lane

+ +

 

+ +
+ + + + + +------_=_NextPart_001_01C5BFD4.C4CAA56A-- + +From pgsql-performance-owner@postgresql.org Thu Sep 22 22:41:39 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E52FBD83A5 + for ; + Thu, 22 Sep 2005 22:41:36 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 89332-03 + for ; + Fri, 23 Sep 2005 01:41:31 +0000 (GMT) +Received: from BAYC1-PASMTP04.bayc1.hotmail.com + (bayc1-pasmtp04.bayc1.hotmail.com [65.54.191.164]) + by svr1.postgresql.org (Postfix) with ESMTP id 8C14FD81D2 + for ; + Thu, 22 Sep 2005 22:41:32 -0300 (ADT) +Message-ID: +X-Originating-IP: [70.50.100.93] +X-Originating-Email: [pelletier_32@sympatico.ca] +Received: from JP ([70.50.100.93]) by BAYC1-PASMTP04.bayc1.hotmail.com over + TLS secured channel with Microsoft SMTPSVC(6.0.3790.1830); + Thu, 22 Sep 2005 18:41:04 -0700 +Message-ID: <006201c5bfdf$f0c71bc0$6501a8c0@JP> +From: "Jean-Pierre Pelletier" +To: , +Cc: "John Arbash Meinel" +References: + <433326A6.8010708@arbash-meinel.com> + + <200509221519.05555.josh@agliodbs.com> +Subject: Re: Queries 15 times slower on 8.1 beta 2 than on 8.0 +Date: Thu, 22 Sep 2005 21:41:37 -0400 +MIME-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="iso-8859-1"; + reply-type=original +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2900.2670 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670 +X-OriginalArrivalTime: 23 Sep 2005 01:41:04.0559 (UTC) + FILETIME=[DC5C83F0:01C5BFDF] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.518 required=5 tests=[AWL=0.002, + FROM_ENDS_IN_NUMS=0.516, MSGID_FROM_MTA_HEADER=0] +X-Spam-Level: +X-Archive-Number: 200509/270 +X-Sequence-Number: 14578 + +Explain analyze on my 8.0.1 installation does report the time for +slower queries but for this small query it reports 0.000 ms + +----- Original Message ----- +From: "Josh Berkus" +To: +Cc: "Jean-Pierre Pelletier" ; "John Arbash +Meinel" +Sent: Thursday, September 22, 2005 6:19 PM +Subject: Re: [PERFORM] Queries 15 times slower on 8.1 beta 2 than on 8.0 + + +> Jean-Pierre, +> +> First off, you're on Windows? +> +>> " -> Seq Scan on price p (cost=0.00..11317.75 rows=581475 width=4) +>> (actual time=0.004..1143.720 rows=581475 loops=1)" +> +> Well, this is your pain point. Can we see the index scan plan on 8.1? +> Given that it's *expecting* only one row, I can't understand why it's +> using a seq scan ... +> +>> "Nested Loop Left Join (cost=0.00..11.02 rows=1 width=0) (actual +>> time=0.000..0.000 rows=1 loops=1)" +>> " -> Nested Loop Left Join (cost=0.00..5.48 rows=1 width=4) (actual +>> time=0.000..0.000 rows=1 loops=1)" +>> "Total runtime: 0.000 ms" +> +> Feh, this looks like the "windows does not report times" bug, which makes +> it hard to compare ... +> +> -- +> --Josh +> +> Josh Berkus +> Aglio Database Solutions +> San Francisco +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 3: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faq + + +From pgsql-performance-owner@postgresql.org Thu Sep 22 23:45:43 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0E096D8B2F + for ; + Thu, 22 Sep 2005 23:45:40 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 05739-05 + for ; + Fri, 23 Sep 2005 02:45:35 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 977B1D8B07 + for ; + Thu, 22 Sep 2005 23:45:36 -0300 (ADT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [64.81.245.111] (account josh@agliodbs.com HELO + temoku.sf.agliodbs.com) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 8137796; Thu, 22 Sep 2005 19:48:04 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: FW: Deadlock Issue with PostgreSQL +Date: Thu, 22 Sep 2005 19:49:18 -0700 +User-Agent: KMail/1.8 +Cc: "Anu Kucharlapati" , tgl@sss.pgh.pa.us +References: + <684E37D19BEFA148B453F5C4FB466B6223A4EF@rws-exch01.rapidweb.com.au> +In-Reply-To: + <684E37D19BEFA148B453F5C4FB466B6223A4EF@rws-exch01.rapidweb.com.au> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200509221949.19121.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.047 required=5 tests=[AWL=-0.003, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/271 +X-Sequence-Number: 14579 + +Anu, + +> Thanks a lot for your quick response. Which version do you think is the +> more stable one that we should upgrade to? + +8.0.3 + +> Please provide us with the Upgrade instructions/documentation to be +> followed for both red hat and PostgreSQL. + +See the PostgreSQL documentation for upgrade instructions. Given how old +your version is, you might need to go through an intermediate version, +like 7.3. + +Red Hat upgrades are between you and Red Hat. They sell support for a +reason ... + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Fri Sep 23 03:58:45 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 16A51D8B2F + for ; + Fri, 23 Sep 2005 03:49:42 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 73255-03 + for ; + Fri, 23 Sep 2005 06:49:36 +0000 (GMT) +Received: from obelix.askesis.nl (laudanum.demon.nl [82.161.125.16]) + by svr1.postgresql.org (Postfix) with ESMTP id 117CBD86BF + for ; + Fri, 23 Sep 2005 03:49:35 -0300 (ADT) +Received: obelix.askesis.nl 172.31.0.1 from 172.31.1.8 172.31.1.8 via HTTP + with MS-WebStorage 6.0.6249 +Received: from Panoramix by obelix.askesis.nl; 23 Sep 2005 08:49:27 +0200 +Subject: How to determine cause of performance problem? +From: Joost Kraaijeveld +To: Pgsql-Performance +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Date: Fri, 23 Sep 2005 08:49:27 +0200 +Message-Id: <1127458167.2475.105.camel@Panoramix> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.4 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.095 required=5 tests=[AWL=0.045, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/275 +X-Sequence-Number: 14583 + +Hi, + +I must convert an old table into a new table. The conversion goes at ~ +100 records per second. Given the fact that I must convert 40 million +records, it takes too much time: more hours than the 48 hour weekend I +have for the conversion;-). + +The tables are rather simple: both tables only have a primary key +constraint (of type text) and no other indexes. I only copy 3 columns. I +use Java for the conversion. For the exact code see below. + +During the conversion my processor load is almost non existant. The +harddisk throughput is ~ 6 megabyte/second max (measured with iostat). + +My platform is Debian Sarge AMD64. My hardware is a Tyan Thunder K8W +2885 motherboard, 2 Opteron 248 processors, 2 GB RAM, a SATA bootdisk +with / and swap, and a 3Ware 9500S-8 RAID-5 controller with 5 attached +SATA disks with /home and /var. /var contains *all* PostgreSQL log and +database files (default Debian installation). + +Output of hdparm -Tt /dev/sdb (sdb is the RAID opartition) + +/dev/sdb: + Timing cached reads: 1696 MB in 2.00 seconds = 846.86 MB/sec + Timing buffered disk reads: 246 MB in 3.01 seconds = 81.79 MB/sec + + +I want to determine the cause of my performance problem (if it is one). + +1. Is this a performance I can expect? +2. If not, how can I determine the cause? +3. Can I anyhow improve the performance without replacing my hardware, +e.g. by tweaking the software? +4. Is there a Linux (Debian) tool that I can use to benchmark write +performance? + + + +-- +Groeten, + +Joost Kraaijeveld +Askesis B.V. +Molukkenstraat 14 +6524NB Nijmegen +tel: 024-3888063 / 06-51855277 +fax: 024-3608416 +e-mail: J.Kraaijeveld@Askesis.nl +web: www.askesis.nl + + +The Java code I use for the conversion : + +//////////////// .... +ResultSet resultSet = selectStatement.executeQuery( +"select ordernummer, orderdatum, klantnummer from odbc.orders order by +ordernummer"); + +connection.setAutoCommit(false); + +PreparedStatement ordersInsertStatement = +connection.prepareStatement("insert into prototype.orders +(objectid,ordernumber,orderdate,customernumber) values (?,?,?,?)"); + +while( resultSet.next() ) +{ + +if( (++record % 100) == 0){ + System.err.println( "handling record: " + record); +} + +// the next line can do > 1.000.000 objectId/sec +String orderObjectId = ObjectIdGenerator.newObjectId(); +ordersInsertStatement.setString(1,orderObjectId); +ordersInsertStatement.setInt(2,resultSet.getInt("ordernummer")); +ordersInsertStatement.setDate(3,resultSet.getDate("orderdatum")); +ordersInsertStatement.setInt(4,resultSet.getInt("klantnummer")); + +ordersInsertStatement.execute(); + +} + +connection.commit(); + + +From pgsql-performance-owner@postgresql.org Fri Sep 23 04:36:31 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D141CD84AD + for ; + Fri, 23 Sep 2005 04:36:29 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 82606-05 + for ; + Fri, 23 Sep 2005 07:36:26 +0000 (GMT) +Received: from ra.sai.msu.su (ra.sai.msu.su [158.250.29.2]) + by svr1.postgresql.org (Postfix) with ESMTP id F0297D7E1D + for ; + Fri, 23 Sep 2005 04:36:16 -0300 (ADT) +Received: from ra (ra [158.250.29.2]) + by ra.sai.msu.su (8.13.4/8.13.4) with ESMTP id j8N7Znp5008183; + Fri, 23 Sep 2005 11:35:53 +0400 (MSD) +Date: Fri, 23 Sep 2005 11:35:48 +0400 (MSD) +From: Oleg Bartunov +X-X-Sender: megera@ra.sai.msu.su +To: Ahmad Fajar +Cc: pgsql-performance@postgresql.org +Subject: Re: tsearch2 seem very slow +In-Reply-To: +Message-ID: +References: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.324 required=5 tests=[AWL=-0.050, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200509/276 +X-Sequence-Number: 14584 + +Ahmad, + +how fast is repeated runs ? First time system could be very slow. +Also, have you checked my page +http://www.sai.msu.su/~megera/oddmuse/index.cgi/Tsearch_V2_Notes +and some info about tsearch2 internals +http://www.sai.msu.su/~megera/oddmuse/index.cgi/Tsearch_V2_internals + + Oleg +On Thu, 22 Sep 2005, Ahmad Fajar wrote: + +> I have about 419804 rows in my article table. I have installed tsearch2 and +> its gist index correctly. +> +> My table structure is: +> +> CREATE TABLE tbarticles +> +> ( +> +> articleid int4 NOT NULL, +> +> title varchar(250), +> +> mediaid int4, +> +> datee date, +> +> content text, +> +> contentvar text, +> +> mmcol float4 NOT NULL, +> +> sirkulasi float4, +> +> page varchar(10), +> +> tglisidata date, +> +> namapc varchar(12), +> +> usere varchar(12), +> +> file_pdf varchar(255), +> +> file_pdf2 varchar(50), +> +> kolom int4, +> +> size_jpeg int4, +> +> journalist varchar(120), +> +> ratebw float4, +> +> ratefc float4, +> +> fti tsvector, +> +> CONSTRAINT pk_tbarticles PRIMARY KEY (articleid) +> +> ) WITHOUT OIDS; +> +> Create index fti_idx1 on tbarticles using gist (fti); +> +> Create index fti_idx2 on tbarticles using gist (datee, fti); +> +> +> +> But when I search something like: +> +> Select articleid, title, datee from tbarticles where fti @@ +> to_tsquery('susilo&bambang&yudhoyono&jusuf&kalla'); +> +> It takes about 30 sec. I run explain analyze and the index is used +> correctly. +> +> +> +> Then I try multi column index to filter by date, and my query something +> like: +> +> Select articleid, title, datee from tbarticles where fti @@ +> to_tsquery('susilo&bambang&yudhoyono&jusuf&kalla') and datee >= '2002-01-01' +> and datee <= current_date +> +> An it still run about 25 sec. I do run explain analyze and my multicolumn +> index is used correctly. +> +> This is not acceptable if want to publish my website if the search took very +> longer. +> +> +> +> I have run vacuum full analyze before doing such query. What going wrong +> with my query?? Is there any way to make this faster? +> +> I have try to tune my postgres configuration, but it seem helpless. My linux +> box is Redhat 4 AS, and +> +> the hardware: 2 GB RAM DDR 400, 2x200 GB Serial ATA 7200RPM and configure as +> RAID0 (just for postgres data), my sistem run at EIDE 80GB 7200 RPM. +> +> +> +> Please.help.help. +> +> + + Regards, + Oleg +_____________________________________________________________ +Oleg Bartunov, sci.researcher, hostmaster of AstroNet, +Sternberg Astronomical Institute, Moscow University (Russia) +Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ +phone: +007(095)939-16-83, +007(095)939-23-83 + +From pgsql-performance-owner@postgresql.org Fri Sep 23 05:54:09 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 05BEDD709A + for ; + Fri, 23 Sep 2005 05:54:08 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 03019-02 + for ; + Fri, 23 Sep 2005 08:54:04 +0000 (GMT) +Received: from imsm057dat.netvigator.com (imsm057.netvigator.com + [218.102.48.210]) + by svr1.postgresql.org (Postfix) with ESMTP id E9A2FD6EAF + for ; + Fri, 23 Sep 2005 05:54:03 -0300 (ADT) +Received: from n2.netvigator.com ([218.102.147.167]) + by imsm057dat.netvigator.com + (InterMail vM.6.01.05.02 201-2131-123-102-20050715) with ESMTP id + <20050923085404.CNCP10762.imsm057dat.netvigator.com@n2.netvigator.com> + for ; + Fri, 23 Sep 2005 16:54:04 +0800 +Message-Id: <6.2.1.2.0.20050923155952.05889a50@localhost> +X-Mailer: QUALCOMM Windows Eudora Version 6.2.1.2 +Date: Fri, 23 Sep 2005 16:53:55 +0800 +To: +From: K C Lau +Subject: Re: SELECT LIMIT 1 VIEW Performance Issue +In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB3417DD406@Herge.rcsinc.local> +References: <6EE64EF3AB31D5448D0007DD34EEB3417DD406@Herge.rcsinc.local> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.53 required=5 tests=[AWL=-0.362, + DNS_FROM_RFC_POST=1.376, FROM_ENDS_IN_NUMS=0.516] +X-Spam-Level: * +X-Archive-Number: 200509/277 +X-Sequence-Number: 14585 + +Thank you all for your suggestions. I' tried, with some variations too, but +still no success. The times given are the best of a few repeated tries on +an 8.1 beta 2 db freshly migrated from 8.0.3 on Windows. + +For reference, only the following gets the record quickly: + +esdt=> explain analyze select PlayerID,AtDate from Player a + where PlayerID='22220' and AtDate = (select b.AtDate from Player b + where b.PlayerID = '22220' order by b.PlayerID desc, b.AtDate desc LIMIT 1); + + Index Scan using pk_player on player a (cost=0.75..4.26 rows=1 width=23) +(actual time=0.054..0.057 rows=1 loops=1) + Index Cond: (((playerid)::text = '22220'::text) AND ((atdate)::text = +($0)::text)) + InitPlan + -> Limit (cost=0.00..0.75 rows=1 width=23) (actual +time=0.027..0.028 rows=1 loops=1) + -> Index Scan Backward using pk_player on player +b (cost=0.00..1323.05 rows=1756 width=23) (actual time=0.023..0.023 rows=1 +loops=1) + Index Cond: ((playerid)::text = '22220'::text) + Total runtime: 0.132 ms + +At 02:19 05/09/23, Kevin Grittner wrote: +>Have you tried the "best choice" pattern -- where you select the set of +>candidate rows and then exclude those for which a better choice +>exists within the set? I often get better results with this pattern than +>with the alternatives. + +esdt=> explain analyze select PlayerID,AtDate from Player a where +PlayerID='22220' +and not exists (select * from Player b where b.PlayerID = a.PlayerID and +b.AtDate > a.AtDate); + + Index Scan using pk_player on player a (cost=0.00..3032.46 rows=878 +width=23) +(actual time=35.820..35.823 rows=1 loops=1) + Index Cond: ((playerid)::text = '22220'::text) + Filter: (NOT (subplan)) + SubPlan + -> Index Scan using pk_player on player b (cost=0.00..378.68 +rows=389 width=776) (actual time=0.013..0.013 rows=1 loops=1743) + Index Cond: (((playerid)::text = ($0)::text) AND +((atdate)::text > ($1)::text)) + Total runtime: 35.950 ms + +Note that it is faster than the LIMIT 1: + +esdt=> explain analyze select PlayerID,AtDate from Player a where +PlayerID='22220' and AtDate = (select b.AtDate from Pl +ayer b where b.PlayerID = a.PlayerID order by b.PlayerID desc, b.AtDate +desc LIMIT 1); + + Index Scan using pk_player on player a (cost=0.00..2789.07 rows=9 +width=23) (actual time=41.366..41.371 rows=1 loops=1) + Index Cond: ((playerid)::text = '22220'::text) + Filter: ((atdate)::text = ((subplan))::text) + SubPlan + -> Limit (cost=0.00..0.83 rows=1 width=23) (actual +time=0.013..0.014 rows=1 loops=1743) + -> Index Scan Backward using pk_player on player +b (cost=0.00..970.53 rows=1166 width=23) (actual time=0.008..0.008 rows=1 +loops=1743) + Index Cond: ((playerid)::text = ($0)::text) + Total runtime: 41.490 ms + +At 02:07 05/09/23, Merlin Moncure wrote: +> > >Here is a trick I use sometimes with views, etc. This may or may not be +> > >effective to solve your problem but it's worth a shot. Create one small +> > >SQL function taking date, etc. and returning the values and define it +> > >immutable. Now in-query it is treated like a constant. + +esdt=> create or replace function player_max_atdate (varchar(32)) returns +varchar(32) as $$ +esdt$> select atdate from player where playerid = $1 order by playerid +desc, AtDate desc limit 1; +esdt$> $$ language sql immutable; +CREATE FUNCTION +esdt=> create or replace view VCurPlayer3 as select * from Player where +AtDate = player_max_atdate(PlayerID); +CREATE VIEW +esdt=> explain analyze select PlayerID,AtDate from VCurPlayer3 where +PlayerID='22220'; + + Index Scan using pk_player on player (cost=0.00..1331.83 rows=9 +width=23) (actual time=65.434..65.439 rows=1 loops=1) + Index Cond: ((playerid)::text = '22220'::text) + Filter: ((atdate)::text = (player_max_atdate(playerid))::text) + Total runtime: 65.508 ms + +While it says loops=1, the time suggests that it is going through all 1743 +records for that PlayerID. + +I tried to simulate the fast subquery inside the function, but it is taking +almost twice as much time: + +esdt=> create or replace function player_max_atdate (varchar(32)) returns +varchar(32) as $$ +esdt$> select atdate from player a where playerid = $1 and AtDate = +(select b.AtDate from Player b +esdt$> where b.PlayerID = $1 order by b.PlayerID desc, b.AtDate desc LIMIT 1); +esdt$> $$ language sql immutable; +CREATE FUNCTION +esdt=> explain analyze select PlayerID,AtDate from VCurPlayer3 where +PlayerID='22220'; + + Index Scan using pk_player on player (cost=0.00..1331.83 rows=9 +width=23) (actual time=119.369..119.373 rows=1 loops=1) + Index Cond: ((playerid)::text = '22220'::text) + Filter: ((atdate)::text = (player_max_atdate(playerid))::text) + Total runtime: 119.441 ms + +Adding another LIMIT 1 inside the function makes it even slower: + +esdt=> create or replace function player_max_atdate (varchar(32)) returns +varchar(32) as $$ +esdt$> select atdate from player where playerid = $1 and AtDate = (select +b.AtDate from Player b +esdt$> where b.PlayerID = $1 order by b.PlayerID desc, b.AtDate desc LIMIT 1) +esdt$> order by PlayerID desc, AtDate desc LIMIT 1; +esdt$> $$ language sql immutable; +CREATE FUNCTION +esdt=> explain analyze select PlayerID,AtDate from VCurPlayer3 where +PlayerID='22220'; + + Index Scan using pk_player on player (cost=0.00..1331.83 rows=9 +width=23) (actual time=129.858..129.863 rows=1 loops=1) + Index Cond: ((playerid)::text = '22220'::text) + Filter: ((atdate)::text = (player_max_atdate(playerid))::text) + Total runtime: 129.906 ms + +At 00:16 05/09/23, Simon Riggs wrote: +>If the current value is used so often, use two tables - one with a +>current view only of the row maintained using UPDATE. Different +>performance issues maybe, but at least not correlated subquery ones. + +Many of our tables have similar construct and it would be a huge task to +duplicate and maintain all these tables throughout the system. We would +prefer a solution with SQL or function at the view or db level, or better +still, a fix, if this problem is considered general enough. + +>You're welcome in advance, ;) +>Merlin + +Thank you all in advance for any further ideas. +KC. + + +From pgsql-performance-owner@postgresql.org Fri Sep 23 06:31:35 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4DFD3D8134 + for ; + Fri, 23 Sep 2005 06:31:34 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 11690-02 + for ; + Fri, 23 Sep 2005 09:31:29 +0000 (GMT) +Received: from thor.netera.se (thor.netera.se [85.112.172.11]) + by svr1.postgresql.org (Postfix) with ESMTP id 4018ED8CE7 + for ; + Fri, 23 Sep 2005 06:31:28 -0300 (ADT) +Received: from [192.168.2.240] (1-1-1-41a.o.sth.bostream.se [81.26.246.14]) + by thor.netera.se (Postfix) with ESMTP id 362EF13AC07A; + Fri, 23 Sep 2005 11:31:28 +0200 (CEST) +Message-ID: <4333CB6D.1010208@relevanttraffic.se> +Date: Fri, 23 Sep 2005 11:31:25 +0200 +From: Ulrich Wisser +Organization: Relevant Traffic AB +User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Joost Kraaijeveld +Cc: Pgsql-Performance +Subject: Re: How to determine cause of performance problem? +References: <1127458167.2475.105.camel@Panoramix> +In-Reply-To: <1127458167.2475.105.camel@Panoramix> +Content-Type: text/plain; charset=ISO-8859-15; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.001 required=5 tests=[AWL=0.001] +X-Spam-Level: +X-Archive-Number: 200509/278 +X-Sequence-Number: 14586 + +Hi Joost, + +why do you convert programmatically? I would do something like + +create sequence s_objectid; + +insert into +prototype.orders(objectid,ordernumber,orderdate,customernumber) +select next_val('s_objectid'),ordernummer, orderdatum, klantnummer from +odbc.orders + + +Sounds a lot faster to me. + + +/Ulrich + +From pgsql-hackers-owner@postgresql.org Fri Sep 23 06:37:20 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1DEC9D8E04; + Fri, 23 Sep 2005 06:37:19 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 12228-02; Fri, 23 Sep 2005 09:37:12 +0000 (GMT) +Received: from cmailm2.svr.pol.co.uk (cmailm2.svr.pol.co.uk [195.92.193.210]) + by svr1.postgresql.org (Postfix) with ESMTP id 7ED3FD8CE7; + Fri, 23 Sep 2005 06:37:12 -0300 (ADT) +Received: from modem-701.lion.dialup.pol.co.uk ([217.135.162.189] + helo=192.168.0.102) by cmailm2.svr.pol.co.uk with esmtp (Exim 4.41) + id 1EIjzV-0001Ys-2V; Fri, 23 Sep 2005 10:37:13 +0100 +Subject: Releasing memory during External sorting? +From: Simon Riggs +To: pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org +Content-Type: text/plain +Organization: 2nd Quadrant +Date: Fri, 23 Sep 2005 10:37:12 +0100 +Message-Id: <1127468233.4145.178.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-3) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.052 required=5 tests=[AWL=0.002, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/993 +X-Sequence-Number: 73390 + +I have concerns about whether we are overallocating memory for use in +external sorts. (All code relating to this is in tuplesort.c) + +When we begin a sort we allocate (work_mem | maintenance_work_mem) and +attempt to do the sort in memory. If the sort set is too big to fit in +memory we then write to disk and begin an external sort. The same memory +allocation is used for both types of sort, AFAICS. + +The external sort algorithm benefits from some memory but not much. +Knuth says that the amount of memory required is very low, with a value +typically less than 1 kB. I/O overheads mean that there is benefit from +having longer sequential writes, so the optimum is much larger than +that. I've not seen any data that indicates that a setting higher than +16 MB adds any value at all to a large external sort. I have some +indications from private tests that very high memory settings may +actually hinder performance of the sorts, though I cannot explain that +and wonder whether it is the performance tests themselves that have +issues. + +Does anyone have any clear data that shows the value of large settings +of work_mem when the data to be sorted is much larger than memory? (I am +well aware of the value of setting work_mem higher for smaller sorts, so +any performance data needs to reflect only very large sorts). + +If not, I would propose that when we move from qsort to tapesort mode we +free the larger work_mem setting (if one exists) and allocate only a +lower, though still optimal setting for the tapesort. That way the +memory can be freed for use by other users or the OS while the tapesort +proceeds (which is usually quite a while...). + +Feedback, please. + +Best Regards, Simon Riggs + + +From pgsql-performance-owner@postgresql.org Fri Sep 23 06:55:27 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7E189D8E7C + for ; + Fri, 23 Sep 2005 06:55:26 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 11988-09 + for ; + Fri, 23 Sep 2005 09:55:20 +0000 (GMT) +Received: from vms044pub.verizon.net (vms044pub.verizon.net [206.46.252.44]) + by svr1.postgresql.org (Postfix) with ESMTP id D1329D8E04 + for ; + Fri, 23 Sep 2005 06:55:20 -0300 (ADT) +Received: from osgiliath.mathom.us ([70.108.61.78]) + by vms044.mailsrvcs.net (Sun Java System Messaging Server 6.2 HotFix + 0.04 (built Dec 24 2004)) with ESMTPA id + <0IN900DO4KW67U20@vms044.mailsrvcs.net> for + pgsql-performance@postgresql.org; Fri, 23 Sep 2005 04:55:18 -0500 (CDT) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id D808C622500 for + ; + Fri, 23 Sep 2005 05:55:17 -0400 (EDT) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 10115-02-6 for ; Fri, + 23 Sep 2005 05:55:17 -0400 (EDT) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id ACE6E619213; Fri, 23 Sep 2005 05:55:17 -0400 (EDT) +Date: Fri, 23 Sep 2005 05:55:17 -0400 +From: Michael Stone +Subject: Re: How to determine cause of performance problem? +In-reply-to: <1127458167.2475.105.camel@Panoramix> +To: pgsql-performance@postgresql.org +Mail-Followup-To: pgsql-performance@postgresql.org +Message-id: <20050923095517.GW14918@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: by amavisd-new-20030616-p10 (Debian) at mathom.us +References: <1127458167.2475.105.camel@Panoramix> +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.005 required=5 tests=[AWL=0.005] +X-Spam-Level: +X-Archive-Number: 200509/280 +X-Sequence-Number: 14588 + +On Fri, Sep 23, 2005 at 08:49:27AM +0200, Joost Kraaijeveld wrote: +>3. Can I anyhow improve the performance without replacing my hardware, +>e.g. by tweaking the software? + +It's not clear what your object id generator does. If it's just a +sequence, it's not clear that you need this program at all--just use a +SELECT INTO and make the object id a SERIAL. + +If you do need to control the object id or do some other processing +before putting the data into the new table, rewrite to use a COPY +instead of an INSERT. + +Mike Stone + +From pgsql-performance-owner@postgresql.org Fri Sep 23 07:21:23 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1277AD8CBE + for ; + Fri, 23 Sep 2005 07:21:23 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 21950-03 + for ; + Fri, 23 Sep 2005 10:21:17 +0000 (GMT) +Received: from obelix.askesis.nl (laudanum.demon.nl [82.161.125.16]) + by svr1.postgresql.org (Postfix) with ESMTP id 1CCA0D8BD0 + for ; + Fri, 23 Sep 2005 07:21:15 -0300 (ADT) +Received: obelix.askesis.nl 172.31.0.1 from 172.31.1.8 172.31.1.8 via HTTP + with MS-WebStorage 6.0.6249 +Received: from Panoramix by obelix.askesis.nl; 23 Sep 2005 12:21:15 +0200 +Subject: Re: How to determine cause of performance problem? +From: Joost Kraaijeveld +To: Michael Stone +Cc: pgsql-performance@postgresql.org +In-Reply-To: <20050923095517.GW14918@mathom.us> +References: <1127458167.2475.105.camel@Panoramix> + <20050923095517.GW14918@mathom.us> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Date: Fri, 23 Sep 2005 12:21:15 +0200 +Message-Id: <1127470875.3524.17.camel@Panoramix> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.4 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.094 required=5 tests=[AWL=0.044, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/281 +X-Sequence-Number: 14589 + +On Fri, 2005-09-23 at 05:55 -0400, Michael Stone wrote: +> It's not clear what your object id generator does. If it's just a +> sequence, it's not clear that you need this program at all--just use a +> SELECT INTO and make the object id a SERIAL. +It generates a GUID (and no, I do not want to turn this in a discussion +about GUIDs). As in the Java code comment: it is not the generation of +the GUID that is the problem (that is, I can generate millions of them +per second.) + +> If you do need to control the object id or do some other processing +> before putting the data into the new table, rewrite to use a COPY +> instead of an INSERT. +It is actually the shortest piece of code that gives me a poor +performance. The conversion problem is much, much larger and much much +more complicated. + +I suspect that either my hardware is to slow (but then again, see the +specs), or my Debian is to slow, or my PostgreSQL settings are wrong. + +But I have no clue where to begin with determining the bottleneck (it +even may be a normal performance for all I know: I have no experience +with converting such (large) database). + +Any suggestions? + + +-- +Groeten, + +Joost Kraaijeveld +Askesis B.V. +Molukkenstraat 14 +6524NB Nijmegen +tel: 024-3888063 / 06-51855277 +fax: 024-3608416 +e-mail: J.Kraaijeveld@Askesis.nl +web: www.askesis.nl + + + +From pgsql-performance-owner@postgresql.org Fri Sep 23 08:05:07 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0CF0FD8E5D + for ; + Fri, 23 Sep 2005 08:05:07 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 31475-04 + for ; + Fri, 23 Sep 2005 11:04:59 +0000 (GMT) +Received: from vms040pub.verizon.net (vms040pub.verizon.net [206.46.252.40]) + by svr1.postgresql.org (Postfix) with ESMTP id 38223D8D6E + for ; + Fri, 23 Sep 2005 08:04:59 -0300 (ADT) +Received: from osgiliath.mathom.us ([70.108.61.78]) + by vms040.mailsrvcs.net (Sun Java System Messaging Server 6.2 HotFix + 0.04 (built Dec 24 2004)) with ESMTPA id + <0IN900DY1O4DGN10@vms040.mailsrvcs.net> for + pgsql-performance@postgresql.org; Fri, 23 Sep 2005 06:05:02 -0500 (CDT) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id 1A81F637C33 for + ; + Fri, 23 Sep 2005 07:05:01 -0400 (EDT) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 11884-02-5 for ; Fri, + 23 Sep 2005 07:05:00 -0400 (EDT) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id D28D662CA50; Fri, 23 Sep 2005 07:05:00 -0400 (EDT) +Date: Fri, 23 Sep 2005 07:05:00 -0400 +From: Michael Stone +Subject: Re: How to determine cause of performance problem? +In-reply-to: <1127470875.3524.17.camel@Panoramix> +To: pgsql-performance@postgresql.org +Mail-Followup-To: pgsql-performance@postgresql.org +Message-id: <20050923110500.GX14918@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: by amavisd-new-20030616-p10 (Debian) at mathom.us +References: <1127458167.2475.105.camel@Panoramix> + <20050923095517.GW14918@mathom.us> <1127470875.3524.17.camel@Panoramix> +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.005 required=5 tests=[AWL=0.005] +X-Spam-Level: +X-Archive-Number: 200509/282 +X-Sequence-Number: 14590 + +On Fri, Sep 23, 2005 at 12:21:15PM +0200, Joost Kraaijeveld wrote: +>On Fri, 2005-09-23 at 05:55 -0400, Michael Stone wrote: +>> It's not clear what your object id generator does. If it's just a +>> sequence, it's not clear that you need this program at all--just use a +>> SELECT INTO and make the object id a SERIAL. +>It generates a GUID (and no, I do not want to turn this in a discussion +>about GUIDs). As in the Java code comment: it is not the generation of +>the GUID that is the problem (that is, I can generate millions of them +>per second.) + +I didn't say it was, did I? If you use a SELECT INTO instead of +SELECTing each record and then reINSERTing it you avoid a round trip +latency for each row. There's a reason I said "if it's just a sequence". + +>> If you do need to control the object id or do some other processing +>> before putting the data into the new table, rewrite to use a COPY +>> instead of an INSERT. +>It is actually the shortest piece of code that gives me a poor +>performance. The conversion problem is much, much larger and much much +>more complicated. + +Ok, that's great, but you didn't respond to the suggestion of using COPY +INTO instead of INSERT. + +>But I have no clue where to begin with determining the bottleneck (it +>even may be a normal performance for all I know: I have no experience +>with converting such (large) database). +> +>Any suggestions? + +Respond to the first suggestion? + +Mike Stone + +From pgsql-performance-owner@postgresql.org Fri Sep 23 08:15:40 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 66DB1D8E94 + for ; + Fri, 23 Sep 2005 08:15:39 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 31675-07 + for ; + Fri, 23 Sep 2005 11:15:35 +0000 (GMT) +Received: from cmailm4.svr.pol.co.uk (cmailm4.svr.pol.co.uk [195.92.193.211]) + by svr1.postgresql.org (Postfix) with ESMTP id 0B2A5D8EA1 + for ; + Fri, 23 Sep 2005 08:15:36 -0300 (ADT) +Received: from modem-181.lion.dialup.pol.co.uk ([217.135.160.181] + helo=192.168.0.102) by cmailm4.svr.pol.co.uk with esmtp (Exim 4.41) + id 1EIlWk-00042I-B3; Fri, 23 Sep 2005 12:15:38 +0100 +Subject: Re: SELECT LIMIT 1 VIEW Performance Issue +From: Simon Riggs +To: K C Lau +Cc: pgsql-performance@postgresql.org +In-Reply-To: <6.2.1.2.0.20050922181009.02c36ca8@localhost> +References: <6.2.1.2.0.20050615100524.04f9d6a8@localhost> + <6.2.1.2.0.20050922102035.07bcf2e0@localhost> + <1127378456.4145.76.camel@localhost.localdomain> + <6.2.1.2.0.20050922181009.02c36ca8@localhost> +Content-Type: text/plain +Organization: 2nd Quadrant +Date: Fri, 23 Sep 2005 12:15:41 +0100 +Message-Id: <1127474141.19345.10.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-3) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.052 required=5 tests=[AWL=0.002, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/283 +X-Sequence-Number: 14591 + +On Thu, 2005-09-22 at 18:40 +0800, K C Lau wrote: +> > > esdt=> explain analyze select PlayerID,AtDate from Player a +> > > where PlayerID='22220' and AtDate = (select b.AtDate from Player b +> > > where b.PlayerID = a.PlayerID order by b.PlayerID desc, b.AtDate desc +> > > LIMIT 1); + +I think you should try: + +select distinct on (PlayerID) PlayerID,AtDate from Player a +where PlayerID='22220' order by PlayerId, AtDate Desc; + +Does that work for you? + +Best Regards, Simon Riggs + + +From pgsql-performance-owner@postgresql.org Fri Sep 23 08:19:49 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 96725D8E84 + for ; + Fri, 23 Sep 2005 08:19:48 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 32025-07 + for ; + Fri, 23 Sep 2005 11:19:45 +0000 (GMT) +Received: from olive.qinip.net (olive.qinip.net [62.100.30.40]) + by svr1.postgresql.org (Postfix) with ESMTP id BF9B9D8E7B + for ; + Fri, 23 Sep 2005 08:19:45 -0300 (ADT) +Received: from [10.0.0.2] (h8441139206.dsl.speedlinq.nl [84.41.139.206]) + by olive.qinip.net (Postfix) with ESMTP id 3281218167; + Fri, 23 Sep 2005 13:19:44 +0200 (MEST) +Message-ID: <4333E4DB.4020206@tweakers.net> +Date: Fri, 23 Sep 2005 13:19:55 +0200 +From: Arjen van der Meijden +User-Agent: Mozilla Thunderbird 1.0RC1 (Windows/20041201) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Michael Stone +Cc: pgsql-performance@postgresql.org +Subject: Re: How to determine cause of performance problem? +References: <1127458167.2475.105.camel@Panoramix> + <20050923095517.GW14918@mathom.us> + <1127470875.3524.17.camel@Panoramix> + <20050923110500.GX14918@mathom.us> +In-Reply-To: <20050923110500.GX14918@mathom.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/284 +X-Sequence-Number: 14592 + +On 23-9-2005 13:05, Michael Stone wrote: +> On Fri, Sep 23, 2005 at 12:21:15PM +0200, Joost Kraaijeveld wrote: +> +> Ok, that's great, but you didn't respond to the suggestion of using COPY +> INTO instead of INSERT. +> +>> But I have no clue where to begin with determining the bottleneck (it +>> even may be a normal performance for all I know: I have no experience +>> with converting such (large) database). +>> +>> Any suggestions? +> +> +> Respond to the first suggestion? + +Another suggestion: +How many indexes and constraints are on the new table? +Drop all of them and recreate them once the table is filled. Of course +that only works if you know your data will be ok (which is normal for +imports of already conforming data like database dumps of existing tables). +This will give major performance improvements, if you have indexes and +such on the new table. + +Best regards, + +Arjen + +From pgsql-performance-owner@postgresql.org Fri Sep 23 08:25:56 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 43F8FD8F23 + for ; + Fri, 23 Sep 2005 08:25:56 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37594-01 + for ; + Fri, 23 Sep 2005 11:25:51 +0000 (GMT) +Received: from ra.sai.msu.su (ra.sai.msu.su [158.250.29.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E13B4D8D6E + for ; + Fri, 23 Sep 2005 08:25:45 -0300 (ADT) +Received: from ra (ra [158.250.29.2]) + by ra.sai.msu.su (8.13.4/8.13.4) with ESMTP id j8NBPbiK012446; + Fri, 23 Sep 2005 15:25:37 +0400 (MSD) +Date: Fri, 23 Sep 2005 15:25:37 +0400 (MSD) +From: Oleg Bartunov +X-X-Sender: megera@ra.sai.msu.su +To: Ahmad Fajar +Cc: pgsql-performance@postgresql.org +Subject: Re: tsearch2 seem very slow +In-Reply-To: +Message-ID: +References: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.324 required=5 tests=[AWL=-0.050, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200509/285 +X-Sequence-Number: 14593 + +On Fri, 23 Sep 2005, Ahmad Fajar wrote: + +> Hi Oleg, +> +> I didn't deny on the third repeat or more, it can reach < 600 msec. It is +> only because the result still in postgres cache, but how about in the first +> run? I didn't dare, the values is un-acceptable. Because my table will grows +> rapidly, it's about 100000 rows per-week. And the visitor will search +> anything that I don't know, whether it's the repeated search or new search, +> or whether it's in postgres cache or not. + +if you have enoush shared memory postgresql will keep index pages there. + + +> +> I just compare with http://www.postgresql.org, the search is quite fast, and +> I don't know whether the site uses tsearch2 or something else. But as fas as +> I know, if the rows reach >100 milion (I have try for 200 milion rows and it +> seem very slow), even if don't use tsearch2, only use simple query like: +> select f1, f2 from table1 where f2='blabla', +> and f2 is indexes, my postgres still slow on the first time, about >10 sec. +> because of this I tried something brand new to fullfill my needs. I have +> used fti, and tsearch2 but still slow. +> +> I don't know what's going wrong with my postgres, what configuration must I +> do to perform the query get fast result. Or must I use enterprisedb 2005 or +> pervasive postgres (both uses postgres), I don't know very much about these +> two products. + +you didn't show us your configuration (hardware,postgresql and tsearch2), +explain analyze of your queries, so we can't help you. +How big is your database, tsearch2 index size ? + + +> +> Regards, +> ahmad fajar +> +> +> -----Original Message----- +> From: Oleg Bartunov [mailto:oleg@sai.msu.su] +> Sent: Jumat, 23 September 2005 14:36 +> To: Ahmad Fajar +> Cc: pgsql-performance@postgresql.org +> Subject: Re: [PERFORM] tsearch2 seem very slow +> +> Ahmad, +> +> how fast is repeated runs ? First time system could be very slow. +> Also, have you checked my page +> http://www.sai.msu.su/~megera/oddmuse/index.cgi/Tsearch_V2_Notes +> and some info about tsearch2 internals +> http://www.sai.msu.su/~megera/oddmuse/index.cgi/Tsearch_V2_internals +> +> Oleg +> On Thu, 22 Sep 2005, Ahmad Fajar wrote: +> +>> I have about 419804 rows in my article table. I have installed tsearch2 +> and +>> its gist index correctly. +>> +>> My table structure is: +>> +>> CREATE TABLE tbarticles +>> +>> ( +>> +>> articleid int4 NOT NULL, +>> +>> title varchar(250), +>> +>> mediaid int4, +>> +>> datee date, +>> +>> content text, +>> +>> contentvar text, +>> +>> mmcol float4 NOT NULL, +>> +>> sirkulasi float4, +>> +>> page varchar(10), +>> +>> tglisidata date, +>> +>> namapc varchar(12), +>> +>> usere varchar(12), +>> +>> file_pdf varchar(255), +>> +>> file_pdf2 varchar(50), +>> +>> kolom int4, +>> +>> size_jpeg int4, +>> +>> journalist varchar(120), +>> +>> ratebw float4, +>> +>> ratefc float4, +>> +>> fti tsvector, +>> +>> CONSTRAINT pk_tbarticles PRIMARY KEY (articleid) +>> +>> ) WITHOUT OIDS; +>> +>> Create index fti_idx1 on tbarticles using gist (fti); +>> +>> Create index fti_idx2 on tbarticles using gist (datee, fti); +>> +>> +>> +>> But when I search something like: +>> +>> Select articleid, title, datee from tbarticles where fti @@ +>> to_tsquery('susilo&bambang&yudhoyono&jusuf&kalla'); +>> +>> It takes about 30 sec. I run explain analyze and the index is used +>> correctly. +>> +>> +>> +>> Then I try multi column index to filter by date, and my query something +>> like: +>> +>> Select articleid, title, datee from tbarticles where fti @@ +>> to_tsquery('susilo&bambang&yudhoyono&jusuf&kalla') and datee >= +> '2002-01-01' +>> and datee <= current_date +>> +>> An it still run about 25 sec. I do run explain analyze and my multicolumn +>> index is used correctly. +>> +>> This is not acceptable if want to publish my website if the search took +> very +>> longer. +>> +>> +>> +>> I have run vacuum full analyze before doing such query. What going wrong +>> with my query?? Is there any way to make this faster? +>> +>> I have try to tune my postgres configuration, but it seem helpless. My +> linux +>> box is Redhat 4 AS, and +>> +>> the hardware: 2 GB RAM DDR 400, 2x200 GB Serial ATA 7200RPM and configure +> as +>> RAID0 (just for postgres data), my sistem run at EIDE 80GB 7200 RPM. +>> +>> +>> +>> Please.help.help. +>> +>> +> +> Regards, +> Oleg +> _____________________________________________________________ +> Oleg Bartunov, sci.researcher, hostmaster of AstroNet, +> Sternberg Astronomical Institute, Moscow University (Russia) +> Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ +> phone: +007(095)939-16-83, +007(095)939-23-83 +> + + Regards, + Oleg +_____________________________________________________________ +Oleg Bartunov, sci.researcher, hostmaster of AstroNet, +Sternberg Astronomical Institute, Moscow University (Russia) +Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ +phone: +007(095)939-16-83, +007(095)939-23-83 + +From pgsql-performance-owner@postgresql.org Fri Sep 23 08:31:05 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 890E1D8EA1 + for ; + Fri, 23 Sep 2005 08:31:04 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 36998-03 + for ; + Fri, 23 Sep 2005 11:30:59 +0000 (GMT) +Received: from net2.micro-automation.com (net2.micro-automation.com + [64.7.141.29]) + by svr1.postgresql.org (Postfix) with SMTP id 6E2FFD8EA0 + for ; + Fri, 23 Sep 2005 08:30:59 -0300 (ADT) +Received: (qmail 24440 invoked from network); 23 Sep 2005 11:31:01 -0000 +Received: from dcdsl.ebox.com (HELO ?192.168.1.2?) (davec@64.7.143.116) + by net2.micro-automation.com with SMTP; 23 Sep 2005 11:31:01 -0000 +In-Reply-To: <1127458167.2475.105.camel@Panoramix> +References: <1127458167.2475.105.camel@Panoramix> +Mime-Version: 1.0 (Apple Message framework v734) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: +Cc: Pgsql-Performance +Content-Transfer-Encoding: 7bit +From: Dave Cramer +Subject: Re: How to determine cause of performance problem? +Date: Fri, 23 Sep 2005 07:30:59 -0400 +To: Joost Kraaijeveld +X-Mailer: Apple Mail (2.734) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.02 required=5 tests=[AWL=0.020] +X-Spam-Level: +X-Archive-Number: 200509/286 +X-Sequence-Number: 14594 + +Joost, + +I presume you are using a relatively new jdbc driver. Make sure you +have added prepareThreshold=1 to the url to that it will use a named +server side prepared statement + +You could also use your mod 100 code block to implement batch +processing of the inserts. + +see addBatch, in jdbc specs + +Dave + +On 23-Sep-05, at 2:49 AM, Joost Kraaijeveld wrote: + +> Hi, +> +> I must convert an old table into a new table. The conversion goes at ~ +> 100 records per second. Given the fact that I must convert 40 million +> records, it takes too much time: more hours than the 48 hour weekend I +> have for the conversion;-). +> +> The tables are rather simple: both tables only have a primary key +> constraint (of type text) and no other indexes. I only copy 3 +> columns. I +> use Java for the conversion. For the exact code see below. +> +> During the conversion my processor load is almost non existant. The +> harddisk throughput is ~ 6 megabyte/second max (measured with iostat). +> +> My platform is Debian Sarge AMD64. My hardware is a Tyan Thunder K8W +> 2885 motherboard, 2 Opteron 248 processors, 2 GB RAM, a SATA bootdisk +> with / and swap, and a 3Ware 9500S-8 RAID-5 controller with 5 attached +> SATA disks with /home and /var. /var contains *all* PostgreSQL log and +> database files (default Debian installation). +> +> Output of hdparm -Tt /dev/sdb (sdb is the RAID opartition) +> +> /dev/sdb: +> Timing cached reads: 1696 MB in 2.00 seconds = 846.86 MB/sec +> Timing buffered disk reads: 246 MB in 3.01 seconds = 81.79 MB/sec +> +> +> I want to determine the cause of my performance problem (if it is +> one). +> +> 1. Is this a performance I can expect? +> 2. If not, how can I determine the cause? +> 3. Can I anyhow improve the performance without replacing my hardware, +> e.g. by tweaking the software? +> 4. Is there a Linux (Debian) tool that I can use to benchmark write +> performance? +> +> +> +> -- +> Groeten, +> +> Joost Kraaijeveld +> Askesis B.V. +> Molukkenstraat 14 +> 6524NB Nijmegen +> tel: 024-3888063 / 06-51855277 +> fax: 024-3608416 +> e-mail: J.Kraaijeveld@Askesis.nl +> web: www.askesis.nl +> +> +> The Java code I use for the conversion : +> +> //////////////// .... +> ResultSet resultSet = selectStatement.executeQuery( +> "select ordernummer, orderdatum, klantnummer from odbc.orders order by +> ordernummer"); +> +> connection.setAutoCommit(false); +> +> PreparedStatement ordersInsertStatement = +> connection.prepareStatement("insert into prototype.orders +> (objectid,ordernumber,orderdate,customernumber) values (?,?,?,?)"); +> +> while( resultSet.next() ) +> { +> +> if( (++record % 100) == 0){ +> System.err.println( "handling record: " + record); +> } +> +> // the next line can do > 1.000.000 objectId/sec +> String orderObjectId = ObjectIdGenerator.newObjectId(); +> ordersInsertStatement.setString(1,orderObjectId); +> ordersInsertStatement.setInt(2,resultSet.getInt("ordernummer")); +> ordersInsertStatement.setDate(3,resultSet.getDate("orderdatum")); +> ordersInsertStatement.setInt(4,resultSet.getInt("klantnummer")); +> +> ordersInsertStatement.execute(); +> +> } +> +> connection.commit(); +> +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 3: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faq +> +> + + +From pgsql-performance-owner@postgresql.org Fri Sep 23 09:17:13 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D427BD900C + for ; + Fri, 23 Sep 2005 09:17:11 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 43038-09 + for ; + Fri, 23 Sep 2005 12:17:07 +0000 (GMT) +Received: from imsm057dat.netvigator.com (imsm057.netvigator.com + [218.102.48.210]) + by svr1.postgresql.org (Postfix) with ESMTP id 40C9FD90A5 + for ; + Fri, 23 Sep 2005 09:17:07 -0300 (ADT) +Received: from n2.netvigator.com ([218.102.147.167]) + by imsm057dat.netvigator.com + (InterMail vM.6.01.05.02 201-2131-123-102-20050715) with ESMTP id + <20050923121709.CTHT10762.imsm057dat.netvigator.com@n2.netvigator.com>; + Fri, 23 Sep 2005 20:17:09 +0800 +Message-Id: <6.2.1.2.0.20050923195457.02c4fd30@localhost> +X-Mailer: QUALCOMM Windows Eudora Version 6.2.1.2 +Date: Fri, 23 Sep 2005 20:17:03 +0800 +To: Simon Riggs +From: K C Lau +Subject: Re: SELECT LIMIT 1 VIEW Performance Issue +Cc: pgsql-performance@postgresql.org +In-Reply-To: <1127474141.19345.10.camel@localhost.localdomain> +References: <6.2.1.2.0.20050615100524.04f9d6a8@localhost> + <6.2.1.2.0.20050922102035.07bcf2e0@localhost> + <1127378456.4145.76.camel@localhost.localdomain> + <6.2.1.2.0.20050922181009.02c36ca8@localhost> + <1127474141.19345.10.camel@localhost.localdomain> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.532 required=5 tests=[AWL=-0.360, + DNS_FROM_RFC_POST=1.376, FROM_ENDS_IN_NUMS=0.516] +X-Spam-Level: * +X-Archive-Number: 200509/287 +X-Sequence-Number: 14595 + +At 19:15 05/09/23, Simon Riggs wrote: +>select distinct on (PlayerID) PlayerID,AtDate from Player a +>where PlayerID='22220' order by PlayerId, AtDate Desc; +> +>Does that work for you? +> +>Best Regards, Simon Riggs + +esdt=> explain analyze select distinct on (PlayerID) PlayerID,AtDate from +Player a where PlayerID='22220' order by PlayerId, AtDate Desc; + Unique (cost=1417.69..1426.47 rows=2 width=23) (actual +time=31.231..36.609 rows=1 loops=1) + -> Sort (cost=1417.69..1422.08 rows=1756 width=23) (actual +time=31.129..32.473 rows=1743 loops=1) + Sort Key: playerid, atdate + -> Index Scan using pk_player on player a (cost=0.00..1323.05 +rows=1756 width=23) (actual time=0.035..6.575 rows=1743 loops=1) + Index Cond: ((playerid)::text = '22220'::text) + Total runtime: 36.943 ms + +The sort was eliminated with: order by PlayerId Desc, AtDate Desc: + +esdt=> explain analyze select distinct on (PlayerID) PlayerID,AtDate from +Player a where PlayerID='22220' order by PlayerId Desc, AtDate Desc; + Unique (cost=0.00..1327.44 rows=2 width=23) (actual time=0.027..8.438 +rows=1 loops=1) + -> Index Scan Backward using pk_player on player +a (cost=0.00..1323.05 rows=1756 width=23) (actual time=0.022..4.950 +rows=1743 loops=1) + Index Cond: ((playerid)::text = '22220'::text) + Total runtime: 8.499 ms + +That is the fastest of all queries looping the 1743 rows. +I do get the desired result by adding LIMIT 1: + +esdt=> explain analyze select distinct on (PlayerID) PlayerID,AtDate from +Player a where PlayerID='22220' order by PlayerId Desc, AtDate Desc LIMIT 1; + + Limit (cost=0.00..663.72 rows=1 width=23) (actual time=0.032..0.033 +rows=1 loops=1) + -> Unique (cost=0.00..1327.44 rows=2 width=23) (actual +time=0.028..0.028 rows=1 loops=1) + -> Index Scan Backward using pk_player on player +a (cost=0.00..1323.05 rows=1756 width=23) (actual time=0.022..0.022 rows=1 +loops=1) + Index Cond: ((playerid)::text = '22220'::text) + Total runtime: 0.094 ms + +However, when I use that within a function in a view, it is slow again: + +esdt=> create or replace function player_max_atdate (varchar(32)) returns +varchar(32) as $$ +esdt$> select distinct on (PlayerID) AtDate from player where PlayerID= $1 +order by PlayerID desc, AtDate desc limit 1; +esdt$> $$ language sql immutable; +CREATE FUNCTION +esdt=> create or replace view VCurPlayer3 as select * from Player where +AtDate = player_max_atdate(PlayerID); +CREATE VIEW +esdt=> explain analyze select PlayerID,AtDate from VCurPlayer3 where +PlayerID='22220'; + + Index Scan using pk_player on player (cost=0.00..1331.83 rows=9 +width=23) (actual time=76.660..76.664 rows=1 loops=1) + Index Cond: ((playerid)::text = '22220'::text) + Filter: ((atdate)::text = (player_max_atdate(playerid))::text) + Total runtime: 76.716 ms + +Why wouldn't the function get the row as quickly as the direct sql does? + +Best regards, KC. + + + +From pgsql-performance-owner@postgresql.org Fri Sep 23 09:34:30 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 034D4D8F3D + for ; + Fri, 23 Sep 2005 09:34:26 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 54851-02 + for ; + Fri, 23 Sep 2005 12:34:21 +0000 (GMT) +Received: from Herge.rcsinc.local (unknown [70.89.208.142]) + by svr1.postgresql.org (Postfix) with ESMTP id 55115D7E12 + for ; + Fri, 23 Sep 2005 09:34:20 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Subject: Re: SELECT LIMIT 1 VIEW Performance Issue +Date: Fri, 23 Sep 2005 08:34:21 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3417DD41B@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] SELECT LIMIT 1 VIEW Performance Issue +Thread-Index: AcXAHPaGfCCBDHgTS6ybxiOUWk6iNAAG55aw +From: "Merlin Moncure" +To: "K C Lau" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.039 required=5 tests=[AWL=-0.011, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/288 +X-Sequence-Number: 14596 + +> At 02:07 05/09/23, Merlin Moncure wrote: +> > > >Here is a trick I use sometimes with views, etc. This may or may +not +> be +> > > >effective to solve your problem but it's worth a shot. Create +one +> small +> > > >SQL function taking date, etc. and returning the values and +define it +> > > >immutable. Now in-query it is treated like a constant. +>=20 +> esdt=3D> create or replace function player_max_atdate (varchar(32)) +returns +> varchar(32) as $$ +> esdt$> select atdate from player where playerid =3D $1 order by +playerid +> desc, AtDate desc limit 1; +> esdt$> $$ language sql immutable; + +Can you time just the execution of this function and compare vs. pure +SQL version? If the times are different, can you do a exaplain analyze +of a prepared version of above? + +prepare test(character varying) as select atdate from player where +playerid =3D $1 order by playerid desc, AtDate desc limit 1; + +explain analyze execute test('22220'); + +> CREATE FUNCTION +> esdt=3D> create or replace view VCurPlayer3 as select * from Player +where +> AtDate =3D player_max_atdate(PlayerID); +> CREATE VIEW + +This is wrong, it should have been=20 +create or replace view VCurPlayer3 as select *, +player_max_atdate(PlayerID) as max_date from Player; + +I did a test on a table with 124k records and a two part key, ID & date. +esp# select count(*) from parts_order_file; +count +-------- + 124158 +(1 row) + + +esp=3D# select count(*) from parts_order_file where pr_dealer_no =3D +'000500'; + count +------- + 27971 +(1 row) + +created same function, view v, etc. +esp=3D# explain analyze select * from v where pr_dealer_no =3D '000500' +limit 1; +=20 +QUERY PLAN + +------------------------------------------------------------------------ +---------------------------- +---------------------------------------------------------------- + Limit (cost=3D0.00..3.87 rows=3D1 width=3D10) (actual = +time=3D1.295..1.297 +rows=3D1 loops=3D1) + -> Index Scan using parts_order_file_pr_dealer_no_key on +parts_order_file (cost=3D0.00..109369.15 + rows=3D28226 width=3D10) (actual time=3D1.287..1.287 rows=3D1 = +loops=3D1) + Index Cond: (pr_dealer_no =3D '000500'::bpchar) + Total runtime: 1.413 ms +(4 rows) + +Something is not jiving here. However, if the server plan still does +not come out correct, try the following (p.s. why is function returning +varchar(32) and not date?): + +create or replace function player_max_atdate (varchar(32)) returns date +as +$$ + DECLARE + player_record record; + return date date; + BEGIN + for player_record in execute + 'select atdate from player where playerid =3D \'' || $1 || = +'\' +order by playerid desc, AtDate desc limit 1;' loop + return_date =3D player_record.atdate; =20 + end loop; + =20 + return return_date; + END; +$ language plpgsql immutable; + +Merlin + +From pgsql-performance-owner@postgresql.org Fri Sep 23 10:36:02 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7642FD90EB + for ; + Fri, 23 Sep 2005 10:36:01 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 67623-05 + for ; + Fri, 23 Sep 2005 13:35:56 +0000 (GMT) +Received: from obelix.askesis.nl (laudanum.demon.nl [82.161.125.16]) + by svr1.postgresql.org (Postfix) with ESMTP id 29162D90E7 + for ; + Fri, 23 Sep 2005 10:35:56 -0300 (ADT) +Received: obelix.askesis.nl 172.31.0.1 from 172.31.1.8 172.31.1.8 via HTTP + with MS-WebStorage 6.0.6249 +Received: from Panoramix by obelix.askesis.nl; 23 Sep 2005 15:35:58 +0200 +Subject: Re: How to determine cause of performance problem? +From: Joost Kraaijeveld +To: Arjen van der Meijden +Cc: Michael Stone , + pgsql-performance@postgresql.org +In-Reply-To: <4333E4DB.4020206@tweakers.net> +References: <1127458167.2475.105.camel@Panoramix> + <20050923095517.GW14918@mathom.us> <1127470875.3524.17.camel@Panoramix> + <20050923110500.GX14918@mathom.us> <4333E4DB.4020206@tweakers.net> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Date: Fri, 23 Sep 2005 15:35:58 +0200 +Message-Id: <1127482558.3524.23.camel@Panoramix> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.4 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.094 required=5 tests=[AWL=0.044, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/289 +X-Sequence-Number: 14597 + +On Fri, 2005-09-23 at 13:19 +0200, Arjen van der Meijden wrote: +> Another suggestion: +> How many indexes and constraints are on the new table? +As mentioned in the first mail: in this tables only primary key +constraints, no other indexes or constraints. + +> Drop all of them and recreate them once the table is filled. Of course +> that only works if you know your data will be ok (which is normal for +> imports of already conforming data like database dumps of existing tables). +> This will give major performance improvements, if you have indexes and +> such on the new table. +I will test this a for perfomance improvement, but still, I wonder if ~ +100 inserts/second is a reasonable performance for my software/hardware +combination. + +-- +Groeten, + +Joost Kraaijeveld +Askesis B.V. +Molukkenstraat 14 +6524NB Nijmegen +tel: 024-3888063 / 06-51855277 +fax: 024-3608416 +e-mail: J.Kraaijeveld@Askesis.nl +web: www.askesis.nl + + + +From pgsql-performance-owner@postgresql.org Fri Sep 23 10:40:15 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 61679D9171 + for ; + Fri, 23 Sep 2005 10:40:14 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 70129-03 + for ; + Fri, 23 Sep 2005 13:40:07 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id BF7F1D9167 + for ; + Fri, 23 Sep 2005 10:40:08 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j8NDe8oN003193; + Fri, 23 Sep 2005 09:40:09 -0400 (EDT) +To: eVl +Cc: pgsql-performance@postgresql.org +Subject: Re: optimization downgrade perfomance? +In-reply-to: <133614678.20050923012716@gmail.com> +References: <133614678.20050923012716@gmail.com> +Comments: In-reply-to eVl + message dated "Fri, 23 Sep 2005 01:27:16 +0300" +Date: Fri, 23 Sep 2005 09:40:08 -0400 +Message-ID: <3192.1127482808@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/290 +X-Sequence-Number: 14598 + +eVl writes: +> When executing this SELECT (see SELECT.A above) it executes in about 700 ms, but when I want wipe out all info about local traffic, with query like this: +> SELECT * FROM ( SELECT.A ) a WHERE type = 'global'; +> It executes about 10000 ms - more then 10 TIMES SLOWER! + +> Why this could be? + +You tell us --- let's see EXPLAIN ANALYZE results for both cases. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Sep 23 10:49:27 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E44D3D914E + for ; + Fri, 23 Sep 2005 10:49:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 71441-05 + for ; + Fri, 23 Sep 2005 13:49:20 +0000 (GMT) +Received: from obelix.askesis.nl (laudanum.demon.nl [82.161.125.16]) + by svr1.postgresql.org (Postfix) with ESMTP id DC0CFD9161 + for ; + Fri, 23 Sep 2005 10:49:21 -0300 (ADT) +Received: obelix.askesis.nl 172.31.0.1 from 172.31.1.8 172.31.1.8 via HTTP + with MS-WebStorage 6.0.6249 +Received: from Panoramix by obelix.askesis.nl; 23 Sep 2005 15:49:25 +0200 +Subject: Re: How to determine cause of performance problem? +From: Joost Kraaijeveld +To: Michael Stone +Cc: pgsql-performance@postgresql.org +In-Reply-To: <20050923110500.GX14918@mathom.us> +References: <1127458167.2475.105.camel@Panoramix> + <20050923095517.GW14918@mathom.us> <1127470875.3524.17.camel@Panoramix> + <20050923110500.GX14918@mathom.us> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Date: Fri, 23 Sep 2005 15:49:25 +0200 +Message-Id: <1127483365.3524.36.camel@Panoramix> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.4 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.093 required=5 tests=[AWL=0.043, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/291 +X-Sequence-Number: 14599 + +On Fri, 2005-09-23 at 07:05 -0400, Michael Stone wrote: +> On Fri, Sep 23, 2005 at 12:21:15PM +0200, Joost Kraaijeveld wrote: +> >On Fri, 2005-09-23 at 05:55 -0400, Michael Stone wrote: +> I didn't say it was, did I? +No, you did not. But only last week someon'es head was (luckely for him +only virtually) almost chopped off for suggesting the usage of GUIDs ;-) + + +> Ok, that's great, but you didn't respond to the suggestion of using COPY +> INTO instead of INSERT. +Part of the code I left out are some data conversions (e.g. from +path-to-file to blob, from text to date (not castable because of the +homebrew original format)). I don't believe that I can do these in a SQL +statement, can I (my knowledge of SQL as a langage is not that good)? . +However I will investigate if I can do the conversion in two steps and +check if it is faster. + +But still, I wonder if ~100 inserts/second is a reasonable performance +for my software/hardware combination. + + +-- +Groeten, + +Joost Kraaijeveld +Askesis B.V. +Molukkenstraat 14 +6524NB Nijmegen +tel: 024-3888063 / 06-51855277 +fax: 024-3608416 +e-mail: J.Kraaijeveld@Askesis.nl +web: www.askesis.nl + + + +From pgsql-performance-owner@postgresql.org Fri Sep 23 11:06:51 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 246C6D919E + for ; + Fri, 23 Sep 2005 11:06:50 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 76855-01 + for ; + Fri, 23 Sep 2005 14:06:41 +0000 (GMT) +Received: from olive.qinip.net (olive.qinip.net [62.100.30.40]) + by svr1.postgresql.org (Postfix) with ESMTP id 2AC52D9121 + for ; + Fri, 23 Sep 2005 11:06:42 -0300 (ADT) +Received: from [10.0.0.2] (h8441139206.dsl.speedlinq.nl [84.41.139.206]) + by olive.qinip.net (Postfix) with ESMTP id BA8EC180F3; + Fri, 23 Sep 2005 16:06:44 +0200 (MEST) +Message-ID: <43340BFE.1070503@tweakers.net> +Date: Fri, 23 Sep 2005 16:06:54 +0200 +From: Arjen van der Meijden +User-Agent: Mozilla Thunderbird 1.0RC1 (Windows/20041201) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Joost Kraaijeveld +Cc: Michael Stone , + pgsql-performance@postgresql.org +Subject: Re: How to determine cause of performance problem? +References: <1127458167.2475.105.camel@Panoramix> + <20050923095517.GW14918@mathom.us> + <1127470875.3524.17.camel@Panoramix> + <20050923110500.GX14918@mathom.us> <4333E4DB.4020206@tweakers.net> + <1127482558.3524.23.camel@Panoramix> +In-Reply-To: <1127482558.3524.23.camel@Panoramix> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/292 +X-Sequence-Number: 14600 + +On 23-9-2005 15:35, Joost Kraaijeveld wrote: +> On Fri, 2005-09-23 at 13:19 +0200, Arjen van der Meijden wrote: +>>Drop all of them and recreate them once the table is filled. Of course +>>that only works if you know your data will be ok (which is normal for +>>imports of already conforming data like database dumps of existing tables). +>>This will give major performance improvements, if you have indexes and +>>such on the new table. +> +> I will test this a for perfomance improvement, but still, I wonder if ~ +> 100 inserts/second is a reasonable performance for my software/hardware +> combination. + +For the hardware: no, I don't think it is for such a simple table/small +recordsize. +I did a few batch-inserts with indexes on tables and was very +disappointed about the time it took. But with no indexes and constraints +left it flew and the table of 7 million records (of 3 ints and 2 +bigints) was imported in 75 seconds, on a bit simpler hardware. That was +done using a simple pg_dump-built sql-file which was then fed to psql as +input. And of course that used the local unix socket, not the local +network interface (I don't know which jdbc takes). +But generating a single transaction (as you do) with inserts shouldn't +be that much slower. + +So I don't think its your hardware, nor your postgresql, although a bit +extra maintenance_work_mem may help, if you haven't touched that. +Leaving the queries, the application and the driver. But I don't have +that much experience with jdbc and postgresql-performance. In php I +wouldn't select all the 40M records at once, the resultset would be in +the clients-memory and that may actually cause trouble. But I don't know +how that is implemented in JDBC, it may of course be using cursors and +it would be less of a problem than perhaps. +You could try writing the inserts to file and see how long that takes, +to eliminate the possibility of your application being slow on other +parts than the inserting of data. If that is fast enough, a last resort +may be to write a csv-file from java and use that with a copy-statement +in psql ;) + +Best regards, + +Arjen + +From pgsql-hackers-owner@postgresql.org Fri Sep 23 11:12:08 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0DC7ED9238; + Fri, 23 Sep 2005 11:09:44 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 75218-05; Fri, 23 Sep 2005 14:09:39 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id BAE20D9253; + Fri, 23 Sep 2005 11:09:41 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j8NE9eRf003466; + Fri, 23 Sep 2005 10:09:40 -0400 (EDT) +To: Simon Riggs +Cc: pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: Releasing memory during External sorting? +In-reply-to: <1127468233.4145.178.camel@localhost.localdomain> +References: <1127468233.4145.178.camel@localhost.localdomain> +Comments: In-reply-to Simon Riggs + message dated "Fri, 23 Sep 2005 10:37:12 +0100" +Date: Fri, 23 Sep 2005 10:09:39 -0400 +Message-ID: <3465.1127484579@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/1005 +X-Sequence-Number: 73402 + +Simon Riggs writes: +> If not, I would propose that when we move from qsort to tapesort mode we +> free the larger work_mem setting (if one exists) and allocate only a +> lower, though still optimal setting for the tapesort. That way the +> memory can be freed for use by other users or the OS while the tapesort +> proceeds (which is usually quite a while...). + +On most platforms it's quite unlikely that any memory would actually get +released back to the OS before transaction end, because the memory +blocks belonging to the tuplesort context will be intermixed with blocks +belonging to other contexts. So I think this is pretty pointless. +(If you can't afford to have the sort using all of sort_mem, you've set +sort_mem too large, anyway.) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Sep 23 11:19:48 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 434A1D9161 + for ; + Fri, 23 Sep 2005 11:19:39 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 78095-06 + for ; + Fri, 23 Sep 2005 14:19:34 +0000 (GMT) +Received: from wolff.to (wolff.to [66.93.197.194]) + by svr1.postgresql.org (Postfix) with SMTP id CDC2AD9117 + for ; + Fri, 23 Sep 2005 11:19:36 -0300 (ADT) +Received: (qmail 6406 invoked by uid 500); 23 Sep 2005 14:20:27 -0000 +Date: Fri, 23 Sep 2005 09:20:27 -0500 +From: Bruno Wolff III +To: Markus Benne +Cc: pgsql-performance@postgresql.org +Subject: Re: VACUUM FULL vs CLUSTER +Message-ID: <20050923142027.GC2298@wolff.to> +Mail-Followup-To: Bruno Wolff III , + Markus Benne , pgsql-performance@postgresql.org +References: <5.2.0.9.1.20050920144041.0287c300@pop.puc.cl> + <1127242399.26562.15.camel@host-140.engineering.n-able.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1127242399.26562.15.camel@host-140.engineering.n-able.com> +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/294 +X-Sequence-Number: 14602 + +On Tue, Sep 20, 2005 at 14:53:19 -0400, + Markus Benne wrote: +> I have a table that is purged by 25% each night. I'd like to do a +> vacuum nightly after the purge to reclaim the space, but I think I'll +> still need to do a vacuum full weekly. +> +> Would there be any benefit to doing a cluster instead of the vacuum? + +If you have a proper FSM setting you shouldn't need to do vacuum fulls +(unless you have an older version of postgres where index bloat might +be an issue). + +From pgsql-performance-owner@postgresql.org Fri Sep 23 11:33:09 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 157BAD9175 + for ; + Fri, 23 Sep 2005 11:33:08 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 84387-03 + for ; + Fri, 23 Sep 2005 14:33:03 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 1D41CD90EC + for ; + Fri, 23 Sep 2005 11:33:05 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j8NEX6aX003712; + Fri, 23 Sep 2005 10:33:06 -0400 (EDT) +To: Joost Kraaijeveld +Cc: Arjen van der Meijden , + Michael Stone , pgsql-performance@postgresql.org +Subject: Re: How to determine cause of performance problem? +In-reply-to: <1127482558.3524.23.camel@Panoramix> +References: <1127458167.2475.105.camel@Panoramix> + <20050923095517.GW14918@mathom.us> + <1127470875.3524.17.camel@Panoramix> + <20050923110500.GX14918@mathom.us> <4333E4DB.4020206@tweakers.net> + <1127482558.3524.23.camel@Panoramix> +Comments: In-reply-to Joost Kraaijeveld + message dated "Fri, 23 Sep 2005 15:35:58 +0200" +Date: Fri, 23 Sep 2005 10:33:06 -0400 +Message-ID: <3711.1127485986@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/295 +X-Sequence-Number: 14603 + +Joost Kraaijeveld writes: +> I will test this a for perfomance improvement, but still, I wonder if ~ +> 100 inserts/second is a reasonable performance for my software/hardware +> combination. + +Is the client code running on the same machine as the database server? +If not, what's the network delay and latency between them? + +The major problem you're going to have here is at least one network +round trip per row inserted --- possibly more, if the jdbc driver is +doing "helpful" stuff behind your back like starting/committing +transactions. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Sep 23 11:47:10 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7B896D9196 + for ; + Fri, 23 Sep 2005 11:47:09 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 88987-03 + for ; + Fri, 23 Sep 2005 14:47:00 +0000 (GMT) +Received: from obelix.askesis.nl (laudanum.demon.nl [82.161.125.16]) + by svr1.postgresql.org (Postfix) with ESMTP id 63623D709A + for ; + Fri, 23 Sep 2005 11:47:00 -0300 (ADT) +Received: obelix.askesis.nl 172.31.0.1 from 172.31.1.8 172.31.1.8 via HTTP + with MS-WebStorage 6.0.6249 +Received: from Panoramix by obelix.askesis.nl; 23 Sep 2005 16:47:04 +0200 +Subject: Re: How to determine cause of performance problem? +From: Joost Kraaijeveld +To: Tom Lane +Cc: Arjen van der Meijden , + Michael Stone , pgsql-performance@postgresql.org +In-Reply-To: <3711.1127485986@sss.pgh.pa.us> +References: <1127458167.2475.105.camel@Panoramix> + <20050923095517.GW14918@mathom.us> <1127470875.3524.17.camel@Panoramix> + <20050923110500.GX14918@mathom.us> <4333E4DB.4020206@tweakers.net> + <1127482558.3524.23.camel@Panoramix> <3711.1127485986@sss.pgh.pa.us> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Date: Fri, 23 Sep 2005 16:47:04 +0200 +Message-Id: <1127486824.3524.58.camel@Panoramix> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.4 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.092 required=5 tests=[AWL=0.042, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/296 +X-Sequence-Number: 14604 + +On Fri, 2005-09-23 at 10:33 -0400, Tom Lane wrote: +> Is the client code running on the same machine as the database server? +> If not, what's the network delay and latency between them? +Yes, it is running on the same machine. + + +> The major problem you're going to have here is at least one network +> round trip per row inserted --- possibly more, if the jdbc driver is +> doing "helpful" stuff behind your back like starting/committing +> transactions. +OK, I will look into that. + +But do you maybe know a pointer to info, or tools that can measure, what +my machine is doing during all the time it is doing nothing? Something +like the performance monitor in Windows but than for Linux? + +-- +Groeten, + +Joost Kraaijeveld +Askesis B.V. +Molukkenstraat 14 +6524NB Nijmegen +tel: 024-3888063 / 06-51855277 +fax: 024-3608416 +e-mail: J.Kraaijeveld@Askesis.nl +web: www.askesis.nl + + + +From pgsql-performance-owner@postgresql.org Fri Sep 23 11:50:40 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0A1C3D8F56 + for ; + Fri, 23 Sep 2005 11:50:38 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 86528-09 + for ; + Fri, 23 Sep 2005 14:50:32 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 439EAD90EB + for ; + Fri, 23 Sep 2005 11:50:33 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j8NEoZuh003904; + Fri, 23 Sep 2005 10:50:35 -0400 (EDT) +To: Joost Kraaijeveld +Cc: Arjen van der Meijden , + Michael Stone , pgsql-performance@postgresql.org +Subject: Re: How to determine cause of performance problem? +In-reply-to: <1127486824.3524.58.camel@Panoramix> +References: <1127458167.2475.105.camel@Panoramix> + <20050923095517.GW14918@mathom.us> + <1127470875.3524.17.camel@Panoramix> + <20050923110500.GX14918@mathom.us> <4333E4DB.4020206@tweakers.net> + <1127482558.3524.23.camel@Panoramix> + <3711.1127485986@sss.pgh.pa.us> + <1127486824.3524.58.camel@Panoramix> +Comments: In-reply-to Joost Kraaijeveld + message dated "Fri, 23 Sep 2005 16:47:04 +0200" +Date: Fri, 23 Sep 2005 10:50:35 -0400 +Message-ID: <3903.1127487035@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/297 +X-Sequence-Number: 14605 + +Joost Kraaijeveld writes: +> But do you maybe know a pointer to info, or tools that can measure, what +> my machine is doing during all the time it is doing nothing? Something +> like the performance monitor in Windows but than for Linux? + +top, vmstat, iostat, sar, strace, oprofile, ... + + regards, tom lane + +From pgsql-hackers-owner@postgresql.org Fri Sep 23 12:07:04 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1E346D919E; + Fri, 23 Sep 2005 12:06:29 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 90509-08; Fri, 23 Sep 2005 15:06:22 +0000 (GMT) +Received: from smtp3.freeserve.com (smtp3.wanadoo.co.uk [193.252.22.156]) + by svr1.postgresql.org (Postfix) with ESMTP id 527B8D709A; + Fri, 23 Sep 2005 12:06:21 -0300 (ADT) +Received: from me-wanadoo.net (localhost [127.0.0.1]) + by mwinf3208.me.freeserve.com (SMTP Server) with ESMTP id E5CEA7400092; + Fri, 23 Sep 2005 17:06:16 +0200 (CEST) +Received: from 192.168.0.102 (modem-3183.leopard.dialup.pol.co.uk + [217.135.156.111]) + by mwinf3208.me.freeserve.com (SMTP Server) with ESMTP id 3D3B9740008F; + Fri, 23 Sep 2005 17:06:16 +0200 (CEST) +X-ME-UUID: 20050923150616250.3D3B9740008F@mwinf3208.me.freeserve.com +Subject: Re: Releasing memory during External sorting? +From: Simon Riggs +To: Tom Lane +Cc: pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org +In-Reply-To: <3465.1127484579@sss.pgh.pa.us> +References: <1127468233.4145.178.camel@localhost.localdomain> + <3465.1127484579@sss.pgh.pa.us> +Content-Type: text/plain +Organization: 2nd Quadrant +Date: Fri, 23 Sep 2005 16:06:18 +0100 +Message-Id: <1127487978.19345.43.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-3) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.052 required=5 tests=[AWL=0.002, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/1015 +X-Sequence-Number: 73412 + +On Fri, 2005-09-23 at 10:09 -0400, Tom Lane wrote: +> Simon Riggs writes: +> > If not, I would propose that when we move from qsort to tapesort mode we +> > free the larger work_mem setting (if one exists) and allocate only a +> > lower, though still optimal setting for the tapesort. That way the +> > memory can be freed for use by other users or the OS while the tapesort +> > proceeds (which is usually quite a while...). +> +> On most platforms it's quite unlikely that any memory would actually get +> released back to the OS before transaction end, because the memory +> blocks belonging to the tuplesort context will be intermixed with blocks +> belonging to other contexts. So I think this is pretty pointless. + +I take it you mean pointless because of the way the memory allocation +works, rather than because giving memory back isn't worthwhile ? + +Surely the sort memory would be allocated in contiguous chunks? In some +cases we might be talking about more than a GB of memory, so it'd be +good to get that back ASAP. I'm speculating.... + +> (If you can't afford to have the sort using all of sort_mem, you've set +> sort_mem too large, anyway.) + +Sort takes care to allocate only what it needs as starts up. All I'm +suggesting is to take the same care when the sort mode changes. If the +above argument held water then we would just allocate all the memory in +one lump at startup, "because we can afford to", so I don't buy that. + +Since we know the predicted size of the sort set prior to starting the +sort node, could we not use that information to allocate memory +appropriately? i.e. if sort size is predicted to be more than twice the +size of work_mem, then just move straight to the external sort algorithm +and set the work_mem down at the lower limit? + +That is, unless somebody has evidence that having a very large memory +has any performance benefit for external sorting? + +Best Regards, Simon Riggs + + + + + +From pgsql-performance-owner@postgresql.org Fri Sep 23 12:08:44 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A7FFBD919E + for ; + Fri, 23 Sep 2005 12:08:40 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 94398-02 + for ; + Fri, 23 Sep 2005 15:08:37 +0000 (GMT) +Received: from imsm057dat.netvigator.com (imsm057.netvigator.com + [218.102.48.210]) + by svr1.postgresql.org (Postfix) with ESMTP id 25403D928F + for ; + Fri, 23 Sep 2005 12:08:35 -0300 (ADT) +Received: from n2.netvigator.com ([218.102.147.167]) + by imsm057dat.netvigator.com + (InterMail vM.6.01.05.02 201-2131-123-102-20050715) with ESMTP id + <20050923150833.CYWO10762.imsm057dat.netvigator.com@n2.netvigator.com>; + Fri, 23 Sep 2005 23:08:33 +0800 +Message-Id: <6.2.1.2.0.20050923224328.05897fa0@localhost> +X-Mailer: QUALCOMM Windows Eudora Version 6.2.1.2 +Date: Fri, 23 Sep 2005 23:08:20 +0800 +To: "Merlin Moncure" +From: K C Lau +Subject: Re: SELECT LIMIT 1 VIEW Performance Issue +Cc: +In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB3417DD41B@Herge.rcsinc.local> +References: <6EE64EF3AB31D5448D0007DD34EEB3417DD41B@Herge.rcsinc.local> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.533 required=5 tests=[AWL=-0.359, + DNS_FROM_RFC_POST=1.376, FROM_ENDS_IN_NUMS=0.516] +X-Spam-Level: * +X-Archive-Number: 200509/299 +X-Sequence-Number: 14607 + +Dear Merlin, + +At 20:34 05/09/23, Merlin Moncure wrote: +>Can you time just the execution of this function and compare vs. pure +>SQL version? If the times are different, can you do a exaplain analyze +>of a prepared version of above? + +esdt=> prepare test(character varying) as select atdate from player where +esdt-> playerid = $1 order by playerid desc, AtDate desc limit 1; +PREPARE +esdt=> explain analyze execute test('22220'); + Limit (cost=0.00..0.83 rows=1 width=23) (actual time=0.032..0.033 rows=1 +loops=1) + -> Index Scan Backward using pk_player on player (cost=0.00..970.53 +rows=1166 width=23) (actual time=0.027..0.027 rows=1 loops=1) + Index Cond: ((playerid)::text = ($1)::text) + Total runtime: 0.088 ms + +The prepared SQL timing is similar to that of a direct SQL. + +> > esdt=> create or replace view VCurPlayer3 as select * from Player where +> > AtDate = player_max_atdate(PlayerID); +> +>This is wrong, it should have been +>create or replace view VCurPlayer3 as select *, +>player_max_atdate(PlayerID) as max_date from Player; + +Your suggestion returns all the records plus a max AtDate column for each +PlayerID. +What I want to get with the view is the record that has the max value of +AtDate for each PlayerID. +The AtDate is a varchar(23) field containing a string date of format +'yyyymmddhh', not the SQL Date field. Sorry if that confused you. + +>Something is not jiving here. However, if the server plan still does +>not come out correct, try the following (p.s. why is function returning +>varchar(32) and not date?): + +esdt=> create or replace function player_max_atdate (varchar(32)) returns +varchar(32) as $$ +esdt$> DECLARE +esdt$> player_record record; +esdt$> return_date varchar(32); +esdt$> BEGIN +esdt$> for player_record in execute +esdt$> 'select atdate from player where playerid = \'' || $1 || +'\' order by playerid desc, AtDate desc limit 1;' loop +esdt$> return_date = player_record.atdate; +esdt$> end loop; +esdt$> return return_date; +esdt$> END; +esdt$> $$ language plpgsql immutable; +CREATE FUNCTION +esdt=> create or replace view VCurPlayer3 as select * from Player where +AtDate = player_max_atdate(PlayerID); +CREATE VIEW +esdt=> explain analyze select PlayerID,AtDate from VCurPlayer3 where +PlayerID='22220'; + + Index Scan using pk_player on player (cost=0.00..1331.83 rows=9 +width=23) (actual time=849.021..849.025 rows=1 loops=1) + Index Cond: ((playerid)::text = '22220'::text) + Filter: ((atdate)::text = (player_max_atdate(playerid))::text) + Total runtime: 849.078 ms + +Your suggested plpgsql function seems to be even slower, with a best time +of 849 ms after several tries. Is that expected? + +Thanks again and best regards, +KC. + + +From pgsql-performance-owner@postgresql.org Fri Sep 23 12:31:33 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4AEACD92CC + for ; + Fri, 23 Sep 2005 12:31:31 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 00171-01 + for ; + Fri, 23 Sep 2005 15:31:21 +0000 (GMT) +Received: from vms044pub.verizon.net (vms044pub.verizon.net [206.46.252.44]) + by svr1.postgresql.org (Postfix) with ESMTP id 2E0B0D9298 + for ; + Fri, 23 Sep 2005 12:31:19 -0300 (ADT) +Received: from osgiliath.mathom.us ([70.108.61.78]) + by vms044.mailsrvcs.net (Sun Java System Messaging Server 6.2 HotFix + 0.04 (built Dec 24 2004)) with ESMTPA id + <0INA000TT0G68MC0@vms044.mailsrvcs.net> for + pgsql-performance@postgresql.org; Fri, 23 Sep 2005 10:31:19 -0500 (CDT) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id A396C637C2A for + ; + Fri, 23 Sep 2005 11:31:18 -0400 (EDT) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 16449-02-8 for ; Fri, + 23 Sep 2005 11:31:18 -0400 (EDT) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id 85AC3637C28; Fri, 23 Sep 2005 11:31:18 -0400 (EDT) +Date: Fri, 23 Sep 2005 11:31:18 -0400 +From: Michael Stone +Subject: Re: How to determine cause of performance problem? +In-reply-to: <1127483365.3524.36.camel@Panoramix> +To: pgsql-performance@postgresql.org +Mail-Followup-To: pgsql-performance@postgresql.org +Message-id: <20050923153118.GB14918@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: by amavisd-new-20030616-p10 (Debian) at mathom.us +References: <1127458167.2475.105.camel@Panoramix> + <20050923095517.GW14918@mathom.us> <1127470875.3524.17.camel@Panoramix> + <20050923110500.GX14918@mathom.us> <1127483365.3524.36.camel@Panoramix> +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.004 required=5 tests=[AWL=0.004] +X-Spam-Level: +X-Archive-Number: 200509/300 +X-Sequence-Number: 14608 + +On Fri, Sep 23, 2005 at 03:49:25PM +0200, Joost Kraaijeveld wrote: +>On Fri, 2005-09-23 at 07:05 -0400, Michael Stone wrote: +>> Ok, that's great, but you didn't respond to the suggestion of using COPY +>> INTO instead of INSERT. +>Part of the code I left out are some data conversions (e.g. from +>path-to-file to blob, from text to date (not castable because of the +>homebrew original format)). I don't believe that I can do these in a SQL +>statement, can I (my knowledge of SQL as a langage is not that good)? . +>However I will investigate if I can do the conversion in two steps and +>check if it is faster. + +I'm not sure what you're trying to say. + +You're currently putting rows into the table by calling "INSERT INTO" +for each row. The sample code you send could be rewritten to use "COPY +INTO" instead. For bulk inserts like you're doing, the copy approach +will be a lot faster. Instead of inserting one row, waiting for a +reply, and inserting the next row, you just cram data down a pipe to the +server. + +See: +http://www.postgresql.org/docs/8.0/interactive/sql-copy.html +http://www.faqs.org/docs/ppbook/x5504.htm + +Mike Stone + +From pgsql-hackers-owner@postgresql.org Fri Sep 23 12:31:42 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B27BDD90CA; + Fri, 23 Sep 2005 12:31:39 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 00171-02; Fri, 23 Sep 2005 15:31:33 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 252C7D92E1; + Fri, 23 Sep 2005 12:31:32 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j8NFVSNg004203; + Fri, 23 Sep 2005 11:31:28 -0400 (EDT) +To: Simon Riggs +Cc: pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: Releasing memory during External sorting? +In-reply-to: <1127487978.19345.43.camel@localhost.localdomain> +References: <1127468233.4145.178.camel@localhost.localdomain> + <3465.1127484579@sss.pgh.pa.us> + <1127487978.19345.43.camel@localhost.localdomain> +Comments: In-reply-to Simon Riggs + message dated "Fri, 23 Sep 2005 16:06:18 +0100" +Date: Fri, 23 Sep 2005 11:31:28 -0400 +Message-ID: <4202.1127489488@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/1016 +X-Sequence-Number: 73413 + +Simon Riggs writes: +> Since we know the predicted size of the sort set prior to starting the +> sort node, could we not use that information to allocate memory +> appropriately? i.e. if sort size is predicted to be more than twice the +> size of work_mem, then just move straight to the external sort algorithm +> and set the work_mem down at the lower limit? + +Have you actually read the sort code? + +During the run-forming phase it's definitely useful to eat all the +memory you can: that translates directly to longer initial runs and +hence fewer merge passes. During the run-merging phase it's possible +that using less memory would not hurt performance any, but as already +stated, I don't think it will actually end up cutting the backend's +memory footprint --- the sbrk point will be established during the run +forming phase and it's unlikely to move back much until transaction end. + +Also, if I recall the development of that code correctly, the reason for +using more than minimum memory during the merge phase is that writing or +reading lots of tuples at once improves sequentiality of access to the +temp files. So I'm not sure that cutting down the memory wouldn't hurt +performance. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Sep 23 13:02:37 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 31758D9286 + for ; + Fri, 23 Sep 2005 13:02:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 06406-05 + for ; + Fri, 23 Sep 2005 16:02:32 +0000 (GMT) +Received: from vt-pe2550-001.VANTAGE.vantage.com (unknown [64.80.203.244]) + by svr1.postgresql.org (Postfix) with ESMTP id 0C1F6D9227 + for ; + Fri, 23 Sep 2005 13:02:30 -0300 (ADT) +X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C5C058.32EA7B4A" +Subject: slow database, queries accumulating +Date: Fri, 23 Sep 2005 12:02:29 -0400 +Message-ID: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF785026FFDE1@vt-pe2550-001.vantage.vantage.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: slow database, queries accumulating +Thread-Index: AcXAWDLxpjMuu4hfS4izP1AHnxQZPw== +From: "Anjan Dave" +To: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.031 required=5 tests=[AWL=0.030, HTML_MESSAGE=0.001] +X-Spam-Level: +X-Archive-Number: 200509/302 +X-Sequence-Number: 14610 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C5C058.32EA7B4A +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + +Hi + +=20 + +We are experiencing consistent slowness on the database for one +application. This is more a reporting type of application, heavy on the +bytea data type usage (gets rendered into PDFs in the app server). A lot +of queries, mostly selects and a few random updates, get accumulated on +the server - with increasing volume of users on the application. Below +is a snapshot of top, with about 80 selects and 3 or 4 updates. Things +get better eventually if I cancel (SIGINT) some of the oldest queries. I +also see a few instances of shared locks not being granted during this +time...I don't even see high iowait or memory starvation during these +times, as indicated by top. + +=20 + +-bash-2.05b$ psql -c "select * from pg_locks;" dbname | grep f + + | | 77922136 | 16761 | ShareLock | f + +=20 + +=20 + +=20 + +We (development) are looking into the query optimization (explain +analyze, indexes, etc), and my understanding is that the queries when +run for explain analyze execute fast, but during busy times, they become +quite slow, taking from a few seconds to a few minutes to execute. I do +see in the log that almost all queries do have either ORDER BY, or GROUP +BY, or DISTINCT. Does it hurt to up the sort_mem to 3MB or 4MB? Should I +up the effective_cache_size to 5 or 6GB? The app is does not need a lot +of connections on the database, I can reduce it down from 600. + +=20 + +Based on the description above and the configuration below does any +thing appear bad in config? Is there anything I can try in the +configuration to improve performance? + +=20 + +=20 + +The database size is about 4GB.=20 + +This is PG 7.4.7, RHAS3.0 (u5), Local 4 spindle RAID10 (15KRPM), and +logs on a separate set of drives, RAID10. 6650 server, 4 x XEON, 12GB +RAM. + +Vacuum is done every night, full vacuum done once a week. + +I had increased the shared_buffers and sort_memory recently, which +didn't help. + +=20 + +Thanks, +Anjan + +=20 + +=20 + +=20 + +=20 + +10:44:51 up 14 days, 13:38, 2 users, load average: 0.98, 1.14, 1.12 + +264 processes: 257 sleeping, 7 running, 0 zombie, 0 stopped + +CPU states: cpu user nice system irq softirq iowait idle + + total 14.4% 0.0% 7.4% 0.0% 0.0% 0.0% 77.9% + + cpu00 15.7% 0.0% 5.7% 0.0% 0.1% 0.0% 78.2% + + cpu01 15.1% 0.0% 7.5% 0.0% 0.0% 0.1% 77.0% + + cpu02 10.5% 0.0% 5.9% 0.0% 0.0% 0.0% 83.4% + + cpu03 9.9% 0.0% 5.9% 0.0% 0.0% 0.0% 84.0% + + cpu04 7.9% 0.0% 3.7% 0.0% 0.0% 0.0% 88.2% + + cpu05 19.3% 0.0% 12.3% 0.0% 0.0% 0.0% 68.3% + + cpu06 20.5% 0.0% 9.5% 0.0% 0.0% 0.1% 69.7% + + cpu07 16.1% 0.0% 8.5% 0.0% 0.1% 0.3% 74.7% + +Mem: 12081736k av, 7881972k used, 4199764k free, 0k shrd, +82372k buff + + 4823496k actv, 2066260k in_d, 2036k in_c + +Swap: 4096532k av, 0k used, 4096532k free 6888900k +cached + +=20 + + PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME CPU +COMMAND + +16773 postgres 15 0 245M 245M 240M S 0.0 2.0 1:16 7 +postmaster + +16880 postgres 15 0 245M 245M 240M S 0.1 2.0 0:49 6 +postmaster + +16765 postgres 15 0 245M 245M 240M S 0.0 2.0 1:16 0 +postmaster + +16825 postgres 15 0 245M 245M 240M S 0.0 2.0 1:02 5 +postmaster + +16774 postgres 15 0 245M 245M 240M S 0.1 2.0 1:16 0 +postmaster + +16748 postgres 15 0 245M 245M 240M S 0.0 2.0 1:19 5 +postmaster + +16881 postgres 15 0 245M 245M 240M S 0.1 2.0 0:50 7 +postmaster + +16762 postgres 15 0 245M 245M 240M S 0.0 2.0 1:14 4 +postmaster + +... + +... + +=20 + +=20 + +max_connections =3D 600 + +=20 + +shared_buffers =3D 30000 #=3D234MB, up from 21760=3D170MB min 16, at = +least +max_connections*2, 8KB each + +sort_mem =3D 2048 # min 64, size in KB + +vacuum_mem =3D 32768 # up from 16384 min 1024, size in KB + +=20 + +# - Free Space Map - + +=20 + +#max_fsm_pages =3D 20000 # min max_fsm_relations*16, 6 bytes = +each + +#max_fsm_relations =3D 1000 # min 100, ~50 bytes each + +=20 + +#fsync =3D true # turns forced synchronization on or = +off + +#wal_sync_method =3D fsync # the default varies across platforms: + + # fsync, fdatasync, open_sync, or +open_datasync + +#wal_buffers =3D 8 # min 4, 8KB each + +=20 + +# - Checkpoints - + +=20 + +checkpoint_segments =3D 125 # in logfile segments, min 1, 16MB = +each + +checkpoint_timeout =3D 600 # range 30-3600, in seconds + +#checkpoint_warning =3D 30 # 0 is off, in seconds + +#commit_delay =3D 0 # range 0-100000, in microseconds + +#commit_siblings =3D 5 # range 1-1000 + +=20 + +=20 + +=20 + +# - Planner Method Enabling - + +=20 + +#enable_hashagg =3D true + +#enable_hashjoin =3D true + +#enable_indexscan =3D true + +#enable_mergejoin =3D true + +#enable_nestloop =3D true + +#enable_seqscan =3D true + +#enable_sort =3D true + +#enable_tidscan =3D true + +=20 + +# - Planner Cost Constants - + +=20 + +effective_cache_size =3D 262144 # =3D2GB typically 8KB each + +#random_page_cost =3D 4 # units are one sequential page fetch +cost + +#cpu_tuple_cost =3D 0.01 # (same) + +#cpu_index_tuple_cost =3D 0.001 # (same) + +#cpu_operator_cost =3D 0.0025 # (same) + +=20 + +# - Genetic Query Optimizer - + +=20 + +#geqo =3D true + +#geqo_threshold =3D 11 + +#geqo_effort =3D 1 + +#geqo_generations =3D 0 + +#geqo_pool_size =3D 0 # default based on tables in = +statement, + + # range 128-1024 + +#geqo_selection_bias =3D 2.0 # range 1.5-2.0 + +=20 + +# - Other Planner Options - + +=20 + +#default_statistics_target =3D 10 # range 1-1000 + +#from_collapse_limit =3D 8 + +#join_collapse_limit =3D 8 # 1 disables collapsing of explicit +JOINs + +=20 + +=20 + + +------_=_NextPart_001_01C5C058.32EA7B4A +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + +
+ +

Hi

+ +

 

+ +

We are experiencing consistent slowness on the = +database for +one application. This is more a reporting type of application, heavy on = +the +bytea data type usage (gets rendered into PDFs in the app server). A lot = +of +queries, mostly selects and a few random updates, get accumulated on the = +server +– with increasing volume of users on the application. Below is a = +snapshot +of top, with about 80 selects and 3 or 4 updates. Things get better = +eventually if +I cancel (SIGINT) some of the oldest queries. I also see a few instances = +of +shared locks not being granted during this time…I don’t even = +see high +iowait or memory starvation during these times, as indicated by = +top.

+ +

 

+ +

-bash-2.05b$ psql -c "select * from = +pg_locks;" dbname +| grep f

+ +

         = + |          = +|    77922136 | 16761 | +ShareLock        | = +f

+ +

 

+ +

 

+ +

 

+ +

We (development) are looking into the query = +optimization +(explain analyze, indexes, etc), and my understanding is that the = +queries when +run for explain analyze execute fast, but during busy times, they become = +quite +slow, taking from a few seconds to a few minutes to execute. I do see in = +the +log that almost all queries do have either ORDER BY, or GROUP BY, or = +DISTINCT. +Does it hurt to up the sort_mem to 3MB or 4MB? Should I up the +effective_cache_size to 5 or 6GB? The app is does not need a lot of = +connections +on the database, I can reduce it down from = +600.

+ +

 

+ +

Based on the description above and the configuration = +below +does any thing appear bad in config? Is there anything I can try in the +configuration to improve performance?

+ +

 

+ +

 

+ +

The database size is about 4GB. = +

+ +

This is PG 7.4.7, RHAS3.0 (u5), Local 4 spindle = +RAID10 +(15KRPM), and logs on a separate set of drives, RAID10. 6650 server, 4 x = +XEON, +12GB RAM.

+ +

Vacuum is done every night, full vacuum done once a = +week.

+ +

I had increased the shared_buffers and sort_memory = +recently, +which didn’t help.

+ +

 

+ +

Thanks,
+Anjan

+ +

 

+ +

 

+ +

 

+ +

 

+ +

10:44:51  up 14 days, 13:38,  2 = +users,  load average: 0.98, +1.14, 1.12

+ +

264 processes: 257 sleeping, 7 running, 0 zombie, 0 = +stopped

+ +

CPU states:  cpu    = +user    nice  system    irq  = +softirq  +iowait    idle

+ +

    = +       total   = +14.4%    0.0%    7.4%   = +0.0%     0.0%    +0.0%   77.9%

+ +

         = +  cpu00   15.7%    0.0%    = +5.7%   0.0%     0.1%    +0.0%   78.2%

+ +

         = +  cpu01   15.1%    0.0%    = +7.5%   0.0%     0.0%    +0.1%   77.0%

+ +

         = +  cpu02   10.5%    0.0%    = +5.9%   0.0%     0.0%    +0.0%   83.4%

+ +

         = +  cpu03    9.9%    = +0.0%    5.9%   0.0%     = +0.0%    +0.0%   84.0%

+ +

         = +  cpu04    7.9%    = +0.0%    3.7%   0.0%     = +0.0%    +0.0%   88.2%

+ +

         = +  cpu05   19.3%    0.0%   = +12.3%   0.0%     0.0%    +0.0%   68.3%

+ +

     = +      cpu06   = +20.5%    0.0%    9.5%   = +0.0%     0.0%    +0.1%   69.7%

+ +

         = +  cpu07   16.1%    0.0%    = +8.5%   0.0%     0.1%    +0.3%   74.7%

+ +

Mem:  12081736k av, 7881972k used, 4199764k = +free,       0k +shrd,   82372k buff

+ +

         = +          4823496k actv, = +2066260k in_d,    2036k +in_c

+ +

Swap: 4096532k = +av,       0k used, 4096532k +free           &nb= +sp;     6888900k cached

+ +

 

+ +

  PID USER     PRI  = +NI  SIZE  RSS SHARE STAT %CPU %MEM   +TIME CPU COMMAND

+ +

16773 postgres  15   0  245M = +245M  240M S     0.0  2.0   +1:16   7 postmaster

+ +

16880 postgres  15   0  245M = +245M  240M S     0.1  2.0   +0:49   6 postmaster

+ +

16765 postgres  15   0  245M = +245M  240M S     0.0  2.0   +1:16   0 postmaster

+ +

16825 postgres  15   0  245M = +245M  240M S     0.0  2.0   +1:02   5 postmaster

+ +

16774 postgres  15   0  245M = +245M  240M S     0.1  2.0   +1:16   0 postmaster

+ +

16748 postgres  15   0  245M = +245M  240M S     0.0  2.0   +1:19   5 postmaster

+ +

16881 postgres  15   0  245M = +245M  240M S     0.1  2.0   +0:50   7 postmaster

+ +

16762 postgres  15   0  245M = +245M  240M S     0.0  2.0   +1:14   4 postmaster

+ +

+ +

+ +

 

+ +

 

+ +

max_connections =3D 600

+ +

 

+ +

shared_buffers =3D 30000  #=3D234MB, up from = +21760=3D170MB min 16, +at least max_connections*2, 8KB each

+ +

sort_mem =3D = +2048         # min 64, size in = +KB

+ +

vacuum_mem =3D = +32768           &n= +bsp;  # up from 16384 min 1024, +size in KB

+ +

 

+ +

# - Free Space Map -

+ +

 

+ +

#max_fsm_pages =3D = +20000          # min = +max_fsm_relations*16, +6 bytes each

+ +

#max_fsm_relations =3D = +1000       # min 100, ~50 bytes = +each

+ +

 

+ +

#fsync =3D = +true           &nb= +sp;       # turns forced +synchronization on or off

+ +

#wal_sync_method =3D = +fsync        # the default varies = +across +platforms:

+ +

         = +            &= +nbsp;          # fsync, = +fdatasync, +open_sync, or open_datasync

+ +

#wal_buffers =3D = +8            = +    # min 4, 8KB each

+ +

 

+ +

# - Checkpoints -

+ +

 

+ +

checkpoint_segments =3D = +125       # in logfile segments, min +1, 16MB each

+ +

checkpoint_timeout =3D = +600        # range 30-3600, in = +seconds

+ +

#checkpoint_warning =3D = +30        # 0 is off, in = +seconds

+ +

#commit_delay =3D = +0            = +   # range 0-100000, in +microseconds

+ +

#commit_siblings =3D = +5            # = +range 1-1000

+ +

 

+ +

 

+ +

 

+ +

# - Planner Method Enabling = +-

+ +

 

+ +

#enable_hashagg =3D true

+ +

#enable_hashjoin =3D = +true

+ +

#enable_indexscan =3D = +true

+ +

#enable_mergejoin =3D = +true

+ +

#enable_nestloop =3D = +true

+ +

#enable_seqscan =3D true

+ +

#enable_sort =3D true

+ +

#enable_tidscan =3D true

+ +

 

+ +

# - Planner Cost Constants = +-

+ +

 

+ +

effective_cache_size =3D 262144   # =3D2GB = +typically 8KB each

+ +

#random_page_cost =3D = +4           # units = +are one sequential +page fetch cost

+ +

#cpu_tuple_cost =3D = +0.01          # = +(same)

+ +

#cpu_index_tuple_cost =3D 0.001   # = +(same)

+ +

#cpu_operator_cost =3D 0.0025     = +# (same)

+ +

 

+ +

# - Genetic Query Optimizer = +-

+ +

 

+ +

#geqo =3D true

+ +

#geqo_threshold =3D 11

+ +

#geqo_effort =3D 1

+ +

#geqo_generations =3D 0

+ +

#geqo_pool_size =3D = +0            = + # default based on tables in +statement,

+ +

         = +            &= +nbsp;          # range = +128-1024

+ +

#geqo_selection_bias =3D 2.0    = +  # range 1.5-2.0

+ +

 

+ +

# - Other Planner Options = +-

+ +

 

+ +

#default_statistics_target =3D 10 # range = +1-1000

+ +

#from_collapse_limit =3D = +8

+ +

#join_collapse_limit =3D = +8        # 1 disables collapsing of +explicit JOINs

+ +

 

+ +

 

+ +
+ + + + + +------_=_NextPart_001_01C5C058.32EA7B4A-- + +From pgsql-performance-owner@postgresql.org Fri Sep 23 13:16:58 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9301ED923D + for ; + Fri, 23 Sep 2005 13:16:54 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 11095-07 + for ; + Fri, 23 Sep 2005 16:16:51 +0000 (GMT) +Received: from ucsns.ucs.co.za (ucsns.ucs.co.za [196.23.43.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 24D62D8D77 + for ; + Fri, 23 Sep 2005 13:16:48 -0300 (ADT) +Received: from ucspost.ucs.co.za (mailgw1.ucs.co.za [196.23.43.253]) + by ucsns.ucs.co.za (Postfix) with ESMTP id 4A6552BD50; + Fri, 23 Sep 2005 18:16:45 +0200 (SAST) +Received: from jhb.ucs.co.za (jhb.ucs.co.za [172.31.1.3]) + by ucspost.ucs.co.za (Postfix) with ESMTP id 570D3D9DAA; + Fri, 23 Sep 2005 18:16:45 +0200 (SAST) +Received: from svb.ucs.co.za (svb.ucs.co.za [172.31.1.148]) + by jhb.ucs.co.za (Postfix) with ESMTP id 0AAB1977C4; + Fri, 23 Sep 2005 18:16:45 +0200 (SAST) +Date: Fri, 23 Sep 2005 18:16:44 +0200 +From: Stef +To: Bruno Wolff III +Cc: Markus Benne , + pgsql-performance@postgresql.org +Subject: Re: VACUUM FULL vs CLUSTER +Message-ID: <20050923181644.161bf160@svb.ucs.co.za> +In-Reply-To: <20050923142027.GC2298@wolff.to> +References: <5.2.0.9.1.20050920144041.0287c300@pop.puc.cl> + <1127242399.26562.15.camel@host-140.engineering.n-able.com> + <20050923142027.GC2298@wolff.to> +X-Mailer: Sylpheed-Claws 1.9.6cvs1 (GTK+ 2.6.9; i486-pc-linux-gnu) +User-Agent: sillypheed-claws (anti-aliased) +X-Face: +lU/o'$=Zv9%Xjo]Kq[_{n&Kb`f{YEWH4&Y#M]'6BkD?VoWe#*@S\MWyD'I>s:0v4{#\[J]l*?]t2uaO(j$d*77Ca-UHo.tkl2)0$B3Jxww\o:xor]<:*Yfx9Vceh)9I/'2g\RKhGTxIIsR^ke^`LVeZ9ksb*:$kQeR@ +X-Operating-System: sid +X-X-X: _-^-_ +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.16 required=5 tests=[AWL=0.160] +X-Spam-Level: +X-Archive-Number: 200509/303 +X-Sequence-Number: 14611 + +Bruno Wolff III mentioned : +=> If you have a proper FSM setting you shouldn't need to do vacuum fulls +=> (unless you have an older version of postgres where index bloat might +=> be an issue). + +What version of postgres was the last version that had +the index bloat problem? + +From pgsql-hackers-owner@postgresql.org Fri Sep 23 13:40:29 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6CC3AD916E + for ; + Fri, 23 Sep 2005 13:40:19 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 15482-09 + for ; + Fri, 23 Sep 2005 16:40:14 +0000 (GMT) +Received: from mail.rilk.com (mail.rilk.com [193.19.217.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 5DB23D8F59 + for ; + Fri, 23 Sep 2005 13:40:13 -0300 (ADT) +Received: from [193.248.185.37] (Mix-St-Amand-106-3-37.w193-248.abo.wanadoo.fr + [193.248.185.37]) (authenticated bits=0) + by mail.rilk.com (8.13.0/8.13.0) with ESMTP id j8NGdgrj008577 + (version=TLSv1/SSLv3 cipher=EDH-DSS-DES-CBC3-SHA bits=168 verify=NO); + Fri, 23 Sep 2005 18:40:06 +0200 (CEST) +In-Reply-To: <3465.1127484579@sss.pgh.pa.us> +References: <1127468233.4145.178.camel@localhost.localdomain> + <3465.1127484579@sss.pgh.pa.us> +Mime-Version: 1.0 (Apple Message framework v734) +Content-Type: text/plain; charset=ISO-8859-1; delsp=yes; format=flowed +Message-Id: +Cc: Tom Lane +Content-Transfer-Encoding: quoted-printable +From: Pailloncy Jean-Gerard +Subject: Re: Releasing memory during External sorting? +Date: Fri, 23 Sep 2005 18:39:35 +0200 +To: Pg Hackers +X-Mailer: Apple Mail (2.734) +X-DCC-CTc-dcc2-Metrics: mail.rilk.com 1031; Body=2 Fuz1=2 Fuz2=2 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/1018 +X-Sequence-Number: 73415 + +> On most platforms it's quite unlikely that any memory would =20 +> actually get +> released back to the OS before transaction end, because the memory +> blocks belonging to the tuplesort context will be intermixed with =20 +> blocks +> belonging to other contexts. So I think this is pretty pointless. +> (If you can't afford to have the sort using all of sort_mem, you've =20= + +> set +> sort_mem too large, anyway.) +On OpenBSD 3.8 malloc use mmap(2) and no more sbrk. +So, as soon as the bloc is free, it returns to the OS. +Access to the freed pointer crashs immediatly. + +Cordialement, +Jean-G=E9rard Pailloncy + + +From pgsql-performance-owner@postgresql.org Fri Sep 23 13:36:07 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AD7A0D929B + for ; + Fri, 23 Sep 2005 13:36:04 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 15145-04 + for ; + Fri, 23 Sep 2005 16:35:55 +0000 (GMT) +Received: from ki-communication.com (unknown [202.147.194.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 7B1C2D9227 + for ; + Fri, 23 Sep 2005 13:35:46 -0300 (ADT) +Received: from iacn01wks ([192.168.0.128]) by ki-communication.com with + Microsoft SMTPSVC(6.0.3790.1830); Fri, 23 Sep 2005 23:40:04 +0700 +From: "Ahmad Fajar" +To: "'Oleg Bartunov'" +Cc: +Subject: Re: tsearch2 seem very slow +Date: Fri, 23 Sep 2005 23:40:05 +0700 +Keywords: Postgresql +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Mailer: Microsoft Office Outlook, Build 11.0.6353 +In-Reply-To: +Thread-Index: AcXAMYlWO2K/kTWZSkWioTkW/d5q9wAIfSYw +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +Message-ID: +X-OriginalArrivalTime: 23 Sep 2005 16:40:04.0156 (UTC) + FILETIME=[72DDD7C0:01C5C05D] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.492 required=5 tests=[AWL=0.001, + DNS_FROM_RFC_WHOIS=0.492] +X-Spam-Level: +X-Archive-Number: 200509/304 +X-Sequence-Number: 14612 + +Hi Oleg, + +For single index I try this query: +explain analyze +select articleid, title, datee from articles +where fti @@ to_tsquery('bank&indonesia'); + +analyze result: +---------------- +"Index Scan using fti_idx on articles (cost=0.00..862.97 rows=420 width=51) +(actual time=0.067..183761.324 rows=46186 loops=1)" +" Index Cond: (fti @@ '\'bank\' & \'indonesia\''::tsquery)" +"Total runtime: 183837.826 ms" + +And for multicolumn index I try this query: +explain analyze +select articleid, title, datee from articles +where fti @@ to_tsquery('bank&mega'); + +analyze result: +---------------- +"Index Scan using articles_x1 on articles (cost=0.00..848.01 rows=410 +width=51) (actual time=52.204..37914.135 rows=1841 loops=1)" +" Index Cond: ((datee >= '2002-01-01'::date) AND (datee <= +('now'::text)::date) AND (fti @@ '\'bank\' & \'mega\''::tsquery))" +"Total runtime: 37933.757 ms" + +The table structure is as mention on the first talk. If you wanna know how +much table in my database, it's about 100 tables or maybe more. Now I +develop the version 2 of my web application, you can take a look at: +http://www.mediatrac.net, so it will hold many datas. But the biggest table +is article's table. On develop this version 2 I just use half data of the +article's table (about 419804 rows). May be if I import all of the article's +table data it will have 1 million rows. The article's table grows rapidly, +about 100000 rows per-week. My developing database size is 28 GB (not real +database, coz I still develop the version 2 and I use half of the data for +play around). I just wanna to perform quick search (fulltext search) on my +article's table not other table. On version 1, the current running version I +use same hardware spesification as mention below, but there is no fulltext +search. So I develop the new version with new features, new interface and +include the fulltext search. + +I do know, if the application finish, I must use powerfull hardware. But how +can I guarantee the application will run smooth, if I do fulltext search on +419804 rows in a table it took a long time to get the result. + +Could you or friends in this maling-list help me....plz..plzz + +Tsearch2 configuration: +------------------------- +I use default configuration, english stop word file as tsearch2 provide, +stem dictionary as default (coz I don't know how to configure and add new +data to stem dictionary) and I add some words to the english stop word file. + +Postgresql configuration +------------------------- +max_connections = 32 +shared_buffers = 32768 +sort_mem = 8192 +vacuum_mem = 65536 +work_mem = 16384 +maintenance_work_mem = 65536 +max_fsm_pages = 30000 +max_fsm_relations = 1000 +max_files_per_process = 100000 +checkpoint_segments = 15 +effective_cache_size = 192000 +random_page_cost = 2 +geqo = true +geqo_threshold = 50 +geqo_effort = 5 +geqo_pool_size = 0 +geqo_generations = 0 +geqo_selection_bias = 2.0 +from_collapse_limit = 10 +join_collapse_limit = 15 + +OS configuration: +------------------ +I use Redhat 4 AS, kernel 2.6.9-11 +kernel.shmmax=1073741824 +kernel.sem=250 32000 100 128 +fs.aio-max-nr=5242880 +the server I configure just only for postgresql, no other service is running +like: www, samba, ftp, email, firewall + +hardware configuration: +------------------------ +Motherboard ASUS P5GD1 +Processor P4 3,2 GHz +Memory 2 GB DDR 400, +2x200 GB Serial ATA 7200 RPM UltraATA/133, configure as RAID0 for postgresql +data and the partition is EXT3 +1x80 GB EIDE 7200 RPM configure for system and home directory and the +partiton is EXT3 + +Did I miss something? + +Regards, +ahmad fajar + + +-----Original Message----- +From: Oleg Bartunov [mailto:oleg@sai.msu.su] +Sent: Jumat, 23 September 2005 18:26 +To: Ahmad Fajar +Cc: pgsql-performance@postgresql.org +Subject: RE: [PERFORM] tsearch2 seem very slow + +On Fri, 23 Sep 2005, Ahmad Fajar wrote: + +> Hi Oleg, +> +> I didn't deny on the third repeat or more, it can reach < 600 msec. It is +> only because the result still in postgres cache, but how about in the +first +> run? I didn't dare, the values is un-acceptable. Because my table will +grows +> rapidly, it's about 100000 rows per-week. And the visitor will search +> anything that I don't know, whether it's the repeated search or new +search, +> or whether it's in postgres cache or not. + +if you have enoush shared memory postgresql will keep index pages there. + + +> +> I just compare with http://www.postgresql.org, the search is quite fast, +and +> I don't know whether the site uses tsearch2 or something else. But as fas +as +> I know, if the rows reach >100 milion (I have try for 200 milion rows and +it +> seem very slow), even if don't use tsearch2, only use simple query like: +> select f1, f2 from table1 where f2='blabla', +> and f2 is indexes, my postgres still slow on the first time, about >10 +sec. +> because of this I tried something brand new to fullfill my needs. I have +> used fti, and tsearch2 but still slow. +> +> I don't know what's going wrong with my postgres, what configuration must +I +> do to perform the query get fast result. Or must I use enterprisedb 2005 +or +> pervasive postgres (both uses postgres), I don't know very much about +these +> two products. + +you didn't show us your configuration (hardware,postgresql and tsearch2), +explain analyze of your queries, so we can't help you. +How big is your database, tsearch2 index size ? + + +> +> Regards, +> ahmad fajar +> +> +> -----Original Message----- +> From: Oleg Bartunov [mailto:oleg@sai.msu.su] +> Sent: Jumat, 23 September 2005 14:36 +> To: Ahmad Fajar +> Cc: pgsql-performance@postgresql.org +> Subject: Re: [PERFORM] tsearch2 seem very slow +> +> Ahmad, +> +> how fast is repeated runs ? First time system could be very slow. +> Also, have you checked my page +> http://www.sai.msu.su/~megera/oddmuse/index.cgi/Tsearch_V2_Notes +> and some info about tsearch2 internals +> http://www.sai.msu.su/~megera/oddmuse/index.cgi/Tsearch_V2_internals +> +> Oleg +> On Thu, 22 Sep 2005, Ahmad Fajar wrote: +> +>> I have about 419804 rows in my article table. I have installed tsearch2 +> and +>> its gist index correctly. +>> +>> My table structure is: +>> +>> CREATE TABLE tbarticles +>> +>> ( +>> +>> articleid int4 NOT NULL, +>> +>> title varchar(250), +>> +>> mediaid int4, +>> +>> datee date, +>> +>> content text, +>> +>> contentvar text, +>> +>> mmcol float4 NOT NULL, +>> +>> sirkulasi float4, +>> +>> page varchar(10), +>> +>> tglisidata date, +>> +>> namapc varchar(12), +>> +>> usere varchar(12), +>> +>> file_pdf varchar(255), +>> +>> file_pdf2 varchar(50), +>> +>> kolom int4, +>> +>> size_jpeg int4, +>> +>> journalist varchar(120), +>> +>> ratebw float4, +>> +>> ratefc float4, +>> +>> fti tsvector, +>> +>> CONSTRAINT pk_tbarticles PRIMARY KEY (articleid) +>> +>> ) WITHOUT OIDS; +>> +>> Create index fti_idx1 on tbarticles using gist (fti); +>> +>> Create index fti_idx2 on tbarticles using gist (datee, fti); +>> +>> +>> +>> But when I search something like: +>> +>> Select articleid, title, datee from tbarticles where fti @@ +>> to_tsquery('susilo&bambang&yudhoyono&jusuf&kalla'); +>> +>> It takes about 30 sec. I run explain analyze and the index is used +>> correctly. +>> +>> +>> +>> Then I try multi column index to filter by date, and my query something +>> like: +>> +>> Select articleid, title, datee from tbarticles where fti @@ +>> to_tsquery('susilo&bambang&yudhoyono&jusuf&kalla') and datee >= +> '2002-01-01' +>> and datee <= current_date +>> +>> An it still run about 25 sec. I do run explain analyze and my multicolumn +>> index is used correctly. +>> +>> This is not acceptable if want to publish my website if the search took +> very +>> longer. +>> +>> +>> +>> I have run vacuum full analyze before doing such query. What going wrong +>> with my query?? Is there any way to make this faster? +>> +>> I have try to tune my postgres configuration, but it seem helpless. My +> linux +>> box is Redhat 4 AS, and +>> +>> the hardware: 2 GB RAM DDR 400, 2x200 GB Serial ATA 7200RPM and configure +> as +>> RAID0 (just for postgres data), my sistem run at EIDE 80GB 7200 RPM. +>> +>> +>> +>> Please.help.help. +>> +>> +> +> Regards, +> Oleg +> _____________________________________________________________ +> Oleg Bartunov, sci.researcher, hostmaster of AstroNet, +> Sternberg Astronomical Institute, Moscow University (Russia) +> Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ +> phone: +007(095)939-16-83, +007(095)939-23-83 +> + + Regards, + Oleg +_____________________________________________________________ +Oleg Bartunov, sci.researcher, hostmaster of AstroNet, +Sternberg Astronomical Institute, Moscow University (Russia) +Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ +phone: +007(095)939-16-83, +007(095)939-23-83 + + +From pgsql-hackers-owner@postgresql.org Fri Sep 23 18:04:01 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5C2CFD92E1; + Fri, 23 Sep 2005 13:48:40 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 19181-02; Fri, 23 Sep 2005 16:48:38 +0000 (GMT) +Received: from pop-gadwall.atl.sa.earthlink.net + (pop-gadwall.atl.sa.earthlink.net [207.69.195.61]) + by svr1.postgresql.org (Postfix) with ESMTP id 44268D92A9; + Fri, 23 Sep 2005 13:48:37 -0300 (ADT) +Received: from elwamui-huard.atl.sa.earthlink.net ([209.86.224.35]) + by pop-gadwall.atl.sa.earthlink.net with esmtp (Exim 3.36 #10) + id 1EIqix-00023M-00; Fri, 23 Sep 2005 12:48:35 -0400 +Message-ID: + <2559192.1127494115558.JavaMail.root@elwamui-huard.atl.sa.earthlink.net> +Date: Fri, 23 Sep 2005 12:48:35 -0400 (EDT) +From: Ron Peacetree +Reply-To: Ron Peacetree +To: Simon Riggs , + pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Releasing memory during External sorting? +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Mailer: Earthlink Zoo Mail 1.0 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.28 required=5 tests=[AWL=-0.093, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200509/1032 +X-Sequence-Number: 73429 + +From: Simon Riggs +Sent: Sep 23, 2005 5:37 AM +Subject: [PERFORM] Releasing memory during External sorting? + +>I have concerns about whether we are overallocating memory for use in +>external sorts. (All code relating to this is in tuplesort.c) +> +A decent external sorting algorithm, say a Merge Sort + Radix (or +Distribution Counting) hybrid with appropriate optimizations for small sub- +files, should become more effective / efficient the more RAM you give it. + + +>The external sort algorithm benefits from some memory but not much. +> +That's probably an artifact of the psql external sorting code and _not_ +due to some fundamental external sorting issue. + + +>Knuth says that the amount of memory required is very low, with a value +>typically less than 1 kB. +> +"Required" means the external sort can operate on that little memory. How +Much memory is required for optimal performance is another matter. + + +>I/O overheads mean that there is benefit from having longer sequential +>writes, so the optimum is much larger than that. I've not seen any data +>that indicates that a setting higher than 16 MB adds any value at all to a +>large external sort. +> +It should. A first pass upper bound would be the amount of RAM needed for +Replacement Selection to create a run (ie sort) of the whole file. That should +be ~ the amount of RAM to hold 1/2 the file in a Replacement Selection pass. + +At the simplest, for any file over 32MB the optimum should be more than +16MB. + + +> I have some indications from private tests that very high memory settings +>may actually hinder performance of the sorts, though I cannot explain that +>and wonder whether it is the performance tests themselves that have issues. +> +Hmmm. Are you talking about amounts so high that you are throwing the OS +into paging and swapping thrash behavior? If not, then the above is weird. + + +>Does anyone have any clear data that shows the value of large settings +>of work_mem when the data to be sorted is much larger than memory? (I am +>well aware of the value of setting work_mem higher for smaller sorts, so +>any performance data needs to reflect only very large sorts). +> +This is not PostgreSQL specific, but it does prove the point that the performance +of external sorts benefits greatly from large amounts of RAM being available: + +http://research.microsoft.com/barc/SortBenchmark/ + +Looking at the particulars of the algorithms listed there should shed a lot of light +on what a "good" external sorting algorithm looks like: +1= HD IO matters the most. + 1a= Seeking behavior is the largest factor in poor performance. +2= No optimal external sorting algorithm should use more than 2 passes. +3= Optimal external sorting algorithms should use 1 pass if at all possible. +4= Use as much RAM as possible, and use it as efficiently as possible. +5= The amount of RAM needed to hide the latency of a HD subsytem goes up as +the _square_ of the difference between the bandwidth of the HD subsystem and +memory. +6= Be cache friendly. +7= For large numbers of records whose sorting key is substantially smaller than +the record itself, use a pointer + compressed key representation and write the data +to HD in sorted order (Replace HD seeks with RAM seeks. Minimize RAM seeks). +8= Since your performance will be constrained by HD IO first and RAM IO second, +up to a point it is worth it to spend more CPU cycles to save on IO. + +Given the large and growing gap between CPU IO, RAM IO, and HD IO, these issues +are becoming more important for _internal_ sorts as well. + + +>Feedback, please. +> +>Best Regards, Simon Riggs +> +Hope this is useful, +Ron + +From pgsql-performance-owner@postgresql.org Fri Sep 23 13:59:12 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C08BCD9302 + for ; + Fri, 23 Sep 2005 13:59:10 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18213-09 + for ; + Fri, 23 Sep 2005 16:59:07 +0000 (GMT) +Received: from wolff.to (wolff.to [66.93.197.194]) + by svr1.postgresql.org (Postfix) with SMTP id 84925D930C + for ; + Fri, 23 Sep 2005 13:59:05 -0300 (ADT) +Received: (qmail 8399 invoked by uid 500); 23 Sep 2005 16:59:52 -0000 +Date: Fri, 23 Sep 2005 11:59:52 -0500 +From: Bruno Wolff III +To: Stef +Cc: Markus Benne , + pgsql-performance@postgresql.org +Subject: Re: VACUUM FULL vs CLUSTER +Message-ID: <20050923165952.GA7327@wolff.to> +Mail-Followup-To: Bruno Wolff III , + Stef , Markus Benne , + pgsql-performance@postgresql.org +References: <5.2.0.9.1.20050920144041.0287c300@pop.puc.cl> + <1127242399.26562.15.camel@host-140.engineering.n-able.com> + <20050923142027.GC2298@wolff.to> + <20050923181644.161bf160@svb.ucs.co.za> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20050923181644.161bf160@svb.ucs.co.za> +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/306 +X-Sequence-Number: 14614 + +On Fri, Sep 23, 2005 at 18:16:44 +0200, + Stef wrote: +> Bruno Wolff III mentioned : +> => If you have a proper FSM setting you shouldn't need to do vacuum fulls +> => (unless you have an older version of postgres where index bloat might +> => be an issue). +> +> What version of postgres was the last version that had +> the index bloat problem? + +You can check the release notes to be sure, but my memory is that the +unbounded bloat problem was fixed in 7.4. There still are usage patterns +that can result in bloating, but it is limited to some constant multiplier +of the minimum index size. + +From pgsql-performance-owner@postgresql.org Fri Sep 23 14:02:57 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3B018D9268 + for ; + Fri, 23 Sep 2005 14:02:55 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 19713-03 + for ; + Fri, 23 Sep 2005 17:02:52 +0000 (GMT) +Received: from mx1.surnet.cl (mx2.surnet.cl [216.155.73.181]) + by svr1.postgresql.org (Postfix) with ESMTP id 5963AD90EB + for ; + Fri, 23 Sep 2005 14:02:51 -0300 (ADT) +Received: from unknown (HELO cluster.surnet.cl) ([216.155.73.165]) + by mx1.surnet.cl with ESMTP; 23 Sep 2005 13:02:30 -0400 +X-IronPort-AV: i="3.97,114,1125892800"; + d="scan'208"; a="11660630:sNHT35146534" +Received: from alvh.no-ip.org (216.155.84.209) by cluster.surnet.cl (7.0.043) + (authenticated as alvherre@surnet.cl) + id 4327E85F00112762; Fri, 23 Sep 2005 13:02:50 -0400 +Received: by alvh.no-ip.org (Postfix, from userid 1000) + id 1C597C37448; Fri, 23 Sep 2005 13:03:05 -0400 (CLT) +Date: Fri, 23 Sep 2005 13:03:05 -0400 +From: Alvaro Herrera +To: Stef +Cc: Bruno Wolff III , + Markus Benne , pgsql-performance@postgresql.org +Subject: Re: VACUUM FULL vs CLUSTER +Message-ID: <20050923170304.GC7575@surnet.cl> +Mail-Followup-To: Stef , + Bruno Wolff III , Markus Benne , + pgsql-performance@postgresql.org +References: <5.2.0.9.1.20050920144041.0287c300@pop.puc.cl> + <1127242399.26562.15.camel@host-140.engineering.n-able.com> + <20050923142027.GC2298@wolff.to> + <20050923181644.161bf160@svb.ucs.co.za> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20050923181644.161bf160@svb.ucs.co.za> +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=2.394 required=5 tests=[AWL=-0.432, + DNS_FROM_RFC_ABUSE=0.374, DNS_FROM_RFC_POST=1.376, FORGED_RCVD_HELO=0.05, + RCVD_IN_NJABL_PROXY=1.026] +X-Spam-Level: ** +X-Archive-Number: 200509/307 +X-Sequence-Number: 14615 + +On Fri, Sep 23, 2005 at 06:16:44PM +0200, Stef wrote: +> Bruno Wolff III mentioned : +> => If you have a proper FSM setting you shouldn't need to do vacuum fulls +> => (unless you have an older version of postgres where index bloat might +> => be an issue). +> +> What version of postgres was the last version that had +> the index bloat problem? + +The worst problems were solved in 7.4. There are problems in certain +limited circumstances even with current releases. + +-- +Alvaro Herrera http://www.amazon.com/gp/registry/DXLWNGRJD34 +"The ability to monopolize a planet is insignificant +next to the power of the source" + +From pgsql-performance-owner@postgresql.org Fri Sep 23 14:15:47 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C4C53D9306 + for ; + Fri, 23 Sep 2005 14:15:45 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 24401-07 + for ; + Fri, 23 Sep 2005 17:15:42 +0000 (GMT) +Received: from ecmailer.ecmarket.com (ecmailer.ecmarket.com [216.187.109.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B9166D9305 + for ; + Fri, 23 Sep 2005 14:15:39 -0300 (ADT) +Received: from hummer.enterprise.ecmarket.com (hummer.enterprise.ecmarket.com + [10.0.7.2]) + by ecmailer.ecmarket.com (Postfix) with ESMTP id CD8EDB81B8 + for ; + Fri, 23 Sep 2005 10:15:36 -0700 (PDT) +Received: from gurpreet2 (gaulakh2.devel.ecmarket.com [10.0.5.33]) + by hummer.enterprise.ecmarket.com (Postfix) with SMTP id CE09A2416E + for ; + Fri, 23 Sep 2005 10:15:34 -0700 (PDT) +From: "Gurpreet Aulakh" +To: +Subject: Re: Query slower on 8.0.3 (Windows) vs 7.3 (cygwin) +Date: Fri, 23 Sep 2005 10:15:36 -0700 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) +Importance: Normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506 +In-Reply-To: <24008.1127358777@sss.pgh.pa.us> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/308 +X-Sequence-Number: 14616 + +After further investigation I have found that the reason why the query is +slower on 8.0.3 is that the hash and hash joins are slower on the 8.0.3. + +So the question comes down to : Why are hash and hash joins slower? Is this +a postgres configuration setting that I am missing? Is the locale still +screwing me up? I have set the locale to 'C' without any improvements. Is it +because the column type is a varchar that the hash is slower? + + + + +From pgsql-hackers-owner@postgresql.org Fri Sep 23 14:17:32 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E50F3D90C1; + Fri, 23 Sep 2005 14:17:29 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 24366-10; Fri, 23 Sep 2005 17:17:27 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id C2CB5D8F98; + Fri, 23 Sep 2005 14:17:26 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j8NHHOoW005022; + Fri, 23 Sep 2005 13:17:24 -0400 (EDT) +To: Ron Peacetree +Cc: Simon Riggs , + pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Releasing memory during External sorting? +In-reply-to: + <2559192.1127494115558.JavaMail.root@elwamui-huard.atl.sa.earthlink.net> +References: + <2559192.1127494115558.JavaMail.root@elwamui-huard.atl.sa.earthlink.net> +Comments: In-reply-to Ron Peacetree + message dated "Fri, 23 Sep 2005 12:48:35 -0400" +Date: Fri, 23 Sep 2005 13:17:24 -0400 +Message-ID: <5021.1127495844@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/1020 +X-Sequence-Number: 73417 + +Ron Peacetree writes: +> 2= No optimal external sorting algorithm should use more than 2 passes. +> 3= Optimal external sorting algorithms should use 1 pass if at all possible. + +A comparison-based sort must use at least N log N operations, so it +would appear to me that if you haven't got approximately log N passes +then your algorithm doesn't work. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Sep 23 14:18:15 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 62ACFD92E9 + for ; + Fri, 23 Sep 2005 14:18:12 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 27392-01 + for ; + Fri, 23 Sep 2005 17:18:08 +0000 (GMT) +Received: from ucsns.ucs.co.za (ucsns.ucs.co.za [196.23.43.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 44A00D92D5 + for ; + Fri, 23 Sep 2005 14:18:05 -0300 (ADT) +Received: from ucspost.ucs.co.za (mailgw1.ucs.co.za [196.23.43.253]) + by ucsns.ucs.co.za (Postfix) with ESMTP id 4E0CA2BD48; + Fri, 23 Sep 2005 19:18:05 +0200 (SAST) +Received: from jhb.ucs.co.za (jhb.ucs.co.za [172.31.1.3]) + by ucspost.ucs.co.za (Postfix) with ESMTP id 57A90DC22B; + Fri, 23 Sep 2005 19:18:05 +0200 (SAST) +Received: from svb.ucs.co.za (svb.ucs.co.za [172.31.1.148]) + by jhb.ucs.co.za (Postfix) with ESMTP id 1D7A0977C4; + Fri, 23 Sep 2005 19:18:05 +0200 (SAST) +Date: Fri, 23 Sep 2005 19:18:03 +0200 +From: Stef +To: Bruno Wolff III +Cc: Markus Benne , + pgsql-performance@postgresql.org +Subject: Re: VACUUM FULL vs CLUSTER +Message-ID: <20050923191803.14fff2a1@svb.ucs.co.za> +In-Reply-To: <20050923165952.GA7327@wolff.to> +References: <5.2.0.9.1.20050920144041.0287c300@pop.puc.cl> + <1127242399.26562.15.camel@host-140.engineering.n-able.com> + <20050923142027.GC2298@wolff.to> + <20050923181644.161bf160@svb.ucs.co.za> + <20050923165952.GA7327@wolff.to> +X-Mailer: Sylpheed-Claws 1.9.6cvs1 (GTK+ 2.6.10; i486-pc-linux-gnu) +User-Agent: sillypheed-claws (anti-aliased) +X-Face: +lU/o'$=Zv9%Xjo]Kq[_{n&Kb`f{YEWH4&Y#M]'6BkD?VoWe#*@S\MWyD'I>s:0v4{#\[J]l*?]t2uaO(j$d*77Ca-UHo.tkl2)0$B3Jxww\o:xor]<:*Yfx9Vceh)9I/'2g\RKhGTxIIsR^ke^`LVeZ9ksb*:$kQeR@ +X-Operating-System: sid +X-X-X: _-^-_ +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.152 required=5 tests=[AWL=0.152] +X-Spam-Level: +X-Archive-Number: 200509/310 +X-Sequence-Number: 14618 + + +Bruno Wolff III mentioned : +=> > => If you have a proper FSM setting you shouldn't need to do vacuum fulls +=> > => (unless you have an older version of postgres where index bloat might +=> > => be an issue). + +Thanks Alvaro and Bruno + +I just want to clarify something that I also couldn't +find a clear cut answer for before. + +What is a proper fsm setting? + +Someone told me to set max_fsm_relations to the number of +relations in pg_class plus a few more to allow for new relations. +And max_fsm_pages to the number of rows in the biggest table I +want to vacuum, plus a few 1000's for extra room? + +Where does this free space map sit? On the disk somewhere, +or in memory, or both. + +I once set the max_fsm_pages very high by mistake, and postgres +then started up and used a _lot_ of shared memory, and I had to +increase shmmax. Is there abything to watch out for when bumping this +setting up a lot? + +Kind Regards +Stefan + +From pgsql-hackers-owner@postgresql.org Fri Sep 23 18:11:22 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 697E9D921C; + Fri, 23 Sep 2005 14:43:13 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34397-01; Fri, 23 Sep 2005 17:43:10 +0000 (GMT) +Received: from mir3-fs.mir3.com (mail.mir3.com [65.208.188.100]) + by svr1.postgresql.org (Postfix) with ESMTP id 82DDDD90C1; + Fri, 23 Sep 2005 14:43:07 -0300 (ADT) +Received: from archimedes ([172.16.2.68]) by mir3-fs.mir3.com with Microsoft + SMTPSVC(5.0.2195.6713); Fri, 23 Sep 2005 10:46:15 -0700 +Subject: Re: [PERFORM] Releasing memory during External sorting? +From: Mark Lewis +To: Tom Lane +Cc: Ron Peacetree , + Simon Riggs , pgsql-hackers@postgresql.org, + pgsql-performance@postgresql.org +In-Reply-To: <5021.1127495844@sss.pgh.pa.us> +References: + <2559192.1127494115558.JavaMail.root@elwamui-huard.atl.sa.earthlink.net> + <5021.1127495844@sss.pgh.pa.us> +Content-Type: text/plain +Organization: MIR3, Inc. +Date: Fri, 23 Sep 2005 10:43:02 -0700 +Message-Id: <1127497383.23567.218.camel@archimedes> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-16.3) +Content-Transfer-Encoding: 7bit +X-OriginalArrivalTime: 23 Sep 2005 17:46:15.0535 (UTC) + FILETIME=[B1FE2FF0:01C5C066] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.057 required=5 tests=[AWL=0.057] +X-Spam-Level: +X-Archive-Number: 200509/1034 +X-Sequence-Number: 73431 + +operations != passes. If you were clever, you could probably write a +modified bubble-sort algorithm that only made 2 passes. A pass is a +disk scan, operations are then performed (hopefully in memory) on what +you read from the disk. So there's no theoretical log N lower-bound on +the number of disk passes. + +Not that I have anything else useful to add to this discussion, just a +tidbit I remembered from my CS classes back in college :) + +-- Mark + +On Fri, 2005-09-23 at 13:17 -0400, Tom Lane wrote: +> Ron Peacetree writes: +> > 2= No optimal external sorting algorithm should use more than 2 passes. +> > 3= Optimal external sorting algorithms should use 1 pass if at all possible. +> +> A comparison-based sort must use at least N log N operations, so it +> would appear to me that if you haven't got approximately log N passes +> then your algorithm doesn't work. +> +> 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 Fri Sep 23 15:04:17 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B4637D9306 + for ; + Fri, 23 Sep 2005 15:04:15 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 39360-01 + for ; + Fri, 23 Sep 2005 18:04:07 +0000 (GMT) +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2DD91D920C + for ; + Fri, 23 Sep 2005 15:04:05 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id F214031F51; Fri, 23 Sep 2005 20:04:04 +0200 (MET DST) +From: Chris Browne +X-Newsgroups: pgsql.performance +Subject: Re: VACUUM FULL vs CLUSTER +Date: Fri, 23 Sep 2005 13:48:32 -0400 +Organization: cbbrowne Computing Inc +Lines: 17 +Message-ID: <60ll1noetr.fsf@dba2.int.libertyrms.com> +References: <5.2.0.9.1.20050920144041.0287c300@pop.puc.cl> + <1127242399.26562.15.camel@host-140.engineering.n-able.com> + <20050923142027.GC2298@wolff.to> + <20050923181644.161bf160@svb.ucs.co.za> +Mime-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +X-Complaints-To: usenet@news.hub.org +User-Agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4.17 (Jumbo Shrimp, linux) +Cancel-Lock: sha1:sjFDQAZ3l/ybDeeqLPwtzqIzx9g= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.094 required=5 tests=[AWL=0.094] +X-Spam-Level: +X-Archive-Number: 200509/312 +X-Sequence-Number: 14620 + +svb@ucs.co.za (Stef) writes: +> Bruno Wolff III mentioned : +> => If you have a proper FSM setting you shouldn't need to do vacuum fulls +> => (unless you have an older version of postgres where index bloat might +> => be an issue). +> +> What version of postgres was the last version that had +> the index bloat problem? + +I believe that was fixed in 7.3; it was certainly resolved by 7.4... +-- +(format nil "~S@~S" "cbbrowne" "cbbrowne.com") +http://www.ntlug.org/~cbbrowne/spiritual.html +MICROS~1 has brought the microcomputer OS to the point where it is +more bloated than even OSes from what was previously larger classes of +machines altogether. This is perhaps Bill's single greatest +accomplishment. + +From pgsql-hackers-owner@postgresql.org Fri Sep 23 15:16:08 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 81286D931F; + Fri, 23 Sep 2005 15:15:56 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 38634-08; Fri, 23 Sep 2005 18:15:53 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 2C006D930B; + Fri, 23 Sep 2005 15:15:53 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j8NIFemK005442; + Fri, 23 Sep 2005 14:15:40 -0400 (EDT) +To: Mark Lewis +Cc: Ron Peacetree , + Simon Riggs , pgsql-hackers@postgresql.org, + pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Releasing memory during External sorting? +In-reply-to: <1127497383.23567.218.camel@archimedes> +References: + <2559192.1127494115558.JavaMail.root@elwamui-huard.atl.sa.earthlink.net> + <5021.1127495844@sss.pgh.pa.us> + <1127497383.23567.218.camel@archimedes> +Comments: In-reply-to Mark Lewis + message dated "Fri, 23 Sep 2005 10:43:02 -0700" +Date: Fri, 23 Sep 2005 14:15:40 -0400 +Message-ID: <5441.1127499340@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/1025 +X-Sequence-Number: 73422 + +Mark Lewis writes: +> operations != passes. If you were clever, you could probably write a +> modified bubble-sort algorithm that only made 2 passes. A pass is a +> disk scan, operations are then performed (hopefully in memory) on what +> you read from the disk. So there's no theoretical log N lower-bound on +> the number of disk passes. + +Given infinite memory that might be true, but I don't think I believe it +for limited memory. If you have room for K tuples in memory then it's +impossible to perform more than K*N useful comparisons per pass (ie, as +each tuple comes off the disk you can compare it to all the ones +currently in memory; anything more is certainly redundant work). So if +K < logN it's clearly not gonna work. + +It's possible that you could design an algorithm that works in a fixed +number of passes if you are allowed to assume you can hold O(log N) +tuples in memory --- and in practice that would probably work fine, +if the constant factor implied by the O() isn't too big. But it's not +really solving the general external-sort problem. + + regards, tom lane + +From pgsql-hackers-owner@postgresql.org Fri Sep 23 15:32:58 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 356FAD92E6 + for ; + Fri, 23 Sep 2005 15:32:57 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 41520-10 + for ; + Fri, 23 Sep 2005 18:32:53 +0000 (GMT) +Received: from svana.org (svana.org [203.20.62.76]) + by svr1.postgresql.org (Postfix) with ESMTP id A2D7BD90C1 + for ; + Fri, 23 Sep 2005 15:32:52 -0300 (ADT) +Received: from kleptog by svana.org with local (Exim 3.35 #1 (Debian)) + id 1EIsLm-0003cj-00; Sat, 24 Sep 2005 04:32:46 +1000 +Date: Fri, 23 Sep 2005 20:32:46 +0200 +From: Martijn van Oosterhout +To: Pailloncy Jean-Gerard +Cc: Pg Hackers , + Tom Lane +Subject: Re: Releasing memory during External sorting? +Message-ID: <20050923183241.GA12774@svana.org> +Reply-To: Martijn van Oosterhout +References: <1127468233.4145.178.camel@localhost.localdomain> + <3465.1127484579@sss.pgh.pa.us> + +Mime-Version: 1.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; boundary="RnlQjJ0d97Da+TV1" +Content-Disposition: inline +In-Reply-To: +User-Agent: Mutt/1.3.28i +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: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 required=5 tests=[AWL=0.007] +X-Spam-Level: +X-Archive-Number: 200509/1026 +X-Sequence-Number: 73423 + + +--RnlQjJ0d97Da+TV1 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +Content-Transfer-Encoding: quoted-printable + +On Fri, Sep 23, 2005 at 06:39:35PM +0200, Pailloncy Jean-Gerard wrote: +> >On most platforms it's quite unlikely that any memory would actually +> >get released back to the OS before transaction end, because the +> >memory blocks belonging to the tuplesort context will be intermixed +> >with blocks belonging to other contexts. So I think this is pretty +> >pointless. (If you can't afford to have the sort using all of +> >sort_mem, you've set sort_mem too large, anyway.) + +> On OpenBSD 3.8 malloc use mmap(2) and no more sbrk. +> So, as soon as the bloc is free, it returns to the OS. +> Access to the freed pointer crashs immediatly. + +Interesting point. Glibc also uses mmap() but only for allocations +greater than a few K, otherwise it's a waste of space. + +I guess you would have to look into the postgresql allocator to see if +it doesn't divide the mmap()ed space up between multiple contexts. +Large allocations certainly appear to be passed off to malloc() but I +don't think execSort allocates all it's space in one go, it just counts +the space allocated by palloc(). + +So, unless someone goes and adds changes the tuplesort code to allocate +big blocks and use them only for tuples, I think you're going to run +into issues with data interleaved, meaning not much to give back to the +OS... +--=20 +Martijn van Oosterhout http://svana.org/kleptog/ +> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a +> tool for doing 5% of the work and then sitting around waiting for someone +> else to do the other 95% so you can sue them. + +--RnlQjJ0d97Da+TV1 +Content-Type: application/pgp-signature +Content-Disposition: inline + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.0.6 (GNU/Linux) +Comment: For info see http://www.gnupg.org + +iD8DBQFDNEpIIB7bNG8LQkwRAl/1AJ0ZfpUlNjKI/zz12vPJbzdetjpjOQCggwWU +UykRmsJH02B6+Ro79zXIO+Y= +=f+1O +-----END PGP SIGNATURE----- + +--RnlQjJ0d97Da+TV1-- + +From pgsql-hackers-owner@postgresql.org Fri Sep 23 18:07:42 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9D060D8F59; + Fri, 23 Sep 2005 15:40:48 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 47148-02; Fri, 23 Sep 2005 18:40:43 +0000 (GMT) +Received: from pop-gadwall.atl.sa.earthlink.net + (pop-gadwall.atl.sa.earthlink.net [207.69.195.61]) + by svr1.postgresql.org (Postfix) with ESMTP id BFAB2D7B65; + Fri, 23 Sep 2005 15:40:42 -0300 (ADT) +Received: from elwamui-huard.atl.sa.earthlink.net ([209.86.224.35]) + by pop-gadwall.atl.sa.earthlink.net with esmtp (Exim 3.36 #10) + id 1EIsTP-0002hm-00; Fri, 23 Sep 2005 14:40:39 -0400 +Message-ID: + <24018329.1127500839434.JavaMail.root@elwamui-huard.atl.sa.earthlink.net> +Date: Fri, 23 Sep 2005 14:40:39 -0400 (EDT) +From: Ron Peacetree +Reply-To: Ron Peacetree +To: Mark Lewis , Tom Lane , + pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Releasing memory during External sorting? +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Mailer: Earthlink Zoo Mail 1.0 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.28 required=5 tests=[AWL=-0.093, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200509/1033 +X-Sequence-Number: 73430 + +Yep. Also, bear in mind that the lg(n!)= ~ nlgn - n lower bound on +the number of comparisions: +a= says nothing about the amount of data movement used. +b= only holds for generic comparison based sorting algorithms. + +As Knuth says (vol 3, p180), Distribution Counting sorts without +ever comparing elements to each other at all, and so does Radix +Sort. Similar comments can be found in many algorithms texts. + +Any time we know that the range of the data to be sorted is substantially +restricted compared to the number of items to be sorted, we can sort in +less than O(lg(n!)) time. DB fields tend to take on few values and are +therefore "substantially restricted". + +Given the proper resources and algorithms, O(n) sorts are very plausible +when sorting DB records. + +All of the fastest external sorts of the last decade or so take advantage of +this. Check out that URL I posted. + +Ron + + +-----Original Message----- +From: Mark Lewis +Sent: Sep 23, 2005 1:43 PM +To: Tom Lane +Subject: Re: [PERFORM] Releasing memory during External sorting? + +operations != passes. If you were clever, you could probably write a +modified bubble-sort algorithm that only made 2 passes. A pass is a +disk scan, operations are then performed (hopefully in memory) on what +you read from the disk. So there's no theoretical log N lower-bound on +the number of disk passes. + +Not that I have anything else useful to add to this discussion, just a +tidbit I remembered from my CS classes back in college :) + +-- Mark + +On Fri, 2005-09-23 at 13:17 -0400, Tom Lane wrote: +> Ron Peacetree writes: +> > 2= No optimal external sorting algorithm should use more than 2 passes. +> > 3= Optimal external sorting algorithms should use 1 pass if at all possible. +> +> A comparison-based sort must use at least N log N operations, so it +> would appear to me that if you haven't got approximately log N passes +> then your algorithm doesn't work. +> +> regards, tom lane + +From pgsql-hackers-owner@postgresql.org Fri Sep 23 18:03:41 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4E664D9311; + Fri, 23 Sep 2005 16:45:02 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 59354-09; Fri, 23 Sep 2005 19:44:58 +0000 (GMT) +Received: from pop-gadwall.atl.sa.earthlink.net + (pop-gadwall.atl.sa.earthlink.net [207.69.195.61]) + by svr1.postgresql.org (Postfix) with ESMTP id 02842D92E6; + Fri, 23 Sep 2005 16:44:55 -0300 (ADT) +Received: from elwamui-huard.atl.sa.earthlink.net ([209.86.224.35]) + by pop-gadwall.atl.sa.earthlink.net with esmtp (Exim 3.36 #10) + id 1EItTa-0004UM-00; Fri, 23 Sep 2005 15:44:54 -0400 +Message-ID: + <30396660.1127504694492.JavaMail.root@elwamui-huard.atl.sa.earthlink.net> +Date: Fri, 23 Sep 2005 15:44:54 -0400 (EDT) +From: Ron Peacetree +Reply-To: Ron Peacetree +To: Tom Lane , Mark Lewis , + pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Releasing memory during External sorting? +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Mailer: Earthlink Zoo Mail 1.0 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.28 required=5 tests=[AWL=-0.094, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200509/1031 +X-Sequence-Number: 73428 + +From: Tom Lane +Sent: Sep 23, 2005 2:15 PM +Subject: Re: [PERFORM] Releasing memory during External sorting? + +>Mark Lewis writes: +>> operations != passes. If you were clever, you could probably write a +>> modified bubble-sort algorithm that only made 2 passes. A pass is a +>> disk scan, operations are then performed (hopefully in memory) on what +>> you read from the disk. So there's no theoretical log N lower-bound on +>> the number of disk passes. + +>Given infinite memory that might be true, but I don't think I believe it +>for limited memory. If you have room for K tuples in memory then it's +>impossible to perform more than K*N useful comparisons per pass (ie, as +>each tuple comes off the disk you can compare it to all the ones +>currently in memory; anything more is certainly redundant work). So if +>K < logN it's clearly not gonna work. +> +Actually, it's far better than that. I recall a paper I saw in one of the +algorithms journals 15+ years ago that proved that if you knew the range +of the data, regardless of what that range was, and had n^2 space, you +could sort n items in O(n) time. + +Turns out that with very modest constraints on the range of the data and +substantially less extra space (about the same as you'd need for +Replacement Selection + External Merge Sort), you can _still_ sort in +O(n) time. + + +>It's possible that you could design an algorithm that works in a fixed +>number of passes if you are allowed to assume you can hold O(log N) +>tuples in memory --- and in practice that would probably work fine, +>if the constant factor implied by the O() isn't too big. But it's not +>really solving the general external-sort problem. +> +If you know nothing about the data to be sorted and must guard against +the worst possible edge cases, AKA the classic definition of "the general +external sorting problem", then one can't do better than some variant +of Replacement Selection + Unbalanced Multiway Merge. + +OTOH, ITRW things are _not_ like that. We know the range of the data +in our DB fields or we can safely assume it to be relatively constrained. +This allows us access to much better external sorting algorithms. + +For example Postman Sort (the 2005 winner of the PennySort benchmark) +is basically an IO optimized version of an external Radix Sort. + + +Ron + +From pgsql-performance-owner@postgresql.org Fri Sep 23 18:13:22 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3EA07D93FE + for ; + Fri, 23 Sep 2005 18:12:56 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 83616-06 + for ; + Fri, 23 Sep 2005 21:12:52 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id DB3B5D93FC + for ; + Fri, 23 Sep 2005 18:12:52 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j8NLCnra006519; + Fri, 23 Sep 2005 17:12:49 -0400 (EDT) +To: "Gurpreet Aulakh" +Cc: pgsql-performance@postgresql.org +Subject: Re: Query slower on 8.0.3 (Windows) vs 7.3 (cygwin) +In-reply-to: +References: +Comments: In-reply-to "Gurpreet Aulakh" + message dated "Fri, 23 Sep 2005 10:15:36 -0700" +Date: Fri, 23 Sep 2005 17:12:49 -0400 +Message-ID: <6518.1127509969@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/316 +X-Sequence-Number: 14624 + +"Gurpreet Aulakh" writes: +> After further investigation I have found that the reason why the query is +> slower on 8.0.3 is that the hash and hash joins are slower on the 8.0.3. +> So the question comes down to : Why are hash and hash joins slower? + +I looked into this a bit and determined that the problem seems to have +been introduced here: + +2002-12-30 10:21 tgl + + * src/: backend/executor/nodeHash.c, + backend/executor/nodeHashjoin.c, backend/optimizer/path/costsize.c, + include/executor/nodeHash.h: Better solution to integer overflow + problem in hash batch-number computation: reduce the bucket number + mod nbatch. This changes the association between original bucket + numbers and batches, but that doesn't matter. Minor other cleanups + in hashjoin code to help centralize decisions. + +(which means it's present in 7.4 as well as 8.0). The code now +groups tuples into hash batches according to + (hashvalue % totalbuckets) % nbatch +When a tuple that is not in the first batch is reloaded, it is placed +into a bucket according to + (hashvalue % nbuckets) +This means that if totalbuckets, nbatch, and nbuckets have a common +factor F, the buckets won't be evenly used; in fact, only one in every F +buckets will be used at all, the rest remaining empty. The ones that +are used accordingly will contain about F times more tuples than +intended. The slowdown comes from having to compare these extra tuples +against the outer-relation tuples. + +7.3 uses a different algorithm for grouping tuples that avoids this +problem, but it has performance issues of its own (in particular, to +avoid integer overflow we have to limit the number of batches we can +have). So just reverting this patch doesn't seem very attractive. + +The problem no longer exists in 8.1 because of rewrites undertaken for +another purpose, so I'm sort of tempted to do nothing. To fix this in +the back branches we'd have to develop new code that won't ever go into +CVS tip and thus will never get beta-tested. The risk of breaking +things seems higher than I'd like. + +If we did want to fix it, my first idea is to increment nbatch looking +for a value that has no common factor with nbuckets. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Sep 23 19:05:44 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8C09ED9141 + for ; + Fri, 23 Sep 2005 19:05:42 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 97860-02 + for ; + Fri, 23 Sep 2005 22:05:38 +0000 (GMT) +Received: from mail.clickdiario.com (mail.clickdiario.com [70.85.167.114]) + by svr1.postgresql.org (Postfix) with ESMTP id 958F3D90EC + for ; + Fri, 23 Sep 2005 19:05:36 -0300 (ADT) +Received: from localhost (localhost [127.0.0.1]) + by mail.clickdiario.com (Postfix) with ESMTP id D790610026 + for ; + Fri, 23 Sep 2005 17:08:58 -0500 (CDT) +Received: from mail.clickdiario.com ([127.0.0.1]) + by localhost (mail.clickdiario.com [127.0.0.1]) (amavisd-new, + port 10024) + with ESMTP id 10973-01 for ; + Fri, 23 Sep 2005 17:08:58 -0500 (CDT) +Received: from cristian1 (unknown [216.230.158.50]) + by mail.clickdiario.com (Postfix) with ESMTP id 3A0841001E + for ; + Fri, 23 Sep 2005 17:08:57 -0500 (CDT) +From: "Cristian Prieto" +To: +Subject: Index use in BETWEEN statement... +Date: Fri, 23 Sep 2005 16:03:11 -0600 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Mailer: Microsoft Office Outlook, Build 11.0.5510 +Thread-Index: AcXAipbGc98Fe8XwQlKGyZnlcfBNQQ== +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +Message-Id: <20050923220857.3A0841001E@mail.clickdiario.com> +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at example.com +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.016 required=5 tests=[AWL=0.016] +X-Spam-Level: +X-Archive-Number: 200509/317 +X-Sequence-Number: 14625 + +Hello pals, I have the following table in Postgresql 8.0.1 + +Mydb# \d geoip_block +Table "public.geoip_block" + Column | Type | Modifiers +-------------+--------+----------- + locid | bigint | + start_block | inet | + end_block | inet | + +mydb# explain analyze select locid from geoip_block where +'216.230.158.50'::inet between start_block and end_block; + QUERY PLAN +---------------------------------------------------------------------------- +------------------------------------------- + Seq Scan on geoip_block (cost=0.00..142772.86 rows=709688 width=8) (actual +time=14045.384..14706.927 rows=1 loops=1) + Filter: (('216.230.158.50'::inet >= start_block) AND +('216.230.158.50'::inet <= end_block)) + Total runtime: 14707.038 ms + +Ok, now I decided to create a index to "speed" a little the query + +Mydb# create index idx_ipblocks on geoip_block(start_block, end_block); +CREATE INDEX + +clickad=# explain analyze select locid from geoip_block where +'216.230.158.50'::inet between start_block and end_block; + QUERY PLAN +---------------------------------------------------------------------------- +------------------------------------------ + Seq Scan on geoip_block (cost=0.00..78033.96 rows=230141 width=8) (actual +time=12107.919..12610.199 rows=1 loops=1) + Filter: (('216.230.158.50'::inet >= start_block) AND +('216.230.158.50'::inet <= end_block)) + Total runtime: 12610.329 ms +(3 rows) + +I guess the planner is doing a sequential scan in the table, why not use the +compound index? Do you have any idea in how to speed up this query? + +Thanks a lot! + + +From pgsql-performance-owner@postgresql.org Fri Sep 23 22:41:10 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 71DDAD9340 + for ; + Fri, 23 Sep 2005 22:40:29 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 47496-01 + for ; + Sat, 24 Sep 2005 01:40:22 +0000 (GMT) +Received: from linda-4.paradise.net.nz (bm-4a.paradise.net.nz [202.0.58.23]) + by svr1.postgresql.org (Postfix) with ESMTP id 64928D9020 + for ; + Fri, 23 Sep 2005 22:40:23 -0300 (ADT) +Received: from smtp-2.paradise.net.nz (smtp-2a.paradise.net.nz [202.0.32.195]) + by linda-4.paradise.net.nz (Paradise.net.nz) + with ESMTP id <0INA00DP4SND7X@linda-4.paradise.net.nz> for + pgsql-performance@postgresql.org; Sat, 24 Sep 2005 13:40:25 +1200 (NZST) +Received: from [192.168.1.11] (218-101-45-243.paradise.net.nz + [218.101.45.243]) + by smtp-2.paradise.net.nz (Postfix) with ESMTP id B9AAA9E63F; Sat, + 24 Sep 2005 13:40:26 +1200 (NZST) +Date: Sat, 24 Sep 2005 13:40:25 +1200 +From: Mark Kirkwood +Subject: Re: SELECT LIMIT 1 VIEW Performance Issue +In-reply-to: <6.2.1.2.0.20050923155952.05889a50@localhost> +To: K C Lau +Cc: pgsql-performance@postgresql.org +Message-id: <4334AE89.8060806@paradise.net.nz> +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=ISO-8859-1 +Content-transfer-encoding: 7bit +X-Accept-Language: en-us, en +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050726) +References: <6EE64EF3AB31D5448D0007DD34EEB3417DD406@Herge.rcsinc.local> + <6.2.1.2.0.20050923155952.05889a50@localhost> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.128 required=5 tests=[AWL=0.128] +X-Spam-Level: +X-Archive-Number: 200509/318 +X-Sequence-Number: 14626 + +K C Lau wrote: +> Thank you all for your suggestions. I' tried, with some variations too, +> but still no success. The times given are the best of a few repeated +> tries on an 8.1 beta 2 db freshly migrated from 8.0.3 on Windows. +> + +A small denormalization, where you mark the row with the latest atdate +for each playerid may get you the performance you want. + +e.g: (8.1beta1) + +ALTER TABLE player ADD islastatdate boolean; + +UPDATE player SET islastatdate = true where (playerid,atdate) IN +(SELECT playerid, atdate FROM vcurplayer); + +CREATE OR REPLACE VIEW vcurplayer AS +SELECT * FROM player a +WHERE islastatdate; + +CREATE INDEX player_id_lastatdate ON player(playerid, islastatdate) +WHERE islastatdate; + +ANALYZE player; + +Generating some test data produced: + +EXPLAIN ANALYZE +SELECT playerid,atdate +FROM vcurplayer +WHERE playerid='22220'; + + QUERY PLAN + +-------------------------------------------------------------------------------------------------------------------------------- + Index Scan using player_id_lastatdate on player a (cost=0.00..4.33 +rows=1 width=13) (actual time=0.142..0.149 rows=1 loops=1) + Index Cond: ((playerid = '22220'::text) AND (lastatdate = true)) + Filter: lastatdate + Total runtime: 0.272 ms +(4 rows) + +Whereas with the original view definition: + +CREATE OR REPLACE VIEW vcurplayer AS +SELECT * FROM player a +WHERE a.atdate = +( SELECT max(b.atdate) FROM player b + WHERE a.playerid = b.playerid); + +EXPLAIN ANALYZE +SELECT playerid,atdate +FROM vcurplayer +WHERE playerid='22220'; + + QUERY PLAN + +----------------------------------------------------------------------------------------------------------------------------------------------------------------- + Index Scan using player_id_date on player a (cost=0.00..7399.23 +rows=11 width=13) (actual time=121.738..121.745 rows=1 loops=1) + Index Cond: (playerid = '22220'::text) + Filter: (atdate = (subplan)) + SubPlan + -> Result (cost=1.72..1.73 rows=1 width=0) (actual +time=0.044..0.047 rows=1 loops=2000) + InitPlan + -> Limit (cost=0.00..1.72 rows=1 width=4) (actual +time=0.028..0.031 rows=1 loops=2000) + -> Index Scan Backward using player_id_date on +player b (cost=0.00..3787.94 rows=2198 width=4) (actual +time=0.019..0.019 rows=1 loops=2000) + Index Cond: ($0 = playerid) + Filter: (atdate IS NOT NULL) + Total runtime: 121.916 ms +(11 rows) + +Note that my generated data has too many rows for each playerid, but the + difference in performance should illustrate the idea. + +Cheers + +Mark + +From pgsql-performance-owner@postgresql.org Sat Sep 24 00:09:20 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 96ACAD8E1F + for ; + Sat, 24 Sep 2005 00:09:18 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 86027-01 + for ; + Sat, 24 Sep 2005 03:09:16 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 72DD3D6E40 + for ; + Sat, 24 Sep 2005 00:09:13 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j8O399VT008873; + Fri, 23 Sep 2005 23:09:10 -0400 (EDT) +To: eVl +Cc: pgsql-performance@postgresql.org +Subject: Re: optimization downgrade perfomance? +In-reply-to: <652316563.20050923212351@gmail.com> +References: <133614678.20050923012716@gmail.com> + <3192.1127482808@sss.pgh.pa.us> + <652316563.20050923212351@gmail.com> +Comments: In-reply-to eVl + message dated "Fri, 23 Sep 2005 21:23:51 +0300" +Date: Fri, 23 Sep 2005 23:09:09 -0400 +Message-ID: <8872.1127531349@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/319 +X-Sequence-Number: 14627 + +eVl writes: +>> You tell us --- let's see EXPLAIN ANALYZE results for both cases. + +> Here EXPLAIN ANALYZE results for both queries attached. + +The problem seems to be that the is_uaix() function is really slow +(somewhere around 4 msec per call it looks like). Look at the +first scan over stats: + + -> Index Scan using cdate_cluster on stats s (cost=0.00..201.51 rows=6 width=25) (actual time=5.231..2165.145 rows=418 loops=1) + Index Cond: (cdate = '2005-09-01'::date) + Filter: ((fromip << '192.168.0.0/16'::inet) AND (NOT (toip << '192.168.0.0/16'::inet)) AND (CASE is_uaix(toip) WHEN true THEN 'local'::text ELSE 'global'::text END = 'global'::text)) + +versus + + -> Index Scan using cdate_cluster on stats s (cost=0.00..165.94 rows=1186 width=25) (actual time=0.131..43.258 rows=578 loops=1) + Index Cond: (cdate = '2005-09-01'::date) + Filter: ((fromip << '192.168.0.0/16'::inet) AND (NOT (toip << '192.168.0.0/16'::inet))) + +The 578 evaluations of the CASE are adding over 2100msec. There's +another 1600 evaluations needed in the other arm of the UNION... + +Better look at exactly what is_uaix() is doing, because the CASE structure +is surely not that slow. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sat Sep 24 00:22:55 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EAD5AD906E + for ; + Sat, 24 Sep 2005 00:22:52 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 88915-02 + for ; + Sat, 24 Sep 2005 03:22:48 +0000 (GMT) +Received: from imsm058dat.netvigator.com (imsm058.netvigator.com + [218.102.48.211]) + by svr1.postgresql.org (Postfix) with ESMTP id D924DD8EA4 + for ; + Sat, 24 Sep 2005 00:22:46 -0300 (ADT) +Received: from n2.netvigator.com ([218.102.147.167]) + by imsm058dat.netvigator.com + (InterMail vM.6.01.05.02 201-2131-123-102-20050715) with ESMTP id + <20050924032244.CFTX17909.imsm058dat.netvigator.com@n2.netvigator.com>; + Sat, 24 Sep 2005 11:22:44 +0800 +Message-Id: <6.2.1.2.0.20050924105728.05388920@localhost> +X-Mailer: QUALCOMM Windows Eudora Version 6.2.1.2 +Date: Sat, 24 Sep 2005 11:18:24 +0800 +To: Mark Kirkwood +From: K C Lau +Subject: Re: SELECT LIMIT 1 VIEW Performance Issue +Cc: pgsql-performance@postgresql.org +In-Reply-To: <4334AE89.8060806@paradise.net.nz> +References: <6EE64EF3AB31D5448D0007DD34EEB3417DD406@Herge.rcsinc.local> + <6.2.1.2.0.20050923155952.05889a50@localhost> + <4334AE89.8060806@paradise.net.nz> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.534 required=5 tests=[AWL=-0.358, + DNS_FROM_RFC_POST=1.376, FROM_ENDS_IN_NUMS=0.516] +X-Spam-Level: * +X-Archive-Number: 200509/320 +X-Sequence-Number: 14628 + +Dear Mark, + +Thank you. That seems like a more manageable alternative if nothing else +works out. It should cover many of the OLTP update transactions. But it +does mean quite a bit of programming changes and adding another index on +all such tables, and it would not cover those cases when we need to get the +latest record before a certain time, for example. + +I'm wondering if this performance issue is common enough for other users to +merit a fix in pg, especially as it seems that with MVCC, each of the data +records need to be accessed in addition to scanning the index. + +Best regards, +KC. + +At 09:40 05/09/24, Mark Kirkwood wrote: +>A small denormalization, where you mark the row with the latest atdate for +>each playerid may get you the performance you want. +> +>e.g: (8.1beta1) +> +>ALTER TABLE player ADD islastatdate boolean; +> +>UPDATE player SET islastatdate = true where (playerid,atdate) IN +>(SELECT playerid, atdate FROM vcurplayer); +> +>CREATE OR REPLACE VIEW vcurplayer AS +>SELECT * FROM player a +>WHERE islastatdate; +> +>CREATE INDEX player_id_lastatdate ON player(playerid, islastatdate) +>WHERE islastatdate; +> +>ANALYZE player; +> +>Generating some test data produced: +> +>EXPLAIN ANALYZE +>SELECT playerid,atdate +>FROM vcurplayer +>WHERE playerid='22220'; +> +> QUERY PLAN +>-------------------------------------------------------------------------------------------------------------------------------- +> Index Scan using player_id_lastatdate on player a (cost=0.00..4.33 +> rows=1 width=13) (actual time=0.142..0.149 rows=1 loops=1) +> Index Cond: ((playerid = '22220'::text) AND (lastatdate = true)) +> Filter: lastatdate +> Total runtime: 0.272 ms +>(4 rows) +> +>Whereas with the original view definition: +> +>CREATE OR REPLACE VIEW vcurplayer AS +>SELECT * FROM player a +>WHERE a.atdate = +>( SELECT max(b.atdate) FROM player b +> WHERE a.playerid = b.playerid); +> +>EXPLAIN ANALYZE +>SELECT playerid,atdate +>FROM vcurplayer +>WHERE playerid='22220'; +> QUERY PLAN +>----------------------------------------------------------------------------------------------------------------------------------------------------------------- +> Index Scan using player_id_date on player a (cost=0.00..7399.23 rows=11 +> width=13) (actual time=121.738..121.745 rows=1 loops=1) +> Index Cond: (playerid = '22220'::text) +> Filter: (atdate = (subplan)) +> SubPlan +> -> Result (cost=1.72..1.73 rows=1 width=0) (actual +> time=0.044..0.047 rows=1 loops=2000) +> InitPlan +> -> Limit (cost=0.00..1.72 rows=1 width=4) (actual +> time=0.028..0.031 rows=1 loops=2000) +> -> Index Scan Backward using player_id_date on player +> b (cost=0.00..3787.94 rows=2198 width=4) (actual time=0.019..0.019 +> rows=1 loops=2000) +> Index Cond: ($0 = playerid) +> Filter: (atdate IS NOT NULL) +> Total runtime: 121.916 ms +>(11 rows) +> +>Note that my generated data has too many rows for each playerid, but +>the difference in performance should illustrate the idea. +> +>Cheers +> +>Mark + + +From pgsql-performance-owner@postgresql.org Sat Sep 24 02:15:10 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D80BCD9411 + for ; + Sat, 24 Sep 2005 02:15:08 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 12574-03 + for ; + Sat, 24 Sep 2005 05:15:05 +0000 (GMT) +Received: from linda-2.paradise.net.nz (bm-2a.paradise.net.nz [202.0.58.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 853D5D940A + for ; + Sat, 24 Sep 2005 02:15:02 -0300 (ADT) +Received: from smtp-1.paradise.net.nz (smtp-1a.paradise.net.nz [202.0.32.194]) + by linda-2.paradise.net.nz (Paradise.net.nz) + with ESMTP id <0INB003RQ2L1Q1@linda-2.paradise.net.nz> for + pgsql-performance@postgresql.org; Sat, 24 Sep 2005 17:15:02 +1200 (NZST) +Received: from [192.168.1.11] (218-101-45-243.paradise.net.nz + [218.101.45.243]) + by smtp-1.paradise.net.nz (Postfix) with ESMTP id 9BB50828A3; Sat, + 24 Sep 2005 17:15:01 +1200 (NZST) +Date: Sat, 24 Sep 2005 17:14:59 +1200 +From: Mark Kirkwood +Subject: Re: SELECT LIMIT 1 VIEW Performance Issue +In-reply-to: <6.2.1.2.0.20050924105728.05388920@localhost> +To: K C Lau +Cc: pgsql-performance@postgresql.org +Message-id: <4334E0D3.1080504@paradise.net.nz> +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=us-ascii +Content-transfer-encoding: 7bit +X-Accept-Language: en-us, en +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050726) +References: <6EE64EF3AB31D5448D0007DD34EEB3417DD406@Herge.rcsinc.local> + <6.2.1.2.0.20050923155952.05889a50@localhost> + <4334AE89.8060806@paradise.net.nz> + <6.2.1.2.0.20050924105728.05388920@localhost> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.126 required=5 tests=[AWL=0.126] +X-Spam-Level: +X-Archive-Number: 200509/321 +X-Sequence-Number: 14629 + +K C Lau wrote: + +> I'm wondering if this performance issue is common enough for other users +> to merit a fix in pg, especially as it seems that with MVCC, each of the +> data records need to be accessed in addition to scanning the index. +> + +Yes - there are certainly cases where index only access (or something +similar, like b+tree tables) would be highly desirable. + + From what I have understood from previous discussions, there are +difficulties involved with producing a design that does not cause new +problems... + +regards + +Mark + +From pgsql-hackers-owner@postgresql.org Sat Sep 24 02:24:08 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 19532D93CA + for ; + Sat, 24 Sep 2005 02:24:07 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 09150-08 + for ; + Sat, 24 Sep 2005 05:24:02 +0000 (GMT) +Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.200]) + by svr1.postgresql.org (Postfix) with ESMTP id 621B5D7AB6 + for ; + Sat, 24 Sep 2005 02:24:01 -0300 (ADT) +Received: by zproxy.gmail.com with SMTP id 40so786494nzk + for ; + Fri, 23 Sep 2005 22:24:01 -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=LRH4GAGibSL9YlU0HlnEV7O44dISZYY2zeNL5hFEz3Bm908AAUOKGBivRt24310jZMfzDQtGVJJtvwH7GC6EajYVqejzqnoN9PMRgRYJn2nnN09j6Fg8pEmJ3j3lEgcHnYy8d0d/fCBlDUYAEiJLsvSR1QKXo+UimUj+lIrUzYg= +Received: by 10.36.96.16 with SMTP id t16mr2516435nzb; + Fri, 23 Sep 2005 22:24:01 -0700 (PDT) +Received: by 10.37.22.65 with HTTP; Fri, 23 Sep 2005 22:24:01 -0700 (PDT) +Message-ID: +Date: Sat, 24 Sep 2005 08:24:01 +0300 +From: Meir Maor +Reply-To: Meir Maor +To: Simon Riggs +Subject: Re: Releasing memory during External sorting? +Cc: pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org +In-Reply-To: <1127468233.4145.178.camel@localhost.localdomain> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_9878_20134342.1127539441198" +References: <1127468233.4145.178.camel@localhost.localdomain> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.172 required=5 tests=[AWL=-0.148, HTML_10_20=0.295, + HTML_MESSAGE=0.001, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200509/1050 +X-Sequence-Number: 73447 + +------=_Part_9878_20134342.1127539441198 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Calculating Optimal memory for disk based sort is based only on minimizing +IO. +A previous post stated we can merge as many subfiles as we want in a single +pass, +this is not accurate, as we want to eliminate disk seeks also in the merge +phase, +also the merging should be done by reading blocks of data from each subfile= +, +if we have data of size N and M memory, then we will have K=3DN/M subfiles = +to +merge +after sorting each. +in the merge operation if we want to merge all blocks in one pass we will +read +M/K data from each subfile into memory and begin merging, we will read +another M/K block +when the buffer from a subfile is empty, +we would like disk seek time to be irrelavant when comparing to sequential +IO time. +We notice that we are performing IO in blocks of N/K^2 which is M/(N/M)^2 +let us assume that sequeential IO is done at 100MB/s and that +a random seek requires ~15ms. and we want seek time to be irrelavnt in one +order of +magnitute we get, that in the time of one random seek we can read 1.5MB of +data +and would get optimal performance if we perform IO in blocks of 15MB. +and since in the merge algorithm showed above we perform IO in blocks of M/= +K +we would like M>K*15MB which results in a very large memory requirement. +M^2>N*15MB +M>sqrt(N*15MB) +for example for sorting 10GB of data, we would like M>380MB +for optimal performance. + +alternativly if we can choose a diffrent algorithm in which we merge only a +constant +number of sunfiles to gether at a time but then we will require multiple +passes to merge +the entire file. we will require log(K) passes over the entire data and thi= +s +approach obviously +improves with increase of memory. + +The first aproach requires 2 passes of the entire data and K^2+K random +seeks, +the second aproach(when merging l blocks at a time) requires: log(l,K) +passes over the data +and K*l+K random seeks. + + +On 9/23/05, Simon Riggs wrote: +> +> I have concerns about whether we are overallocating memory for use in +> external sorts. (All code relating to this is in tuplesort.c) +> +> When we begin a sort we allocate (work_mem | maintenance_work_mem) and +> attempt to do the sort in memory. If the sort set is too big to fit in +> memory we then write to disk and begin an external sort. The same memory +> allocation is used for both types of sort, AFAICS. +> +> The external sort algorithm benefits from some memory but not much. +> Knuth says that the amount of memory required is very low, with a value +> typically less than 1 kB. I/O overheads mean that there is benefit from +> having longer sequential writes, so the optimum is much larger than +> that. I've not seen any data that indicates that a setting higher than +> 16 MB adds any value at all to a large external sort. I have some +> indications from private tests that very high memory settings may +> actually hinder performance of the sorts, though I cannot explain that +> and wonder whether it is the performance tests themselves that have +> issues. +> +> Does anyone have any clear data that shows the value of large settings +> of work_mem when the data to be sorted is much larger than memory? (I am +> well aware of the value of setting work_mem higher for smaller sorts, so +> any performance data needs to reflect only very large sorts). +> +> If not, I would propose that when we move from qsort to tapesort mode we +> free the larger work_mem setting (if one exists) and allocate only a +> lower, though still optimal setting for the tapesort. That way the +> memory can be freed for use by other users or the OS while the tapesort +> proceeds (which is usually quite a while...). +> +> Feedback, please. +> +> Best Regards, Simon Riggs +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 5: don't forget to increase your free space map settings +> + +------=_Part_9878_20134342.1127539441198 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Calculating Optimal memory for disk based sort is based only on minimizing = +IO.
+A previous post stated we can merge as many subfiles as we want in a single= + pass,
+this is not accurate, as we want to eliminate disk seeks also in the merge = +phase,
+also the merging should be done by reading blocks of data from each subfile= +,
+if we have data of size N and M memory, then we will have K=3DN/M subfiles = +to merge
+after sorting each.
+in the merge operation if we want to merge all blocks in one pass we will r= +ead
+M/K data from each subfile into memory and begin merging, we will read anot= +her M/K block
+when the buffer from a subfile is empty,
+we would like disk seek time to be irrelavant when comparing to sequential = +IO time.
+We notice that we are performing IO in blocks of N/K^2 which is M/(N/M)^2 <= +br> +let us assume that sequeential IO is done at 100MB/s and that
+a random seek requires ~15ms. and we want seek time to be irrelavnt in one = +order of
+magnitute we get, that in the time of one random seek we can read 1.5MB of = +data
+and would get optimal performance if we perform IO in blocks of 15MB.
+and since in the merge algorithm showed above we perform IO in blocks of M/= +K
+we would like M>K*15MB which results in a very large memory requirement.= +
+M^2>N*15MB
+M>sqrt(N*15MB)
+for example for sorting 10GB of data, we would like M>380MB
+for optimal performance.
+
+alternativly if we can choose a diffrent algorithm in which we merge only a= + constant
+number of sunfiles to gether at a time but then we will require multiple pa= +sses to merge
+the entire file. we will require log(K) passes over the entire data and thi= +s approach obviously
+improves with increase of memory.
+
+The first aproach requires 2 passes of the entire data and K^2+K random see= +ks,
+the second aproach(when merging l blocks at a time) requires: log(l,K) pass= +es over the data
+and K*l+K random seeks.
+
+
On 9/23/05, Simon Riggs <simon@2ndq= +uadrant.com> wrote:
+I have concerns about whether we are overallocating memory for use in
ex= +ternal sorts. (All code relating to this is in tuplesort.c)

When we = +begin a sort we allocate (work_mem | maintenance_work_mem) and
attempt t= +o do the sort in memory. If the sort set is too big to fit in +
memory we then write to disk and begin an external sort. The same memor= +y
allocation is used for both types of sort, AFAICS.

The external= + sort algorithm benefits from some memory but not much.
Knuth says that = +the amount of memory required is very low, with a value +
typically less than 1 kB. I/O overheads mean that there is benefit from= +
having longer sequential writes, so the optimum is much larger than
= +that. I've not seen any data that indicates that a setting higher than
+16 MB adds any value at all to a large external sort. I have some
indica= +tions from private tests that very high memory settings may
actually hin= +der performance of the sorts, though I cannot explain that
and wonder wh= +ether it is the performance tests themselves that have +
issues.

Does anyone have any clear data that shows the value of = +large settings
of work_mem when the data to be sorted is much larger tha= +n memory? (I am
well aware of the value of setting work_mem higher for s= +maller sorts, so +
any performance data needs to reflect only very large sorts).

If= + not, I would propose that when we move from qsort to tapesort mode we
f= +ree the larger work_mem setting (if one exists) and allocate only a
+lower, though still optimal setting for the tapesort. That way the
memor= +y can be freed for use by other users or the OS while the tapesort
proce= +eds (which is usually quite a while...).

Feedback, please.

+Best Regards, Simon Riggs


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

+ +------=_Part_9878_20134342.1127539441198-- + +From pgsql-performance-owner@postgresql.org Sat Sep 24 03:11:07 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CF2DFD80D7 + for ; + Sat, 24 Sep 2005 03:11:06 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 27971-03 + for ; + Sat, 24 Sep 2005 06:11:03 +0000 (GMT) +Received: from svr2.postgresql.org (svr2.postgresql.org [65.19.161.25]) + by svr1.postgresql.org (Postfix) with ESMTP id 8C722D6F35 + for ; + Sat, 24 Sep 2005 03:11:03 -0300 (ADT) +Received: from ra.sai.msu.su (ra.sai.msu.su [158.250.29.2]) + by svr2.postgresql.org (Postfix) with ESMTP id 086FBF0B26 + for ; + Sat, 24 Sep 2005 07:05:58 +0100 (BST) +Received: from ra (ra [158.250.29.2]) + by ra.sai.msu.su (8.13.4/8.13.4) with ESMTP id j8O67gOP023640; + Sat, 24 Sep 2005 10:07:42 +0400 (MSD) +Date: Sat, 24 Sep 2005 10:07:42 +0400 (MSD) +From: Oleg Bartunov +X-X-Sender: megera@ra.sai.msu.su +To: Ahmad Fajar +Cc: pgsql-performance@postgresql.org +Subject: Re: tsearch2 seem very slow +In-Reply-To: +Message-ID: +References: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.323 required=5 tests=[AWL=-0.051, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200509/322 +X-Sequence-Number: 14630 + +Ahmad, + +what's about the number of unique words ? I mean stat() function. +Sometimes, it helps to identify garbage words. +How big is your articles (average length) ? + +please, cut'n paste queries and output from psql ! How fast are +next queries ? + + Oleg +On Fri, 23 Sep 2005, Ahmad Fajar wrote: + +> Hi Oleg, +> +> For single index I try this query: +> explain analyze +> select articleid, title, datee from articles +> where fti @@ to_tsquery('bank&indonesia'); +> +> analyze result: +> ---------------- +> "Index Scan using fti_idx on articles (cost=0.00..862.97 rows=420 width=51) +> (actual time=0.067..183761.324 rows=46186 loops=1)" +> " Index Cond: (fti @@ '\'bank\' & \'indonesia\''::tsquery)" +> "Total runtime: 183837.826 ms" +> +> And for multicolumn index I try this query: +> explain analyze +> select articleid, title, datee from articles +> where fti @@ to_tsquery('bank&mega'); +> +> analyze result: +> ---------------- +> "Index Scan using articles_x1 on articles (cost=0.00..848.01 rows=410 +> width=51) (actual time=52.204..37914.135 rows=1841 loops=1)" +> " Index Cond: ((datee >= '2002-01-01'::date) AND (datee <= +> ('now'::text)::date) AND (fti @@ '\'bank\' & \'mega\''::tsquery))" +> "Total runtime: 37933.757 ms" +> +> The table structure is as mention on the first talk. If you wanna know how +> much table in my database, it's about 100 tables or maybe more. Now I +> develop the version 2 of my web application, you can take a look at: +> http://www.mediatrac.net, so it will hold many datas. But the biggest table +> is article's table. On develop this version 2 I just use half data of the +> article's table (about 419804 rows). May be if I import all of the article's +> table data it will have 1 million rows. The article's table grows rapidly, +> about 100000 rows per-week. My developing database size is 28 GB (not real +> database, coz I still develop the version 2 and I use half of the data for +> play around). I just wanna to perform quick search (fulltext search) on my +> article's table not other table. On version 1, the current running version I +> use same hardware spesification as mention below, but there is no fulltext +> search. So I develop the new version with new features, new interface and +> include the fulltext search. +> +> I do know, if the application finish, I must use powerfull hardware. But how +> can I guarantee the application will run smooth, if I do fulltext search on +> 419804 rows in a table it took a long time to get the result. +> +> Could you or friends in this maling-list help me....plz..plzz +> +> Tsearch2 configuration: +> ------------------------- +> I use default configuration, english stop word file as tsearch2 provide, +> stem dictionary as default (coz I don't know how to configure and add new +> data to stem dictionary) and I add some words to the english stop word file. +> +> Postgresql configuration +> ------------------------- +> max_connections = 32 +> shared_buffers = 32768 +> sort_mem = 8192 +> vacuum_mem = 65536 +> work_mem = 16384 +> maintenance_work_mem = 65536 +> max_fsm_pages = 30000 +> max_fsm_relations = 1000 +> max_files_per_process = 100000 +> checkpoint_segments = 15 +> effective_cache_size = 192000 +> random_page_cost = 2 +> geqo = true +> geqo_threshold = 50 +> geqo_effort = 5 +> geqo_pool_size = 0 +> geqo_generations = 0 +> geqo_selection_bias = 2.0 +> from_collapse_limit = 10 +> join_collapse_limit = 15 +> +> OS configuration: +> ------------------ +> I use Redhat 4 AS, kernel 2.6.9-11 +> kernel.shmmax=1073741824 +> kernel.sem=250 32000 100 128 +> fs.aio-max-nr=5242880 +> the server I configure just only for postgresql, no other service is running +> like: www, samba, ftp, email, firewall +> +> hardware configuration: +> ------------------------ +> Motherboard ASUS P5GD1 +> Processor P4 3,2 GHz +> Memory 2 GB DDR 400, +> 2x200 GB Serial ATA 7200 RPM UltraATA/133, configure as RAID0 for postgresql +> data and the partition is EXT3 +> 1x80 GB EIDE 7200 RPM configure for system and home directory and the +> partiton is EXT3 +> +> Did I miss something? +> +> Regards, +> ahmad fajar +> +> +> -----Original Message----- +> From: Oleg Bartunov [mailto:oleg@sai.msu.su] +> Sent: Jumat, 23 September 2005 18:26 +> To: Ahmad Fajar +> Cc: pgsql-performance@postgresql.org +> Subject: RE: [PERFORM] tsearch2 seem very slow +> +> On Fri, 23 Sep 2005, Ahmad Fajar wrote: +> +>> Hi Oleg, +>> +>> I didn't deny on the third repeat or more, it can reach < 600 msec. It is +>> only because the result still in postgres cache, but how about in the +> first +>> run? I didn't dare, the values is un-acceptable. Because my table will +> grows +>> rapidly, it's about 100000 rows per-week. And the visitor will search +>> anything that I don't know, whether it's the repeated search or new +> search, +>> or whether it's in postgres cache or not. +> +> if you have enoush shared memory postgresql will keep index pages there. +> +> +>> +>> I just compare with http://www.postgresql.org, the search is quite fast, +> and +>> I don't know whether the site uses tsearch2 or something else. But as fas +> as +>> I know, if the rows reach >100 milion (I have try for 200 milion rows and +> it +>> seem very slow), even if don't use tsearch2, only use simple query like: +>> select f1, f2 from table1 where f2='blabla', +>> and f2 is indexes, my postgres still slow on the first time, about >10 +> sec. +>> because of this I tried something brand new to fullfill my needs. I have +>> used fti, and tsearch2 but still slow. +>> +>> I don't know what's going wrong with my postgres, what configuration must +> I +>> do to perform the query get fast result. Or must I use enterprisedb 2005 +> or +>> pervasive postgres (both uses postgres), I don't know very much about +> these +>> two products. +> +> you didn't show us your configuration (hardware,postgresql and tsearch2), +> explain analyze of your queries, so we can't help you. +> How big is your database, tsearch2 index size ? +> +> +>> +>> Regards, +>> ahmad fajar +>> +>> +>> -----Original Message----- +>> From: Oleg Bartunov [mailto:oleg@sai.msu.su] +>> Sent: Jumat, 23 September 2005 14:36 +>> To: Ahmad Fajar +>> Cc: pgsql-performance@postgresql.org +>> Subject: Re: [PERFORM] tsearch2 seem very slow +>> +>> Ahmad, +>> +>> how fast is repeated runs ? First time system could be very slow. +>> Also, have you checked my page +>> http://www.sai.msu.su/~megera/oddmuse/index.cgi/Tsearch_V2_Notes +>> and some info about tsearch2 internals +>> http://www.sai.msu.su/~megera/oddmuse/index.cgi/Tsearch_V2_internals +>> +>> Oleg +>> On Thu, 22 Sep 2005, Ahmad Fajar wrote: +>> +>>> I have about 419804 rows in my article table. I have installed tsearch2 +>> and +>>> its gist index correctly. +>>> +>>> My table structure is: +>>> +>>> CREATE TABLE tbarticles +>>> +>>> ( +>>> +>>> articleid int4 NOT NULL, +>>> +>>> title varchar(250), +>>> +>>> mediaid int4, +>>> +>>> datee date, +>>> +>>> content text, +>>> +>>> contentvar text, +>>> +>>> mmcol float4 NOT NULL, +>>> +>>> sirkulasi float4, +>>> +>>> page varchar(10), +>>> +>>> tglisidata date, +>>> +>>> namapc varchar(12), +>>> +>>> usere varchar(12), +>>> +>>> file_pdf varchar(255), +>>> +>>> file_pdf2 varchar(50), +>>> +>>> kolom int4, +>>> +>>> size_jpeg int4, +>>> +>>> journalist varchar(120), +>>> +>>> ratebw float4, +>>> +>>> ratefc float4, +>>> +>>> fti tsvector, +>>> +>>> CONSTRAINT pk_tbarticles PRIMARY KEY (articleid) +>>> +>>> ) WITHOUT OIDS; +>>> +>>> Create index fti_idx1 on tbarticles using gist (fti); +>>> +>>> Create index fti_idx2 on tbarticles using gist (datee, fti); +>>> +>>> +>>> +>>> But when I search something like: +>>> +>>> Select articleid, title, datee from tbarticles where fti @@ +>>> to_tsquery('susilo&bambang&yudhoyono&jusuf&kalla'); +>>> +>>> It takes about 30 sec. I run explain analyze and the index is used +>>> correctly. +>>> +>>> +>>> +>>> Then I try multi column index to filter by date, and my query something +>>> like: +>>> +>>> Select articleid, title, datee from tbarticles where fti @@ +>>> to_tsquery('susilo&bambang&yudhoyono&jusuf&kalla') and datee >= +>> '2002-01-01' +>>> and datee <= current_date +>>> +>>> An it still run about 25 sec. I do run explain analyze and my multicolumn +>>> index is used correctly. +>>> +>>> This is not acceptable if want to publish my website if the search took +>> very +>>> longer. +>>> +>>> +>>> +>>> I have run vacuum full analyze before doing such query. What going wrong +>>> with my query?? Is there any way to make this faster? +>>> +>>> I have try to tune my postgres configuration, but it seem helpless. My +>> linux +>>> box is Redhat 4 AS, and +>>> +>>> the hardware: 2 GB RAM DDR 400, 2x200 GB Serial ATA 7200RPM and configure +>> as +>>> RAID0 (just for postgres data), my sistem run at EIDE 80GB 7200 RPM. +>>> +>>> +>>> +>>> Please.help.help. +>>> +>>> +>> +>> Regards, +>> Oleg +>> _____________________________________________________________ +>> Oleg Bartunov, sci.researcher, hostmaster of AstroNet, +>> Sternberg Astronomical Institute, Moscow University (Russia) +>> Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ +>> phone: +007(095)939-16-83, +007(095)939-23-83 +>> +> +> Regards, +> Oleg +> _____________________________________________________________ +> Oleg Bartunov, sci.researcher, hostmaster of AstroNet, +> Sternberg Astronomical Institute, Moscow University (Russia) +> Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ +> phone: +007(095)939-16-83, +007(095)939-23-83 +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: Don't 'kill -9' the postmaster +> + + Regards, + Oleg +_____________________________________________________________ +Oleg Bartunov, sci.researcher, hostmaster of AstroNet, +Sternberg Astronomical Institute, Moscow University (Russia) +Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ +phone: +007(095)939-16-83, +007(095)939-23-83 + +From pgsql-performance-owner@postgresql.org Sat Sep 24 05:34:24 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 385AED8B28 + for ; + Sat, 24 Sep 2005 05:34:22 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 54653-04 + for ; + Sat, 24 Sep 2005 08:34:18 +0000 (GMT) +Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 218F9D8A36 + for ; + Sat, 24 Sep 2005 05:34:18 -0300 (ADT) +Received: (qmail 29162 invoked from network); 24 Sep 2005 10:35:04 +0200 +Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) + by boutiquenumerique.com with SMTP; 24 Sep 2005 10:35:04 +0200 +Date: Sat, 24 Sep 2005 10:34:15 +0200 +To: pgsql-performance@postgresql.org +Subject: Advice on RAID card +References: +From: PFC +Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= +Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-ID: +In-Reply-To: +User-Agent: Opera M2/8.0 (Linux, build 1095) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/323 +X-Sequence-Number: 14631 + + + Hello fellow Postgresql'ers. + + I've been stumbled on this RAID card which looks nice. It is a PCI-X SATA +Raid card with 6 channels, and does RAID 0,1,5,10,50. + It is a HP card with an Adaptec chip on it, and 64 MB cache. + + HP Part # : 372953-B21 + Adaptec Part # : AAR-2610SA/64MB/HP + + There' even a picture : + http://megbytes.free.fr/Sata/DSC05970.JPG + + I know it isn't as good as a full SCSI system. I just want to know if +some of you have had experiences with these, and if this cards belong to +the "slower than no RAID" camp, like some DELL card we often see mentioned +here, or to the "decent performance for the price" camp. It is to run on a +Linux. + + Thanks in advance for your time and information. + +From pgsql-hackers-owner@postgresql.org Sat Sep 24 13:03:38 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6A344D8134; + Sat, 24 Sep 2005 07:31:18 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 83278-04; Sat, 24 Sep 2005 10:31:14 +0000 (GMT) +Received: from pop-gadwall.atl.sa.earthlink.net + (pop-gadwall.atl.sa.earthlink.net [207.69.195.61]) + by svr1.postgresql.org (Postfix) with ESMTP id BF0F9D7BFB; + Sat, 24 Sep 2005 07:31:15 -0300 (ADT) +Received: from elwamui-huard.atl.sa.earthlink.net ([209.86.224.35]) + by pop-gadwall.atl.sa.earthlink.net with esmtp (Exim 3.36 #10) + id 1EJ7It-0003cr-00; Sat, 24 Sep 2005 06:30:47 -0400 +Message-ID: + <24299535.1127557847225.JavaMail.root@elwamui-huard.atl.sa.earthlink.net> +Date: Sat, 24 Sep 2005 06:30:47 -0400 (EDT) +From: Ron Peacetree +Reply-To: Ron Peacetree +To: Dann Corbit , pgsql-hackers@postgresql.org, + pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Releasing memory during External sorting? +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Mailer: Earthlink Zoo Mail 1.0 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.255 required=5 tests=[AWL=-0.119, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200509/1062 +X-Sequence-Number: 73459 + +From: Dann Corbit +Sent: Sep 23, 2005 5:38 PM +Subject: RE: [HACKERS] [PERFORM] Releasing memory during External sorting? + +>_C Unleashed_ also explains how to use a callback function to perform +>arbitrary radix sorts (you simply need a method that returns the +>[bucketsize] most significant bits for a given data type, for the length +>of the key). +> +>So you can sort fairly arbitrary data in linear time (of course if the +>key is long then O(n*log(n)) will be better anyway.) +> +>But in any case, if we are talking about external sorting, then disk +>time will be so totally dominant that the choice of algorithm is +>practically irrelevant. +> +Horsefeathers. Jim Gray's sorting contest site: +http://research.microsoft.com/barc/SortBenchmark/ + +proves that the choice of algorithm can have a profound affect on +performance. After all, the amount of IO done is the most +important of the things that you should be optimizing for in +choosing an external sorting algorithm. + +Clearly, if we know or can assume the range of the data in question +the theoretical minimum amount of IO is one pass through all of the +data (otherwise, we are back in O(lg(n!)) land ). Equally clearly, for +HD's that one pass should involve as few seeks as possible. + +In fact, such a principle can be applied to _all_ forms of IO: HD, +RAM, and CPU cache. The absolute best that any sort can +possibly do is to make one pass through the data and deduce the +proper ordering of the data during that one pass. + +It's usually also important that our algorithm be Stable, preferably +Wholly Stable. + +Let's call such a sort Optimal External Sort (OES). Just how much +faster would it be than current practice? + +The short answer is the difference between how long it currently +takes to sort a file vs how long it would take to "cat" the contents +of the same file to a RAM buffer (_without_ displaying it). IOW, +there's SIGNIFICANT room for improvement over current +standard practice in terms of sorting performance, particularly +external sorting performance. + +Since sorting is a fundamental operation in many parts of a DBMS, +this is a Big Deal. + +This discussion has gotten my creative juices flowing. I'll post +some Straw Man algorithm sketches after I've done some more +thought. + +Ron + +> -----Original Message----- +> From: Dann Corbit +> Sent: Friday, September 23, 2005 2:21 PM +> Subject: Re: [HACKERS] [PERFORM] Releasing memory during ... +> +>For the subfiles, load the top element of each subfile into a priority +>queue. Extract the min element and write it to disk. If the next +>value is the same, then the queue does not need to be adjusted. +>If the next value in the subfile changes, then adjust it. +> +>Then, when the lowest element in the priority queue changes, adjust +>the queue. +> +>Keep doing that until the queue is empty. +> +>You can create all the subfiles in one pass over the data. +> +>You can read all the subfiles, merge them, and write them out in a +>second pass (no matter how many of them there are). +> +The Gotcha with Priority Queues is that their performance depends +entirely on implementation. In naive implementations either Enqueue() +or Dequeue() takes O(n) time, which reduces sorting time to O(n^2). + +The best implementations I know of need O(lglgn) time for those +operations, allowing sorting to be done in O(nlglgn) time. +Unfortunately, there's a lot of data manipulation going on in the +process and two IO passes are required to sort any given file. +Priority Queues do not appear to be very "IO friendly". + +I know of no sorting performance benchmark contest winner based on +Priority Queues. + + +>Replacement selection is not a good idea any more, since obvious +>better ideas should take over. Longer runs are of no value if you do not +>have to do multiple merge passes. +> +Judging from the literature and the contest winners, Replacement +Selection is still a viable and important technique. Besides Priority +Queues, what "obvious better ideas" have you heard of? + + +>I have explained this general technique in the book "C Unleashed", +>chapter 13. +> +>Sample code is available on the book's home page. +> +URL please? + +From pgsql-performance-owner@postgresql.org Sat Sep 24 12:56:06 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9E754D82FF + for ; + Sat, 24 Sep 2005 12:56:04 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 05704-05 + for ; + Sat, 24 Sep 2005 15:55:58 +0000 (GMT) +Received: from pop-knobcone.atl.sa.earthlink.net + (pop-knobcone.atl.sa.earthlink.net [207.69.195.64]) + by svr1.postgresql.org (Postfix) with ESMTP id 4CE55D91FA + for ; + Sat, 24 Sep 2005 12:55:57 -0300 (ADT) +Received: from elwamui-hound.atl.sa.earthlink.net ([209.86.224.34]) + by pop-knobcone.atl.sa.earthlink.net with esmtp (Exim 3.36 #10) + id 1EJCNV-0000Nl-00; Sat, 24 Sep 2005 11:55:53 -0400 +Message-ID: + <5559818.1127577353936.JavaMail.root@elwamui-hound.atl.sa.earthlink.net> +Date: Sat, 24 Sep 2005 11:55:53 -0400 (EDT) +From: Ron Peacetree +Reply-To: Ron Peacetree +To: PFC , + pgsql-performance@postgresql.org +Subject: Re: Advice on RAID card +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Mailer: Earthlink Zoo Mail 1.0 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.259 required=5 tests=[AWL=-0.115, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200509/325 +X-Sequence-Number: 14633 + +It looks like a rebranded low end Adaptec 64MB PCI-X <-> SATA RAID card. +Looks like the 64MB buffer is not upgradable. +Looks like it's SATA, not SATA II + +There are much better ways to spend your money. + +These are the products with the current best price/performance ratio: +http://www.areca.us/products/html/pcix-sata.htm + +Assuming you are not building 1U boxes, get one of the full height +cards and order it with the maximum size buffer you can afford. +The cards take 1 SODIMM, so that will be a max of 1GB or 2GB +depending on whether 2GB SODIMMs are available to you yet. + +Ron + +-----Original Message----- +From: PFC +Sent: Sep 24, 2005 4:34 AM +To: pgsql-performance@postgresql.org +Subject: [PERFORM] Advice on RAID card + + + Hello fellow Postgresql'ers. + + I've been stumbled on this RAID card which looks nice. It is a PCI-X SATA +Raid card with 6 channels, and does RAID 0,1,5,10,50. + It is a HP card with an Adaptec chip on it, and 64 MB cache. + + HP Part # : 372953-B21 + Adaptec Part # : AAR-2610SA/64MB/HP + + There' even a picture : + http://megbytes.free.fr/Sata/DSC05970.JPG + + I know it isn't as good as a full SCSI system. I just want to know if +some of you have had experiences with these, and if this cards belong to +the "slower than no RAID" camp, like some DELL card we often see mentioned +here, or to the "decent performance for the price" camp. It is to run on a +Linux. + + Thanks in advance for your time and information. + +---------------------------(end of broadcast)--------------------------- +TIP 4: Have you searched our list archives? + + http://archives.postgresql.org + + +From pgsql-performance-owner@postgresql.org Sat Sep 24 13:27:46 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AA4A9D9444 + for ; + Sat, 24 Sep 2005 13:27:44 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 10769-07 + for ; + Sat, 24 Sep 2005 16:27:41 +0000 (GMT) +Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id EF7CCD9376 + for ; + Sat, 24 Sep 2005 13:27:40 -0300 (ADT) +Received: (qmail 17740 invoked from network); 24 Sep 2005 18:28:26 +0200 +Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) + by boutiquenumerique.com with SMTP; 24 Sep 2005 18:28:26 +0200 +To: "Ron Peacetree" , pgsql-performance@postgresql.org +Subject: Re: Advice on RAID card +References: + <5559818.1127577353936.JavaMail.root@elwamui-hound.atl.sa.earthlink.net> +Message-ID: +Date: Sat, 24 Sep 2005 18:27:36 +0200 +From: PFC +Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= +Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +In-Reply-To: + <5559818.1127577353936.JavaMail.root@elwamui-hound.atl.sa.earthlink.net> +User-Agent: Opera M2/8.0 (Linux, build 1095) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/326 +X-Sequence-Number: 14634 + + +> It looks like a rebranded low end Adaptec 64MB PCI-X <-> SATA RAID card. +> Looks like the 64MB buffer is not upgradable. +> Looks like it's SATA, not SATA II + + Yeah, that's exactly what it is. I can get one for 150 Euro, the Areca is +at least 600. This is for a budget server so while it would be nice to +have all the high-tech stuff, it's not the point. My question was raher, +is it one of the crap RAID5 cards which are actually SLOWER than plain IDE +disks, or is it decent, even though low-end (and cheap), and worth it +compared to software RAID5 ? + +> Assuming you are not building 1U boxes, get one of the full height +> cards and order it with the maximum size buffer you can afford. +> The cards take 1 SODIMM, so that will be a max of 1GB or 2GB +> depending on whether 2GB SODIMMs are available to you yet. + + It's for a budget dev server which should have RAID5 for reliability, but +not necessarily stellar performance (and price). I asked about this card +because I can get one at a good price. + + Thanks for taking the time to answer. + +From pgsql-performance-owner@postgresql.org Sat Sep 24 17:51:30 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AE4DCD6EB0 + for ; + Sat, 24 Sep 2005 17:51:29 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 65170-08 + for ; + Sat, 24 Sep 2005 20:51:26 +0000 (GMT) +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9FE70D6DA1 + for ; + Sat, 24 Sep 2005 17:51:26 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 02E2131F51; Sat, 24 Sep 2005 22:51:26 +0200 (MET DST) +From: Ron Mayer +X-Newsgroups: pgsql.performance +Subject: Multiple insert performance trick or performance misunderstanding? +Date: Sat, 24 Sep 2005 13:51:16 -0700 +Organization: Hub.Org Networking Services +Lines: 32 +Message-ID: +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=-0.012 required=5 tests=[AWL=-0.012] +X-Spam-Level: +X-Archive-Number: 200509/327 +X-Sequence-Number: 14635 + +When I need to insert a few hundred or thousand things in +a table from a 3-tier application, it seems I'm much better +off creating a big string of semicolon separated insert +statements rather than sending them one at a time - even +when I use the obvious things like wrapping the statements +in a transaction and using the library's prepared statements. + + + +I tried both Ruby/DBI and C#/Npgsql; and in both cases +sets of inserts that took 3 seconds when run individually +took about 0.7 seconds when concatenated together. + +Is it expected that I'd be better off sending big +concatenated strings like + "insert into tbl (c1,c2) values (v1,v2);insert into tbl (c1,c2) values (v3,v4);..." +instead of sending them one at a time? + + + + + +db.ExecuteSQL("BEGIN"); +sql = new System.Text.StringBulder(10000); +for ([a lot of data elements]) { + sql.Append( + "insert into user_point_features (col1,col2)"+ + " values (" +obj.val1 +","+obj.val2+");" + ); +} +db.ExecuteSQL(sql.ToString()); +db.ExecuteSQL("COMMIT"); + +From pgsql-performance-owner@postgresql.org Sat Sep 24 18:15:43 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 54F60D91FA + for ; + Sat, 24 Sep 2005 18:15:41 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 71750-07 + for ; + Sat, 24 Sep 2005 21:15:38 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 8CC72D8EF1 + for ; + Sat, 24 Sep 2005 18:15:39 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j8OLFfpK023703; + Sat, 24 Sep 2005 17:15:41 -0400 (EDT) +To: Ron Mayer +Cc: pgsql-performance@postgresql.org +Subject: Re: Multiple insert performance trick or performance + misunderstanding? +In-reply-to: +References: +Comments: In-reply-to Ron Mayer + message dated "Sat, 24 Sep 2005 13:51:16 -0700" +Date: Sat, 24 Sep 2005 17:15:41 -0400 +Message-ID: <23702.1127596541@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/328 +X-Sequence-Number: 14636 + +Ron Mayer writes: +> Is it expected that I'd be better off sending big +> concatenated strings like +> "insert into tbl (c1,c2) values (v1,v2);insert into tbl (c1,c2) values (v3,v4);..." +> instead of sending them one at a time? + +It's certainly possible, if the network round trip from client to server +is slow. I do not think offhand that there is any material advantage +for the processing within the server (assuming you've wrapped the whole +thing into one transaction in both cases); if anything, the +concatenated-statement case is probably a bit worse inside the server +because it will transiently eat more memory. But network latency or +client-side per-command overhead could well cause the results you see. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Sep 25 07:16:08 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2F33BD90FC + for ; + Sun, 25 Sep 2005 07:16:07 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 65886-01 + for ; + Sun, 25 Sep 2005 10:15:54 +0000 (GMT) +Received: from mxout5.netvision.net.il (mxout5.netvision.net.il [194.90.9.29]) + by svr1.postgresql.org (Postfix) with ESMTP id 08969D6DA1 + for ; + Sun, 25 Sep 2005 07:15:54 -0300 (ADT) +Received: from [192.168.0.50] ([194.90.15.25]) by mxout5.netvision.net.il + (Sun Java System Messaging Server 6.1 HotFix 0.11 (built Jan 28 2005)) + with ESMTP id <0IND00G3LB6J1UC0@mxout5.netvision.net.il> for + pgsql-performance@postgresql.org; Sun, 25 Sep 2005 13:15:56 +0300 (IDT) +Date: Sun, 25 Sep 2005 13:17:27 +0300 +From: Michael Ben-Nes +Subject: Re: Advice on RAID card +In-reply-to: +To: PFC +Cc: pgsql-performance@postgresql.org +Message-id: <43367937.40809@canaan.co.il> +Organization: Canaan Surfing Ltd +MIME-version: 1.0 +Content-type: text/plain; charset=ISO-8859-15; format=flowed +Content-transfer-encoding: 7BIT +X-Accept-Language: en-us, en +References: + +User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.086 required=5 tests=[AWL=0.086] +X-Spam-Level: +X-Archive-Number: 200509/329 +X-Sequence-Number: 14637 + +I would consider Software Raid + + +PFC wrote: + +> +> Hello fellow Postgresql'ers. +> +> I've been stumbled on this RAID card which looks nice. It is a +> PCI-X SATA Raid card with 6 channels, and does RAID 0,1,5,10,50. +> It is a HP card with an Adaptec chip on it, and 64 MB cache. +> +> HP Part # : 372953-B21 +> Adaptec Part # : AAR-2610SA/64MB/HP +> +> There' even a picture : +> http://megbytes.free.fr/Sata/DSC05970.JPG +> +> I know it isn't as good as a full SCSI system. I just want to know +> if some of you have had experiences with these, and if this cards +> belong to the "slower than no RAID" camp, like some DELL card we +> often see mentioned here, or to the "decent performance for the +> price" camp. It is to run on a Linux. +> +> Thanks in advance for your time and information. +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 4: Have you searched our list archives? +> +> http://archives.postgresql.org + + +-- +-------------------------- +Canaan Surfing Ltd. +Internet Service Providers +Ben-Nes Michael - Manager +Tel: 972-4-6991122 +Cel: 972-52-8555757 +Fax: 972-4-6990098 +http://www.canaan.net.il +-------------------------- + + +From pgsql-performance-owner@postgresql.org Sun Sep 25 11:57:59 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A306FD953D + for ; + Sun, 25 Sep 2005 11:57:58 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 48110-01 + for ; + Sun, 25 Sep 2005 14:57:51 +0000 (GMT) +Received: from net2.micro-automation.com (net2.micro-automation.com + [64.7.141.29]) + by svr1.postgresql.org (Postfix) with SMTP id DACACD956A + for ; + Sun, 25 Sep 2005 11:57:53 -0300 (ADT) +Received: (qmail 8232 invoked from network); 25 Sep 2005 14:57:57 -0000 +Received: from dcdsl.ebox.com (HELO ?192.168.1.2?) (davec@64.7.143.116) + by net2.micro-automation.com with SMTP; 25 Sep 2005 14:57:57 -0000 +In-Reply-To: <43367937.40809@canaan.co.il> +References: + <43367937.40809@canaan.co.il> +Mime-Version: 1.0 (Apple Message framework v734) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: +Cc: PFC , + pgsql-performance@postgresql.org +Content-Transfer-Encoding: 7bit +From: Dave Cramer +Subject: Re: Advice on RAID card +Date: Sun, 25 Sep 2005 10:57:56 -0400 +To: Michael Ben-Nes +X-Mailer: Apple Mail (2.734) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.02 required=5 tests=[AWL=0.020] +X-Spam-Level: +X-Archive-Number: 200509/330 +X-Sequence-Number: 14638 + +I would think software raid would be quite inappropriate considering +postgres when it is working is taking a fair amount of CPU as would +software RAID. Does anyone know if this is really the case ? + +Dave +On 25-Sep-05, at 6:17 AM, Michael Ben-Nes wrote: + +> I would consider Software Raid +> +> +> PFC wrote: +> +> +>> +>> Hello fellow Postgresql'ers. +>> +>> I've been stumbled on this RAID card which looks nice. It is a +>> PCI-X SATA Raid card with 6 channels, and does RAID 0,1,5,10,50. +>> It is a HP card with an Adaptec chip on it, and 64 MB cache. +>> +>> HP Part # : 372953-B21 +>> Adaptec Part # : AAR-2610SA/64MB/HP +>> +>> There' even a picture : +>> http://megbytes.free.fr/Sata/DSC05970.JPG +>> +>> I know it isn't as good as a full SCSI system. I just want to +>> know if some of you have had experiences with these, and if this +>> cards belong to the "slower than no RAID" camp, like some DELL +>> card we often see mentioned here, or to the "decent performance +>> for the price" camp. It is to run on a Linux. +>> +>> Thanks in advance for your time and information. +>> +>> ---------------------------(end of +>> broadcast)--------------------------- +>> TIP 4: Have you searched our list archives? +>> +>> http://archives.postgresql.org +>> +> +> +> -- +> -------------------------- +> Canaan Surfing Ltd. +> Internet Service Providers +> Ben-Nes Michael - Manager +> Tel: 972-4-6991122 +> Cel: 972-52-8555757 +> Fax: 972-4-6990098 +> http://www.canaan.net.il +> -------------------------- +> +> +> ---------------------------(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 Sep 25 12:27:44 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1D290D8DE1 + for ; + Sun, 25 Sep 2005 12:27:41 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 53385-07 + for ; + Sun, 25 Sep 2005 15:27:35 +0000 (GMT) +Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.204]) + by svr1.postgresql.org (Postfix) with ESMTP id 32914D7FDC + for ; + Sun, 25 Sep 2005 12:27:34 -0300 (ADT) +Received: by zproxy.gmail.com with SMTP id 13so150928nzp + for ; + Sun, 25 Sep 2005 08:27:31 -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:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=twl7I9n0t3NgBfaY055r7E/DcvUOflQBQws5NLkabCjKuoSEcfSVMJjtu7cCN8bWtQxoRF3BWOv34HNFL6xn1k+TWhbYxZX+7Y/VIJtENntqUGEq3G14224vtvVE5hmav0VmJWguzTeo6Q384ryXRERFYedS+haijxIdh4Gx3Is= +Received: by 10.54.49.69 with SMTP id w69mr1043052wrw; + Sun, 25 Sep 2005 08:27:31 -0700 (PDT) +Received: by 10.54.148.2 with HTTP; Sun, 25 Sep 2005 08:27:31 -0700 (PDT) +Message-ID: +Date: Sun, 25 Sep 2005 15:27:31 +0000 +From: Mike Rylander +Reply-To: Mike Rylander +To: pgsql-perform +Subject: Re: Advice on RAID card +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: + <43367937.40809@canaan.co.il> + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.089 required=5 tests=[AWL=0.065, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200509/331 +X-Sequence-Number: 14639 + +On 9/25/05, Dave Cramer wrote: +> I would think software raid would be quite inappropriate considering +> postgres when it is working is taking a fair amount of CPU as would +> software RAID. Does anyone know if this is really the case ? +> + +I attempted to get some extra speed out of my Compaq/HP SA6404 card by +using software RAID1 across to hardware RAID10 sets. It didn't help, +but there was no noticeable load or drop in performance because of it. + Granted, this was on a 4-way Opteron, but, anecdotally speaking, the +linux software RAID has surprisingly low overhead. + +My $0.02, hope it helps. + +-- +Mike Rylander +mrylander@gmail.com +GPLS -- PINES Development +Database Developer +http://open-ils.org + +From pgsql-performance-owner@postgresql.org Sun Sep 25 13:21:16 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 16E33D953D + for ; + Sun, 25 Sep 2005 12:43:26 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 62710-03 + for ; + Sun, 25 Sep 2005 15:43:21 +0000 (GMT) +Received: from hosting.commandprompt.com (128.commandprompt.com + [207.173.200.128]) + by svr1.postgresql.org (Postfix) with ESMTP id EFF76D9186 + for ; + Sun, 25 Sep 2005 12:43:20 -0300 (ADT) +Received: from [192.168.1.100] (clbb-248.saw.net [64.146.135.248]) + (authenticated bits=0) + by hosting.commandprompt.com (8.13.4/8.13.4) with ESMTP id + j8PFcHH2007334; Sun, 25 Sep 2005 08:38:18 -0700 +Message-ID: <4336C57B.6090800@commandprompt.com> +Date: Sun, 25 Sep 2005 08:42:51 -0700 +From: "Joshua D. Drake" +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050912) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Dave Cramer +Cc: Michael Ben-Nes , + PFC , pgsql-performance@postgresql.org +Subject: Re: Advice on RAID card +References: + <43367937.40809@canaan.co.il> + +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Greylist: Sender succeded SMTP AUTH authentication, not delayed by + milter-greylist-1.6 (hosting.commandprompt.com [192.168.1.101]); + Sun, 25 Sep 2005 08:38:18 -0700 (PDT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.02 required=5 tests=[AWL=0.020] +X-Spam-Level: +X-Archive-Number: 200509/333 +X-Sequence-Number: 14641 + +Dave Cramer wrote: + +> I would think software raid would be quite inappropriate considering +> postgres when it is working is taking a fair amount of CPU as would +> software RAID. Does anyone know if this is really the case ? + +The common explanation is that CPUs are so fast now that it doesn't make +a difference. + From my experience software raid works very, very well. However I have +never put +software raid on anything that is very heavily loaded. + +I would still use hardware raid if it is very heavily loaded. + +Sincerely, + +Joshua D. Drake + +-- +Your PostgreSQL solutions company - Command Prompt, Inc. 1.800.492.2240 +PostgreSQL Replication, Consulting, Custom Programming, 24x7 support +Managed Services, Shared and Dedicated Hosting +Co-Authors: plPHP, plPerlNG - http://www.commandprompt.com/ + + +From pgsql-performance-owner@postgresql.org Sun Sep 25 13:03:42 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1837FD959F + for ; + Sun, 25 Sep 2005 12:59:13 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 67875-04 + for ; + Sun, 25 Sep 2005 15:59:11 +0000 (GMT) +Received: from vms046pub.verizon.net (vms046pub.verizon.net [206.46.252.46]) + by svr1.postgresql.org (Postfix) with ESMTP id 35967D958C + for ; + Sun, 25 Sep 2005 12:59:10 -0300 (ADT) +Received: from osgiliath.mathom.us ([70.108.61.78]) + by vms046.mailsrvcs.net (Sun Java System Messaging Server 6.2 HotFix + 0.04 (built Dec 24 2004)) with ESMTPA id + <0IND007QDR2L7Z37@vms046.mailsrvcs.net> for + pgsql-performance@postgresql.org; Sun, 25 Sep 2005 10:59:10 -0500 (CDT) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id 335AE60036E for + ; + Sun, 25 Sep 2005 11:59:09 -0400 (EDT) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 01708-05-2 for ; Sun, + 25 Sep 2005 11:59:09 -0400 (EDT) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id 18A2960034E; Sun, 25 Sep 2005 11:59:09 -0400 (EDT) +Date: Sun, 25 Sep 2005 11:59:09 -0400 +From: Michael Stone +Subject: Re: Advice on RAID card +In-reply-to: +To: pgsql-performance@postgresql.org +Mail-Followup-To: pgsql-performance@postgresql.org +Message-id: <20050925155909.GB18077@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: by amavisd-new-20030616-p10 (Debian) at mathom.us +References: + <43367937.40809@canaan.co.il> + +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.004 required=5 tests=[AWL=0.004] +X-Spam-Level: +X-Archive-Number: 200509/332 +X-Sequence-Number: 14640 + +On Sun, Sep 25, 2005 at 10:57:56AM -0400, Dave Cramer wrote: +>I would think software raid would be quite inappropriate considering +>postgres when it is working is taking a fair amount of CPU as would +>software RAID. Does anyone know if this is really the case ? + +It's not. Modern cpu's can handle raid operations without even noticing. +At the point where your raid ops become a significant fraction of the +cpu you'll be i/o bound anyway. + +Mike Stone + +From pgsql-performance-owner@postgresql.org Sun Sep 25 13:22:01 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 35690D95AA + for ; + Sun, 25 Sep 2005 13:08:41 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 67893-07 + for ; + Sun, 25 Sep 2005 16:08:35 +0000 (GMT) +Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 95654D905E + for ; + Sun, 25 Sep 2005 13:08:31 -0300 (ADT) +Received: (qmail 27396 invoked from network); 25 Sep 2005 18:09:16 +0200 +Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) + by boutiquenumerique.com with SMTP; 25 Sep 2005 18:09:16 +0200 +To: "Joshua D. Drake" , "Dave Cramer" +Cc: "Michael Ben-Nes" , + pgsql-performance@postgresql.org +Subject: Re: Advice on RAID card +References: + <43367937.40809@canaan.co.il> + + <4336C57B.6090800@commandprompt.com> +Message-ID: +Date: Sun, 25 Sep 2005 18:08:27 +0200 +From: PFC +Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= +Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +In-Reply-To: <4336C57B.6090800@commandprompt.com> +User-Agent: Opera M2/8.0 (Linux, build 1095) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/334 +X-Sequence-Number: 14642 + + + +> The common explanation is that CPUs are so fast now that it doesn't make +> a difference. +> From my experience software raid works very, very well. However I have +> never put +> software raid on anything that is very heavily loaded. + + Even for RAID5 ? it uses a bit more CPU for the parity calculations. + An advantage of software raid, is that if the RAID card dies, you have to +buy the same one ; whether I think that you can transfer a bunch of +software RAID5 disks to another machine if the machine they're in dies... + +From pgsql-performance-owner@postgresql.org Sun Sep 25 13:48:36 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A35EAD95C0 + for ; + Sun, 25 Sep 2005 13:22:33 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 71232-04 + for ; + Sun, 25 Sep 2005 16:22:28 +0000 (GMT) +Received: from hosting.commandprompt.com (128.commandprompt.com + [207.173.200.128]) + by svr1.postgresql.org (Postfix) with ESMTP id CE84FD95A8 + for ; + Sun, 25 Sep 2005 13:22:28 -0300 (ADT) +Received: from [192.168.1.100] (clbb-248.saw.net [64.146.135.248]) + (authenticated bits=0) + by hosting.commandprompt.com (8.13.4/8.13.4) with ESMTP id + j8PGHS6T008529; Sun, 25 Sep 2005 09:17:29 -0700 +Message-ID: <4336CEAA.7070208@commandprompt.com> +Date: Sun, 25 Sep 2005 09:22:02 -0700 +From: "Joshua D. Drake" +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050912) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: PFC +Cc: Dave Cramer , + Michael Ben-Nes , pgsql-performance@postgresql.org +Subject: Re: Advice on RAID card +References: + <43367937.40809@canaan.co.il> + + <4336C57B.6090800@commandprompt.com> +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-15; format=flowed +Content-Transfer-Encoding: 7bit +X-Greylist: Sender succeded SMTP AUTH authentication, not delayed by + milter-greylist-1.6 (hosting.commandprompt.com [192.168.1.101]); + Sun, 25 Sep 2005 09:17:29 -0700 (PDT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.02 required=5 tests=[AWL=0.020] +X-Spam-Level: +X-Archive-Number: 200509/335 +X-Sequence-Number: 14643 + + +> +> Even for RAID5 ? it uses a bit more CPU for the parity calculations. + +I honestly can't speak to RAID 5. I don't (and won't) use it. RAID 5 is +a little brutal when under +heavy write load. I use either 1, or 10. + +> An advantage of software raid, is that if the RAID card dies, you +> have to buy the same one ; whether I think that you can transfer a +> bunch of software RAID5 disks to another machine if the machine +> they're in dies... + +There is a huge advantage to software raid on all kinds of levels. If +you have the CPU then I suggest +it. However you will never get the performance out of software raid on +the high level (think 1 gig of cache) +that you would on a software raid setup. + +It is a bit of a tradeoff but for most installations software raid is +more than adequate. + +Sincerely, + +Joshua D. Drake + + + + +-- +Your PostgreSQL solutions company - Command Prompt, Inc. 1.800.492.2240 +PostgreSQL Replication, Consulting, Custom Programming, 24x7 support +Managed Services, Shared and Dedicated Hosting +Co-Authors: plPHP, plPerlNG - http://www.commandprompt.com/ + + +From pgsql-performance-owner@postgresql.org Sun Sep 25 13:54:04 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 92742D91A4 + for ; + Sun, 25 Sep 2005 13:54:03 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 80052-07 + for ; + Sun, 25 Sep 2005 16:54:01 +0000 (GMT) +Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id C8E77D905E + for ; + Sun, 25 Sep 2005 13:53:59 -0300 (ADT) +Received: (qmail 29392 invoked from network); 25 Sep 2005 18:54:46 +0200 +Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) + by boutiquenumerique.com with SMTP; 25 Sep 2005 18:54:46 +0200 +To: "Joshua D. Drake" +Cc: "Dave Cramer" , "Michael Ben-Nes" , + pgsql-performance@postgresql.org +Subject: Re: Advice on RAID card +References: + <43367937.40809@canaan.co.il> + + <4336C57B.6090800@commandprompt.com> + <4336CEAA.7070208@commandprompt.com> +Message-ID: +Date: Sun, 25 Sep 2005 18:53:57 +0200 +From: PFC +Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= +Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +In-Reply-To: <4336CEAA.7070208@commandprompt.com> +User-Agent: Opera M2/8.0 (Linux, build 1095) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/336 +X-Sequence-Number: 14644 + + +> There is a huge advantage to software raid on all kinds of levels. If +> you have the CPU then I suggest +> it. However you will never get the performance out of software raid on +> the high level (think 1 gig of cache) +> that you would on a software raid setup. +> +> It is a bit of a tradeoff but for most installations software raid is +> more than adequate. + + Which makes me think that I will use Software Raid 5 and convert the +price of the card into RAM. + This should be nice for a budget server. + Gonna investigate now if Linux software RAID5 is rugged enough. Can +always buy the a card later if not. + + Thanks all for the advice, you were really helpful. + +From pgsql-performance-owner@postgresql.org Sun Sep 25 14:41:29 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 68647D95E4 + for ; + Sun, 25 Sep 2005 14:41:27 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 90396-02 + for ; + Sun, 25 Sep 2005 17:41:21 +0000 (GMT) +Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 6110DD95F4 + for ; + Sun, 25 Sep 2005 14:41:20 -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 1EJaUs-0003Em-00; Sun, 25 Sep 2005 13:41:06 -0400 +To: PFC +Cc: "Joshua D. Drake" , + "Dave Cramer" , + "Michael Ben-Nes" , pgsql-performance@postgresql.org +Subject: Re: Advice on RAID card +References: + <43367937.40809@canaan.co.il> + + <4336C57B.6090800@commandprompt.com> + <4336CEAA.7070208@commandprompt.com> +In-Reply-To: +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 25 Sep 2005 13:41:06 -0400 +Message-ID: <873bntjb9p.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: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.011 required=5 tests=[AWL=0.011] +X-Spam-Level: +X-Archive-Number: 200509/337 +X-Sequence-Number: 14645 + +PFC writes: + +> Which makes me think that I will use Software Raid 5 and convert the +> price of the card into RAM. +> This should be nice for a budget server. +> Gonna investigate now if Linux software RAID5 is rugged enough. Can +> always buy the a card later if not. + +Raid 5 is perhaps the exception here. For Raid 5 a substantial amount of CPU +power is needed. + +Also, Raid 5 is particularly inappropriate for write-heavy Database traffic. +Raid 5 actually hurts write latency dramatically and Databases are very +sensitive to latency. + +On the other hand if your database is primarily read-only then Raid 5 may not +be a problem and may be faster than raid 1+0. + +-- +greg + + +From pgsql-hackers-owner@postgresql.org Sun Sep 25 14:45:42 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AC162D95B2; + Sun, 25 Sep 2005 14:45:36 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 92415-05; Sun, 25 Sep 2005 17:45:34 +0000 (GMT) +Received: from cmailm3.svr.pol.co.uk (cmailm3.svr.pol.co.uk [195.92.193.19]) + by svr1.postgresql.org (Postfix) with ESMTP id BD316D95D2; + Sun, 25 Sep 2005 14:45:33 -0300 (ADT) +Received: from modem-2295.lion.dialup.pol.co.uk ([217.135.168.247] + helo=192.168.0.102) by cmailm3.svr.pol.co.uk with esmtp (Exim 4.41) + id 1EJaZ6-0000Xz-R1; Sun, 25 Sep 2005 18:45:29 +0100 +Subject: Re: Releasing memory during External sorting? +From: Simon Riggs +To: Tom Lane +Cc: pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org +In-Reply-To: <4202.1127489488@sss.pgh.pa.us> +References: <1127468233.4145.178.camel@localhost.localdomain> + <3465.1127484579@sss.pgh.pa.us> + <1127487978.19345.43.camel@localhost.localdomain> + <4202.1127489488@sss.pgh.pa.us> +Content-Type: text/plain +Organization: 2nd Quadrant +Date: Sun, 25 Sep 2005 18:45:22 +0100 +Message-Id: <1127670323.19345.83.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-3) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.052 required=5 tests=[AWL=0.002, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/1099 +X-Sequence-Number: 73496 + +On Fri, 2005-09-23 at 11:31 -0400, Tom Lane wrote: +> Simon Riggs writes: +> > Since we know the predicted size of the sort set prior to starting the +> > sort node, could we not use that information to allocate memory +> > appropriately? i.e. if sort size is predicted to be more than twice the +> > size of work_mem, then just move straight to the external sort algorithm +> > and set the work_mem down at the lower limit? +> +> Have you actually read the sort code? + +Yes and Knuth too. Your research and code are incredible, almost +untouchable. Yet sort performance is important and empirical evidence +suggests that this can be improved upon significantly, so I am and will +be spending time trying to improve upon that. Another time... + +This thread was aiming to plug a problem I saw with 8.1's ability to use +very large work_mem settings. I felt that either my performance numbers +were wrong or we needed to do something; I've not had anybody show me +performance numbers that prove mine doubtful, yet. + +> During the run-forming phase it's definitely useful to eat all the +> memory you can: that translates directly to longer initial runs and +> hence fewer merge passes. + +Sounds good, but maybe that is not the dominant effect. I'll retest, on +the assumption that there is a benefit, but there's something wrong with +my earlier tests. + +> During the run-merging phase it's possible +> that using less memory would not hurt performance any, but as already +> stated, I don't think it will actually end up cutting the backend's +> memory footprint --- the sbrk point will be established during the run +> forming phase and it's unlikely to move back much until transaction end. + +> Also, if I recall the development of that code correctly, the reason for +> using more than minimum memory during the merge phase is that writing or +> reading lots of tuples at once improves sequentiality of access to the +> temp files. So I'm not sure that cutting down the memory wouldn't hurt +> performance. + +Cutting memory below about 16 MB does definitely hurt external sort +performance; I explain that as being the effect of sequential access. I +haven't looked to nail down the breakpoint exactly since it seemed more +important simply to say that there looked like there was one.. Its just +that raising it above that mark doesn't help much, according to my +current results. + +I'll get some more test results and repost them, next week. I will be +very happy if the results show that more memory helps. + +Best Regards, Simon Riggs + + +From pgsql-hackers-owner@postgresql.org Sun Sep 25 14:45:47 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8550BD95C8; + Sun, 25 Sep 2005 14:45:41 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 87435-08; Sun, 25 Sep 2005 17:45:38 +0000 (GMT) +Received: from smtp1.freeserve.com (smtp1.wanadoo.co.uk [193.252.22.158]) + by svr1.postgresql.org (Postfix) with ESMTP id 606B0D95C2; + Sun, 25 Sep 2005 14:45:37 -0300 (ADT) +Received: from me-wanadoo.net (localhost [127.0.0.1]) + by mwinf3009.me.freeserve.com (SMTP Server) with ESMTP id F2F301C0008E; + Sun, 25 Sep 2005 19:45:36 +0200 (CEST) +Received: from 192.168.0.102 (modem-2295.lion.dialup.pol.co.uk + [217.135.168.247]) + by mwinf3009.me.freeserve.com (SMTP Server) with ESMTP id 7E3731C00085; + Sun, 25 Sep 2005 19:45:36 +0200 (CEST) +X-ME-UUID: 20050925174536517.7E3731C00085@mwinf3009.me.freeserve.com +Subject: Re: [PERFORM] Releasing memory during External sorting? +From: Simon Riggs +To: Ron Peacetree +Cc: pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org +In-Reply-To: + <2559192.1127494115558.JavaMail.root@elwamui-huard.atl.sa.earthlink.net> +References: + <2559192.1127494115558.JavaMail.root@elwamui-huard.atl.sa.earthlink.net> +Content-Type: text/plain +Organization: 2nd Quadrant +Date: Sun, 25 Sep 2005 18:45:30 +0100 +Message-Id: <1127670330.19345.84.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-3) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.052 required=5 tests=[AWL=0.002, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/1100 +X-Sequence-Number: 73497 + +On Fri, 2005-09-23 at 12:48 -0400, Ron Peacetree wrote: + +> > I have some indications from private tests that very high memory settings +> >may actually hinder performance of the sorts, though I cannot explain that +> >and wonder whether it is the performance tests themselves that have issues. +> > +> Hmmm. Are you talking about amounts so high that you are throwing the OS +> into paging and swapping thrash behavior? If not, then the above is weird. + +Thanks for your thoughts. I'll retest, on the assumption that there is a +benefit, but there's something wrong with my earlier tests. + +Best Regards, Simon Riggs + + + +From pgsql-performance-owner@postgresql.org Sun Sep 25 15:14:32 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E29F2D9586 + for ; + Sun, 25 Sep 2005 15:14:29 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 96432-06 + for ; + Sun, 25 Sep 2005 18:14:27 +0000 (GMT) +Received: from mail.Mi8.com (d01gw01.mi8.com [63.240.6.47]) + by svr1.postgresql.org (Postfix) with ESMTP id 3B301D95B5 + for ; + Sun, 25 Sep 2005 15:14:26 -0300 (ADT) +Received: from 172.16.1.118 by mail.Mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D1)); Sun, 25 Sep 2005 14:14:21 -0400 +X-Server-Uuid: 241911D6-425B-44B9-A073-E3FE0F8FC774 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.174]) by + d01smtp03.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Sun, 25 Sep + 2005 14:14:20 -0400 +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Subject: Re: Advice on RAID card +Date: Sun, 25 Sep 2005 14:09:30 -0400 +Message-ID: <3E37B936B592014B978C4415F90D662D0C4276@MI8NYCMAIL06.Mi8.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Advice on RAID card +Thread-Index: AcXB8fFcpTQLOZRaTF2BXPrPRVbukAAClSvZ +From: "Luke Lonergan" +To: "Joshua D. Drake" , + "PFC" +Cc: "Dave Cramer" , "Michael Ben-Nes" , + pgsql-performance@postgresql.org +X-OriginalArrivalTime: 25 Sep 2005 18:14:20.0931 (UTC) + FILETIME=[F364B530:01C5C1FC] +X-WSS-ID: 6F28377732O1449129-01-01 +Content-Type: text/plain; + charset=iso-8859-1 +Content-Transfer-Encoding: quoted-printable +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/342 +X-Sequence-Number: 14650 + +>> Even for RAID5 ? it uses a bit more CPU for the parity = +calculations. + +> I honestly can't speak to RAID 5. I don't (and won't) use it. RAID 5 = +is=20 +> a little brutal when under +> heavy write load. I use either 1, or 10. + +Yes, for RAID5 software RAID is better than HW RAID today - the modern = +general purpose CPUs are *much* faster at the ECC calculations than the = +CPUs on most modern hardware SCSI RAID cards. + +Note that there is a trend toward SATA RAID, and the newer crop of SATA = +RAID adapters from companies like 3Ware are starting to be much faster = +than software RAID with lower CPU consumption. + +Use non-RAID SCSI controllers if you want high performance and low CPU = +consumption with software RAID. The write-combining and TCQ of SCSI is = +well suited to SW RAID. Note that if you use HW RAID controllers for SW = +RAID, expect slightly better performance than in their HW RAID mode, but = +much higher CPU consumption, as they make for terrible JBOD SCSI = +controllers. This is especially true of the HP smartarray controllers = +with their Linux drivers. + +- Luke +Greenplum + + +From pgsql-performance-owner@postgresql.org Sun Sep 25 15:13:59 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 988FBD9586 + for ; + Sun, 25 Sep 2005 15:13:57 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 94030-09 + for ; + Sun, 25 Sep 2005 18:13:53 +0000 (GMT) +Received: from vms042pub.verizon.net (vms042pub.verizon.net [206.46.252.42]) + by svr1.postgresql.org (Postfix) with ESMTP id 1458AD95C8 + for ; + Sun, 25 Sep 2005 15:13:52 -0300 (ADT) +Received: from osgiliath.mathom.us ([70.108.61.78]) + by vms042.mailsrvcs.net (Sun Java System Messaging Server 6.2 HotFix + 0.04 (built Dec 24 2004)) with ESMTPA id + <0IND00227XB5CUT3@vms042.mailsrvcs.net> for + pgsql-performance@postgresql.org; Sun, 25 Sep 2005 13:13:53 -0500 (CDT) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id 9EDE9622B38 for + ; + Sun, 25 Sep 2005 14:13:52 -0400 (EDT) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 06029-03-7 for ; Sun, + 25 Sep 2005 14:13:52 -0400 (EDT) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id 7805C62255C; Sun, 25 Sep 2005 14:13:52 -0400 (EDT) +Date: Sun, 25 Sep 2005 14:13:52 -0400 +From: Michael Stone +Subject: Re: Advice on RAID card +In-reply-to: <873bntjb9p.fsf@stark.xeocode.com> +To: pgsql-performance@postgresql.org +Mail-Followup-To: pgsql-performance@postgresql.org +Message-id: <20050925181352.GA2241@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: by amavisd-new-20030616-p10 (Debian) at mathom.us +References: + <43367937.40809@canaan.co.il> + + <4336C57B.6090800@commandprompt.com> + <4336CEAA.7070208@commandprompt.com> + <873bntjb9p.fsf@stark.xeocode.com> +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.004 required=5 tests=[AWL=0.004] +X-Spam-Level: +X-Archive-Number: 200509/341 +X-Sequence-Number: 14649 + +On Sun, Sep 25, 2005 at 01:41:06PM -0400, Greg Stark wrote: +>Also, Raid 5 is particularly inappropriate for write-heavy Database traffic. +>Raid 5 actually hurts write latency dramatically and Databases are very +>sensitive to latency. + +Software raid 5 actually may have an advantage here. The main cause for +high raid5 write latency is the necessity of having blocks from each +disk available to calculate the parity. The chances of a pc with several +gigs of ram having all the blocks cached (thus not requiring any reads) +are higher than on a hardware raid with several hundred megs of ram. + +Mike Stone + +From pgsql-performance-owner@postgresql.org Sun Sep 25 15:10:38 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BD1BBD76BA + for ; + Sun, 25 Sep 2005 15:10:36 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 96432-05 + for ; + Sun, 25 Sep 2005 18:10:30 +0000 (GMT) +Received: from ki-communication.com (unknown [202.147.194.21]) + by svr1.postgresql.org (Postfix) with ESMTP id AF17CD95D5 + for ; + Sun, 25 Sep 2005 15:10:28 -0300 (ADT) +Received: from iacn01wks ([192.168.0.128]) by ki-communication.com with + Microsoft SMTPSVC(6.0.3790.1830); Mon, 26 Sep 2005 01:14:48 +0700 +From: "Ahmad Fajar" +To: "'Oleg Bartunov'" +Cc: +Subject: Re: tsearch2 seem very slow +Date: Mon, 26 Sep 2005 01:14:46 +0700 +Keywords: Postgresql +MIME-Version: 1.0 +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: 7bit +X-Mailer: Microsoft Office Outlook, Build 11.0.6353 +In-Reply-To: +Thread-Index: AcXAzpvSWd3ZCaHyTgOGZxhgIJC1XQBKPQaQ +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +Message-ID: +X-OriginalArrivalTime: 25 Sep 2005 18:14:48.0515 (UTC) + FILETIME=[03D5B130:01C5C1FD] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.41 required=5 tests=[AWL=-0.082, + DNS_FROM_RFC_WHOIS=0.492] +X-Spam-Level: +X-Archive-Number: 200509/340 +X-Sequence-Number: 14648 + +Hi Oleg, + +Sorry for my late. From the stat() function I got 1,5 million rows, although +I've added garbage words to the stop word file, there seem still have +garbage words. So I ask for my team to identify the garbage words and add to +stop words and I will update the articles after that. And about my articles, +it is quite big enough, the average length is about 2900 characters. And I +think, I have to tune tsearch2 and concentrate to the garbage words. The +most articles are indonesian language. What others way to tune the tsearch2 +beside the garbage words? + +Beside that, I still have problem, if I do a simple query like: +Select ids, keywords from dict where keywords='blabla' ('blabla' is a single +word); The table have 200 million rows, I have index the keywords field. On +the first time my query seem to slow to get the result, about 15-60 sec to +get the result. I use latest pgAdmin3 to test all queries. But if I repeat +the query I will get fast result. My question is why on the first time the +query seem to slow. + +I try to cluster the table base on keyword index, but after 15 hours waiting +and it doesn't finish I stop clustering. Now I think I have to change the +file system for postgresql data. Do you have any idea what best for +postgresql, JFS or XFS? I will not try reiserfs, because there are some +rumors about reiserfs stability, although reiserfs is fast enough for +postgresql. And must I down grade my postgresql from version 8.0.3 to 7.4.8? + + + +Regards, +ahmad fajar + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Oleg Bartunov +Sent: Saturday, September 24, 2005 1:08 PM +To: Ahmad Fajar +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] tsearch2 seem very slow + +Ahmad, + +what's about the number of unique words ? I mean stat() function. +Sometimes, it helps to identify garbage words. +How big is your articles (average length) ? + +please, cut'n paste queries and output from psql ! How fast are +next queries ? + + Oleg +On Fri, 23 Sep 2005, Ahmad Fajar wrote: + +> Hi Oleg, +> +> For single index I try this query: +> explain analyze +> select articleid, title, datee from articles +> where fti @@ to_tsquery('bank&indonesia'); +> +> analyze result: +> ---------------- +> "Index Scan using fti_idx on articles (cost=0.00..862.97 rows=420 +width=51) +> (actual time=0.067..183761.324 rows=46186 loops=1)" +> " Index Cond: (fti @@ '\'bank\' & \'indonesia\''::tsquery)" +> "Total runtime: 183837.826 ms" +> +> And for multicolumn index I try this query: +> explain analyze +> select articleid, title, datee from articles +> where fti @@ to_tsquery('bank&mega'); +> +> analyze result: +> ---------------- +> "Index Scan using articles_x1 on articles (cost=0.00..848.01 rows=410 +> width=51) (actual time=52.204..37914.135 rows=1841 loops=1)" +> " Index Cond: ((datee >= '2002-01-01'::date) AND (datee <= +> ('now'::text)::date) AND (fti @@ '\'bank\' & \'mega\''::tsquery))" +> "Total runtime: 37933.757 ms" +> +> The table structure is as mention on the first talk. If you wanna know how +> much table in my database, it's about 100 tables or maybe more. Now I +> develop the version 2 of my web application, you can take a look at: +> http://www.mediatrac.net, so it will hold many datas. But the biggest +table +> is article's table. On develop this version 2 I just use half data of the +> article's table (about 419804 rows). May be if I import all of the +article's +> table data it will have 1 million rows. The article's table grows rapidly, +> about 100000 rows per-week. My developing database size is 28 GB (not real +> database, coz I still develop the version 2 and I use half of the data for +> play around). I just wanna to perform quick search (fulltext search) on my +> article's table not other table. On version 1, the current running version +I +> use same hardware spesification as mention below, but there is no fulltext +> search. So I develop the new version with new features, new interface and +> include the fulltext search. +> +> I do know, if the application finish, I must use powerfull hardware. But +how +> can I guarantee the application will run smooth, if I do fulltext search +on +> 419804 rows in a table it took a long time to get the result. +> +> Could you or friends in this maling-list help me....plz..plzz +> +> Tsearch2 configuration: +> ------------------------- +> I use default configuration, english stop word file as tsearch2 provide, +> stem dictionary as default (coz I don't know how to configure and add new +> data to stem dictionary) and I add some words to the english stop word +file. +> +> Postgresql configuration +> ------------------------- +> max_connections = 32 +> shared_buffers = 32768 +> sort_mem = 8192 +> vacuum_mem = 65536 +> work_mem = 16384 +> maintenance_work_mem = 65536 +> max_fsm_pages = 30000 +> max_fsm_relations = 1000 +> max_files_per_process = 100000 +> checkpoint_segments = 15 +> effective_cache_size = 192000 +> random_page_cost = 2 +> geqo = true +> geqo_threshold = 50 +> geqo_effort = 5 +> geqo_pool_size = 0 +> geqo_generations = 0 +> geqo_selection_bias = 2.0 +> from_collapse_limit = 10 +> join_collapse_limit = 15 +> +> OS configuration: +> ------------------ +> I use Redhat 4 AS, kernel 2.6.9-11 +> kernel.shmmax=1073741824 +> kernel.sem=250 32000 100 128 +> fs.aio-max-nr=5242880 +> the server I configure just only for postgresql, no other service is +running +> like: www, samba, ftp, email, firewall +> +> hardware configuration: +> ------------------------ +> Motherboard ASUS P5GD1 +> Processor P4 3,2 GHz +> Memory 2 GB DDR 400, +> 2x200 GB Serial ATA 7200 RPM UltraATA/133, configure as RAID0 for +postgresql +> data and the partition is EXT3 +> 1x80 GB EIDE 7200 RPM configure for system and home directory and the +> partiton is EXT3 +> +> Did I miss something? +> +> Regards, +> ahmad fajar +> +> +> -----Original Message----- +> From: Oleg Bartunov [mailto:oleg@sai.msu.su] +> Sent: Jumat, 23 September 2005 18:26 +> To: Ahmad Fajar +> Cc: pgsql-performance@postgresql.org +> Subject: RE: [PERFORM] tsearch2 seem very slow +> +> On Fri, 23 Sep 2005, Ahmad Fajar wrote: +> +>> Hi Oleg, +>> +>> I didn't deny on the third repeat or more, it can reach < 600 msec. It is +>> only because the result still in postgres cache, but how about in the +> first +>> run? I didn't dare, the values is un-acceptable. Because my table will +> grows +>> rapidly, it's about 100000 rows per-week. And the visitor will search +>> anything that I don't know, whether it's the repeated search or new +> search, +>> or whether it's in postgres cache or not. +> +> if you have enoush shared memory postgresql will keep index pages there. +> +> +>> +>> I just compare with http://www.postgresql.org, the search is quite fast, +> and +>> I don't know whether the site uses tsearch2 or something else. But as fas +> as +>> I know, if the rows reach >100 milion (I have try for 200 milion rows and +> it +>> seem very slow), even if don't use tsearch2, only use simple query like: +>> select f1, f2 from table1 where f2='blabla', +>> and f2 is indexes, my postgres still slow on the first time, about >10 +> sec. +>> because of this I tried something brand new to fullfill my needs. I have +>> used fti, and tsearch2 but still slow. +>> +>> I don't know what's going wrong with my postgres, what configuration must +> I +>> do to perform the query get fast result. Or must I use enterprisedb 2005 +> or +>> pervasive postgres (both uses postgres), I don't know very much about +> these +>> two products. +> +> you didn't show us your configuration (hardware,postgresql and tsearch2), +> explain analyze of your queries, so we can't help you. +> How big is your database, tsearch2 index size ? +> +> +>> +>> Regards, +>> ahmad fajar +>> +>> +>> -----Original Message----- +>> From: Oleg Bartunov [mailto:oleg@sai.msu.su] +>> Sent: Jumat, 23 September 2005 14:36 +>> To: Ahmad Fajar +>> Cc: pgsql-performance@postgresql.org +>> Subject: Re: [PERFORM] tsearch2 seem very slow +>> +>> Ahmad, +>> +>> how fast is repeated runs ? First time system could be very slow. +>> Also, have you checked my page +>> http://www.sai.msu.su/~megera/oddmuse/index.cgi/Tsearch_V2_Notes +>> and some info about tsearch2 internals +>> http://www.sai.msu.su/~megera/oddmuse/index.cgi/Tsearch_V2_internals +>> +>> Oleg +>> On Thu, 22 Sep 2005, Ahmad Fajar wrote: +>> +>>> I have about 419804 rows in my article table. I have installed tsearch2 +>> and +>>> its gist index correctly. +>>> +>>> My table structure is: +>>> +>>> CREATE TABLE tbarticles +>>> +>>> ( +>>> +>>> articleid int4 NOT NULL, +>>> +>>> title varchar(250), +>>> +>>> mediaid int4, +>>> +>>> datee date, +>>> +>>> content text, +>>> +>>> contentvar text, +>>> +>>> mmcol float4 NOT NULL, +>>> +>>> sirkulasi float4, +>>> +>>> page varchar(10), +>>> +>>> tglisidata date, +>>> +>>> namapc varchar(12), +>>> +>>> usere varchar(12), +>>> +>>> file_pdf varchar(255), +>>> +>>> file_pdf2 varchar(50), +>>> +>>> kolom int4, +>>> +>>> size_jpeg int4, +>>> +>>> journalist varchar(120), +>>> +>>> ratebw float4, +>>> +>>> ratefc float4, +>>> +>>> fti tsvector, +>>> +>>> CONSTRAINT pk_tbarticles PRIMARY KEY (articleid) +>>> +>>> ) WITHOUT OIDS; +>>> +>>> Create index fti_idx1 on tbarticles using gist (fti); +>>> +>>> Create index fti_idx2 on tbarticles using gist (datee, fti); +>>> +>>> +>>> +>>> But when I search something like: +>>> +>>> Select articleid, title, datee from tbarticles where fti @@ +>>> to_tsquery('susilo&bambang&yudhoyono&jusuf&kalla'); +>>> +>>> It takes about 30 sec. I run explain analyze and the index is used +>>> correctly. +>>> +>>> +>>> +>>> Then I try multi column index to filter by date, and my query something +>>> like: +>>> +>>> Select articleid, title, datee from tbarticles where fti @@ +>>> to_tsquery('susilo&bambang&yudhoyono&jusuf&kalla') and datee >= +>> '2002-01-01' +>>> and datee <= current_date +>>> +>>> An it still run about 25 sec. I do run explain analyze and my +multicolumn +>>> index is used correctly. +>>> +>>> This is not acceptable if want to publish my website if the search took +>> very +>>> longer. +>>> +>>> +>>> +>>> I have run vacuum full analyze before doing such query. What going wrong +>>> with my query?? Is there any way to make this faster? +>>> +>>> I have try to tune my postgres configuration, but it seem helpless. My +>> linux +>>> box is Redhat 4 AS, and +>>> +>>> the hardware: 2 GB RAM DDR 400, 2x200 GB Serial ATA 7200RPM and +configure +>> as +>>> RAID0 (just for postgres data), my sistem run at EIDE 80GB 7200 RPM. +>>> +>>> +>>> +>>> Please.help.help. +>>> +>>> +>> +>> Regards, +>> Oleg +>> _____________________________________________________________ +>> Oleg Bartunov, sci.researcher, hostmaster of AstroNet, +>> Sternberg Astronomical Institute, Moscow University (Russia) +>> Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ +>> phone: +007(095)939-16-83, +007(095)939-23-83 +>> +> +> Regards, +> Oleg +> _____________________________________________________________ +> Oleg Bartunov, sci.researcher, hostmaster of AstroNet, +> Sternberg Astronomical Institute, Moscow University (Russia) +> Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ +> phone: +007(095)939-16-83, +007(095)939-23-83 +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: Don't 'kill -9' the postmaster +> + + Regards, + Oleg +_____________________________________________________________ +Oleg Bartunov, sci.researcher, hostmaster of AstroNet, +Sternberg Astronomical Institute, Moscow University (Russia) +Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ +phone: +007(095)939-16-83, +007(095)939-23-83 + +---------------------------(end of broadcast)--------------------------- +TIP 2: Don't 'kill -9' the postmaster + + +From pgsql-performance-owner@postgresql.org Sun Sep 25 15:34:30 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0322AD956D + for ; + Sun, 25 Sep 2005 15:34:29 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 95260-07 + for ; + Sun, 25 Sep 2005 18:34:25 +0000 (GMT) +Received: from ra.sai.msu.su (ra.sai.msu.su [158.250.29.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3D4C6D9554 + for ; + Sun, 25 Sep 2005 15:34:16 -0300 (ADT) +Received: from ra (ra [158.250.29.2]) + by ra.sai.msu.su (8.13.4/8.13.4) with ESMTP id j8PIX27D016418; + Sun, 25 Sep 2005 22:33:02 +0400 (MSD) +Date: Sun, 25 Sep 2005 22:33:02 +0400 (MSD) +From: Oleg Bartunov +X-X-Sender: megera@ra.sai.msu.su +To: Ahmad Fajar +Cc: pgsql-performance@postgresql.org +Subject: Re: tsearch2 seem very slow +In-Reply-To: +Message-ID: +References: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.323 required=5 tests=[AWL=-0.051, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200509/343 +X-Sequence-Number: 14651 + +On Mon, 26 Sep 2005, Ahmad Fajar wrote: + +> Hi Oleg, +> +> Sorry for my late. From the stat() function I got 1,5 million rows, although +> I've added garbage words to the stop word file, there seem still have +> garbage words. So I ask for my team to identify the garbage words and add to + +what king of garbage ? Probably you index not needed token types, for +example, email address, file names.... + +> stop words and I will update the articles after that. And about my articles, +> it is quite big enough, the average length is about 2900 characters. And I +> think, I have to tune tsearch2 and concentrate to the garbage words. The +> most articles are indonesian language. What others way to tune the tsearch2 +> beside the garbage words? + +do you need proximity ? If no, use strip(tsvector) function to remove +coordinate information from tsvector. + +don't index default configuration and index only needed tokens, for +example, to index only 3 type of tokens, first create 'qq' configuration +and specify tokens to index. + +insert into pg_ts_cfg values('qq','default','en_US'); +-- tokens to index +insert into pg_ts_cfgmap values('qq','lhword','{en_ispell,en_stem}'); +insert into pg_ts_cfgmap values('qq','lword','{en_ispell,en_stem}'); +insert into pg_ts_cfgmap values('qq','lpart_hword','{en_ispell,en_stem}'); + + +> +> Beside that, I still have problem, if I do a simple query like: +> Select ids, keywords from dict where keywords='blabla' ('blabla' is a single +> word); The table have 200 million rows, I have index the keywords field. On +> the first time my query seem to slow to get the result, about 15-60 sec to +> get the result. I use latest pgAdmin3 to test all queries. But if I repeat +> the query I will get fast result. My question is why on the first time the +> query seem to slow. + +because index pages should be readed from disk into shared buffers, so next +query will benefit from that. You need enough shared memory to get real +benefit. You may get postgresql stats and look on cache hit ration. + +btw, how does your query ( keywords='blabla') relates to tsearch2 ? + +> +> I try to cluster the table base on keyword index, but after 15 hours waiting +> and it doesn't finish I stop clustering. Now I think I have to change the + +don't use cluster for big tables ! simple + select * into clustered_foo from foo order by indexed_field +would be faster and does the same job. + +> file system for postgresql data. Do you have any idea what best for +> postgresql, JFS or XFS? I will not try reiserfs, because there are some +> rumors about reiserfs stability, although reiserfs is fast enough for +> postgresql. And must I down grade my postgresql from version 8.0.3 to 7.4.8? +> + +I'm not experienced with filesystems :) + + +> +> +> Regards, +> ahmad fajar +> +> -----Original Message----- +> From: pgsql-performance-owner@postgresql.org +> [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Oleg Bartunov +> Sent: Saturday, September 24, 2005 1:08 PM +> To: Ahmad Fajar +> Cc: pgsql-performance@postgresql.org +> Subject: Re: [PERFORM] tsearch2 seem very slow +> +> Ahmad, +> +> what's about the number of unique words ? I mean stat() function. +> Sometimes, it helps to identify garbage words. +> How big is your articles (average length) ? +> +> please, cut'n paste queries and output from psql ! How fast are +> next queries ? +> +> Oleg +> On Fri, 23 Sep 2005, Ahmad Fajar wrote: +> +>> Hi Oleg, +>> +>> For single index I try this query: +>> explain analyze +>> select articleid, title, datee from articles +>> where fti @@ to_tsquery('bank&indonesia'); +>> +>> analyze result: +>> ---------------- +>> "Index Scan using fti_idx on articles (cost=0.00..862.97 rows=420 +> width=51) +>> (actual time=0.067..183761.324 rows=46186 loops=1)" +>> " Index Cond: (fti @@ '\'bank\' & \'indonesia\''::tsquery)" +>> "Total runtime: 183837.826 ms" +>> +>> And for multicolumn index I try this query: +>> explain analyze +>> select articleid, title, datee from articles +>> where fti @@ to_tsquery('bank&mega'); +>> +>> analyze result: +>> ---------------- +>> "Index Scan using articles_x1 on articles (cost=0.00..848.01 rows=410 +>> width=51) (actual time=52.204..37914.135 rows=1841 loops=1)" +>> " Index Cond: ((datee >= '2002-01-01'::date) AND (datee <= +>> ('now'::text)::date) AND (fti @@ '\'bank\' & \'mega\''::tsquery))" +>> "Total runtime: 37933.757 ms" +>> +>> The table structure is as mention on the first talk. If you wanna know how +>> much table in my database, it's about 100 tables or maybe more. Now I +>> develop the version 2 of my web application, you can take a look at: +>> http://www.mediatrac.net, so it will hold many datas. But the biggest +> table +>> is article's table. On develop this version 2 I just use half data of the +>> article's table (about 419804 rows). May be if I import all of the +> article's +>> table data it will have 1 million rows. The article's table grows rapidly, +>> about 100000 rows per-week. My developing database size is 28 GB (not real +>> database, coz I still develop the version 2 and I use half of the data for +>> play around). I just wanna to perform quick search (fulltext search) on my +>> article's table not other table. On version 1, the current running version +> I +>> use same hardware spesification as mention below, but there is no fulltext +>> search. So I develop the new version with new features, new interface and +>> include the fulltext search. +>> +>> I do know, if the application finish, I must use powerfull hardware. But +> how +>> can I guarantee the application will run smooth, if I do fulltext search +> on +>> 419804 rows in a table it took a long time to get the result. +>> +>> Could you or friends in this maling-list help me....plz..plzz +>> +>> Tsearch2 configuration: +>> ------------------------- +>> I use default configuration, english stop word file as tsearch2 provide, +>> stem dictionary as default (coz I don't know how to configure and add new +>> data to stem dictionary) and I add some words to the english stop word +> file. +>> +>> Postgresql configuration +>> ------------------------- +>> max_connections = 32 +>> shared_buffers = 32768 +>> sort_mem = 8192 +>> vacuum_mem = 65536 +>> work_mem = 16384 +>> maintenance_work_mem = 65536 +>> max_fsm_pages = 30000 +>> max_fsm_relations = 1000 +>> max_files_per_process = 100000 +>> checkpoint_segments = 15 +>> effective_cache_size = 192000 +>> random_page_cost = 2 +>> geqo = true +>> geqo_threshold = 50 +>> geqo_effort = 5 +>> geqo_pool_size = 0 +>> geqo_generations = 0 +>> geqo_selection_bias = 2.0 +>> from_collapse_limit = 10 +>> join_collapse_limit = 15 +>> +>> OS configuration: +>> ------------------ +>> I use Redhat 4 AS, kernel 2.6.9-11 +>> kernel.shmmax=1073741824 +>> kernel.sem=250 32000 100 128 +>> fs.aio-max-nr=5242880 +>> the server I configure just only for postgresql, no other service is +> running +>> like: www, samba, ftp, email, firewall +>> +>> hardware configuration: +>> ------------------------ +>> Motherboard ASUS P5GD1 +>> Processor P4 3,2 GHz +>> Memory 2 GB DDR 400, +>> 2x200 GB Serial ATA 7200 RPM UltraATA/133, configure as RAID0 for +> postgresql +>> data and the partition is EXT3 +>> 1x80 GB EIDE 7200 RPM configure for system and home directory and the +>> partiton is EXT3 +>> +>> Did I miss something? +>> +>> Regards, +>> ahmad fajar +>> +>> +>> -----Original Message----- +>> From: Oleg Bartunov [mailto:oleg@sai.msu.su] +>> Sent: Jumat, 23 September 2005 18:26 +>> To: Ahmad Fajar +>> Cc: pgsql-performance@postgresql.org +>> Subject: RE: [PERFORM] tsearch2 seem very slow +>> +>> On Fri, 23 Sep 2005, Ahmad Fajar wrote: +>> +>>> Hi Oleg, +>>> +>>> I didn't deny on the third repeat or more, it can reach < 600 msec. It is +>>> only because the result still in postgres cache, but how about in the +>> first +>>> run? I didn't dare, the values is un-acceptable. Because my table will +>> grows +>>> rapidly, it's about 100000 rows per-week. And the visitor will search +>>> anything that I don't know, whether it's the repeated search or new +>> search, +>>> or whether it's in postgres cache or not. +>> +>> if you have enoush shared memory postgresql will keep index pages there. +>> +>> +>>> +>>> I just compare with http://www.postgresql.org, the search is quite fast, +>> and +>>> I don't know whether the site uses tsearch2 or something else. But as fas +>> as +>>> I know, if the rows reach >100 milion (I have try for 200 milion rows and +>> it +>>> seem very slow), even if don't use tsearch2, only use simple query like: +>>> select f1, f2 from table1 where f2='blabla', +>>> and f2 is indexes, my postgres still slow on the first time, about >10 +>> sec. +>>> because of this I tried something brand new to fullfill my needs. I have +>>> used fti, and tsearch2 but still slow. +>>> +>>> I don't know what's going wrong with my postgres, what configuration must +>> I +>>> do to perform the query get fast result. Or must I use enterprisedb 2005 +>> or +>>> pervasive postgres (both uses postgres), I don't know very much about +>> these +>>> two products. +>> +>> you didn't show us your configuration (hardware,postgresql and tsearch2), +>> explain analyze of your queries, so we can't help you. +>> How big is your database, tsearch2 index size ? +>> +>> +>>> +>>> Regards, +>>> ahmad fajar +>>> +>>> +>>> -----Original Message----- +>>> From: Oleg Bartunov [mailto:oleg@sai.msu.su] +>>> Sent: Jumat, 23 September 2005 14:36 +>>> To: Ahmad Fajar +>>> Cc: pgsql-performance@postgresql.org +>>> Subject: Re: [PERFORM] tsearch2 seem very slow +>>> +>>> Ahmad, +>>> +>>> how fast is repeated runs ? First time system could be very slow. +>>> Also, have you checked my page +>>> http://www.sai.msu.su/~megera/oddmuse/index.cgi/Tsearch_V2_Notes +>>> and some info about tsearch2 internals +>>> http://www.sai.msu.su/~megera/oddmuse/index.cgi/Tsearch_V2_internals +>>> +>>> Oleg +>>> On Thu, 22 Sep 2005, Ahmad Fajar wrote: +>>> +>>>> I have about 419804 rows in my article table. I have installed tsearch2 +>>> and +>>>> its gist index correctly. +>>>> +>>>> My table structure is: +>>>> +>>>> CREATE TABLE tbarticles +>>>> +>>>> ( +>>>> +>>>> articleid int4 NOT NULL, +>>>> +>>>> title varchar(250), +>>>> +>>>> mediaid int4, +>>>> +>>>> datee date, +>>>> +>>>> content text, +>>>> +>>>> contentvar text, +>>>> +>>>> mmcol float4 NOT NULL, +>>>> +>>>> sirkulasi float4, +>>>> +>>>> page varchar(10), +>>>> +>>>> tglisidata date, +>>>> +>>>> namapc varchar(12), +>>>> +>>>> usere varchar(12), +>>>> +>>>> file_pdf varchar(255), +>>>> +>>>> file_pdf2 varchar(50), +>>>> +>>>> kolom int4, +>>>> +>>>> size_jpeg int4, +>>>> +>>>> journalist varchar(120), +>>>> +>>>> ratebw float4, +>>>> +>>>> ratefc float4, +>>>> +>>>> fti tsvector, +>>>> +>>>> CONSTRAINT pk_tbarticles PRIMARY KEY (articleid) +>>>> +>>>> ) WITHOUT OIDS; +>>>> +>>>> Create index fti_idx1 on tbarticles using gist (fti); +>>>> +>>>> Create index fti_idx2 on tbarticles using gist (datee, fti); +>>>> +>>>> +>>>> +>>>> But when I search something like: +>>>> +>>>> Select articleid, title, datee from tbarticles where fti @@ +>>>> to_tsquery('susilo&bambang&yudhoyono&jusuf&kalla'); +>>>> +>>>> It takes about 30 sec. I run explain analyze and the index is used +>>>> correctly. +>>>> +>>>> +>>>> +>>>> Then I try multi column index to filter by date, and my query something +>>>> like: +>>>> +>>>> Select articleid, title, datee from tbarticles where fti @@ +>>>> to_tsquery('susilo&bambang&yudhoyono&jusuf&kalla') and datee >= +>>> '2002-01-01' +>>>> and datee <= current_date +>>>> +>>>> An it still run about 25 sec. I do run explain analyze and my +> multicolumn +>>>> index is used correctly. +>>>> +>>>> This is not acceptable if want to publish my website if the search took +>>> very +>>>> longer. +>>>> +>>>> +>>>> +>>>> I have run vacuum full analyze before doing such query. What going wrong +>>>> with my query?? Is there any way to make this faster? +>>>> +>>>> I have try to tune my postgres configuration, but it seem helpless. My +>>> linux +>>>> box is Redhat 4 AS, and +>>>> +>>>> the hardware: 2 GB RAM DDR 400, 2x200 GB Serial ATA 7200RPM and +> configure +>>> as +>>>> RAID0 (just for postgres data), my sistem run at EIDE 80GB 7200 RPM. +>>>> +>>>> +>>>> +>>>> Please.help.help. +>>>> +>>>> +>>> +>>> Regards, +>>> Oleg +>>> _____________________________________________________________ +>>> Oleg Bartunov, sci.researcher, hostmaster of AstroNet, +>>> Sternberg Astronomical Institute, Moscow University (Russia) +>>> Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ +>>> phone: +007(095)939-16-83, +007(095)939-23-83 +>>> +>> +>> Regards, +>> Oleg +>> _____________________________________________________________ +>> Oleg Bartunov, sci.researcher, hostmaster of AstroNet, +>> Sternberg Astronomical Institute, Moscow University (Russia) +>> Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ +>> phone: +007(095)939-16-83, +007(095)939-23-83 +>> +>> +>> ---------------------------(end of broadcast)--------------------------- +>> TIP 2: Don't 'kill -9' the postmaster +>> +> +> Regards, +> Oleg +> _____________________________________________________________ +> Oleg Bartunov, sci.researcher, hostmaster of AstroNet, +> Sternberg Astronomical Institute, Moscow University (Russia) +> Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ +> phone: +007(095)939-16-83, +007(095)939-23-83 +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: Don't 'kill -9' the postmaster +> + + Regards, + Oleg +_____________________________________________________________ +Oleg Bartunov, sci.researcher, hostmaster of AstroNet, +Sternberg Astronomical Institute, Moscow University (Russia) +Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ +phone: +007(095)939-16-83, +007(095)939-23-83 + +From pgsql-performance-owner@postgresql.org Sun Sep 25 15:38:50 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 38C4AD95DD + for ; + Sun, 25 Sep 2005 15:38:48 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 01941-05 + for ; + Sun, 25 Sep 2005 18:38:45 +0000 (GMT) +Received: from ki-communication.com (unknown [202.147.194.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 05F01D9595 + for ; + Sun, 25 Sep 2005 15:38:43 -0300 (ADT) +Received: from iacn01wks ([192.168.0.128]) by ki-communication.com with + Microsoft SMTPSVC(6.0.3790.1830); Mon, 26 Sep 2005 01:43:06 +0700 +From: "Ahmad Fajar" +To: +Subject: Query seem to slow if table have more than 200 million rows +Date: Mon, 26 Sep 2005 01:42:59 +0700 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0000_01C5C23B.A03CDF10" +X-Mailer: Microsoft Office Outlook, Build 11.0.6353 +Thread-Index: AcXCAPPImU/GMgDCQvGVGxjPhimImA== +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +Message-ID: +X-OriginalArrivalTime: 25 Sep 2005 18:43:06.0234 (UTC) + FILETIME=[F7C10DA0:01C5C200] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.394 required=5 tests=[AWL=-0.099, + DNS_FROM_RFC_WHOIS=0.492, HTML_MESSAGE=0.001] +X-Spam-Level: +X-Archive-Number: 200509/344 +X-Sequence-Number: 14652 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0000_01C5C23B.A03CDF10 +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: 7bit + +If I do a simple query like: + +Select ids, keywords from dict where keywords='blabla' ('blabla' is a single +word); + +The table have 200 million rows, I have index the keywords field. On the +first time my query seem to slow to get the result, about 15-60 sec to get +the result. But if I repeat the query I will get fast result. My question is +why on the first time the query seem very slow. + +Table structure is quite simple: + +Ids bigint, keywords varchar(150), weight varchar(1), dpos int. + + + +I use latest pgAdmin3 to test all queries. My linux box is Redhat 4 AS, +kernel 2.6.9-11, postgresql version 8.0.3, 2x200 GB SATA 7200 RPM configure +as RAID0 with ext3 file system for postgresql data only. 80 GB EIDE 7200 RPM +with ext3 file system for OS only. The server has 2 GB RAM with P4 3,2 GHz. + + + +If I do this query on mssql server, with the same hardware spesification and +same data, mssql server beat postgresql, the query about 0-4 sec to get the +result. What wrong with my postgresql. + + + +wassalam, + +ahmad fajar + + + + +------=_NextPart_000_0000_01C5C23B.A03CDF10 +Content-Type: text/html; + charset="US-ASCII" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + +
+ +

If I do a simple = +query like:

+ +

Select ids, keywords from dict where +keywords=3D'blabla' ('blabla' is a single word); = +

+ +

The table have 200 million rows, I have index = +the +keywords field. On the first time my query seem to slow to get the = +result, +about 15-60 sec to get the result. But if I repeat the query I will get = +fast +result. My question is why on the first time the query seem very slow. = +

+ +

Table structure is quite = +simple:

+ +

Ids bigint, keywords varchar(150), weight +varchar(1), dpos int.

+ +

 

+ +

I use latest pgAdmin3 to test all queries. My = +linux +box is Redhat 4 AS, kernel 2.6.9-11, postgresql version 8.0.3, 2x200 GB = +SATA 7200 +RPM configure as RAID0 with ext3 file system for postgresql data only. = +80 GB +EIDE 7200 RPM with ext3 file system for OS only. The server has 2 GB RAM = +with +P4 3,2 GHz.

+ +

 

+ +

If I do this query on mssql server, with the = +same +hardware spesification and same data, mssql server beat postgresql, the = +query +about 0-4 sec to get the result. What wrong with my = +postgresql. + +

 

+ +
+ +

wassalam,<= +/p> + +

ahmad = +fajar

+ +
+ +

 

+ +
+ + + + + +------=_NextPart_000_0000_01C5C23B.A03CDF10-- + + +From pgsql-performance-owner@postgresql.org Sun Sep 25 16:10:35 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 00AD7D95A9 + for ; + Sun, 25 Sep 2005 16:10:34 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 07329-04 + for ; + Sun, 25 Sep 2005 19:10:28 +0000 (GMT) +Received: from ki-communication.com (unknown [202.147.194.21]) + by svr1.postgresql.org (Postfix) with ESMTP id A38B5D76BA + for ; + Sun, 25 Sep 2005 16:10:27 -0300 (ADT) +Received: from iacn01wks ([192.168.0.128]) by ki-communication.com with + Microsoft SMTPSVC(6.0.3790.1830); Mon, 26 Sep 2005 02:14:50 +0700 +From: "Ahmad Fajar" +To: "'Oleg Bartunov'" +Cc: +Subject: Re: tsearch2 seem very slow +Date: Mon, 26 Sep 2005 02:14:38 +0700 +Keywords: Postgresql +MIME-Version: 1.0 +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: 7bit +X-Mailer: Microsoft Office Outlook, Build 11.0.6353 +In-Reply-To: +Thread-Index: AcXB/4OudUZ5HDloQ+eQJFZPZjge7QAAnprA +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +Message-ID: +X-OriginalArrivalTime: 25 Sep 2005 19:14:50.0062 (UTC) + FILETIME=[668626E0:01C5C205] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.387 required=5 tests=[AWL=-0.105, + DNS_FROM_RFC_WHOIS=0.492] +X-Spam-Level: +X-Archive-Number: 200509/345 +X-Sequence-Number: 14653 + +Hi Oleg, + +> what king of garbage ? Probably you index not needed token types, for +> example, email address, file names.... + +> do you need proximity ? If no, use strip(tsvector) function to remove +> coordinate information from tsvector. + +I need proximity. Some time I have to rank my article and make a chart for +that. + +> don't index default configuration and index only needed tokens, for +> example, to index only 3 type of tokens, first create 'qq' configuration +> and specify tokens to index. + +> insert into pg_ts_cfg values('qq','default','en_US'); +-- tokens to index +> insert into pg_ts_cfgmap values('qq','lhword','{en_ispell,en_stem}'); +> insert into pg_ts_cfgmap values('qq','lword','{en_ispell,en_stem}'); +> insert into pg_ts_cfgmap values('qq','lpart_hword','{en_ispell,en_stem}'); + +I still don't understand about tsearch2 configuration, so until now I just +use default configuration. I will try your suggestion. But how can I get the +en_ispell? Does my system will know if I use: ....,'{en_ispell,en_stem}'; +>From default configuration I only see: ..., '{en_stem}'; + +> Beside that, I still have problem, if I do a simple query like: +> Select ids, keywords from dict where keywords='blabla' ('blabla' is a +single +> word); The table have 200 million rows, I have index the keywords field. +On +> the first time my query seem to slow to get the result, about 15-60 sec to +> get the result. I use latest pgAdmin3 to test all queries. But if I repeat +> the query I will get fast result. My question is why on the first time the +> query seem to slow. + +> because index pages should be readed from disk into shared buffers, so +> next query will benefit from that. You need enough shared memory to get +> real benefit. You may get postgresql stats and look on cache hit ration. + +> btw, how does your query ( keywords='blabla') relates to tsearch2 ? + +(Keywords='blabla') isn't related to tsearch2, I just got an idea from +tsearch2 and try different approach. But I stuck on the query result speed. +Very slow to get result on the first query. +And how to see postgresql stats and look on cache hit ratio? I still don't +know how to get it. + +> I try to cluster the table base on keyword index, but after 15 hours +> waiting and it doesn't finish I stop clustering. + +> don't use cluster for big tables ! simple +> select * into clustered_foo from foo order by indexed_field +> would be faster and does the same job. + +What the use of clustered_foo table? And how to use it? +I think it will not distinct duplicate rows. And the clustered_foo table +still not have an index, so if query to this table, I think the query will +be very slow to get a result. + +Regards, +ahmad fajar + + +From pgsql-performance-owner@postgresql.org Sun Sep 25 17:12:09 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E704FD9438 + for ; + Sun, 25 Sep 2005 17:12:06 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 24600-10 + for ; + Sun, 25 Sep 2005 20:12:00 +0000 (GMT) +Received: from ra.sai.msu.su (ra.sai.msu.su [158.250.29.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4F06BD76BA + for ; + Sun, 25 Sep 2005 17:11:53 -0300 (ADT) +Received: from ra (ra [158.250.29.2]) + by ra.sai.msu.su (8.13.4/8.13.4) with ESMTP id j8PKBXef018346; + Mon, 26 Sep 2005 00:11:33 +0400 (MSD) +Date: Mon, 26 Sep 2005 00:11:33 +0400 (MSD) +From: Oleg Bartunov +X-X-Sender: megera@ra.sai.msu.su +To: Ahmad Fajar +Cc: pgsql-performance@postgresql.org +Subject: Re: tsearch2 seem very slow +In-Reply-To: +Message-ID: +References: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.323 required=5 tests=[AWL=-0.051, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200509/346 +X-Sequence-Number: 14654 + +Ahmad, + +On Mon, 26 Sep 2005, Ahmad Fajar wrote: + +> Hi Oleg, +> +>> what king of garbage ? Probably you index not needed token types, for +>> example, email address, file names.... +> +>> do you need proximity ? If no, use strip(tsvector) function to remove +>> coordinate information from tsvector. +> +> I need proximity. Some time I have to rank my article and make a chart for +> that. +> +>> don't index default configuration and index only needed tokens, for +>> example, to index only 3 type of tokens, first create 'qq' configuration +>> and specify tokens to index. +> +>> insert into pg_ts_cfg values('qq','default','en_US'); +> -- tokens to index +>> insert into pg_ts_cfgmap values('qq','lhword','{en_ispell,en_stem}'); +>> insert into pg_ts_cfgmap values('qq','lword','{en_ispell,en_stem}'); +>> insert into pg_ts_cfgmap values('qq','lpart_hword','{en_ispell,en_stem}'); +> +> I still don't understand about tsearch2 configuration, so until now I just +> use default configuration. I will try your suggestion. But how can I get the +> en_ispell? Does my system will know if I use: ....,'{en_ispell,en_stem}'; +>> From default configuration I only see: ..., '{en_stem}'; + +I think you should read documentation. I couldn't explain you things already +written. + +> +>> Beside that, I still have problem, if I do a simple query like: +>> Select ids, keywords from dict where keywords='blabla' ('blabla' is a +> single +>> word); The table have 200 million rows, I have index the keywords field. +> On +>> the first time my query seem to slow to get the result, about 15-60 sec to +>> get the result. I use latest pgAdmin3 to test all queries. But if I repeat +>> the query I will get fast result. My question is why on the first time the +>> query seem to slow. +> +>> because index pages should be readed from disk into shared buffers, so +>> next query will benefit from that. You need enough shared memory to get +>> real benefit. You may get postgresql stats and look on cache hit ration. +> +>> btw, how does your query ( keywords='blabla') relates to tsearch2 ? +> +> (Keywords='blabla') isn't related to tsearch2, I just got an idea from +> tsearch2 and try different approach. But I stuck on the query result speed. +> Very slow to get result on the first query. +> And how to see postgresql stats and look on cache hit ratio? I still don't +> know how to get it. +> + +learn from http://www.postgresql.org/docs/8.0/static/monitoring-stats.html + +>> I try to cluster the table base on keyword index, but after 15 hours +>> waiting and it doesn't finish I stop clustering. +> +>> don't use cluster for big tables ! simple +>> select * into clustered_foo from foo order by indexed_field +>> would be faster and does the same job. +> +> What the use of clustered_foo table? And how to use it? +> I think it will not distinct duplicate rows. And the clustered_foo table +> still not have an index, so if query to this table, I think the query will +> be very slow to get a result. + +oh guy, you certainly need to read documentation +http://www.postgresql.org/docs/8.0/static/sql-cluster.html + + +> +> Regards, +> ahmad fajar +> + + Regards, + Oleg +_____________________________________________________________ +Oleg Bartunov, sci.researcher, hostmaster of AstroNet, +Sternberg Astronomical Institute, Moscow University (Russia) +Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ +phone: +007(095)939-16-83, +007(095)939-23-83 + +From pgsql-performance-owner@postgresql.org Sun Sep 25 17:54:56 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 866CBD76BA + for ; + Sun, 25 Sep 2005 17:54:55 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 82118-09 + for ; + Sun, 25 Sep 2005 20:54:48 +0000 (GMT) +Received: from cassarossa.samfundet.no (cassarossa.samfundet.no + [129.241.93.19]) + by svr1.postgresql.org (Postfix) with ESMTP id EBDB1D95F5 + for ; + Sun, 25 Sep 2005 17:54:48 -0300 (ADT) +Received: from trofast.sesse.net ([129.241.93.32]) + by cassarossa.samfundet.no with esmtp (Exim 4.50) id 1EJdWK-0003aU-25 + for pgsql-performance@postgresql.org; Sun, 25 Sep 2005 22:54:49 +0200 +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1EJdWI-000855-00 + for ; Sun, 25 Sep 2005 22:54:46 +0200 +Date: Sun, 25 Sep 2005 22:54:46 +0200 +From: "Steinar H. Gunderson" +To: pgsql-performance@postgresql.org +Subject: Re: Advice on RAID card +Message-ID: <20050925205446.GA30704@uio.no> +Mail-Followup-To: pgsql-performance@postgresql.org +References: + <43367937.40809@canaan.co.il> + + <4336C57B.6090800@commandprompt.com> + <4336CEAA.7070208@commandprompt.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Disposition: inline +In-Reply-To: +X-Operating-System: Linux 2.6.11.8 on a i686 +X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.014 required=5 tests=[AWL=0.014] +X-Spam-Level: +X-Archive-Number: 200509/347 +X-Sequence-Number: 14655 + +On Sun, Sep 25, 2005 at 06:53:57PM +0200, PFC wrote: +> Gonna investigate now if Linux software RAID5 is rugged enough. Can +> always buy the a card later if not. + +Note that 2.6.13 and 2.6.14 have several improvements to the software RAID +code, some with regard to ruggedness. You might want to read the changelogs. + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-performance-owner@postgresql.org Sun Sep 25 18:03:20 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B4232D95F3 + for ; + Sun, 25 Sep 2005 18:03:18 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 83645-08 + for ; + Sun, 25 Sep 2005 21:03:13 +0000 (GMT) +Received: from ki-communication.com (unknown [202.147.194.21]) + by svr1.postgresql.org (Postfix) with ESMTP id E651FD95E8 + for ; + Sun, 25 Sep 2005 18:03:12 -0300 (ADT) +Received: from iacn01wks ([192.168.0.128]) by ki-communication.com with + Microsoft SMTPSVC(6.0.3790.1830); Mon, 26 Sep 2005 04:07:36 +0700 +From: "Ahmad Fajar" +To: "'Oleg Bartunov'" +Cc: +Subject: Re: tsearch2 seem very slow +Date: Mon, 26 Sep 2005 04:07:08 +0700 +Keywords: Postgresql +MIME-Version: 1.0 +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: 7bit +X-Mailer: Microsoft Office Outlook, Build 11.0.6353 +In-Reply-To: +Thread-Index: AcXCDL5qXjRxZEwcQ1iJyejUhcIhzAAB7xQQ +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +Message-ID: +X-OriginalArrivalTime: 25 Sep 2005 21:07:36.0312 (UTC) + FILETIME=[2785F780:01C5C215] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.383 required=5 tests=[AWL=-0.109, + DNS_FROM_RFC_WHOIS=0.492] +X-Spam-Level: +X-Archive-Number: 200509/348 +X-Sequence-Number: 14656 + +Hi Oleg, + +Thanks, I will read your documentation again, and try to understand what I +miss. And about pgmanual, it is very help me. I'll take attention on that. + +Regards, +ahmad fajar + +-----Original Message----- +From: Oleg Bartunov [mailto:oleg@sai.msu.su] +Sent: Monday, September 26, 2005 3:12 AM +To: Ahmad Fajar +Cc: pgsql-performance@postgresql.org +Subject: RE: [PERFORM] tsearch2 seem very slow + +Ahmad, + +On Mon, 26 Sep 2005, Ahmad Fajar wrote: + +> Hi Oleg, +> +>> what king of garbage ? Probably you index not needed token types, for +>> example, email address, file names.... +> +>> do you need proximity ? If no, use strip(tsvector) function to remove +>> coordinate information from tsvector. +> +> I need proximity. Some time I have to rank my article and make a chart for +> that. +> +>> don't index default configuration and index only needed tokens, for +>> example, to index only 3 type of tokens, first create 'qq' configuration +>> and specify tokens to index. +> +>> insert into pg_ts_cfg values('qq','default','en_US'); +> -- tokens to index +>> insert into pg_ts_cfgmap values('qq','lhword','{en_ispell,en_stem}'); +>> insert into pg_ts_cfgmap values('qq','lword','{en_ispell,en_stem}'); +>> insert into pg_ts_cfgmap +values('qq','lpart_hword','{en_ispell,en_stem}'); +> +> I still don't understand about tsearch2 configuration, so until now I just +> use default configuration. I will try your suggestion. But how can I get +the +> en_ispell? Does my system will know if I use: ....,'{en_ispell,en_stem}'; +>> From default configuration I only see: ..., '{en_stem}'; + +I think you should read documentation. I couldn't explain you things already +written. + +> +>> Beside that, I still have problem, if I do a simple query like: +>> Select ids, keywords from dict where keywords='blabla' ('blabla' is a +> single +>> word); The table have 200 million rows, I have index the keywords field. +> On +>> the first time my query seem to slow to get the result, about 15-60 sec +to +>> get the result. I use latest pgAdmin3 to test all queries. But if I +repeat +>> the query I will get fast result. My question is why on the first time +the +>> query seem to slow. +> +>> because index pages should be readed from disk into shared buffers, so +>> next query will benefit from that. You need enough shared memory to get +>> real benefit. You may get postgresql stats and look on cache hit ration. +> +>> btw, how does your query ( keywords='blabla') relates to tsearch2 ? +> +> (Keywords='blabla') isn't related to tsearch2, I just got an idea from +> tsearch2 and try different approach. But I stuck on the query result +speed. +> Very slow to get result on the first query. +> And how to see postgresql stats and look on cache hit ratio? I still don't +> know how to get it. +> + +learn from http://www.postgresql.org/docs/8.0/static/monitoring-stats.html + +>> I try to cluster the table base on keyword index, but after 15 hours +>> waiting and it doesn't finish I stop clustering. +> +>> don't use cluster for big tables ! simple +>> select * into clustered_foo from foo order by indexed_field +>> would be faster and does the same job. +> +> What the use of clustered_foo table? And how to use it? +> I think it will not distinct duplicate rows. And the clustered_foo table +> still not have an index, so if query to this table, I think the query will +> be very slow to get a result. + +oh guy, you certainly need to read documentation +http://www.postgresql.org/docs/8.0/static/sql-cluster.html + + +> +> Regards, +> ahmad fajar +> + + Regards, + Oleg +_____________________________________________________________ +Oleg Bartunov, sci.researcher, hostmaster of AstroNet, +Sternberg Astronomical Institute, Moscow University (Russia) +Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ +phone: +007(095)939-16-83, +007(095)939-23-83 + + +From pgsql-performance-owner@postgresql.org Sun Sep 25 22:04:05 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CFBB7D9653 + for ; + Sun, 25 Sep 2005 22:04:03 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 70012-09 + for ; + Mon, 26 Sep 2005 01:03:58 +0000 (GMT) +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 832B3D964D + for ; + Sun, 25 Sep 2005 22:04:00 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 9DEB831F51; Mon, 26 Sep 2005 03:04:03 +0200 (MET DST) +From: Chris Browne +X-Newsgroups: pgsql.performance +Subject: Re: Advice on RAID card +Date: Sun, 25 Sep 2005 20:10:00 -0400 +Organization: cbbrowne Computing Inc +Lines: 26 +Message-ID: <60ek7cn0yv.fsf@dba2.int.libertyrms.com> +References: + <43367937.40809@canaan.co.il> + + <4336C57B.6090800@commandprompt.com> + <4336CEAA.7070208@commandprompt.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +X-Complaints-To: usenet@news.hub.org +User-Agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4.17 (Jumbo Shrimp, linux) +Cancel-Lock: sha1:1KLdeeRKSnLlTLkWp2Oj1YAuCyg= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.095 required=5 tests=[AWL=0.095] +X-Spam-Level: +X-Archive-Number: 200509/349 +X-Sequence-Number: 14657 + +jd@commandprompt.com ("Joshua D. Drake") writes: +> There is a huge advantage to software raid on all kinds of +> levels. If you have the CPU then I suggest it. However you will +> never get the performance out of software raid on the high level +> (think 1 gig of cache) that you would on a software raid setup. + +This appears to be a case where the "ludicrous MHz increases" on +desktop CPUs has actually provided a material benefit. + +The sorts of embedded controllers typically used on RAID controllers +are StrongARMs and i960s, and, well, 250MHz is actually fast for +these. + +When AMD and Intel fight over adding gigahertz and megabytes of cache +to their chips, this means that the RAID work can get pushed over to +one's "main CPU" without chewing up terribly much of its bandwidth. + +That says to me that in the absence of battery backed cache, it's not +worth having a "bottom-end" RAID controller. Particularly if the +death of the controller would be likely to kill your data. + +Battery-backed cache changes the value proposition, of course... +-- +select 'cbbrowne' || '@' || 'acm.org'; +http://cbbrowne.com/info/linuxdistributions.html +All generalizations are false, including this one. + +From pgsql-performance-owner@postgresql.org Mon Sep 26 04:49:57 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6343CD96C0 + for ; + Mon, 26 Sep 2005 04:49:55 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 99071-04 + for ; + Mon, 26 Sep 2005 07:49:52 +0000 (GMT) +Received: from wmail05dat.netvigator.com (unknown [218.102.48.220]) + by svr1.postgresql.org (Postfix) with ESMTP id C1AFDD96CB + for ; + Mon, 26 Sep 2005 04:49:51 -0300 (ADT) +Received: from n2.netvigator.com ([218.102.147.167]) + by wmail05dat.netvigator.com + (InterMail vM.6.01.05.02 201-2131-123-102-20050715) with ESMTP id + <20050926074952.DBIR18019.wmail05dat.netvigator.com@n2.netvigator.com>; + Mon, 26 Sep 2005 15:49:52 +0800 +Message-Id: <6.2.1.2.0.20050926152048.0542bcc8@localhost> +X-Mailer: QUALCOMM Windows Eudora Version 6.2.1.2 +Date: Mon, 26 Sep 2005 15:46:30 +0800 +To: Simon Riggs +From: K C Lau +Subject: Re: SELECT LIMIT 1 VIEW Performance Issue +Cc: pgsql-performance@postgresql.org +In-Reply-To: <6.2.1.2.0.20050923195457.02c4fd30@localhost> +References: <6.2.1.2.0.20050615100524.04f9d6a8@localhost> + <6.2.1.2.0.20050922102035.07bcf2e0@localhost> + <1127378456.4145.76.camel@localhost.localdomain> + <6.2.1.2.0.20050922181009.02c36ca8@localhost> + <1127474141.19345.10.camel@localhost.localdomain> + <6.2.1.2.0.20050923195457.02c4fd30@localhost> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.535 required=5 tests=[AWL=-0.357, + DNS_FROM_RFC_POST=1.376, FROM_ENDS_IN_NUMS=0.516] +X-Spam-Level: * +X-Archive-Number: 200509/350 +X-Sequence-Number: 14658 + +At 20:17 05/09/23, K C Lau wrote: +>At 19:15 05/09/23, Simon Riggs wrote: +>>select distinct on (PlayerID) PlayerID,AtDate from Player a +>>where PlayerID='22220' order by PlayerId, AtDate Desc; +>> +>>Does that work for you? +>> +>>Best Regards, Simon Riggs +> +>esdt=> explain analyze select distinct on (PlayerID) PlayerID,AtDate from +>Player a where PlayerID='22220' order by PlayerId Desc, AtDate Desc; +> Unique (cost=0.00..1327.44 rows=2 width=23) (actual time=0.027..8.438 +> rows=1 loops=1) +> -> Index Scan Backward using pk_player on player +> a (cost=0.00..1323.05 rows=1756 width=23) (actual time=0.022..4.950 +> rows=1743 loops=1) +> Index Cond: ((playerid)::text = '22220'::text) +> Total runtime: 8.499 ms +> +>That is the fastest of all queries looping the 1743 rows. +>I do get the desired result by adding LIMIT 1: +> +>esdt=> explain analyze select distinct on (PlayerID) PlayerID,AtDate from +>Player a where PlayerID='22220' order by PlayerId Desc, AtDate Desc LIMIT 1; +> +> Limit (cost=0.00..663.72 rows=1 width=23) (actual time=0.032..0.033 +> rows=1 loops=1) +> -> Unique (cost=0.00..1327.44 rows=2 width=23) (actual +> time=0.028..0.028 rows=1 loops=1) +> -> Index Scan Backward using pk_player on player +> a (cost=0.00..1323.05 rows=1756 width=23) (actual time=0.022..0.022 +> rows=1 loops=1) +> Index Cond: ((playerid)::text = '22220'::text) +> Total runtime: 0.094 ms +> +>However, when I use that within a function in a view, it is slow again: +> +>esdt=> create or replace function player_max_atdate (varchar(32)) returns +>varchar(32) as $$ +>esdt$> select distinct on (PlayerID) AtDate from player where PlayerID= +>$1 order by PlayerID desc, AtDate desc limit 1; +>esdt$> $$ language sql immutable; +>CREATE FUNCTION +>esdt=> create or replace view VCurPlayer3 as select * from Player where +>AtDate = player_max_atdate(PlayerID); +>CREATE VIEW +>esdt=> explain analyze select PlayerID,AtDate from VCurPlayer3 where +>PlayerID='22220'; +> +> Index Scan using pk_player on player (cost=0.00..1331.83 rows=9 +> width=23) (actual time=76.660..76.664 rows=1 loops=1) +> Index Cond: ((playerid)::text = '22220'::text) +> Filter: ((atdate)::text = (player_max_atdate(playerid))::text) +> Total runtime: 76.716 ms +> +>Why wouldn't the function get the row as quickly as the direct sql does? + +Results from the following query suggests that the explain analyze output +above only tells half the story, and that the function is in fact called +1743 times: + +esdt=> create or replace view VCurPlayer3 as select distinct on (PlayerID) +* from Player a where OID = (select distinct on (PlayerID) OID from Player +b where b.PlayerID = a.PlayerID and b.AtDate = +player_max_atdate(b.PlayerID) order by PlayerID desc, AtDate desc limit 1) +order by PlayerId Desc, AtDate desc; +CREATE VIEW +esdt=> explain analyze select PlayerID,AtDate from VCurPlayer3 where +PlayerID='22220'; + Subquery Scan vcurplayer3 (cost=0.00..1715846.91 rows=1 width=68) +(actual time=0.640..119.124 rows=1 loops=1) + -> Unique (cost=0.00..1715846.90 rows=1 width=776) (actual +time=0.633..119.112 rows=1 loops=1) + -> Index Scan Backward using pk_player on player +a (cost=0.00..1715846.88 rows=9 width=776) (actual time=0.628..119.104 +rows=1 loops=1) + Index Cond: ((playerid)::text = '22220'::text) + Filter: (oid = (subplan)) + SubPlan + -> Limit (cost=0.00..976.38 rows=1 width=27) (actual +time=0.057..0.058 rows=1 loops=1743) + -> Unique (cost=0.00..976.38 rows=1 width=27) +(actual time=0.052..0.052 rows=1 loops=1743) + -> Index Scan Backward using pk_player on +player b (cost=0.00..976.36 rows=6 width=27) (actual time=0.047..0.047 +rows=1 loops=1743) + Index Cond: ((playerid)::text = ($0)::text) + Filter: ((atdate)::text = +(player_max_atdate(playerid))::text) + Total runtime: 119.357 ms + +It would also explain the very long time taken by the pl/pgsql function I +posted a bit earlier. + +So I guess it all comes back to the basic question: + +For the query select distinct on (PlayerID) * from Player a where +PlayerID='22220' order by PlayerId Desc, AtDate Desc; +can the optimizer recognise the fact the query is selecting by the primary +key (PlayerID,AtDate), so it can skip the remaining rows for that PlayerID, +as if LIMIT 1 is implied? + +Best regards, KC. + + + +From pgsql-performance-owner@postgresql.org Mon Sep 26 08:02:03 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 29DF0D96B1 + for ; + Mon, 26 Sep 2005 08:02:02 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 44776-03 + for ; + Mon, 26 Sep 2005 11:01:57 +0000 (GMT) +Received: from pop-siberian.atl.sa.earthlink.net + (pop-siberian.atl.sa.earthlink.net [207.69.195.71]) + by svr1.postgresql.org (Postfix) with ESMTP id 2ABCCD96F8 + for ; + Mon, 26 Sep 2005 08:01:58 -0300 (ADT) +Received: from elwamui-polski.atl.sa.earthlink.net ([209.86.224.45]) + by pop-siberian.atl.sa.earthlink.net with esmtp (Exim 3.36 #10) + id 1EJqkB-0003lI-00; Mon, 26 Sep 2005 07:01:59 -0400 +Message-ID: + <19340086.1127732519601.JavaMail.root@elwamui-polski.atl.sa.earthlink.net> +Date: Mon, 26 Sep 2005 07:01:59 -0400 (EDT) +From: Ron Peacetree +Reply-To: Ron Peacetree +To: PFC , + pgsql-performance@postgresql.org +Subject: Re: Advice on RAID card +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Mailer: Earthlink Zoo Mail 1.0 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.257 required=5 tests=[AWL=-0.117, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200509/351 +X-Sequence-Number: 14659 + +While I understand being economical, at some point one crosses the line +to being penny wise and pound foolish. + +How much is the data on this server going to be worth? +How much much will it cost you to recover or restore it (assuming that +is even possible if you lose it)? + +If your data is worth nothing or the cost to recover or restore it is +negligible, then you don't need (nor should want) a DB server. You'll +get higher performance at less cost via a number of other methods. + +OTOH, if you data _does_ have value by any of the above metrics, +then it is worth it to pay attention to reliable, safe, fast, physical IO. + +Battery backed HD caches of appropriate size are usually well worth +the $, as they pay for themselves (and then some) with the first data +loss they prevent. + +RAID 5 means you are _always_ only 2 HDs from data loss, and 1 HD +from a serious performance hit. Part of the trade-off with using SATA +HDs that cost 1/3-1/4 their U320 15Krpm brethren is that such +circumstances are +FAR+ more likely with SATA HDs. + +If you are not going to use RAID 10 because of cost issues, then +spend the $ to get the biggest battery backed cache you can afford +and justify as being cheaper than what the proper RAID 6 or RAID 10 +setup would cost you. Even if you are going to use SW RAID and the +controller will just be a JBOD controller. + +On the general subject of costs... + +At this writing, SODIMM RAM costs ~$100 (US) per GB. Standard +DIMMs cost ~$75 per GB unless you buy 4GB ones, in which case +they cost ~$100 per GB. + +The "sweet spot" in SATA HD pricing is ~$160 for 320GB at 7200rpm +(don't buy the 36GB or 74GB WD Raptors, they are no longer worth +it). If you are careful you can get SATA HD's with 16MB rather than +8MB buffers for that price. Each such HD will give you ~50MB/s of +raw Average Sustained Transfer Rate. + +Decent x86 compatible CPUs are available for ~$200-$400 apiece. +Rarely will a commodity HW DB server need a more high end CPU. + +Some of the above numbers rate to either fall to 1/2 cost or 2x in value +for the dollar within the next 6-9 months, and all of them will within the +next 18 months. And so will RAID controller costs. + +Your salary will hopefully not degrade at that rate, and it is unlikely that +your value for the dollar will increase at that rate. Nor is it likely that +data worth putting on a DB server will do so. + +Figure out what your required performance and reliability for the next 18 +months is going to be, and buy the stuff from the above list that will +sustain that. No matter what. + +Anything less rates _highly_ to end up costing you and your organization +more money within the next 18months than you will "save" in initial +acquisition cost. + +Ron + + + + + +-----Original Message----- +From: PFC +Sent: Sep 24, 2005 12:27 PM +Subject: Re: [PERFORM] Advice on RAID card + + +> It looks like a rebranded low end Adaptec 64MB PCI-X <-> SATA RAID card. +> Looks like the 64MB buffer is not upgradable. +> Looks like it's SATA, not SATA II + + Yeah, that's exactly what it is. I can get one for 150 Euro, the Areca is +at least 600. This is for a budget server so while it would be nice to +have all the high-tech stuff, it's not the point. My question was raher, +is it one of the crap RAID5 cards which are actually SLOWER than plain IDE +disks, or is it decent, even though low-end (and cheap), and worth it +compared to software RAID5 ? + +> Assuming you are not building 1U boxes, get one of the full height +> cards and order it with the maximum size buffer you can afford. +> The cards take 1 SODIMM, so that will be a max of 1GB or 2GB +> depending on whether 2GB SODIMMs are available to you yet. + + It's for a budget dev server which should have RAID5 for reliability, but +not necessarily stellar performance (and price). I asked about this card +because I can get one at a good price. + + Thanks for taking the time to answer. + + +From pgsql-general-owner@postgresql.org Mon Sep 26 12:29:26 2005 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B9D21D956C + for ; + Mon, 26 Sep 2005 12:29:24 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 15594-05 + for ; + Mon, 26 Sep 2005 15:29:15 +0000 (GMT) +Received: from mail.clickdiario.com (mail.clickdiario.com [70.85.167.114]) + by svr1.postgresql.org (Postfix) with ESMTP id 4DF38D9564 + for ; + Mon, 26 Sep 2005 12:29:14 -0300 (ADT) +Received: from localhost (localhost [127.0.0.1]) + by mail.clickdiario.com (Postfix) with ESMTP id 9258F10329 + for ; + Mon, 26 Sep 2005 10:32:45 -0500 (CDT) +Received: from mail.clickdiario.com ([127.0.0.1]) + by localhost (mail.clickdiario.com [127.0.0.1]) (amavisd-new, + port 10024) + with ESMTP id 26101-04 for ; + Mon, 26 Sep 2005 10:32:45 -0500 (CDT) +Received: from cristian1 (unknown [216.230.158.50]) + by mail.clickdiario.com (Postfix) with ESMTP id C336210149 + for ; + Mon, 26 Sep 2005 10:32:44 -0500 (CDT) +From: "Cristian Prieto" +To: +Subject: Index use in BETWEEN statement... +Date: Mon, 26 Sep 2005 09:26:43 -0600 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Mailer: Microsoft Office Outlook, Build 11.0.5510 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +In-Reply-To: <20050923220857.3A0841001E@mail.clickdiario.com> +Thread-Index: AcXAipbGc98Fe8XwQlKGyZnlcfBNQQCJAatw +Message-Id: <20050926153244.C336210149@mail.clickdiario.com> +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at example.com +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.016 required=5 tests=[AWL=0.016] +X-Spam-Level: +X-Archive-Number: 200509/1016 +X-Sequence-Number: 84031 + + +Hello pals, I have the following table in Postgresql 8.0.1 + +Mydb# \d geoip_block +Table "public.geoip_block" + Column | Type | Modifiers +-------------+--------+----------- + locid | bigint | + start_block | inet | + end_block | inet | + +mydb# explain analyze select locid from geoip_block where +'216.230.158.50'::inet between start_block and end_block; + QUERY PLAN +---------------------------------------------------------------------------- +------------------------------------------- + Seq Scan on geoip_block (cost=0.00..142772.86 rows=709688 width=8) (actual +time=14045.384..14706.927 rows=1 loops=1) + Filter: (('216.230.158.50'::inet >= start_block) AND +('216.230.158.50'::inet <= end_block)) + Total runtime: 14707.038 ms + +Ok, now I decided to create a index to "speed" a little the query + +Mydb# create index idx_ipblocks on geoip_block(start_block, end_block); +CREATE INDEX + +clickad=# explain analyze select locid from geoip_block where +'216.230.158.50'::inet between start_block and end_block; + QUERY PLAN +---------------------------------------------------------------------------- +------------------------------------------ + Seq Scan on geoip_block (cost=0.00..78033.96 rows=230141 width=8) (actual +time=12107.919..12610.199 rows=1 loops=1) + Filter: (('216.230.158.50'::inet >= start_block) AND +('216.230.158.50'::inet <= end_block)) + Total runtime: 12610.329 ms +(3 rows) + +I guess the planner is doing a sequential scan in the table, why not use the +compound index? Do you have any idea in how to speed up this query? + +Thanks a lot! + + +From pgsql-general-owner@postgresql.org Mon Sep 26 13:24:07 2005 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id ACC49D9564 + for ; + Mon, 26 Sep 2005 13:24:04 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 27739-04 + for ; + Mon, 26 Sep 2005 16:23:56 +0000 (GMT) +Received: from wimpy.net.nih.gov (wimpy.net.nih.gov [128.231.88.106]) + by svr1.postgresql.org (Postfix) with ESMTP id A7E74D971F + for ; + Mon, 26 Sep 2005 13:23:55 -0300 (ADT) +Received: from wimpy.net.nih.gov (localhost [127.0.0.1]) + by wimpy.net.nih.gov (8.12.11/8.11.7) with ESMTP id j8QGNrOj007248 + for ; + Mon, 26 Sep 2005 12:23:54 -0400 (EDT) +Received: from [128.231.145.14] (holmes.nhgri.nih.gov [128.231.145.14]) + by wimpy.net.nih.gov (8.12.11/8.11.7) with ESMTP id j8QGNrkn007243; + Mon, 26 Sep 2005 12:23:53 -0400 (EDT) +User-Agent: Microsoft-Entourage/10.1.4.030702.0 +Date: Mon, 26 Sep 2005 12:24:00 -0400 +Subject: Re: Index use in BETWEEN statement... +From: Sean Davis +To: Cristian Prieto , +Message-ID: +In-Reply-To: <20050926153244.C336210149@mail.clickdiario.com> +Mime-version: 1.0 +Content-type: text/plain; charset="US-ASCII" +Content-transfer-encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.014 required=5 tests=[AWL=0.014] +X-Spam-Level: +X-Archive-Number: 200509/1019 +X-Sequence-Number: 84034 + +On 9/26/05 11:26 AM, "Cristian Prieto" wrote: + +> +> Hello pals, I have the following table in Postgresql 8.0.1 +> +> Mydb# \d geoip_block +> Table "public.geoip_block" +> Column | Type | Modifiers +> -------------+--------+----------- +> locid | bigint | +> start_block | inet | +> end_block | inet | +> +> mydb# explain analyze select locid from geoip_block where +> '216.230.158.50'::inet between start_block and end_block; +> QUERY PLAN +> ---------------------------------------------------------------------------- +> ------------------------------------------- +> Seq Scan on geoip_block (cost=0.00..142772.86 rows=709688 width=8) (actual +> time=14045.384..14706.927 rows=1 loops=1) +> Filter: (('216.230.158.50'::inet >= start_block) AND +> ('216.230.158.50'::inet <= end_block)) +> Total runtime: 14707.038 ms +> +> Ok, now I decided to create a index to "speed" a little the query +> +> Mydb# create index idx_ipblocks on geoip_block(start_block, end_block); +> CREATE INDEX +> +> clickad=# explain analyze select locid from geoip_block where +> '216.230.158.50'::inet between start_block and end_block; +> QUERY PLAN +> ---------------------------------------------------------------------------- +> ------------------------------------------ +> Seq Scan on geoip_block (cost=0.00..78033.96 rows=230141 width=8) (actual +> time=12107.919..12610.199 rows=1 loops=1) +> Filter: (('216.230.158.50'::inet >= start_block) AND +> ('216.230.158.50'::inet <= end_block)) +> Total runtime: 12610.329 ms +> (3 rows) +> +> I guess the planner is doing a sequential scan in the table, why not use the +> compound index? Do you have any idea in how to speed up this query? + +Did you vacuum analyze the table after creating the index? + +Sean + + +From pgsql-performance-owner@postgresql.org Mon Sep 26 14:11:09 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 112B1D9762 + for ; + Mon, 26 Sep 2005 14:11:08 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 41466-07 + for ; + Mon, 26 Sep 2005 17:11:01 +0000 (GMT) +Received: from ecmailer.ecmarket.com (ecmailer.ecmarket.com [216.187.109.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 14F82D9760 + for ; + Mon, 26 Sep 2005 14:10:57 -0300 (ADT) +Received: from hummer.enterprise.ecmarket.com (hummer.enterprise.ecmarket.com + [10.0.7.2]) + by ecmailer.ecmarket.com (Postfix) with ESMTP id 5DB08B81A9 + for ; + Mon, 26 Sep 2005 10:10:56 -0700 (PDT) +Received: from gurpreet2 (gaulakh2.devel.ecmarket.com [10.0.5.33]) + by hummer.enterprise.ecmarket.com (Postfix) with SMTP id 2827924170 + for ; + Mon, 26 Sep 2005 10:10:52 -0700 (PDT) +From: "Gurpreet Aulakh" +To: +Subject: Re: Query slower on 8.0.3 (Windows) vs 7.3 (cygwin) +Date: Mon, 26 Sep 2005 10:10:56 -0700 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) +Importance: Normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506 +In-Reply-To: <6518.1127509969@sss.pgh.pa.us> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/352 +X-Sequence-Number: 14660 + +Thanks for your help Tom. + +While testing 8.1, I found that simple joins take longer in 8.1 than 8.0. +For example the sub query + +SELECT doc.doc_documentid FROM document AS doc LEFT JOIN folder_document ON +doc.doc_documentid = folder_document.doc_documentId LEFT JOIN document as +root ON doc.doc_internalRootXref = root.doc_documentId + +is actually slower on 8.1 than 8.0. + +However, the full query that I will be running is much faster. In my +evaluation I found the same pattern. That simple joins were slower but +complex joins were faster. + +Overall though, 8.1 is faster and we will probably be moving to it when it's +officially released. + +-----Original Message----- +From: Tom Lane [mailto:tgl@sss.pgh.pa.us] +Sent: September 23, 2005 2:13 PM +To: Gurpreet Aulakh +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Query slower on 8.0.3 (Windows) vs 7.3 (cygwin) + + +"Gurpreet Aulakh" writes: +> After further investigation I have found that the reason why the query is +> slower on 8.0.3 is that the hash and hash joins are slower on the 8.0.3. +> So the question comes down to : Why are hash and hash joins slower? + +I looked into this a bit and determined that the problem seems to have +been introduced here: + +2002-12-30 10:21 tgl + + * src/: backend/executor/nodeHash.c, + backend/executor/nodeHashjoin.c, backend/optimizer/path/costsize.c, + include/executor/nodeHash.h: Better solution to integer overflow + problem in hash batch-number computation: reduce the bucket number + mod nbatch. This changes the association between original bucket + numbers and batches, but that doesn't matter. Minor other cleanups + in hashjoin code to help centralize decisions. + +(which means it's present in 7.4 as well as 8.0). The code now +groups tuples into hash batches according to + (hashvalue % totalbuckets) % nbatch +When a tuple that is not in the first batch is reloaded, it is placed +into a bucket according to + (hashvalue % nbuckets) +This means that if totalbuckets, nbatch, and nbuckets have a common +factor F, the buckets won't be evenly used; in fact, only one in every F +buckets will be used at all, the rest remaining empty. The ones that +are used accordingly will contain about F times more tuples than +intended. The slowdown comes from having to compare these extra tuples +against the outer-relation tuples. + +7.3 uses a different algorithm for grouping tuples that avoids this +problem, but it has performance issues of its own (in particular, to +avoid integer overflow we have to limit the number of batches we can +have). So just reverting this patch doesn't seem very attractive. + +The problem no longer exists in 8.1 because of rewrites undertaken for +another purpose, so I'm sort of tempted to do nothing. To fix this in +the back branches we'd have to develop new code that won't ever go into +CVS tip and thus will never get beta-tested. The risk of breaking +things seems higher than I'd like. + +If we did want to fix it, my first idea is to increment nbatch looking +for a value that has no common factor with nbuckets. + + regards, tom lane + + + + +From pgsql-performance-owner@postgresql.org Mon Sep 26 16:19:28 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B44A9D975A + for ; + Mon, 26 Sep 2005 14:41:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 50718-06 + for ; + Mon, 26 Sep 2005 17:41:27 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id B38AFD9716 + for ; + Mon, 26 Sep 2005 14:41:26 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j8QHfCp8000644; + Mon, 26 Sep 2005 13:41:12 -0400 (EDT) +To: "Gurpreet Aulakh" +Cc: pgsql-performance@postgresql.org +Subject: Re: Query slower on 8.0.3 (Windows) vs 7.3 (cygwin) +In-reply-to: +References: +Comments: In-reply-to "Gurpreet Aulakh" + message dated "Mon, 26 Sep 2005 10:10:56 -0700" +Date: Mon, 26 Sep 2005 13:41:12 -0400 +Message-ID: <643.1127756472@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/356 +X-Sequence-Number: 14664 + +"Gurpreet Aulakh" writes: +> While testing 8.1, I found that simple joins take longer in 8.1 than 8.0. +> For example the sub query +> SELECT doc.doc_documentid FROM document AS doc LEFT JOIN folder_document ON +> doc.doc_documentid = folder_document.doc_documentId LEFT JOIN document as +> root ON doc.doc_internalRootXref = root.doc_documentId +> is actually slower on 8.1 than 8.0. + +With no more detail than that, this report is utterly unhelpful. Let's +see the table schemas and the EXPLAIN ANALYZE results in both cases. + + regards, tom lane + +From pgsql-hackers-owner@postgresql.org Mon Sep 26 17:46:56 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 16D99D9786; + Mon, 26 Sep 2005 14:47:33 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 53875-07; Mon, 26 Sep 2005 17:47:25 +0000 (GMT) +Received: from pop-siberian.atl.sa.earthlink.net + (pop-siberian.atl.sa.earthlink.net [207.69.195.71]) + by svr1.postgresql.org (Postfix) with ESMTP id 50E30D9781; + Mon, 26 Sep 2005 14:47:24 -0300 (ADT) +Received: from elwamui-polski.atl.sa.earthlink.net ([209.86.224.45]) + by pop-siberian.atl.sa.earthlink.net with esmtp (Exim 3.36 #10) + id 1EJx4W-0007Es-00; Mon, 26 Sep 2005 13:47:24 -0400 +Message-ID: + <21606161.1127756844886.JavaMail.root@elwamui-polski.atl.sa.earthlink.net> +Date: Mon, 26 Sep 2005 13:47:24 -0400 (EDT) +From: Ron Peacetree +Reply-To: Ron Peacetree +To: pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org +Subject: [PERFORM] A Better External Sort? +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Mailer: Earthlink Zoo Mail 1.0 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.266 required=5 tests=[AWL=-0.108, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200509/1165 +X-Sequence-Number: 73562 + +>From: Ron Peacetree +>Sent: Sep 24, 2005 6:30 AM +>Subject: Re: [HACKERS] [PERFORM] Releasing memory during External sorting? +> +>... the amount of IO done is the most +>important of the things that you should be optimizing for in +>choosing an external sorting algorithm. +> +> +> +>Since sorting is a fundamental operation in many parts of a DBMS, +>this is a Big Deal. +> +>This discussion has gotten my creative juices flowing. I'll post +>some Straw Man algorithm sketches after I've done some more +>thought. +> +As a thought exeriment, I've been considering the best way to sort 1TB +(2^40B) of 2-4KB (2^11-2^12B) records. That's 2^28-2^29 records. + +Part I: A Model of the System +The performance of such external sorts is limited by HD IO, then +memory IO, and finally CPU throughput. + +On commodity HW, single HD IO is ~1/2048 (single HD realistic worst +case) to ~1/128 (single HD best case. No more than one seek every +~14.7ms for a ~50MB/s 7200rpm SATA II HD) the throughtput of RAM. + +RAID HD IO will be in the range from as low as a single HD (RAID 1) to +~1/8 (a RAID system saturating the external IO bus) the throughput of +RAM. + +RAM is ~1/8-1/16 the throughput and ~128x the latency of the data +pathways internal to the CPU. + +This model suggests that HD IO will greatly dominate every other +factor, particuarly if we are talking about a single HD rather than a +peripheral bus saturating RAID subsystem. If at all possible, we want +to access the HD subsystem only once for each data item, and we want +to avoid seeking more than the critical number of seeks implied above +when doing it. It also suggests that at a minimum, it's worth it to +spend ~8 memory operations or ~64 CPU operations to avoid a HD access. +Far more than that if we are talking about a single random access. + +It's worth spending ~128 CPU operations to avoid a single random RAM +access, and literally 10's or even 100's of thousands of CPU operations to +avoid a random HD access. In addition, there are many indications in +current ECE and IT literature that the performance gaps between these +pieces of computer systems are increasing and expected to continue to do +so for the forseeable future. In short, _internal_ sorts have some, and are +going to increasingly have more, of the same IO problems usually +associated with external sorts. + + +Part II: a Suggested Algorithm +The simplest case is one where we have to order the data using a key that +only has two values. + +Given 2^40B of data using 2KB or 4KB per record, the most compact +representation we can make of such a data set is to assign a 32b= 4B RID +or Rptr for location + a 1b key for each record. Just the RID's would take up +1.25GB (250M records) or 2.5GB (500M records). Enough space that even +an implied ordering of records may not fit into RAM. + +Still, sorting 1.25GB or 2.5GB of RIDs is considerably less expensive in terms +of IO operations than sorting the actual 1TB of data. + +That IO cost can be lowered even further if instead of actually physically +sorting the RIDs, we assign a RID to the appropriate catagory inside the CPU +as we scan the data set and append the entries in a catagory from CPU cache +to a RAM file in one IO burst whenever said catagory gets full inside the CPU. +We can do the same with either RAM file to HD whenever they get full. The +sorted order of the data is found by concatenating the appropriate files at the +end of the process. + +As simple as this example is, it has many of the characteristics we are looking for: +A= We access each piece of data once on HD and in RAM. +B= We do the minimum amount of RAM and HD IO, and almost no random IO in +either case. +C= We do as much work as possible within the CPU. +D= This process is stable. Equal keys stay in the original order they are encountered. + +To generalize this method, we first need our 1b Key to become a sufficiently large +enough Key or KeyPrefix to be useful, yet not so big as to be CPU cache unfriendly. + +Cache lines (also sometimes called "blocks") are usually 64B= 512b in size. +Therefore our RID+Key or KeyPrefix should never be larger than this. For a 2^40B +data set, a 5B RID leaves us with potentially as much as 59B of Key or KeyPrefix. +Since the data can't take on more than 40b worth different values (actually 500M= 29b +for our example), we have more than adequate space for Key or KeyPrefix. We just +have to figure out how to use it effectively. +A typical CPU L2 cache can hold 10's or 100's of thousands of such cache lines. +That's enough that we should be able to do a significant amount of useful work within +the CPU w/o having to go off-die. + +The data structure we are using to represent the sorted data also needs to be +generalized. We want a space efficient DS that allows us to find any given element in +as few accesses as possible and that allows us to insert new elements or reorganize +the DS as efficiently as possible. This being a DB discussion list, a B+ tree seems like +a fairly obvious suggestion ;-) + +A B+ tree where each element is no larger than a cache line and no node is larger than +what fits into L2 cache can be created dynamically as we scan the data set via any of +the fast, low IO methods well known for doing so. Since the L2 cache can hold 10's of +thousands of cache lines, it should be easy to make sure that the B+ tree has something +like 1000 elements per node (making the base of the logarithm for access being at least +1000). The log base 1000 of 500M is ~2.9, so that means that even in the absolute +worst case where every one of the 500M records is unique we can find any given +element in less than 3 accesses of the B+ tree. Increasing the order of the B+ tree is +an option to reduce average accesses even further. + +Since the DS representing the sorted order of the data is a B+ tree, it's very "IO friendly" +if we need to store part or all of it on HD. + +In an multiprocessor environment, we can assign chunks of the data set to different +CPUs, let them build their independant B+ trees to represent the data in sorted order from +their POV, and then merge the B+ trees very efficiently into one overall DS to represent +the sorted order of the entire data set. + +Finally, since these are B+ trees, we can keep them around and easily update them at will +for frequent used sorting conditions. + +What do people think? + +Ron + +From pgsql-general-owner@postgresql.org Mon Sep 26 15:45:23 2005 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 519EFD9776; + Mon, 26 Sep 2005 14:52:50 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 54414-07; Mon, 26 Sep 2005 17:52:44 +0000 (GMT) +Received: from mail.clickdiario.com (mail.clickdiario.com [70.85.167.114]) + by svr1.postgresql.org (Postfix) with ESMTP id DAE67D9604; + Mon, 26 Sep 2005 14:52:44 -0300 (ADT) +Received: from localhost (localhost [127.0.0.1]) + by mail.clickdiario.com (Postfix) with ESMTP id A8CED10154; + Mon, 26 Sep 2005 12:56:17 -0500 (CDT) +Received: from mail.clickdiario.com ([127.0.0.1]) + by localhost (mail.clickdiario.com [127.0.0.1]) (amavisd-new, + port 10024) + with ESMTP id 00327-04; Mon, 26 Sep 2005 12:56:17 -0500 (CDT) +Received: from cristian1 (unknown [216.230.158.50]) + by mail.clickdiario.com (Postfix) with ESMTP id BA5C21015A; + Mon, 26 Sep 2005 12:56:15 -0500 (CDT) +From: "Cristian Prieto" +To: "'Sean Davis'" , + , +Subject: Re: Index use in BETWEEN statement... +Date: Mon, 26 Sep 2005 11:49:59 -0600 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Mailer: Microsoft Office Outlook, Build 11.0.5510 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +In-Reply-To: +Thread-Index: AcXCuMx2dqpjkzX3R1aD0UXOnoXs9wACX5SA +Message-Id: <20050926175615.BA5C21015A@mail.clickdiario.com> +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at example.com +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.015 required=5 tests=[AWL=0.015] +X-Spam-Level: +X-Archive-Number: 200509/1029 +X-Sequence-Number: 84044 + + +mydb=# explain analyze select locid from geoip_block where +'216.230.158.50'::inet between start_block and end_block; + QUERY PLAN +---------------------------------------------------------------------------- +------------------------------------------ + Seq Scan on geoip_block (cost=0.00..78033.96 rows=230141 width=8) (actual +time=13015.538..13508.708 rows=1 loops=1) + Filter: (('216.230.158.50'::inet >= start_block) AND +('216.230.158.50'::inet <= end_block)) + Total runtime: 13508.905 ms +(3 rows) + +mydb=# alter table geoip_block add constraint pkey_geoip_block primary key +(start_block, end_block); +NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index +"pkey_geoip_block" for table "geoip_block" +ALTER TABLE + +mydb=# vacuum analyze geoip_block; + +mydb=# explain analyze select locid from geoip_block where +'216.230.158.50'::inet between start_block and end_block; + QUERY PLAN +---------------------------------------------------------------------------- +------------------------------------------- + Seq Scan on geoip_block (cost=0.00..101121.01 rows=308324 width=8) (actual +time=12128.190..12631.550 rows=1 loops=1) + Filter: (('216.230.158.50'::inet >= start_block) AND +('216.230.158.50'::inet <= end_block)) + Total runtime: 12631.679 ms +(3 rows) + +mydb=# + + +As you see it still using a sequential scan in the table and ignores the +index, any other suggestion? + +-----Original Message----- +From: pgsql-general-owner@postgresql.org +[mailto:pgsql-general-owner@postgresql.org] On Behalf Of Sean Davis +Sent: Lunes, 26 de Septiembre de 2005 10:24 a.m. +To: Cristian Prieto; pgsql-general@postgresql.org +Subject: Re: [GENERAL] Index use in BETWEEN statement... + +On 9/26/05 11:26 AM, "Cristian Prieto" wrote: + +> +> Hello pals, I have the following table in Postgresql 8.0.1 +> +> Mydb# \d geoip_block +> Table "public.geoip_block" +> Column | Type | Modifiers +> -------------+--------+----------- +> locid | bigint | +> start_block | inet | +> end_block | inet | +> +> mydb# explain analyze select locid from geoip_block where +> '216.230.158.50'::inet between start_block and end_block; +> QUERY PLAN +> +---------------------------------------------------------------------------- +> ------------------------------------------- +> Seq Scan on geoip_block (cost=0.00..142772.86 rows=709688 width=8) +(actual +> time=14045.384..14706.927 rows=1 loops=1) +> Filter: (('216.230.158.50'::inet >= start_block) AND +> ('216.230.158.50'::inet <= end_block)) +> Total runtime: 14707.038 ms +> +> Ok, now I decided to create a index to "speed" a little the query +> +> Mydb# create index idx_ipblocks on geoip_block(start_block, end_block); +> CREATE INDEX +> +> clickad=# explain analyze select locid from geoip_block where +> '216.230.158.50'::inet between start_block and end_block; +> QUERY PLAN +> +---------------------------------------------------------------------------- +> ------------------------------------------ +> Seq Scan on geoip_block (cost=0.00..78033.96 rows=230141 width=8) (actual +> time=12107.919..12610.199 rows=1 loops=1) +> Filter: (('216.230.158.50'::inet >= start_block) AND +> ('216.230.158.50'::inet <= end_block)) +> Total runtime: 12610.329 ms +> (3 rows) +> +> I guess the planner is doing a sequential scan in the table, why not use +the +> compound index? Do you have any idea in how to speed up this query? + +Did you vacuum analyze the table after creating the index? + +Sean + + +---------------------------(end of broadcast)--------------------------- +TIP 3: Have you checked our extensive FAQ? + + http://www.postgresql.org/docs/faq + + +From pgsql-performance-owner@postgresql.org Mon Sep 26 15:13:57 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1A03DD9604 + for ; + Mon, 26 Sep 2005 14:53:14 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 55554-01 + for ; + Mon, 26 Sep 2005 17:53:10 +0000 (GMT) +Received: from sccimhc91.asp.att.net (sccimhc91.asp.att.net [63.240.76.165]) + by svr1.postgresql.org (Postfix) with ESMTP id 03F24D9581 + for ; + Mon, 26 Sep 2005 14:53:09 -0300 (ADT) +Received: from krunk (12-202-107-96.client.insightbb.com[12.202.107.96]) + by sccimhc91.asp.att.net (sccimhc91) with SMTP + id <20050926175309i9100aaekge>; Mon, 26 Sep 2005 17:53:09 +0000 +From: "Announce" +To: +Subject: int2 vs int4 in Postgres +Date: Mon, 26 Sep 2005 12:54:05 -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) +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +Importance: Normal +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/353 +X-Sequence-Number: 14661 + +Is there an performance benefit to using int2 (instead of int4) in cases +where i know i will be well within its numeric range? I want to conserve +storage space and gain speed anywhere i can, but i know some apps simply end +up casting 2byte data to 4byte (like Java int/short). + +These int2 values will be used in primary and foreign key fields and I know +that i must explicitly use tick marks (ex: where int2_column = '12') in +order to make use of indexes, but my question is IS IT WORTH IT? IS THERE +ANY REAL GAIN FOR DOING THIS? + +An simple scenario would be: + +Songs +------- +song_id serial pkey +genre int2 fkey +title varchar +... + + +Genres +------- +genreid int2 pkey +name varchar +description varchar + + + +I KNOW that I am not going to have anywhere near 32,000+ different genres in +my genre table so why use int4? Would that squeeze a few more milliseconds +of performance out of a LARGE song table query with a genre lookup? + + +Thanks, + +-Aaron + + +From pgsql-performance-owner@postgresql.org Mon Sep 26 16:51:39 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 989EBD970B + for ; + Mon, 26 Sep 2005 15:43:03 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 66270-05 + for ; + Mon, 26 Sep 2005 18:42:53 +0000 (GMT) +Received: from mx1.surnet.cl (mx2.surnet.cl [216.155.73.181]) + by svr1.postgresql.org (Postfix) with ESMTP id 38D01D976D + for ; + Mon, 26 Sep 2005 15:42:52 -0300 (ADT) +Received: from unknown (HELO cluster.surnet.cl) ([216.155.73.165]) + by mx1.surnet.cl with ESMTP; 26 Sep 2005 14:42:30 -0400 +X-IronPort-AV: i="3.97,114,1125892800"; + d="scan'208"; a="12207882:sNHT35230056" +Received: from alvh.no-ip.org (216.155.71.178) by cluster.surnet.cl (7.0.043) + (authenticated as alvherre@surnet.cl) + id 4327E85F0015B0E9; Mon, 26 Sep 2005 14:42:52 -0400 +Received: by alvh.no-ip.org (Postfix, from userid 1000) + id 46597C3A034; Mon, 26 Sep 2005 14:42:53 -0400 (CLT) +Date: Mon, 26 Sep 2005 14:42:53 -0400 +From: Alvaro Herrera +To: Announce +Cc: pgsql-performance@postgresql.org +Subject: Re: int2 vs int4 in Postgres +Message-ID: <20050926184253.GA8295@surnet.cl> +Mail-Followup-To: Announce , + pgsql-performance@postgresql.org +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Disposition: inline +Content-Transfer-Encoding: 8bit +In-Reply-To: +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.877 required=5 tests=[AWL=0.077, + DNS_FROM_RFC_ABUSE=0.374, DNS_FROM_RFC_POST=1.376, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: * +X-Archive-Number: 200509/358 +X-Sequence-Number: 14666 + +On Mon, Sep 26, 2005 at 12:54:05PM -0500, Announce wrote: +> Is there an performance benefit to using int2 (instead of int4) in cases +> where i know i will be well within its numeric range? I want to conserve +> storage space and gain speed anywhere i can, but i know some apps simply end +> up casting 2byte data to 4byte (like Java int/short). +> +> These int2 values will be used in primary and foreign key fields and I know +> that i must explicitly use tick marks (ex: where int2_column = '12') in +> order to make use of indexes, but my question is IS IT WORTH IT? IS THERE +> ANY REAL GAIN FOR DOING THIS? + +> An simple scenario would be: +> +> Songs +> ------- +> song_id serial pkey +> genre int2 fkey +> title varchar + +Not in this case, because the varchar column that follows the int2 +column needs 4-byte alignment, so after the int2 column there must be 2 +bytes of padding. + +If you had two consecutive int2 fields you would save some the space. +Or int2/bool/bool (bool has 1-byte alignment), etc. + +This assumes you are in a tipical x86 environment ... in other +environments the situation may be different. + +-- +Alvaro Herrera Valdivia, Chile ICBM: S 39� 49' 17.7", W 73� 14' 26.8" +Voy a acabar con todos los humanos / con los humanos yo acabar� +voy a acabar con todos / con todos los humanos acabar� (Bender) + +From pgsql-general-owner@postgresql.org Mon Sep 26 16:41:39 2005 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 88D2BD97C8; + Mon, 26 Sep 2005 16:17:30 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 70433-09; Mon, 26 Sep 2005 19:17:23 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 17454D976D; + Mon, 26 Sep 2005 16:17:23 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j8QJHN5b001897; + Mon, 26 Sep 2005 15:17:23 -0400 (EDT) +To: "Cristian Prieto" +Cc: "'Sean Davis'" , + pgsql-general@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: Index use in BETWEEN statement... +In-reply-to: <20050926175615.BA5C21015A@mail.clickdiario.com> +References: <20050926175615.BA5C21015A@mail.clickdiario.com> +Comments: In-reply-to "Cristian Prieto" + message dated "Mon, 26 Sep 2005 11:49:59 -0600" +Date: Mon, 26 Sep 2005 15:17:23 -0400 +Message-ID: <1896.1127762243@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/1036 +X-Sequence-Number: 84051 + +"Cristian Prieto" writes: +> mydb=# explain analyze select locid from geoip_block where +> '216.230.158.50'::inet between start_block and end_block; + +> As you see it still using a sequential scan in the table and ignores the +> index, any other suggestion? + +That two-column index is entirely useless for this query; in fact btree +indexes of any sort are pretty useless. You really need some sort of +multidimensional index type like rtree or gist. There was discussion +just a week or three ago of how to optimize searches for intervals +overlapping a specified point, which is identical to your problem. +Can't remember if the question was about timestamp intervals or plain +intervals, but try checking the list archives. + + regards, tom lane + +From pgsql-general-owner@postgresql.org Mon Sep 26 18:07:42 2005 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6A343D97B3; + Mon, 26 Sep 2005 16:48:12 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81240-04; Mon, 26 Sep 2005 19:48:09 +0000 (GMT) +Received: from mx.cbeyond.com (mx.cbeyond.net [66.180.96.58]) + by svr1.postgresql.org (Postfix) with ESMTP id 0B5C1D976D; + Mon, 26 Sep 2005 16:48:08 -0300 (ADT) +Received: from [66.180.98.234] (port=37771 helo=[10.0.1.11]) + by mx.cbeyond.com with esmtp (Exim 4.34) + id 1EJyxN-00033I-VI; Mon, 26 Sep 2005 15:48:10 -0400 +Message-ID: <43384FAA.9030404@soundenergy.com> +Date: Mon, 26 Sep 2005 14:44:42 -0500 +From: Don Isgitt +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20041217 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Cristian Prieto +Cc: 'Sean Davis' , + pgsql-general@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: Index use in BETWEEN statement... +References: <20050926175615.BA5C21015A@mail.clickdiario.com> +In-Reply-To: <20050926175615.BA5C21015A@mail.clickdiario.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 required=5 tests=[AWL=-0.000, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/1041 +X-Sequence-Number: 84056 + + + +Cristian Prieto wrote: + +>mydb=# explain analyze select locid from geoip_block where +>'216.230.158.50'::inet between start_block and end_block; +> QUERY PLAN +>---------------------------------------------------------------------------- +>------------------------------------------ +> Seq Scan on geoip_block (cost=0.00..78033.96 rows=230141 width=8) (actual +>time=13015.538..13508.708 rows=1 loops=1) +> Filter: (('216.230.158.50'::inet >= start_block) AND +>('216.230.158.50'::inet <= end_block)) +> Total runtime: 13508.905 ms +>(3 rows) +> +>mydb=# alter table geoip_block add constraint pkey_geoip_block primary key +>(start_block, end_block); +>NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index +>"pkey_geoip_block" for table "geoip_block" +>ALTER TABLE +> +>mydb=# vacuum analyze geoip_block; +> +>mydb=# explain analyze select locid from geoip_block where +>'216.230.158.50'::inet between start_block and end_block; +> QUERY PLAN +>---------------------------------------------------------------------------- +>------------------------------------------- +> Seq Scan on geoip_block (cost=0.00..101121.01 rows=308324 width=8) (actual +>time=12128.190..12631.550 rows=1 loops=1) +> Filter: (('216.230.158.50'::inet >= start_block) AND +>('216.230.158.50'::inet <= end_block)) +> Total runtime: 12631.679 ms +>(3 rows) +> +>mydb=# +> +> +>As you see it still using a sequential scan in the table and ignores the +>index, any other suggestion? +> +>Cristian, +> +> +Please note that the planner thinks 308324 rows are being returned, +while there is actually only 1 (one!). You might try altering statistics +for the relevant column(s), analyzing the table, and then try again. If +that doesn't give you a more accurate row estimate, though, it won't help. + +Don + + +From pgsql-performance-owner@postgresql.org Mon Sep 26 18:08:55 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1E23DD97C4 + for ; + Mon, 26 Sep 2005 16:40:29 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 76253-09 + for ; + Mon, 26 Sep 2005 19:40:22 +0000 (GMT) +Received: from mailbox.samurai.com (mailbox.samurai.com [205.207.28.82]) + by svr1.postgresql.org (Postfix) with ESMTP id 27DD6D9778 + for ; + Mon, 26 Sep 2005 16:40:19 -0300 (ADT) +Received: from localhost (mailbox.samurai.com [205.207.28.82]) + by mailbox.samurai.com (Postfix) with ESMTP id 374F623948B; + Mon, 26 Sep 2005 15:40:21 -0400 (EDT) +Received: from mailbox.samurai.com ([205.207.28.82]) + by localhost (mailbox.samurai.com [205.207.28.82]) (amavisd-new, + port 10024) + with LMTP id 34380-01-7; Mon, 26 Sep 2005 15:40:16 -0400 (EDT) +Received: from [192.168.1.104] (d226-86-55.home.cgocable.net [24.226.86.55]) + by mailbox.samurai.com (Postfix) with ESMTP id 800BD239473; + Mon, 26 Sep 2005 15:40:15 -0400 (EDT) +Subject: Re: int2 vs int4 in Postgres +From: Neil Conway +To: Announce +Cc: pgsql-performance@postgresql.org +In-Reply-To: +References: +Content-Type: text/plain +Date: Mon, 26 Sep 2005 15:48:30 -0400 +Message-Id: <1127764110.27799.2.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.4.0 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at mailbox.samurai.com +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/359 +X-Sequence-Number: 14667 + +On Mon, 2005-26-09 at 12:54 -0500, Announce wrote: +> Is there an performance benefit to using int2 (instead of int4) in cases +> where i know i will be well within its numeric range? + +int2 uses slightly less storage space (2 bytes rather than 4). Depending +on alignment and padding requirements, as well as the other columns in +the table, that may translate into requiring fewer disk pages and +therefore slightly better performance and lower storage requirements. + +-Neil + + + +From pgsql-performance-owner@postgresql.org Mon Sep 26 19:04:13 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3BF2DD9773 + for ; + Mon, 26 Sep 2005 19:04:09 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 15609-01 + for ; + Mon, 26 Sep 2005 22:04:02 +0000 (GMT) +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0D818D97DF + for ; + Mon, 26 Sep 2005 19:04:03 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id B577331F51; Tue, 27 Sep 2005 00:04:05 +0200 (MET DST) +From: Chris Browne +X-Newsgroups: pgsql.performance +Subject: Re: int2 vs int4 in Postgres +Date: Mon, 26 Sep 2005 17:45:56 -0400 +Organization: cbbrowne Computing Inc +Lines: 22 +Message-ID: <60br2flcyz.fsf@dba2.int.libertyrms.com> +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +X-Complaints-To: usenet@news.hub.org +User-Agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4.17 (Jumbo Shrimp, linux) +Cancel-Lock: sha1:oTNygnAO+1MasDTtlfiXyV5XOew= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.094 required=5 tests=[AWL=0.094] +X-Spam-Level: +X-Archive-Number: 200509/361 +X-Sequence-Number: 14669 + +truthhurts@insightbb.com ("Announce") writes: +> I KNOW that I am not going to have anywhere near 32,000+ different +> genres in my genre table so why use int4? Would that squeeze a few +> more milliseconds of performance out of a LARGE song table query +> with a genre lookup? + +If the field is immaterial in terms of the size of the table, then it +won't help materially. + +If you were going to index on it, however, THAT would make it +significant for indices involving the "genre" column. Fitting more +tuples into each page is a big help, and this would help. + +I doubt it'll be material, but I'd think it a good thing to apply what +restrictions to your data types that you can, a priori, so I'd be +inclined to use "int2" for this... +-- +let name="cbbrowne" and tld="cbbrowne.com" in String.concat "@" [name;tld];; +http://cbbrowne.com/info/nonrdbms.html +Rules of the Evil Overlord #136. "If I build a bomb, I will simply +remember which wire to cut if it has to be deactivated and make every +wire red." + +From pgsql-performance-owner@postgresql.org Mon Sep 26 19:04:09 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BB09DD975A + for ; + Mon, 26 Sep 2005 19:04:06 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 09922-09 + for ; + Mon, 26 Sep 2005 22:04:03 +0000 (GMT) +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 983B6D96CC + for ; + Mon, 26 Sep 2005 19:04:04 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id B7AE431F52; Tue, 27 Sep 2005 00:04:06 +0200 (MET DST) +From: Chris Browne +X-Newsgroups: pgsql.performance +Subject: Re: int2 vs int4 in Postgres +Date: Mon, 26 Sep 2005 17:47:19 -0400 +Organization: cbbrowne Computing Inc +Lines: 14 +Message-ID: <607jd3lcwo.fsf@dba2.int.libertyrms.com> +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +X-Complaints-To: usenet@news.hub.org +User-Agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4.17 (Jumbo Shrimp, linux) +Cancel-Lock: sha1:M5rnQ4Tr4guQbaG0kHtHsscQ2aY= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.094 required=5 tests=[AWL=0.094] +X-Spam-Level: +X-Archive-Number: 200509/360 +X-Sequence-Number: 14668 + +truthhurts@insightbb.com ("Announce") writes: +> I KNOW that I am not going to have anywhere near 32,000+ different +> genres in my genre table so why use int4? Would that squeeze a few +> more milliseconds of performance out of a LARGE song table query +> with a genre lookup? + +By the way, I see a lot of queries on tables NOT optimized in this +fashion that run in less than a millisecond, so it would seem +remarkable to me if there were milliseconds to be squeezed out in the +first place... +-- +output = reverse("moc.enworbbc" "@" "enworbbc") +http://www.ntlug.org/~cbbrowne/sap.html +Why do we drive on parkways and park on driveways? + +From pgsql-performance-owner@postgresql.org Mon Sep 26 20:00:35 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CEC8AD97C4 + for ; + Mon, 26 Sep 2005 20:00:33 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25593-08 + for ; + Mon, 26 Sep 2005 23:00:29 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 79003D97BB + for ; + Mon, 26 Sep 2005 20:00:30 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j8QN0VOH005080; + Mon, 26 Sep 2005 19:00:31 -0400 (EDT) +To: Chris Browne +Cc: pgsql-performance@postgresql.org +Subject: Re: int2 vs int4 in Postgres +In-reply-to: <60br2flcyz.fsf@dba2.int.libertyrms.com> +References: + <60br2flcyz.fsf@dba2.int.libertyrms.com> +Comments: In-reply-to Chris Browne + message dated "Mon, 26 Sep 2005 17:45:56 -0400" +Date: Mon, 26 Sep 2005 19:00:31 -0400 +Message-ID: <5079.1127775631@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/363 +X-Sequence-Number: 14671 + +Chris Browne writes: +> If the field is immaterial in terms of the size of the table, then it +> won't help materially. +> If you were going to index on it, however, THAT would make it +> significant for indices involving the "genre" column. Fitting more +> tuples into each page is a big help, and this would help. + +For a multicolumn index it might help to replace int4 by int2. For a +single-column index, alignment constraints on the index entries will +prevent you from saving anything :-( + + regards, tom lane + +From pgsql-hackers-owner@postgresql.org Tue Sep 27 09:30:20 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D9FF7D8595; + Mon, 26 Sep 2005 22:10:50 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 52884-08; Tue, 27 Sep 2005 01:10:45 +0000 (GMT) +Received: from pop-siberian.atl.sa.earthlink.net + (pop-siberian.atl.sa.earthlink.net [207.69.195.71]) + by svr1.postgresql.org (Postfix) with ESMTP id 2DC86D76BA; + Mon, 26 Sep 2005 22:10:44 -0300 (ADT) +Received: from elwamui-polski.atl.sa.earthlink.net ([209.86.224.45]) + by pop-siberian.atl.sa.earthlink.net with esmtp (Exim 3.36 #10) + id 1EK3zb-0004u8-00; Mon, 26 Sep 2005 21:10:47 -0400 +Message-ID: + <19483839.1127783447942.JavaMail.root@elwamui-polski.atl.sa.earthlink.net> +Date: Mon, 26 Sep 2005 21:10:47 -0400 (EDT) +From: Ron Peacetree +Reply-To: Ron Peacetree +To: Dann Corbit , pgsql-hackers@postgresql.org, + pgsql-performance@postgresql.org +Subject: Re: [PERFORM] A Better External Sort? +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Mailer: Earthlink Zoo Mail 1.0 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.264 required=5 tests=[AWL=-0.111, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200509/1220 +X-Sequence-Number: 73617 + +>From: Dann Corbit +>Sent: Sep 26, 2005 5:13 PM +>To: Ron Peacetree , pgsql-hackers@postgresql.org, +> pgsql-performance@postgresql.org +>Subject: RE: [HACKERS] [PERFORM] A Better External Sort? +> +>I think that the btrees are going to be O(n*log(n)) in construction of +>the indexes in disk access unless you memory map them [which means you +>would need stupendous memory volume] and so I cannot say that I really +>understand your idea yet. +> +Traditional algorithms for the construction of Btree variants (B, B+, B*, ...) +don't require O(nlgn) HD accesses. These shouldn't either. + +Let's start by assuming that an element is <= in size to a cache line and a +node fits into L1 DCache. To make the discussion more concrete, I'll use a +64KB L1 cache + a 1MB L2 cache only as an example. + +Simplest case: the Key has few enough distinct values that all Keys or +KeyPrefixes fit into L1 DCache (for a 64KB cache with 64B lines, that's + <= 1000 different values. More if we can fit more than 1 element into +each cache line.). + +As we scan the data set coming in from HD, we compare the Key or KeyPrefix +to the sorted list of Key values in the node. This can be done in O(lgn) using +Binary Search or O(lglgn) using a variation of Interpolation Search. +If the Key value exists, we append this RID to the list of RIDs having the +same Key: + If the RAM buffer of this list of RIDs is full we append it and the current + RID to the HD list of these RIDs. +Else we insert this new key value into its proper place in the sorted list of Key +values in the node and start a new list for this value of RID. + +We allocate room for a CPU write buffer so we can schedule RAM writes to +the RAM lists of RIDs so as to minimize the randomness of them. + +When we are finished scanning the data set from HD, the sorted node with +RID lists for each Key value contains the sort order for the whole data set. + +Notice that almost all of the random data access is occuring within the CPU +rather than in RAM or HD, and that we are accessing RAM or HD only when +absolutely needed. + +Next simplest case: Multiple nodes, but they all fit in the CPU cache(s). +In the given example CPU, we will be able to fit at least 1000 elements per +node and 2^20/2^16= up to 16 such nodes in this CPU. We use a node's +worth of space as a RAM write buffer, so we end up with room for 15 such +nodes in this CPU. This is enough for a 2 level index to at least 15,000 +distinct Key value lists. + +All of the traditional tricks for splitting a Btree node and redistributing +elements within them during insertion or splitting for maximum node +utilization can be used here. + +The most general case: There are too many nodes to fit within the CPU +cache(s). The root node now points to a maximum of at least 1000 nodes +since each element in the root node points to another node. A full 2 level +index is now enough to point to at least 10^6 distinct Key value lists, and +3 levels will index more distinct Key values than is possible in our 1TB, +500M record example. + +We can use some sort of node use prediction algorithm like LFU to decide +which node should be moved out of CPU when we have to replace one of +the nodes in the CPU. The nodes in RAM or on HD can be arranged to +maximize streaming IO behavior and minimize random access IO +behavior. + +As you can see, both the RAM and HD IO are as minimized as possible, +and what such IO there is has been optimized for streaming behavior. + + +>Can you draw a picture of it for me? (I am dyslexic and understand things +>far better when I can visualize it). +> +Not much for pictures. Hopefully the explanation helps? + +Ron + +From pgsql-hackers-owner@postgresql.org Mon Sep 26 22:42:24 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E0D56D9836; + Mon, 26 Sep 2005 22:42:20 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 65163-02; Tue, 27 Sep 2005 01:42:15 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 4E380D9834; + Mon, 26 Sep 2005 22:42:16 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j8R1gItD006142; + Mon, 26 Sep 2005 21:42:18 -0400 (EDT) +To: Ron Peacetree +Cc: Dann Corbit , pgsql-hackers@postgresql.org, + pgsql-performance@postgresql.org +Subject: Re: [PERFORM] A Better External Sort? +In-reply-to: + <19483839.1127783447942.JavaMail.root@elwamui-polski.atl.sa.earthlink.net> +References: + <19483839.1127783447942.JavaMail.root@elwamui-polski.atl.sa.earthlink.net> +Comments: In-reply-to Ron Peacetree + message dated "Mon, 26 Sep 2005 21:10:47 -0400" +Date: Mon, 26 Sep 2005 21:42:18 -0400 +Message-ID: <6141.1127785338@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/1191 +X-Sequence-Number: 73588 + +Ron Peacetree writes: +> Let's start by assuming that an element is <= in size to a cache line and a +> node fits into L1 DCache. [ much else snipped ] + +So far, you've blithely assumed that you know the size of a cache line, +the sizes of L1 and L2 cache, and that you are working with sort keys +that you can efficiently pack into cache lines. And that you know the +relative access speeds of the caches and memory so that you can schedule +transfers, and that the hardware lets you get at that transfer timing. +And that the number of distinct key values isn't very large. + +I don't see much prospect that anything we can actually use in a +portable fashion is going to emerge from this line of thought. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Sep 26 19:43:25 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DFAB0D9761 + for ; + Mon, 26 Sep 2005 19:43:23 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 24523-03 + for ; + Mon, 26 Sep 2005 22:43:14 +0000 (GMT) +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D9C52D975A + for ; + Mon, 26 Sep 2005 19:43:15 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 683CF31F51; Tue, 27 Sep 2005 00:43:18 +0200 (MET DST) +From: "Qingqing Zhou" +X-Newsgroups: pgsql.performance +Subject: Re: Query seem to slow if table have more than 200 million rows +Date: Mon, 26 Sep 2005 18:43:14 -0700 +Organization: Hub.Org Networking Services +Lines: 30 +Message-ID: +References: +X-Complaints-To: usenet@news.hub.org +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +X-RFC2646: Format=Flowed; Original +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.195 required=5 tests=[AWL=0.010, + PRIORITY_NO_NAME=1.185] +X-Spam-Level: * +X-Archive-Number: 200509/362 +X-Sequence-Number: 14670 + + +""Ahmad Fajar"" wrote +> +> Select ids, keywords from dict where keywords='blabla' ('blabla' is a +> single +> word); +> +> The table have 200 million rows, I have index the keywords field. On the +> first time my query seem to slow to get the result, about 15-60 sec to get +> the result. But if I repeat the query I will get fast result. My question +> is +> why on the first time the query seem very slow. +> +> Table structure is quite simple: +> +> Ids bigint, keywords varchar(150), weight varchar(1), dpos int. +> + +The first slowness is obviously caused by disk IOs. The second time is +faster because all data pages it requires are already in buffer pool. 200 +million rows is not a problem for btree index, even if your client tool +appends some spaces to your keywords at your insertion time, the ideal btree +is 5 to 6 layers high at most. Can you show the iostats of index from your +statistics view? +http://www.postgresql.org/docs/8.0/static/monitoring-stats.html#MONITORING-STATS-VIEWS + +Regards, +Qingqing + + + +From pgsql-hackers-owner@postgresql.org Tue Sep 27 09:34:08 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C29C3D9880; + Tue, 27 Sep 2005 02:09:32 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 21147-08; Tue, 27 Sep 2005 05:09:25 +0000 (GMT) +Received: from pop-siberian.atl.sa.earthlink.net + (pop-siberian.atl.sa.earthlink.net [207.69.195.71]) + by svr1.postgresql.org (Postfix) with ESMTP id 16109D9874; + Tue, 27 Sep 2005 02:09:24 -0300 (ADT) +Received: from elwamui-polski.atl.sa.earthlink.net ([209.86.224.45]) + by pop-siberian.atl.sa.earthlink.net with esmtp (Exim 3.36 #10) + id 1EK7iR-0003wK-00; Tue, 27 Sep 2005 01:09:19 -0400 +Message-ID: + <10783357.1127797759038.JavaMail.root@elwamui-polski.atl.sa.earthlink.net> +Date: Tue, 27 Sep 2005 01:09:19 -0400 (EDT) +From: Ron Peacetree +Reply-To: Ron Peacetree +To: Tom Lane , pgsql-hackers@postgresql.org, + pgsql-performance@postgresql.org +Subject: Re: [PERFORM] A Better External Sort? +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Mailer: Earthlink Zoo Mail 1.0 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.265 required=5 tests=[AWL=-0.109, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200509/1223 +X-Sequence-Number: 73620 + +SECOND ATTEMPT AT POST. Web mailer appears to have +eaten first one. I apologize in advance if anyone gets two +versions of this post. +=r + +>From: Tom Lane +>Sent: Sep 26, 2005 9:42 PM +>Subject: Re: [HACKERS] [PERFORM] A Better External Sort? +> +>So far, you've blithely assumed that you know the size of a cache line, +>the sizes of L1 and L2 cache, +> +NO. I used exact values only as examples. Realistic examples drawn +from an extensive survey of past, present, and what I could find out +about future systems; but only examples nonetheless. For instance, +Hennessy and Patterson 3ed points out that 64B cache lines are +optimally performing for caches between 16KB and 256KB. The same +source as well as sources specifically on CPU memory hierarchy +design points out that we are not likely to see L1 caches larger than +256KB in the forseeable future. + +The important point was the idea of an efficient Key, rather than +Record, sort using a CPU cache friendly data structure with provably +good space and IO characteristics based on a reasonable model of +current and likely future single box computer architecture (although +it would be fairly easy to extend it to include the effects of +networking.) + +No apriori exact or known values are required for the method to work. + + +>and that you are working with sort keys that you can efficiently pack +>into cache lines. +> +Not "pack". "map". n items can not take on more than n values. n +values can be represented in lgn bits. Less efficient mappings can +also work. Either way I demonstrated that we have plenty of space in +a likely and common cache line size. Creating a mapping function +to represent m values in lgm bits is a well known hack, and if we keep +track of minimum and maximum values for fields during insert and +delete operations, we can even create mapping functions fairly easily. +(IIRC, Oracle does keep track of minimum and maximum field +values.) + + +>And that you know the relative access speeds of the caches and +>memory so that you can schedule transfers, +> +Again, no. I created a reasonable model of a computer system that +holds remarkably well over a _very_ wide range of examples. I +don't need the numbers to be exactly right to justify my approach +to this problem or understand why other approaches may have +downsides. I just have to get the relative performance of the +system components and the relative performance gap between them +reasonably correct. The stated model does that very well. + +Please don't take my word for it. Go grab some random box: +laptop, desktop, unix server, etc and try it for yourself. Part of the +reason I published the model was so that others could examine it. + + +>and that the hardware lets you get at that transfer timing. +> +Never said anything about this, and in fact I do not need any such. + + +>And that the number of distinct key values isn't very large. +> +Quite the opposite in fact. I went out of my way to show that the +method still works well even if every Key is distinct. It is _more +efficient_ when the number of distinct keys is small compared to +the number of data items, but it works as well as any other Btree +would when all n of the Keys are distinct. This is just a CPU cache +and more IO friendly Btree, not some magical and unheard of +technique. It's just as general purpose as Btrees usually are. + +I'm simply looking at the current and likely future state of computer +systems architecture and coming up with a slight twist on how to use +already well known and characterized techniques. not trying to start +a revolution. + + +I'm trying very hard NOT to waste anyone's time around here. +Including my own +Ron + +From pgsql-performance-owner@postgresql.org Tue Sep 27 06:15:14 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2E8E1D98CA + for ; + Tue, 27 Sep 2005 06:15:14 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81076-02 + for ; + Tue, 27 Sep 2005 09:15:05 +0000 (GMT) +Received: from sart.must-ipra.com (unknown [80.91.172.78]) + by svr1.postgresql.org (Postfix) with ESMTP id 83371D98C1 + for ; + Tue, 27 Sep 2005 06:15:06 -0300 (ADT) +Received: from localhost (localhost [127.0.0.1]) + by sart.must-ipra.com (Postfix) with ESMTP id 37F8A3C162 + for ; + Tue, 27 Sep 2005 12:12:27 +0300 (EEST) +Received: from sart.must-ipra.com ([127.0.0.1]) + by localhost (sart.must-ipra.com [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 23397-05 for ; + Tue, 27 Sep 2005 12:12:23 +0300 (EEST) +Received: from PRG-45 (unknown [10.0.0.45]) + by sart.must-ipra.com (Postfix) with ESMTP id D5E963C15F + for ; + Tue, 27 Sep 2005 12:12:23 +0300 (EEST) +Date: Tue, 27 Sep 2005 12:14:31 +0300 +From: Andrey Repko +X-Mailer: The Bat! (v3.5.25) Professional +Reply-To: =?Windows-1251?Q?=C0=ED=E4=F0=E5=E9_=D0=E5=EF=EA=EE?= + +Organization: =?Windows-1251?Q?=CE=CE=CE_=22=D1=C0=D0=D2=22?= +X-Priority: 3 (Normal) +Message-ID: <144520928.20050927121431@sart.must-ipra.com> +To: pgsql-performance@postgresql.org +Subject: Index not used on group by +MIME-Version: 1.0 +Content-Type: text/plain; charset=Windows-1251 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: amavisd-new at sart.must-ipra.com +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 required=5 tests=[AWL=0.007] +X-Spam-Level: +X-Archive-Number: 200509/367 +X-Sequence-Number: 14675 + +Hello all, + + I have table ma_data, that contain above 300000 rows. + This table has primary key id, and field alias_id. + I create index (btree)on this field. + Set statistic: + + ALTER TABLE "public"."ma_data" + ALTER COLUMN "alias_id" SET STATISTICS 998; + + So, when I do something like + SELECT alias_id FROM ma_data GROUP BY alias_id + and have (with seq_scan off): + + Group (cost=0.00..1140280.63 rows=32 width=4) (actual time=0.159..2640.090 rows=32 loops=1) + -> Index Scan using reference_9_fk on ma_data (cost=0.00..1139526.57 rows=301624 width=4) (actual time=0.120..1471.128 rows=301624 loops=1) + Total runtime: 2640.407 ms + (3 rows) + + As I understand there are some problems with visibility of records, + but some others DBMS used indexes without problems(for example + FireBird)? Or maybe some another information be helpful for me and + community. + +-- +� ���������� �����������, + ����� ������ ������������ mailto:repko@sart.must-ipra.com + + +From pgsql-performance-owner@postgresql.org Tue Sep 27 06:36:22 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3976DD9895 + for ; + Tue, 27 Sep 2005 06:36:21 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81244-08 + for ; + Tue, 27 Sep 2005 09:36:12 +0000 (GMT) +Received: from ki-communication.com (unknown [202.147.194.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 10D12D9847 + for ; + Tue, 27 Sep 2005 06:36:01 -0300 (ADT) +Received: from iacn01wks ([192.168.0.128]) by ki-communication.com with + Microsoft SMTPSVC(6.0.3790.1830); Tue, 27 Sep 2005 16:40:18 +0700 +From: "Ahmad Fajar" +To: "'Qingqing Zhou'" +Cc: +Subject: Re: Query seem to slow if table have more than 200 million rows +Date: Tue, 27 Sep 2005 16:39:55 +0700 +Keywords: Postgresql +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Mailer: Microsoft Office Outlook, Build 11.0.6353 +In-Reply-To: +Thread-Index: AcXC65FB7KmAMY4KTKSs6Z4F3k8iDgAWbRxA +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +Message-ID: +X-OriginalArrivalTime: 27 Sep 2005 09:40:18.0765 (UTC) + FILETIME=[78DB27D0:01C5C347] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.38 required=5 tests=[AWL=-0.112, + DNS_FROM_RFC_WHOIS=0.492] +X-Spam-Level: +X-Archive-Number: 200509/368 +X-Sequence-Number: 14676 + +Hi Qingqing, + +I don't know whether the statistic got is bad or good, this is the +statistic: +scooby=# select a.relid, a.relname, b.indexrelid, b.indexrelname, +c.idx_scan, c.idx_tup_read, c.idx_tup_fetch, +scooby-# a.heap_blks_read, a.heap_blks_hit, a.idx_blks_read, a.idx_blks_hit, +scooby-# a.toast_blks_read, a.toast_blks_hit, a.tidx_blks_read, +a.tidx_blks_hit, b.idx_blks_read, b.idx_blks_hit +scooby-# from pg_statio_user_tables a, pg_statio_user_indexes b, +pg_stat_all_indexes c +scooby-# where a.relid=b.relid and a.relid=c.relid and +b.indexrelid=c.indexrelid and a.relname=b.relname and +scooby-# a.relname=c.relname and a.relname='fti_dict1'; + relid | relname | indexrelid | indexrelname | idx_scan | idx_tup_read +| idx_tup_fetch | heap_blks_read | heap_blks_hit | idx +_blks_read | idx_blks_hit | toast_blks_read | toast_blks_hit | +tidx_blks_read | tidx_blks_hit | idx_blks_read | idx_blks_hit +----------+-----------+------------+--------------+----------+-------------- ++---------------+----------------+---------------+---- +-----------+--------------+-----------------+----------------+-------------- +--+---------------+---------------+-------------- + 22880226 | fti_dict1 | 22880231 | idx_dict3 | 0 | 0 +| 0 | 0 | 0 | + 0 | 0 | | | +| | 0 | 0 + 22880226 | fti_dict1 | 22880230 | idx_dict2 | 7 | 592799 +| 592799 | 0 | 0 | + 0 | 0 | | | +| | 0 | 0 + 22880226 | fti_dict1 | 22880229 | idx_dict1 | 0 | 0 +| 0 | 0 | 0 | + 0 | 0 | | | +| | 0 | 0 +(3 rows) + +I have try several time the query below with different keyword, but I just +got idx_tup_read and idx_tup_fetch changed, others keep zero. +The Index are: +Ids (Idx_dict1), +keywords (idx_dict2 varchar_ops), +keywords (idx_dict3 varchar_pattern_ops) ==> I use this index for query ... +keywords like 'blabla%', just for testing purpose + +Regards, +ahmad fajar + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Qingqing Zhou +Sent: Selasa, 27 September 2005 8:43 +To: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Query seem to slow if table have more than 200 +million rows + + +""Ahmad Fajar"" wrote +> +> Select ids, keywords from dict where keywords='blabla' ('blabla' is a +> single +> word); +> +> The table have 200 million rows, I have index the keywords field. On the +> first time my query seem to slow to get the result, about 15-60 sec to get +> the result. But if I repeat the query I will get fast result. My question +> is +> why on the first time the query seem very slow. +> +> Table structure is quite simple: +> +> Ids bigint, keywords varchar(150), weight varchar(1), dpos int. +> + +The first slowness is obviously caused by disk IOs. The second time is +faster because all data pages it requires are already in buffer pool. 200 +million rows is not a problem for btree index, even if your client tool +appends some spaces to your keywords at your insertion time, the ideal btree + +is 5 to 6 layers high at most. Can you show the iostats of index from your +statistics view? +http://www.postgresql.org/docs/8.0/static/monitoring-stats.html#MONITORING-S +TATS-VIEWS + +Regards, +Qingqing + + + +---------------------------(end of broadcast)--------------------------- +TIP 6: explain analyze is your friend + + +From pgsql-hackers-owner@postgresql.org Tue Sep 27 09:30:26 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5E60CD9201 + for ; + Tue, 27 Sep 2005 06:50:11 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 83568-09 + for ; + Tue, 27 Sep 2005 09:50:02 +0000 (GMT) +Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.201]) + by svr1.postgresql.org (Postfix) with ESMTP id 734E0D98DB + for ; + Tue, 27 Sep 2005 06:50:02 -0300 (ADT) +Received: by zproxy.gmail.com with SMTP id q3so1652348nzb + for ; + Tue, 27 Sep 2005 02:50:05 -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:mime-version:content-type; + b=TNRbmhtZUzXvN7XqxlxtE3HMmRE///Crd7K+CgtJH5NdWF/IJ/hyD2Jth8nOfnyHoOfeZCtbCqoQoukwowIRtfqFDCYOl/PLLOYvs+xvqTadW1vgc5BagE7Z/w4ZB82G8dECzqgMxsbVLLM4nA/DE0ujHUoVcJKkEN8zHGlV00U= +Received: by 10.36.82.20 with SMTP id f20mr2566465nzb; + Tue, 27 Sep 2005 02:50:05 -0700 (PDT) +Received: by 10.36.120.14 with HTTP; Tue, 27 Sep 2005 02:50:05 -0700 (PDT) +Message-ID: +Date: Tue, 27 Sep 2005 15:20:05 +0530 +From: Gnanavel S +Reply-To: Gnanavel S +To: pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Subject: PostgreSQL overall design +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_242_4124819.1127814605101" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.277 required=5 tests=[AWL=0.157, HTML_50_60=0.095, + HTML_MESSAGE=0.001, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200509/1222 +X-Sequence-Number: 73619 + +------=_Part_242_4124819.1127814605101 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Hi All, + +Can anyone please tell/point me where I can get the postgresql system layou= +t +(I've an interest to contribute). I would also like to know the files +involved for performing each task ( for eg when doing a select operation +what is exactly happening in postgres along with the files). + +I was wandering inside the source for a while and I couldn't get a start +point to go with. + +Need a clarification in copydir.c file of src/port directory, In the +following snippet the destination directory is created first then the sourc= +e +directory is read. Suppose if I don't have permission to read the source, +even then the destination directory would be created. +I just want to know whether there is any reason for doing so? + +if (mkdir(todir, S_IRUSR | S_IWUSR | S_IXUSR) !=3D 0) +ereport(ERROR, +(errcode_for_file_access(), +errmsg("could not create directory \"%s\": %m", todir))); + +xldir =3D AllocateDir(fromdir); +if (xldir =3D=3D NULL) +ereport(ERROR, +(errcode_for_file_access(), +errmsg("could not open directory \"%s\": %m", fromdir))); + + + +-- +with thanks & regards, +S.Gnanavel +Satyam Computer Services Ltd. + +------=_Part_242_4124819.1127814605101 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Hi All,
+
+  Can anyone please tell/point  me where I can get the +postgresql system layout (I've an interest to contribute). I would also +like to know the files involved for performing each task ( for eg when +doing a select operation what is exactly happening in postgres along +with the files).
+
+  I was wandering inside the source for a while and I couldn't get a s= +tart point to go with.
+
+ Need a clarification in copydir.c file of src/port +directory,  In the following snippet the destination directory is +created first then the source directory is read. Suppose if I don't +have permission to read the source, even then the destination directory +would be created.
+I just want to know whether there is any reason for doing so?
+
+        if (mkdir(todir, S_IRUSR | S_IWU= +SR | S_IXUSR) !=3D 0)
+            &nb= +sp;   ereport(ERROR,
+            &nb= +sp;            = +       +(errcode_for_file_access(),
+            &nb= +sp;            = +        +errmsg("could not create directory \"%s\": %m", todir))= +);
+
+        xldir =3D AllocateDir(fromdir);<= +br> +        if (xldir =3D=3D NULL)
+            &nb= +sp;   ereport(ERROR,
+            &nb= +sp;            = +       +(errcode_for_file_access(),
+            &nb= +sp;            = +        +errmsg("could not open directory \"%s\": %m", fromdir))= +);
+
+
+
--
with thanks & regards,
S.Gnanavel
Satyam Computer Serv= +ices Ltd. + +------=_Part_242_4124819.1127814605101-- + +From pgsql-hackers-owner@postgresql.org Tue Sep 27 09:30:24 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 49F57D98B3; + Tue, 27 Sep 2005 07:27:16 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 95088-07; Tue, 27 Sep 2005 10:27:11 +0000 (GMT) +Received: from fugue.toroid.org (fugue.toroid.org [85.10.196.113]) + by svr1.postgresql.org (Postfix) with ESMTP id D19CAD98EB; + Tue, 27 Sep 2005 07:27:12 -0300 (ADT) +Received: from penne.toroid.org (fugue.toroid.org [85.10.196.113]) + by fugue.toroid.org (Postfix) with ESMTP id 8C45F5E61; + Tue, 27 Sep 2005 12:27:03 +0200 (CEST) +Received: by penne.toroid.org (Postfix, from userid 1000) + id F222F3E224E; Tue, 27 Sep 2005 15:57:01 +0530 (IST) +Date: Tue, 27 Sep 2005 15:57:01 +0530 +From: Abhijit Menon-Sen +To: Gnanavel S +Cc: pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Subject: Re: PostgreSQL overall design +Message-ID: <20050927102701.GE1784@penne.toroid.org> +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/1221 +X-Sequence-Number: 73618 + +At 2005-09-27 15:20:05 +0530, s.gnanavel@gmail.com wrote: +> +> Can anyone please tell/point me where I can get the postgresql system +> layout (I've an interest to contribute). + +http://www.postgresql.org/developer/coding + +And, in particular: + +http://www.postgresql.org/docs/faqs.FAQ_DEV.html + +-- ams + +From pgsql-performance-owner@postgresql.org Tue Sep 27 07:50:33 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 803CBD9895 + for ; + Tue, 27 Sep 2005 07:50:32 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 98995-05 + for ; + Tue, 27 Sep 2005 10:50:27 +0000 (GMT) +Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) + by svr1.postgresql.org (Postfix) with ESMTP id 87B88D98C1 + for ; + Tue, 27 Sep 2005 07:50:27 -0300 (ADT) +Received: from mainbox.archonet.com + (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) + by smtp.metronet.co.uk (MetroNet Mail) with ESMTP + id 0EBDC41592C; Tue, 27 Sep 2005 11:50:22 +0100 (BST) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mainbox.archonet.com (Postfix) with ESMTP id 402CC15F1E; + Tue, 27 Sep 2005 11:48:19 +0100 (BST) +Received: from mainbox.archonet.com ([127.0.0.1]) + by localhost (mainbox [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 12192-01; Tue, 27 Sep 2005 11:48:16 +0100 (BST) +Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP id BA55715F1D; + Tue, 27 Sep 2005 11:48:15 +0100 (BST) +Message-ID: <4339236F.7070403@archonet.com> +Date: Tue, 27 Sep 2005 11:48:15 +0100 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: =?windows-1251?Q?=C0=ED=E4=F0=E5=E9_=D0=E5=EF=EA=EE?= + +Cc: pgsql-performance@postgresql.org +Subject: Re: Index not used on group by +References: <144520928.20050927121431@sart.must-ipra.com> +In-Reply-To: <144520928.20050927121431@sart.must-ipra.com> +Content-Type: text/plain; charset=windows-1251; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.057 required=5 tests=[AWL=0.007, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/370 +X-Sequence-Number: 14678 + +Andrey Repko wrote: +> +> I have table ma_data, that contain above 300000 rows. +> This table has primary key id, and field alias_id. +> I create index (btree)on this field. +> Set statistic: +> +> ALTER TABLE "public"."ma_data" +> ALTER COLUMN "alias_id" SET STATISTICS 998; +> +> So, when I do something like +> SELECT alias_id FROM ma_data GROUP BY alias_id + +Why are you using GROUP BY without any aggregate functions? + +What happens if you use something like + SELECT DISTINCT alias_id FROM ma_data; + +-- + Richard Huxton + Archonet Ltd + +From pgsql-general-owner@postgresql.org Tue Sep 27 07:56:16 2005 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 59A95D9896; + Tue, 27 Sep 2005 07:55:24 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 01495-06; Tue, 27 Sep 2005 10:55:20 +0000 (GMT) +Received: from wimpy.net.nih.gov (wimpy.net.nih.gov [128.231.88.106]) + by svr1.postgresql.org (Postfix) with ESMTP id AFF99D98C1; + Tue, 27 Sep 2005 07:55:20 -0300 (ADT) +Received: from wimpy.net.nih.gov (localhost [127.0.0.1]) + by wimpy.net.nih.gov (8.12.11/8.11.7) with ESMTP id j8RAtJvx013475; + Tue, 27 Sep 2005 06:55:23 -0400 (EDT) +Received: from [128.231.145.14] (holmes.nhgri.nih.gov [128.231.145.14]) + by wimpy.net.nih.gov (8.12.11/8.11.7) with ESMTP id j8RAtJ7e013472; + Tue, 27 Sep 2005 06:55:19 -0400 (EDT) +User-Agent: Microsoft-Entourage/10.1.4.030702.0 +Date: Tue, 27 Sep 2005 06:54:51 -0400 +Subject: Re: Index use in BETWEEN statement... +From: Sean Davis +To: Yonatan Ben-Nes , Tom Lane +Cc: Cristian Prieto , + , +Message-ID: +In-Reply-To: <433930E5.7090800@canaan.co.il> +Mime-version: 1.0 +Content-type: text/plain; charset="US-ASCII" +Content-transfer-encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.014 required=5 tests=[AWL=0.014] +X-Spam-Level: +X-Archive-Number: 200509/1069 +X-Sequence-Number: 84084 + +On 9/27/05 7:45 AM, "Yonatan Ben-Nes" wrote: + +> Tom Lane wrote: +>> "Cristian Prieto" writes: +>> +>>> mydb=# explain analyze select locid from geoip_block where +>>> '216.230.158.50'::inet between start_block and end_block; +>> +>> +>>> As you see it still using a sequential scan in the table and ignores the +>>> index, any other suggestion? +>> +>> +>> That two-column index is entirely useless for this query; in fact btree +>> indexes of any sort are pretty useless. You really need some sort of +>> multidimensional index type like rtree or gist. There was discussion +>> just a week or three ago of how to optimize searches for intervals +>> overlapping a specified point, which is identical to your problem. +>> Can't remember if the question was about timestamp intervals or plain +>> intervals, but try checking the list archives. +>> +>> regards, tom lane +>> +>> ---------------------------(end of broadcast)--------------------------- +>> TIP 4: Have you searched our list archives? +>> +>> http://archives.postgresql.org +> +> I think that Tom is talking about a discussion which I started entitled +> "Planner create a slow plan without an available index" search for it +> maybe it will help you. +> At the end I created an RTREE index and it did solved my problem though +> my data was 2 INT fields and not INET fields as yours so im not sure how +> can you work with that... To solve my problem I created boxes from the 2 +> numbers and with them I did overlapping. + +There is some code in this thread that shows the box approach explicitly: + +http://archives.postgresql.org/pgsql-sql/2005-09/msg00189.php + +Sean + + +From pgsql-performance-owner@postgresql.org Tue Sep 27 07:57:57 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0BDEFD8788 + for ; + Tue, 27 Sep 2005 07:57:57 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 03215-05 + for ; + Tue, 27 Sep 2005 10:57:49 +0000 (GMT) +Received: from sart.must-ipra.com (unknown [80.91.172.78]) + by svr1.postgresql.org (Postfix) with ESMTP id 3D4F1D98D4 + for ; + Tue, 27 Sep 2005 07:57:50 -0300 (ADT) +Received: from localhost (localhost [127.0.0.1]) + by sart.must-ipra.com (Postfix) with ESMTP id 6E8F03C162; + Tue, 27 Sep 2005 13:55:13 +0300 (EEST) +Received: from sart.must-ipra.com ([127.0.0.1]) + by localhost (sart.must-ipra.com [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 12977-20; Tue, 27 Sep 2005 13:55:09 +0300 (EEST) +Received: from PRG-45 (unknown [10.0.0.45]) + by sart.must-ipra.com (Postfix) with ESMTP id 73F4C3C140; + Tue, 27 Sep 2005 13:55:09 +0300 (EEST) +Date: Tue, 27 Sep 2005 13:57:16 +0300 +From: =?Windows-1251?Q?=C0=ED=E4=F0=E5=E9_=D0=E5=EF=EA=EE?= + +X-Mailer: The Bat! (v3.5.25) Professional +Reply-To: =?Windows-1251?Q?=C0=ED=E4=F0=E5=E9_=D0=E5=EF=EA=EE?= + +Organization: =?Windows-1251?Q?=CE=CE=CE_=22=D1=C0=D0=D2=22?= +X-Priority: 3 (Normal) +Message-ID: <6110500029.20050927135716@sart.must-ipra.com> +To: Richard Huxton +Cc: pgsql-performance@postgresql.org +Subject: Re: Index not used on group by +In-Reply-To: <4339236F.7070403@archonet.com> +References: <144520928.20050927121431@sart.must-ipra.com> + <4339236F.7070403@archonet.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=Windows-1251 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: amavisd-new at sart.must-ipra.com +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.02 required=5 tests=[AWL=0.020] +X-Spam-Level: +X-Archive-Number: 200509/371 +X-Sequence-Number: 14679 + +������������ Richard, + +Tuesday, September 27, 2005, 1:48:15 PM, �� ������: + +RH> Andrey Repko wrote: +>> +>> I have table ma_data, that contain above 300000 rows. +>> This table has primary key id, and field alias_id. +>> I create index (btree)on this field. +>> Set statistic: +>> +>> ALTER TABLE "public"."ma_data" +>> ALTER COLUMN "alias_id" SET STATISTICS 998; +>> +>> So, when I do something like +>> SELECT alias_id FROM ma_data GROUP BY alias_id + +RH> Why are you using GROUP BY without any aggregate functions? + +RH> What happens if you use something like +RH> SELECT DISTINCT alias_id FROM ma_data; +sart_ma=# EXPLAIN ANALYZE SELECT DISTINCT alias_id FROM ma_data; + QUERY PLAN + +------------------------------------------------------------------------------------------------------------------------------- + Unique (cost=65262.63..66770.75 rows=32 width=4) (actual time=16780.214..18250.761 rows=32 loops=1) + -> Sort (cost=65262.63..66016.69 rows=301624 width=4) (actual time=16780.204..17255.129 rows=301624 loops=1) + Sort Key: alias_id + -> Seq Scan on ma_data (cost=0.00..37811.24 rows=301624 width=4) (actual time=6.896..15321.023 rows=301624 loops=1) + Total runtime: 18292.542 ms +(5 rows) + +sart_ma=# EXPLAIN ANALYZE SELECT alias_id FROM ma_data GROUP BY alias_id; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------- + HashAggregate (cost=38565.30..38565.62 rows=32 width=4) (actual time=15990.863..15990.933 rows=32 loops=1) + -> Seq Scan on ma_data (cost=0.00..37811.24 rows=301624 width=4) (actual time=3.446..14572.141 rows=301624 loops=1) + Total runtime: 15991.244 ms +(3 rows) + +-- +� ���������� �����������, + ����� ������ ������������ mailto:repko@sart.must-ipra.com + + +From pgsql-performance-owner@postgresql.org Tue Sep 27 09:45:32 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4F999D98DB + for ; + Tue, 27 Sep 2005 09:45:31 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 32169-02 + for ; + Tue, 27 Sep 2005 12:45:23 +0000 (GMT) +Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) + by svr1.postgresql.org (Postfix) with ESMTP id 194A0D9916 + for ; + Tue, 27 Sep 2005 08:10:32 -0300 (ADT) +Received: from mainbox.archonet.com + (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) + by smtp.metronet.co.uk (MetroNet Mail) with ESMTP + id 0614440DD67; Tue, 27 Sep 2005 12:10:28 +0100 (BST) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mainbox.archonet.com (Postfix) with ESMTP id 19B7015F1D; + Tue, 27 Sep 2005 12:08:37 +0100 (BST) +Received: from mainbox.archonet.com ([127.0.0.1]) + by localhost (mainbox [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 12659-02; Tue, 27 Sep 2005 12:08:32 +0100 (BST) +Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP id 556C715F1C; + Tue, 27 Sep 2005 12:08:32 +0100 (BST) +Message-ID: <4339282F.1060900@archonet.com> +Date: Tue, 27 Sep 2005 12:08:31 +0100 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: =?windows-1251?Q?=C0=ED=E4=F0=E5=E9_=D0=E5=EF=EA=EE?= + +Cc: pgsql-performance@postgresql.org +Subject: Re: Index not used on group by +References: <144520928.20050927121431@sart.must-ipra.com> + <4339236F.7070403@archonet.com> + <6110500029.20050927135716@sart.must-ipra.com> +In-Reply-To: <6110500029.20050927135716@sart.must-ipra.com> +Content-Type: text/plain; charset=windows-1251; format=flowed +Content-Transfer-Encoding: quoted-printable +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.057 required=5 tests=[AWL=0.007, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/374 +X-Sequence-Number: 14682 + +=C0=ED=E4=F0=E5=E9 =D0=E5=EF=EA=EE wrote: +> RH> What happens if you use something like +> RH> SELECT DISTINCT alias_id FROM ma_data; +> sart_ma=3D# EXPLAIN ANALYZE SELECT DISTINCT alias_id FROM ma_data; +> QUERY PLAN +>=20 +> -----------------------------------------------------------------------= +-------------------------------------------------------- +> Unique (cost=3D65262.63..66770.75 rows=3D32 width=3D4) (actual time=3D= +16780.214..18250.761 rows=3D32 loops=3D1) +> -> Sort (cost=3D65262.63..66016.69 rows=3D301624 width=3D4) (actua= +l time=3D16780.204..17255.129 rows=3D301624 loops=3D1) +> Sort Key: alias_id +> -> Seq Scan on ma_data (cost=3D0.00..37811.24 rows=3D301624 = +width=3D4) (actual time=3D6.896..15321.023 rows=3D301624 loops=3D1) +> Total runtime: 18292.542 ms + +> sart_ma=3D# EXPLAIN ANALYZE SELECT alias_id FROM ma_data GROUP BY alias= +_id; +> QUERY PLAN +> -----------------------------------------------------------------------= +-------------------------------------------------- +> HashAggregate (cost=3D38565.30..38565.62 rows=3D32 width=3D4) (actual= + time=3D15990.863..15990.933 rows=3D32 loops=3D1) +> -> Seq Scan on ma_data (cost=3D0.00..37811.24 rows=3D301624 width=3D= +4) (actual time=3D3.446..14572.141 rows=3D301624 loops=3D1) +> Total runtime: 15991.244 ms + +OK - the planner thinks it's doing the right thing, your cost estimates=20 +are way off. If you look back at where you got an index-scan, it's cost=20 +was 1.1 million. + Index Scan using reference_9_fk on ma_data (cost=3D0.00..1139526.57 + +That's way above the numbers for seq-scan+hash/sort, so if the cost=20 +estimate was right PG would be making the right choice. Looks like you=20 +need to check your configuration settings. Have you read: + http://www.powerpostgresql.com/PerfList +or + http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html +-- + Richard Huxton + Archonet Ltd + + +From pgsql-performance-owner@postgresql.org Tue Sep 27 08:38:20 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B57F5D9900 + for ; + Tue, 27 Sep 2005 08:38:19 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 09978-09 + for ; + Tue, 27 Sep 2005 11:38:08 +0000 (GMT) +Received: from sart.must-ipra.com (unknown [80.91.172.78]) + by svr1.postgresql.org (Postfix) with ESMTP id B0239D9201 + for ; + Tue, 27 Sep 2005 08:38:09 -0300 (ADT) +Received: from localhost (localhost [127.0.0.1]) + by sart.must-ipra.com (Postfix) with ESMTP id F2D433C162 + for ; + Tue, 27 Sep 2005 14:35:31 +0300 (EEST) +Received: from sart.must-ipra.com ([127.0.0.1]) + by localhost (sart.must-ipra.com [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 21815-07 for ; + Tue, 27 Sep 2005 14:35:24 +0300 (EEST) +Received: from PRG-45 (unknown [10.0.0.45]) + by sart.must-ipra.com (Postfix) with ESMTP id A3BD13C15F + for ; + Tue, 27 Sep 2005 14:35:24 +0300 (EEST) +Date: Tue, 27 Sep 2005 14:37:31 +0300 +From: =?Windows-1251?Q?=C0=ED=E4=F0=E5=E9_=D0=E5=EF=EA=EE?= + +X-Mailer: The Bat! (v3.5.25) Professional +Reply-To: =?Windows-1251?Q?=C0=ED=E4=F0=E5=E9_=D0=E5=EF=EA=EE?= + +Organization: =?Windows-1251?Q?=CE=CE=CE_=22=D1=C0=D0=D2=22?= +X-Priority: 3 (Normal) +Message-ID: <4010683035.20050927143731@sart.must-ipra.com> +To: pgsql-performance@postgresql.org +Subject: Re: Index not used on group by +In-Reply-To: <4339282F.1060900@archonet.com> +References: <144520928.20050927121431@sart.must-ipra.com> + <4339236F.7070403@archonet.com> + <6110500029.20050927135716@sart.must-ipra.com> + <4339282F.1060900@archonet.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=Windows-1251 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: amavisd-new at sart.must-ipra.com +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.121 required=5 tests=[AWL=-0.086, + UPPERCASE_25_50=0.207] +X-Spam-Level: +X-Archive-Number: 200509/372 +X-Sequence-Number: 14680 + +������������ Richard, + +Tuesday, September 27, 2005, 2:08:31 PM, �� ������: + + +>> sart_ma=# EXPLAIN ANALYZE SELECT alias_id FROM ma_data GROUP BY alias_id; +>> QUERY PLAN +>> ------------------------------------------------------------------------------------------------------------------------- +>> HashAggregate (cost=38565.30..38565.62 rows=32 width=4) +>> (actual time=15990.863..15990.933 rows=32 loops=1) +>> -> Seq Scan on ma_data (cost=0.00..37811.24 rows=301624 +>> width=4) (actual time=3.446..14572.141 rows=301624 loops=1) +>> Total runtime: 15991.244 ms + +RH> OK - the planner thinks it's doing the right thing, your cost estimates +RH> are way off. If you look back at where you got an index-scan, it's cost +RH> was 1.1 million. +RH> Index Scan using reference_9_fk on ma_data (cost=0.00..1139526.57 +But why PG scan _all_ the records in the table? As I understand we can +"just" select information from index, not scaning all the table? Of +course if we select ALL records from table index can't help us. +If I write something like: +SELECT (SELECT alias_id FROM ma_data WHERE alias_id =1 LIMIT 1) +UNION ALL SELECT (SELECT alias_id FROM ma_data WHERE alias_id =2 LIMIT 1) +UNION ALL SELECT (SELECT alias_id FROM ma_data WHERE alias_id =3 LIMIT 1) +UNION ALL SELECT (SELECT alias_id FROM ma_data WHERE alias_id =4 LIMIT 1) +UNION ALL SELECT (SELECT alias_id FROM ma_data WHERE alias_id =5 LIMIT 1) +UNION ALL SELECT (SELECT alias_id FROM ma_data WHERE alias_id =6 LIMIT 1) +UNION ALL SELECT (SELECT alias_id FROM ma_data WHERE alias_id =7 LIMIT 1) +UNION ALL SELECT (SELECT alias_id FROM ma_data WHERE alias_id =8 LIMIT 1) +UNION ALL SELECT (SELECT alias_id FROM ma_data WHERE alias_id =9 LIMIT 1) +... +UNION ALL SELECT (SELECT alias_id FROM ma_data WHERE alias_id=max_alias_id LIMIT 1) +It works better, much better. + +RH> That's way above the numbers for seq-scan+hash/sort, so if the cost +RH> estimate was right PG would be making the right choice. Looks like you +RH> need to check your configuration settings. Have you read: +RH> http://www.powerpostgresql.com/PerfList +RH> or +RH> http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html +Thanks. + + +-- +� ���������� �����������, + ����� ������ ������������ mailto:repko@sart.must-ipra.com + + +From pgsql-general-owner@postgresql.org Tue Sep 27 07:46:27 2005 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 73255D98EF; + Tue, 27 Sep 2005 07:46:26 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 01495-03; Tue, 27 Sep 2005 10:46:22 +0000 (GMT) +Received: from mxout1.netvision.net.il (mxout1.netvision.net.il [194.90.9.20]) + by svr1.postgresql.org (Postfix) with ESMTP id F17E8D9201; + Tue, 27 Sep 2005 07:46:23 -0300 (ADT) +Received: from [10.0.0.1] ([62.0.102.240]) by mxout1.netvision.net.il + (Sun Java System Messaging Server 6.1 HotFix 0.11 (built Jan 28 2005)) + with ESMTP id <0INH000NS1XDYQD0@mxout1.netvision.net.il>; Tue, + 27 Sep 2005 13:46:26 +0300 (IDT) +Date: Tue, 27 Sep 2005 13:45:41 +0200 +From: Yonatan Ben-Nes +Subject: Re: Index use in BETWEEN statement... +In-reply-to: <1896.1127762243@sss.pgh.pa.us> +To: Tom Lane +Cc: Cristian Prieto , + 'Sean Davis' , pgsql-general@postgresql.org, + pgsql-performance@postgresql.org +Message-id: <433930E5.7090800@canaan.co.il> +MIME-version: 1.0 +Content-type: text/plain; charset=UTF-8; format=flowed +Content-transfer-encoding: 7BIT +X-Accept-Language: en-us, en +References: <20050926175615.BA5C21015A@mail.clickdiario.com> + <1896.1127762243@sss.pgh.pa.us> +User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/1067 +X-Sequence-Number: 84082 + +Tom Lane wrote: +> "Cristian Prieto" writes: +> +>>mydb=# explain analyze select locid from geoip_block where +>>'216.230.158.50'::inet between start_block and end_block; +> +> +>>As you see it still using a sequential scan in the table and ignores the +>>index, any other suggestion? +> +> +> That two-column index is entirely useless for this query; in fact btree +> indexes of any sort are pretty useless. You really need some sort of +> multidimensional index type like rtree or gist. There was discussion +> just a week or three ago of how to optimize searches for intervals +> overlapping a specified point, which is identical to your problem. +> Can't remember if the question was about timestamp intervals or plain +> intervals, but try checking the list archives. +> +> regards, tom lane +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 4: Have you searched our list archives? +> +> http://archives.postgresql.org + +I think that Tom is talking about a discussion which I started entitled +"Planner create a slow plan without an available index" search for it +maybe it will help you. +At the end I created an RTREE index and it did solved my problem though +my data was 2 INT fields and not INET fields as yours so im not sure how +can you work with that... To solve my problem I created boxes from the 2 +numbers and with them I did overlapping. + +From pgsql-performance-owner@postgresql.org Tue Sep 27 09:06:04 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7343FD990F + for ; + Tue, 27 Sep 2005 09:06:02 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 17503-06 + for ; + Tue, 27 Sep 2005 12:05:53 +0000 (GMT) +Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.201]) + by svr1.postgresql.org (Postfix) with ESMTP id 69DC4D9201 + for ; + Tue, 27 Sep 2005 09:05:54 -0300 (ADT) +Received: by zproxy.gmail.com with SMTP id 40so629020nzk + for ; + Tue, 27 Sep 2005 05:05:58 -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=Wx4RmJVrxhVtBxoFhxc6zx8CA/mG2Hu1ce9CPN26Fn4tDDT9byO/QxN+cZ8TiN3SmZmtgrX2hhdSFKpvPucOzCTx4VszxOq847GnwDdTh2HbDa8KGbEh8pfaXoNQHpJjomGwBesQdoizvqQYoEAB5q4DGvw2BWy512Lj1Ulcfqw= +Received: by 10.36.105.3 with SMTP id d3mr2253118nzc; + Tue, 27 Sep 2005 05:05:58 -0700 (PDT) +Received: by 10.36.120.14 with HTTP; Tue, 27 Sep 2005 05:05:58 -0700 (PDT) +Message-ID: +Date: Tue, 27 Sep 2005 17:35:58 +0530 +From: Gnanavel S +Reply-To: Gnanavel S +To: Abhijit Menon-Sen +Subject: Re: PostgreSQL overall design +Cc: pgsql-performance@postgresql.org +In-Reply-To: <20050927102701.GE1784@penne.toroid.org> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_703_10634781.1127822758275" +References: + <20050927102701.GE1784@penne.toroid.org> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.274 required=5 tests=[AWL=0.154, HTML_50_60=0.095, + HTML_MESSAGE=0.001, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200509/373 +X-Sequence-Number: 14681 + +------=_Part_703_10634781.1127822758275 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +On 9/27/05, Abhijit Menon-Sen wrote: +> +> At 2005-09-27 15:20:05 +0530, s.gnanavel@gmail.com wrote: +> > +> > Can anyone please tell/point me where I can get the postgresql system +> > layout (I've an interest to contribute). +> +> http://www.postgresql.org/developer/coding +> +> And, in particular: +> +> http://www.postgresql.org/docs/faqs.FAQ_DEV.html +> +> -- ams +> + +Thanks. I'll go thru' the documentation. + + +-- +with regards, +S.Gnanavel + +------=_Part_703_10634781.1127822758275 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +

On 9/27/05, Abhijit Menon-Sen <ams@tor= +oid.org> wrote:
+At 2005-09-27 15:20:05 +0530, s.gna= +navel@gmail.com wrote:
>
> Can anyone please tell/point me = +where I can get the postgresql system
> layout (I've an interest to c= +ontribute). +

http://www.p= +ostgresql.org/developer/coding

And, in particular:

http://www.postgresq= +l.org/docs/faqs.FAQ_DEV.html +

-- ams

+Thanks. I'll go thru' the documentation.


--
wi= +th regards,
S.Gnanavel
+ + +------=_Part_703_10634781.1127822758275-- + +From pgsql-hackers-owner@postgresql.org Tue Sep 27 09:49:29 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 87063D9921 + for ; + Tue, 27 Sep 2005 09:49:26 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 29406-09 + for ; + Tue, 27 Sep 2005 12:49:17 +0000 (GMT) +Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.201]) + by svr1.postgresql.org (Postfix) with ESMTP id 7FBFBD98E4 + for ; + Tue, 27 Sep 2005 09:49:18 -0300 (ADT) +Received: by rproxy.gmail.com with SMTP id 40so77592rnz + for ; + Tue, 27 Sep 2005 05:49:22 -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=mwx3NMMs/pENNWoASxt7xIMcXOpMTU7l2nBGdcE8nxwTV5tZqER9f8Bk3UnX6jEy01xTz92k5I8tzdqpitjy21GUzsBtZBVeDJG9QjES4Y32EZTOMwaP7Za8+cC+P7HxRuelBoAd985tWSt/xssDH8BZ79PL7VkT3gBm5xdt300= +Received: by 10.11.33.25 with SMTP id g25mr10391cwg; + Tue, 27 Sep 2005 05:49:22 -0700 (PDT) +Received: by 10.11.119.38 with HTTP; Tue, 27 Sep 2005 05:49:22 -0700 (PDT) +Message-ID: <36e6829205092705492b0c9fdd@mail.gmail.com> +Date: Tue, 27 Sep 2005 08:49:22 -0400 +From: "Jonah H. Harris" +Reply-To: "Jonah H. Harris" +To: Ron Peacetree +Subject: Re: [PERFORM] A Better External Sort? +Cc: Tom Lane , pgsql-hackers@postgresql.org, + pgsql-performance@postgresql.org +In-Reply-To: + <10783357.1127797759038.JavaMail.root@elwamui-polski.atl.sa.earthlink.net> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_1923_2109684.1127825362178" +References: + <10783357.1127797759038.JavaMail.root@elwamui-polski.atl.sa.earthlink.net> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.381 required=5 tests=[AWL=0.061, HTML_10_20=0.295, + HTML_MESSAGE=0.001, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200509/1224 +X-Sequence-Number: 73621 + +------=_Part_1923_2109684.1127825362178 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Ron, + +Again, if you feel strongly enough about the theory to argue it, I recommen= +d +that you spend your time constructively; create an implemenation of it. +Citing academics is cool and all, but code speaks louder than theory in thi= +s +case. As Tom mentioned, this has to be portable. Making assumptions about +computing architectures (especially those in the future), is fine for +theory, but not practical for something that needs to be maintained in the +real-world. Go forth and write thy code. + +-Jonah + +On 9/27/05, Ron Peacetree wrote: +> +> SECOND ATTEMPT AT POST. Web mailer appears to have +> eaten first one. I apologize in advance if anyone gets two +> versions of this post. +> =3Dr +> +> >From: Tom Lane +> >Sent: Sep 26, 2005 9:42 PM +> >Subject: Re: [HACKERS] [PERFORM] A Better External Sort? +> > +> >So far, you've blithely assumed that you know the size of a cache line, +> >the sizes of L1 and L2 cache, +> > +> NO. I used exact values only as examples. Realistic examples drawn +> from an extensive survey of past, present, and what I could find out +> about future systems; but only examples nonetheless. For instance, +> Hennessy and Patterson 3ed points out that 64B cache lines are +> optimally performing for caches between 16KB and 256KB. The same +> source as well as sources specifically on CPU memory hierarchy +> design points out that we are not likely to see L1 caches larger than +> 256KB in the forseeable future. +> +> The important point was the idea of an efficient Key, rather than +> Record, sort using a CPU cache friendly data structure with provably +> good space and IO characteristics based on a reasonable model of +> current and likely future single box computer architecture (although +> it would be fairly easy to extend it to include the effects of +> networking.) +> +> No apriori exact or known values are required for the method to work. +> +> +> >and that you are working with sort keys that you can efficiently pack +> >into cache lines. +> > +> Not "pack". "map". n items can not take on more than n values. n +> values can be represented in lgn bits. Less efficient mappings can +> also work. Either way I demonstrated that we have plenty of space in +> a likely and common cache line size. Creating a mapping function +> to represent m values in lgm bits is a well known hack, and if we keep +> track of minimum and maximum values for fields during insert and +> delete operations, we can even create mapping functions fairly easily. +> (IIRC, Oracle does keep track of minimum and maximum field +> values.) +> +> +> >And that you know the relative access speeds of the caches and +> >memory so that you can schedule transfers, +> > +> Again, no. I created a reasonable model of a computer system that +> holds remarkably well over a _very_ wide range of examples. I +> don't need the numbers to be exactly right to justify my approach +> to this problem or understand why other approaches may have +> downsides. I just have to get the relative performance of the +> system components and the relative performance gap between them +> reasonably correct. The stated model does that very well. +> +> Please don't take my word for it. Go grab some random box: +> laptop, desktop, unix server, etc and try it for yourself. Part of the +> reason I published the model was so that others could examine it. +> +> +> >and that the hardware lets you get at that transfer timing. +> > +> Never said anything about this, and in fact I do not need any such. +> +> +> >And that the number of distinct key values isn't very large. +> > +> Quite the opposite in fact. I went out of my way to show that the +> method still works well even if every Key is distinct. It is _more +> efficient_ when the number of distinct keys is small compared to +> the number of data items, but it works as well as any other Btree +> would when all n of the Keys are distinct. This is just a CPU cache +> and more IO friendly Btree, not some magical and unheard of +> technique. It's just as general purpose as Btrees usually are. +> +> I'm simply looking at the current and likely future state of computer +> systems architecture and coming up with a slight twist on how to use +> already well known and characterized techniques. not trying to start +> a revolution. +> +> +> I'm trying very hard NOT to waste anyone's time around here. +> Including my own +> Ron +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 5: don't forget to increase your free space map settings +> + + + +-- +Respectfully, + +Jonah H. Harris, Database Internals Architect +EnterpriseDB Corporation +http://www.enterprisedb.com/ + +------=_Part_1923_2109684.1127825362178 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Ron,
+
+Again, if you feel strongly enough about the theory to argue it, I +recommend that you spend your time constructively; create an +implemenation of it.  Citing academics is cool and all, but code +speaks louder than theory in this case.  As Tom mentioned, this +has to be portable.  Making assumptions about computing +architectures (especially those in the future), is fine for theory, but +not practical for something that needs to be maintained in the +real-world.  Go forth and write thy code.
+
+-Jonah

On 9/27/05, Ron Peacetree <rjpeace@earthlink.net> wrote:
+SECOND ATTEMPT AT POST.  Web mailer appears to have
eaten firs= +t one.  I apologize in advance if anyone gets two
versions of = +this post.
=3Dr

>From: Tom Lane <tgl@sss.pgh.pa.us +>
>Sent: Sep 26, 2005 9:42 PM
>Subject: Re: [HACKERS] [P= +ERFORM] A Better External Sort?
>
>So far, you've blithely assu= +med that you know the size of a cache line,
>the sizes of L1 and L2 c= +ache, +
>
NO.  I used exact values only as examples.  = +;Realistic examples drawn
from an extensive survey of past, present, and= + what I could find out
about future systems; but only examples nonethele= +ss.  For instance, +
Hennessy and Patterson 3ed points out that 64B cache lines are
optim= +ally performing for caches between 16KB and 256KB.  The same
s= +ource as well as sources specifically on CPU memory hierarchy
design poi= +nts out that we are not likely to see L1 caches larger than +
256KB in the forseeable future.

The important point was the idea= + of an efficient Key, rather than
Record, sort using a CPU cache friendl= +y data structure with provably
good space and IO characteristics based o= +n a reasonable model of +
current and likely future single box computer architecture (althoughit would be fairly easy to extend it to include the effects of
networki= +ng.)

No apriori exact or known values are required for the method to= + work. +


>and that you are working with sort keys that you can effici= +ently pack
>into cache lines.
>
Not "pack". &= +nbsp;"map".  n items can not take on more than n values= +.  n
values can be represented in lgn bits.  Less ef= +ficient mappings can +
also work.  Either way I demonstrated that we have plenty of = +space in
a likely and common cache line size.  Creating a mapp= +ing function
to represent m values in lgm bits is a well known hack, and= + if we keep
track of minimum and maximum values for fields during insert= + and +
delete operations, we can even create mapping functions fairly easily.<= +br>(IIRC, Oracle does keep track of minimum and maximum field
values.)

>And that you know the relative access speeds of the caches an= +d +
>memory so that you can schedule transfers,
>
Again, no.&nb= +sp; I created a reasonable model of a computer system that
holds re= +markably well over a _very_ wide range of examples.  I
don't n= +eed the numbers to be exactly right to justify my approach +
to this problem or understand why other approaches may have
downside= +s.  I just have to get the relative performance of the
system = +components and the relative performance gap between them
reasonably corr= +ect.  The stated model does that very well. +

Please don't take my word for it.  Go grab some random bo= +x:
laptop, desktop, unix server, etc and try it for yourself.  = +;Part of the
reason I published the model was so that others could exami= +ne it.


+>and that the hardware lets you get at that transfer timing.
>
= +Never said anything about this, and in fact I do not need any such.

= +
>And that the number of distinct key values isn't very large.
+>
Quite the opposite in fact.  I went out of my way to show= + that the
method still works well even if every Key is distinct. &n= +bsp;It is _more
efficient_ when the number of distinct keys is small com= +pared to
the number of data items, but it works as well as any other Btr= +ee +
would when all n of the Keys are distinct.  This is just a CP= +U cache
and more IO friendly Btree, not some magical and unheard of
t= +echnique.  It's just as general purpose as Btrees usually are.
I'm simply looking at the current and likely future state of computer +
systems architecture and coming up with a slight twist on how to usealready well known and characterized techniques. not trying to start
a = +revolution.


I'm trying very hard NOT to waste anyone's time arou= +nd here. +
Including my own
Ron

---------------------------(end of broad= +cast)---------------------------
TIP 5: don't forget to increase your fr= +ee space map settings



--=20 +
Respectfully,

Jonah H. Harris, Database Internals Architect
E= +nterpriseDB Corporation
http://= +www.enterprisedb.com/
+ +------=_Part_1923_2109684.1127825362178-- + +From pgsql-hackers-owner@postgresql.org Tue Sep 27 10:00:43 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 79A33D98FA + for ; + Tue, 27 Sep 2005 10:00:42 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 32410-10 + for ; + Tue, 27 Sep 2005 13:00:34 +0000 (GMT) +Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.195]) + by svr1.postgresql.org (Postfix) with ESMTP id 09C8AD98EF + for ; + Tue, 27 Sep 2005 10:00:30 -0300 (ADT) +Received: by rproxy.gmail.com with SMTP id 1so77498rny + for ; + Tue, 27 Sep 2005 06:00:35 -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=QQZnoSUSFE8AYYRceT1TZLumDys1JLWjAoAl+luSo4tYODShMb5cUNEMuEEw1u7czmqGK46xJeL/f9wyYXJZsHjLtwhUXTcYQ3djTwihZbrX3Qn0pDhGo45QeblzLSa5JIzLcSehHRSCNQGmoGFxk8uCCPKQU5JugX/VBdl+dkE= +Received: by 10.11.119.4 with SMTP id r4mr10450cwc; + Tue, 27 Sep 2005 06:00:35 -0700 (PDT) +Received: by 10.11.119.38 with HTTP; Tue, 27 Sep 2005 06:00:35 -0700 (PDT) +Message-ID: <36e682920509270600439cfc4a@mail.gmail.com> +Date: Tue, 27 Sep 2005 09:00:35 -0400 +From: "Jonah H. Harris" +Reply-To: "Jonah H. Harris" +To: Abhijit Menon-Sen +Subject: Re: PostgreSQL overall design +Cc: Gnanavel S , pgsql-hackers@postgresql.org +In-Reply-To: <20050927102701.GE1784@penne.toroid.org> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_1935_7933691.1127826035049" +References: + <20050927102701.GE1784@penne.toroid.org> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.275 required=5 tests=[AWL=0.164, HTML_40_50=0.086, + HTML_MESSAGE=0.001, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200509/1225 +X-Sequence-Number: 73622 + +------=_Part_1935_7933691.1127826035049 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Were you looking for a call graph? + +On 9/27/05, Abhijit Menon-Sen wrote: +> +> At 2005-09-27 15:20:05 +0530, s.gnanavel@gmail.com wrote: +> > +> > Can anyone please tell/point me where I can get the postgresql system +> > layout (I've an interest to contribute). +> +> http://www.postgresql.org/developer/coding +> +> And, in particular: +> +> http://www.postgresql.org/docs/faqs.FAQ_DEV.html +> +> -- ams +> +> ---------------------------(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 +> + + + +-- +Respectfully, + +Jonah H. Harris, Database Internals Architect +EnterpriseDB Corporation +http://www.enterprisedb.com/ + +------=_Part_1935_7933691.1127826035049 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Were you looking for a call graph?

= +On 9/27/05, Abhijit Menon-Sen <ams@toroid.org> wrote:
+At 2005-09-27 15:20:05 +0530, s.gna= +navel@gmail.com wrote:
>
> Can anyone please tell/point me = +where I can get the postgresql system
> layout (I've an interest to c= +ontribute). +

http://www.p= +ostgresql.org/developer/coding

And, in particular:

http://www.postgresq= +l.org/docs/faqs.FAQ_DEV.html +

-- ams

---------------------------(end of broadcast)----= +-----------------------
TIP 1: if posting/reading through Usenet, please= + send an appropriate
       subscribe-noma= +il command to +majordomo@postgresql.org so that your
     = +  message can get through to the mailing list cleanly
= +



--
Respectfully,

Jonah H. Harris= +, Database Internals Architect +
EnterpriseDB Corporation
ht= +tp://www.enterprisedb.com/
+ +------=_Part_1935_7933691.1127826035049-- + +From pgsql-hackers-owner@postgresql.org Tue Sep 27 10:08:47 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 568E2D98E4 + for ; + Tue, 27 Sep 2005 10:08:46 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 42997-02 + for ; + Tue, 27 Sep 2005 13:08:34 +0000 (GMT) +Received: from trolak.mydnsbox2.com (ns1.mydnsbox2.com [207.44.142.118]) + by svr1.postgresql.org (Postfix) with ESMTP id 948A7D9931 + for ; + Tue, 27 Sep 2005 10:08:35 -0300 (ADT) +Received: from [192.168.1.103] (cpe-024-211-165-134.nc.res.rr.com + [24.211.165.134]) (authenticated (0 bits)) + by trolak.mydnsbox2.com (8.11.6/8.11.6) with ESMTP id j8RCPfE14261; + Tue, 27 Sep 2005 07:25:41 -0500 +Message-ID: <4339444F.6010101@dunslane.net> +Date: Tue, 27 Sep 2005 09:08:31 -0400 +From: Andrew Dunstan +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; + rv:1.7.10) Gecko/20050909 Fedora/1.7.10-1.3.2 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Gnanavel S +Cc: pgsql-hackers@postgresql.org +Subject: Re: PostgreSQL overall design +References: +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.039 required=5 tests=[AWL=0.039] +X-Spam-Level: +X-Archive-Number: 200509/1228 +X-Sequence-Number: 73625 + + +[ -performance removed ] + +Gnanavel S wrote: + +> +> Need a clarification in copydir.c file of src/port directory, In the +> following snippet the destination directory is created first then the +> source directory is read. Suppose if I don't have permission to read +> the source, even then the destination directory would be created. +> I just want to know whether there is any reason for doing so? +> +> + + +Under what circumstances do you imagine this will happen, since the +postmaster user owns all the files and directories? + +cheers + +andrew + +From pgsql-hackers-owner@postgresql.org Wed Sep 28 10:19:14 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id ED1C1D8788 + for ; + Tue, 27 Sep 2005 10:30:18 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 52443-06 + for ; + Tue, 27 Sep 2005 13:30:09 +0000 (GMT) +Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.205]) + by svr1.postgresql.org (Postfix) with ESMTP id 2FF99D777B + for ; + Tue, 27 Sep 2005 10:30:09 -0300 (ADT) +Received: by zproxy.gmail.com with SMTP id 40so649916nzk + for ; + Tue, 27 Sep 2005 06:30:14 -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=jJiY/EFSGuIYlrCoyRQol/3CHGHyIKmq97PX9Fd7ZNeHQJxNccMRsZvnlQm39vFDFiCd6g5CsLvd331A7WA/8kx4d10IoTu/izEL3LIaiP25Ge5ct9cn6+BfFW3/sJw+62ZXvEdDTDq1i5Y3JNIGxWFrQqQu0JvCzF/KZbUQs6s= +Received: by 10.36.96.3 with SMTP id t3mr1293802nzb; + Tue, 27 Sep 2005 06:30:14 -0700 (PDT) +Received: by 10.36.120.14 with HTTP; Tue, 27 Sep 2005 06:30:14 -0700 (PDT) +Message-ID: +Date: Tue, 27 Sep 2005 19:00:14 +0530 +From: Gnanavel S +Reply-To: Gnanavel S +To: "Jonah H. Harris" +Subject: Re: PostgreSQL overall design +Cc: pgsql-hackers@postgresql.org +In-Reply-To: <36e682920509270600439cfc4a@mail.gmail.com> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_1228_2572057.1127827814272" +References: + <20050927102701.GE1784@penne.toroid.org> + <36e682920509270600439cfc4a@mail.gmail.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.242 required=5 tests=[AWL=0.190, HTML_60_70=0.027, + HTML_MESSAGE=0.001, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200509/1283 +X-Sequence-Number: 73680 + +------=_Part_1228_2572057.1127827814272 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +On 9/27/05, Jonah H. Harris wrote: +> +> Were you looking for a call graph? + + +Yes. I want to know the list and sequence of files involved during a call. + +On 9/27/05, Abhijit Menon-Sen wrote: +> > +> > At 2005-09-27 15:20:05 +0530, s.gnanavel@gmail.com wrote: +> > > +> > > Can anyone please tell/point me where I can get the postgresql system +> > > layout (I've an interest to contribute). +> > +> > http://www.postgresql.org/developer/coding +> > +> > And, in particular: +> > +> > http://www.postgresql.org/docs/faqs.FAQ_DEV.html +> > +> > -- ams +> > +> > ---------------------------(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 +> > +> +> +> +> -- +> Respectfully, +> +> Jonah H. Harris, Database Internals Architect +> EnterpriseDB Corporation +> http://www.enterprisedb.com/ +> + + + +-- +with regards, +S.Gnanavel +Satyam Computer Services Ltd. + +------=_Part_1228_2572057.1127827814272 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +

On 9/27/05, Jonah H. Harris <j= +onah.harris@gmail.com> wrote:
+Were you looking for a call graph?

+Yes. I want to know the list and sequence of files involved during  a = +call.
+

On 9/27/05, +Abhijit Menon-Sen <ams@toroid.org<= +/a>> wrote:
+
+At 2005-09-27 15:20:05 +0530, s.gna= +navel@gmail.com wrote:
>
> Can anyone please tell/point me = +where I can get the postgresql system +
> layout (I've an interest to contribute). +

http://www.p= +ostgresql.org/developer/coding

And, in particular:

+http://www.postgresql.org/docs/faqs.FAQ_DEV.html +

-- ams

---------------------------(end of b= +roadcast)---------------------------
TIP 1: if posting/reading through U= +senet, please send an appropriate
       s= +ubscribe-nomail command to=20 + +majordomo@postgresql.org so that your
     = +  message can get through to the mailing list cleanly
= +



--
Respectfully,
= +
Jonah H. Harris, Database Internals Architect +
EnterpriseDB Corporation
ht= +tp://www.enterprisedb.com/
+ +



--
with regards,S.Gnanavel
Satyam Computer Services Ltd. + +------=_Part_1228_2572057.1127827814272-- + +From pgsql-hackers-owner@postgresql.org Wed Sep 28 10:18:30 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7D1AFD9921 + for ; + Tue, 27 Sep 2005 10:46:18 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 67096-04 + for ; + Tue, 27 Sep 2005 13:46:05 +0000 (GMT) +Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.193]) + by svr1.postgresql.org (Postfix) with ESMTP id 3CA2CD98DB + for ; + Tue, 27 Sep 2005 10:46:05 -0300 (ADT) +Received: by zproxy.gmail.com with SMTP id 40so654267nzk + for ; + Tue, 27 Sep 2005 06:46: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:in-reply-to:mime-version:content-type:references; + b=qHvzajCp8EAUpx5nO5XniB3ECCmc5b9mS5y+f/JooDqbv0OzYowUuOOxQnLYJ++lfkFkQYCVaXvZ4qXTN0bXK9ue68iOf80aEN6RSCl26eXfcT5S0bbVtCwYQ/XAI7FSgryNEH0uhNCon1JlR32iyXE/DIl3/aRobVl+Siq5e4I= +Received: by 10.36.101.9 with SMTP id y9mr421633nzb; + Tue, 27 Sep 2005 06:46:09 -0700 (PDT) +Received: by 10.36.120.14 with HTTP; Tue, 27 Sep 2005 06:46:09 -0700 (PDT) +Message-ID: +Date: Tue, 27 Sep 2005 19:16:09 +0530 +From: Gnanavel S +Reply-To: Gnanavel S +To: Andrew Dunstan +Subject: Re: PostgreSQL overall design +Cc: pgsql-hackers@postgresql.org +In-Reply-To: <4339444F.6010101@dunslane.net> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_1368_22583971.1127828769159" +References: + <4339444F.6010101@dunslane.net> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.255 required=5 tests=[AWL=0.174, HTML_30_40=0.056, + HTML_MESSAGE=0.001, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200509/1282 +X-Sequence-Number: 73679 + +------=_Part_1368_22583971.1127828769159 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +On 9/27/05, Andrew Dunstan wrote: +> +> +> [ -performance removed ] +> +> Gnanavel S wrote: +> +> > +> > Need a clarification in copydir.c file of src/port directory, In the +> > following snippet the destination directory is created first then the +> > source directory is read. Suppose if I don't have permission to read +> > the source, even then the destination directory would be created. +> > I just want to know whether there is any reason for doing so? +> > +> > +> +> +> Under what circumstances do you imagine this will happen, since the +> postmaster user owns all the files and directories? + + +Understood. But can you explain why it is done in that way as what I said +seems to be standard way of doing it (correct me if I'm wrong). + + + +-- +with regards, +S.Gnanavel + +------=_Part_1368_22583971.1127828769159 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +

On 9/27/05, Andrew Dunstan <andre= +w@dunslane.net> wrote:
+
[ -performance removed ]

Gnanavel S wrote:

>
>&n= +bsp; Need a clarification in copydir.c file of src/port directory,&nbs= +p; In the
> following snippet the destination directory is creat= +ed first then the +
> source directory is read. Suppose if I don't have permission to re= +ad
> the source, even then the destination directory would be created= +.
> I just want to know whether there is any reason for doing so? +
>
>


Under what circumstances do you imagine this wi= +ll happen, since the
postmaster user owns all the files and directories?= +

+Understood. But can you explain why it is done in that way as what I +said seems to be standard way of doing it (correct me if I'm wrong).
<= +/div>


--
with regards,
S.Gnanavel + +------=_Part_1368_22583971.1127828769159-- + +From pgsql-hackers-owner@postgresql.org Tue Sep 27 11:12:44 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DACCCD990A; + Tue, 27 Sep 2005 11:12:18 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 96170-01; Tue, 27 Sep 2005 14:12:03 +0000 (GMT) +Received: from candle.pha.pa.us (candle.pha.pa.us [64.139.89.126]) + by svr1.postgresql.org (Postfix) with ESMTP id 3A6BAD9201; + Tue, 27 Sep 2005 11:12:04 -0300 (ADT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id j8REC8u04704; + Tue, 27 Sep 2005 10:12:08 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200509271412.j8REC8u04704@candle.pha.pa.us> +Subject: Re: [PERFORM] PostgreSQL overall design +In-Reply-To: +To: Gnanavel S +Date: Tue, 27 Sep 2005 10:12:08 -0400 (EDT) +Cc: pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL121 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.01 required=5 tests=[AWL=0.010] +X-Spam-Level: +X-Archive-Number: 200509/1233 +X-Sequence-Number: 73630 + + +Have you read the developers FAQ? + +--------------------------------------------------------------------------- + +Gnanavel S wrote: +> Hi All, +> +> Can anyone please tell/point me where I can get the postgresql system layout +> (I've an interest to contribute). I would also like to know the files +> involved for performing each task ( for eg when doing a select operation +> what is exactly happening in postgres along with the files). +> +> I was wandering inside the source for a while and I couldn't get a start +> point to go with. +> +> Need a clarification in copydir.c file of src/port directory, In the +> following snippet the destination directory is created first then the source +> directory is read. Suppose if I don't have permission to read the source, +> even then the destination directory would be created. +> I just want to know whether there is any reason for doing so? +> +> if (mkdir(todir, S_IRUSR | S_IWUSR | S_IXUSR) != 0) +> ereport(ERROR, +> (errcode_for_file_access(), +> errmsg("could not create directory \"%s\": %m", todir))); +> +> xldir = AllocateDir(fromdir); +> if (xldir == NULL) +> ereport(ERROR, +> (errcode_for_file_access(), +> errmsg("could not open directory \"%s\": %m", fromdir))); +> +> +> +> -- +> with thanks & regards, +> S.Gnanavel +> Satyam Computer Services Ltd. + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-hackers-owner@postgresql.org Wed Sep 28 10:22:47 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 31311D9933 + for ; + Tue, 27 Sep 2005 11:20:42 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 97867-05 + for ; + Tue, 27 Sep 2005 14:20:33 +0000 (GMT) +Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.202]) + by svr1.postgresql.org (Postfix) with ESMTP id C8C10D992A + for ; + Tue, 27 Sep 2005 11:20:31 -0300 (ADT) +Received: by zproxy.gmail.com with SMTP id 40so664138nzk + for ; + Tue, 27 Sep 2005 07:20:37 -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=HmUJjNPpp3XGHZr1KpVE7XkbfE5I23l5Mkei2Dwzpdxv7UZOiAwenN8FHBtfp9LQMOiOzc29yYr61Om5Vm6ACTOIq0hoYbKyhwiVmjQLEdsnRZeTU0slTitOuPaTNbidY4K/k2RqNqlV+LDfp15fz1UgZV6AKk45aiQNNTNw51c= +Received: by 10.36.41.3 with SMTP id o3mr2301997nzo; + Tue, 27 Sep 2005 07:20:35 -0700 (PDT) +Received: by 10.36.120.14 with HTTP; Tue, 27 Sep 2005 07:20:35 -0700 (PDT) +Message-ID: +Date: Tue, 27 Sep 2005 19:50:35 +0530 +From: Gnanavel S +Reply-To: Gnanavel S +To: Bruce Momjian +Subject: Re: [PERFORM] PostgreSQL overall design +Cc: pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +In-Reply-To: <200509271412.j8REC8u04704@candle.pha.pa.us> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_1572_2849482.1127830835209" +References: + <200509271412.j8REC8u04704@candle.pha.pa.us> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.268 required=5 tests=[AWL=0.157, HTML_40_50=0.086, + HTML_MESSAGE=0.001, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200509/1285 +X-Sequence-Number: 73682 + +------=_Part_1572_2849482.1127830835209 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +On 9/27/05, Bruce Momjian wrote: +> +> +> Have you read the developers FAQ? + + +Thanks Bruce. I'm going through that. + +--------------------------------------------------------------------------- +> +> Gnanavel S wrote: +> > Hi All, +> > +> > Can anyone please tell/point me where I can get the postgresql system +> layout +> > (I've an interest to contribute). I would also like to know the files +> > involved for performing each task ( for eg when doing a select operatio= +n +> > what is exactly happening in postgres along with the files). +> > +> > I was wandering inside the source for a while and I couldn't get a star= +t +> > point to go with. +> > +> > Need a clarification in copydir.c file of src/port directory, In the +> > following snippet the destination directory is created first then the +> source +> > directory is read. Suppose if I don't have permission to read the +> source, +> > even then the destination directory would be created. +> > I just want to know whether there is any reason for doing so? +> > +> > if (mkdir(todir, S_IRUSR | S_IWUSR | S_IXUSR) !=3D 0) +> > ereport(ERROR, +> > (errcode_for_file_access(), +> > errmsg("could not create directory \"%s\": %m", todir))); +> > +> > xldir =3D AllocateDir(fromdir); +> > if (xldir =3D=3D NULL) +> > ereport(ERROR, +> > (errcode_for_file_access(), +> > errmsg("could not open directory \"%s\": %m", fromdir))); +> > +> > +> > +> > -- +> > with thanks & regards, +> > S.Gnanavel +> > Satyam Computer Services Ltd. +> +> -- +> Bruce Momjian | http://candle.pha.pa.us +> pgman@candle.pha.pa.us | (610) 359-1001 +> + If your life is a hard drive, | 13 Roberts Road +> + Christ can be your backup. | Newtown Square, Pennsylvania 19073 +> + + + +-- +with regards, +S.Gnanavel + +------=_Part_1572_2849482.1127830835209 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +

On 9/27/05, Bruce Momjian <pgm= +an@candle.pha.pa.us> wrote:
+
Have you read the developers FAQ?

+Thanks Bruce. I'm going through that.
+

-------= +--------------------------------------------------------------------
+Gnanavel S wrote:
> Hi All,
>
> Can anyone please tell/po= +int me where I can get the postgresql system layout
> (I've an intere= +st to contribute). I would also like to know the files
> involved for= + performing each task ( for eg when doing a select operation +
> what is exactly happening in postgres along with the files).
&g= +t;
> I was wandering inside the source for a while and I couldn't get= + a start
> point to go with.
>
> Need a clarification in= +=20 +copydir.c file of src/port directory, In the
> following snippet the = +destination directory is created first then the source
> directory is= + read. Suppose if I don't have permission to read the source,
> even = +then the destination directory would be created. +
> I just want to know whether there is any reason for doing so?
&= +gt;
> if (mkdir(todir, S_IRUSR | S_IWUSR | S_IXUSR) !=3D 0)
> e= +report(ERROR,
> (errcode_for_file_access(),
> errmsg("coul= +d not create directory \"%s\": %m", todir))); +
>
> xldir =3D AllocateDir(fromdir);
> if (xldir =3D=3D N= +ULL)
> ereport(ERROR,
> (errcode_for_file_access(),
> err= +msg("could not open directory \"%s\": %m", fromdir)));<= +br> +>
>
>
> --
> with thanks & regards,
> = +S.Gnanavel
> Satyam Computer Services Ltd.

--
  B= +ruce +Momjian           &n= +bsp;            = +;|  http://candle.pha.pa.us
  
pgman@candle.ph= +a.pa.us          &nbs= +p;    +|  (610) 359-1001
  +  If your life is a h= +ard drive,     |  13 Roberts Road
 &n= +bsp;+  Christ +can be your +backup.        |  Newtown +Square, Pennsylvania 19073



= +--
with regards,
S.Gnanavel + +------=_Part_1572_2849482.1127830835209-- + +From pgsql-performance-owner@postgresql.org Tue Sep 27 11:35:36 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BB312D98DB + for ; + Tue, 27 Sep 2005 11:35:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 04137-08 + for ; + Tue, 27 Sep 2005 14:35:21 +0000 (GMT) +Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) + by svr1.postgresql.org (Postfix) with ESMTP id 9F911D9201 + for ; + Tue, 27 Sep 2005 11:35:22 -0300 (ADT) +Received: from mainbox.archonet.com + (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) + by smtp.metronet.co.uk (MetroNet Mail) with ESMTP + id A0D5F415CAF; Tue, 27 Sep 2005 15:35:16 +0100 (BST) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mainbox.archonet.com (Postfix) with ESMTP id A315E15F1D; + Tue, 27 Sep 2005 15:34:08 +0100 (BST) +Received: from mainbox.archonet.com ([127.0.0.1]) + by localhost (mainbox [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 18628-01; Tue, 27 Sep 2005 15:34:03 +0100 (BST) +Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP id 12F9E15F1C; + Tue, 27 Sep 2005 15:34:02 +0100 (BST) +Message-ID: <4339585A.9040507@archonet.com> +Date: Tue, 27 Sep 2005 15:34:02 +0100 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: =?windows-1251?Q?=C0=ED=E4=F0=E5=E9_=D0=E5=EF=EA=EE?= + +Cc: pgsql-performance@postgresql.org +Subject: Re: Index not used on group by +References: <144520928.20050927121431@sart.must-ipra.com> + <4339236F.7070403@archonet.com> + <6110500029.20050927135716@sart.must-ipra.com> + <4339282F.1060900@archonet.com> + <4010683035.20050927143731@sart.must-ipra.com> +In-Reply-To: <4010683035.20050927143731@sart.must-ipra.com> +Content-Type: text/plain; charset=windows-1251; format=flowed +Content-Transfer-Encoding: quoted-printable +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.057 required=5 tests=[AWL=0.007, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/377 +X-Sequence-Number: 14685 + +=C0=ED=E4=F0=E5=E9 =D0=E5=EF=EA=EE wrote: +> =C7=E4=F0=E0=E2=F1=F2=E2=F3=E9=F2=E5 Richard, +>=20 +> Tuesday, September 27, 2005, 2:08:31 PM, =C2=FB =EF=E8=F1=E0=EB=E8: +>=20 +>=20 +>=20 +>>>sart_ma=3D# EXPLAIN ANALYZE SELECT alias_id FROM ma_data GROUP BY alia= +s_id; +>>> QUERY PLAN +>>>----------------------------------------------------------------------= +--------------------------------------------------- +>>> HashAggregate (cost=3D38565.30..38565.62 rows=3D32 width=3D4) +>>>(actual time=3D15990.863..15990.933 rows=3D32 loops=3D1) +>>> -> Seq Scan on ma_data (cost=3D0.00..37811.24 rows=3D301624 +>>>width=3D4) (actual time=3D3.446..14572.141 rows=3D301624 loops=3D1) +>>> Total runtime: 15991.244 ms +>=20 +>=20 +> RH> OK - the planner thinks it's doing the right thing, your cost estim= +ates +> RH> are way off. If you look back at where you got an index-scan, it's = +cost +> RH> was 1.1 million. +> RH> Index Scan using reference_9_fk on ma_data (cost=3D0.00..1139526= +=2E57 +> But why PG scan _all_ the records in the table? As I understand we can +> "just" select information from index, not scaning all the table? Of +> course if we select ALL records from table index can't help us. + +Actually, if you select more than 5-10% of the rows (in general) you are = + +better off using a seq-scan. + +PostgreSQL estimates the total cost of possible query plans and picks=20 +the cheapest. In your case your configuration settings seem to be=20 +pushing the cost of an index scan much higher than it is. So, it picks=20 +the sequential-scan. + +> If I write something like: +> SELECT (SELECT alias_id FROM ma_data WHERE alias_id =3D1 LIMIT 1) +> UNION ALL SELECT (SELECT alias_id FROM ma_data WHERE alias_id =3D2 LI= +MIT 1) +> UNION ALL SELECT (SELECT alias_id FROM ma_data WHERE alias_id =3D3 LI= +MIT 1) +> UNION ALL SELECT (SELECT alias_id FROM ma_data WHERE alias_id =3D4 LI= +MIT 1) +> UNION ALL SELECT (SELECT alias_id FROM ma_data WHERE alias_id =3D5 LI= +MIT 1) +> UNION ALL SELECT (SELECT alias_id FROM ma_data WHERE alias_id =3D6 LI= +MIT 1) +> UNION ALL SELECT (SELECT alias_id FROM ma_data WHERE alias_id =3D7 LI= +MIT 1) +> UNION ALL SELECT (SELECT alias_id FROM ma_data WHERE alias_id =3D8 LI= +MIT 1) +> UNION ALL SELECT (SELECT alias_id FROM ma_data WHERE alias_id =3D9 LI= +MIT 1) +> ... +> UNION ALL SELECT (SELECT alias_id FROM ma_data WHERE alias_id=3Dmax_a= +lias_id LIMIT 1) +> It works better, much better. + +Of course - it will always choose index queries here - it can see you=20 +are only fetching one row in each subquery. + +Correct your configuration settings so PG estimates the cost of an index = + + query correctly and all should be well. +-- + Richard Huxton + Archonet Ltd + + +From pgsql-performance-owner@postgresql.org Tue Sep 27 12:12:45 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 10796D9925 + for ; + Tue, 27 Sep 2005 12:12:43 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 31717-10 + for ; + Tue, 27 Sep 2005 15:12:37 +0000 (GMT) +Received: from netbox.unitech.com.ar (unknown [200.32.92.34]) + by svr1.postgresql.org (Postfix) with ESMTP id C7E14D9921 + for ; + Tue, 27 Sep 2005 12:12:33 -0300 (ADT) +Received: from dariop (dariop.unitech.com.ar [192.168.1.237]) + by netbox.unitech.com.ar (8.11.6/8.11.6) with ESMTP id j8RGLbG20120 + for ; Tue, 27 Sep 2005 12:21:37 -0400 +Received: from 127.0.0.1 (AVG SMTP 7.0.344 [267.11.7]); + Tue, 27 Sep 2005 12:12:53 -0300 +From: "Dario" +To: +Subject: Re: slow database, queries accumulating +Date: Tue, 27 Sep 2005 12:12:53 -0300 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) +In-Reply-To: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF785026FFDE1@vt-pe2550-001.vantage.vantage.com> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506 +Importance: Normal +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.056 required=5 tests=[AWL=0.056] +X-Spam-Level: +X-Archive-Number: 200509/378 +X-Sequence-Number: 14686 + +I have read that 600 connections are a LOT (somebody correct me please if +I'm wrong), since each connections requires a process and your server must +serve this. Besides the overhead involved, you will end up with 1200 +megabytes of sort_mem allocated (probably idle most of time)... + +pgpool allows you to reuse process (similar to oracle shared servers). Fact: +I didn't have the need to use it. AFAICS, it's easy to use. (I'll try to +make it work and I'll share tests, but dunno know when) + +long life, little spam and prosperity + + +-----Mensaje original----- +De: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org]En nombre de Anjan Dave +Enviado el: viernes, 23 de septiembre de 2005 13:02 +Para: pgsql-performance@postgresql.org +Asunto: [PERFORM] slow database, queries accumulating + + +Hi + +We are experiencing consistent slowness on the database for one application. +This is more a reporting type of application, heavy on the bytea data type +usage (gets rendered into PDFs in the app server). A lot of queries, mostly +selects and a few random updates, get accumulated on the server - with +increasing volume of users on the application. Below is a snapshot of top, +with about 80 selects and 3 or 4 updates. Things get better eventually if I +cancel (SIGINT) some of the oldest queries. I also see a few instances of +shared locks not being granted during this time.I don't even see high iowait +or memory starvation during these times, as indicated by top. + +-bash-2.05b$ psql -c "select * from pg_locks;" dbname | grep f + | | 77922136 | 16761 | ShareLock | f + + + +We (development) are looking into the query optimization (explain analyze, +indexes, etc), and my understanding is that the queries when run for explain +analyze execute fast, but during busy times, they become quite slow, taking +from a few seconds to a few minutes to execute. I do see in the log that +almost all queries do have either ORDER BY, or GROUP BY, or DISTINCT. Does +it hurt to up the sort_mem to 3MB or 4MB? Should I up the +effective_cache_size to 5 or 6GB? The app is does not need a lot of +connections on the database, I can reduce it down from 600. + +Based on the description above and the configuration below does any thing +appear bad in config? Is there anything I can try in the configuration to +improve performance? + + +The database size is about 4GB. +This is PG 7.4.7, RHAS3.0 (u5), Local 4 spindle RAID10 (15KRPM), and logs on +a separate set of drives, RAID10. 6650 server, 4 x XEON, 12GB RAM. +Vacuum is done every night, full vacuum done once a week. +I had increased the shared_buffers and sort_memory recently, which didn't +help. + +Thanks, +Anjan + + + + +10:44:51 up 14 days, 13:38, 2 users, load average: 0.98, 1.14, 1.12 +264 processes: 257 sleeping, 7 running, 0 zombie, 0 stopped +CPU states: cpu user nice system irq softirq iowait idle + total 14.4% 0.0% 7.4% 0.0% 0.0% 0.0% 77.9% + cpu00 15.7% 0.0% 5.7% 0.0% 0.1% 0.0% 78.2% + cpu01 15.1% 0.0% 7.5% 0.0% 0.0% 0.1% 77.0% + cpu02 10.5% 0.0% 5.9% 0.0% 0.0% 0.0% 83.4% + cpu03 9.9% 0.0% 5.9% 0.0% 0.0% 0.0% 84.0% + cpu04 7.9% 0.0% 3.7% 0.0% 0.0% 0.0% 88.2% + cpu05 19.3% 0.0% 12.3% 0.0% 0.0% 0.0% 68.3% + cpu06 20.5% 0.0% 9.5% 0.0% 0.0% 0.1% 69.7% + cpu07 16.1% 0.0% 8.5% 0.0% 0.1% 0.3% 74.7% +Mem: 12081736k av, 7881972k used, 4199764k free, 0k shrd, 82372k +buff + 4823496k actv, 2066260k in_d, 2036k in_c +Swap: 4096532k av, 0k used, 4096532k free 6888900k +cached + + PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME CPU COMMAND +16773 postgres 15 0 245M 245M 240M S 0.0 2.0 1:16 7 postmaster +16880 postgres 15 0 245M 245M 240M S 0.1 2.0 0:49 6 postmaster +16765 postgres 15 0 245M 245M 240M S 0.0 2.0 1:16 0 postmaster +16825 postgres 15 0 245M 245M 240M S 0.0 2.0 1:02 5 postmaster +16774 postgres 15 0 245M 245M 240M S 0.1 2.0 1:16 0 postmaster +16748 postgres 15 0 245M 245M 240M S 0.0 2.0 1:19 5 postmaster +16881 postgres 15 0 245M 245M 240M S 0.1 2.0 0:50 7 postmaster +16762 postgres 15 0 245M 245M 240M S 0.0 2.0 1:14 4 postmaster +. +. + + +max_connections = 600 + +shared_buffers = 30000 #=234MB, up from 21760=170MB min 16, at least +max_connections*2, 8KB each +sort_mem = 2048 # min 64, size in KB +vacuum_mem = 32768 # up from 16384 min 1024, size in KB + +# - Free Space Map - + +#max_fsm_pages = 20000 # min max_fsm_relations*16, 6 bytes each +#max_fsm_relations = 1000 # min 100, ~50 bytes each + +#fsync = true # turns forced synchronization on or off +#wal_sync_method = fsync # the default varies across platforms: + # fsync, fdatasync, open_sync, or +open_datasync +#wal_buffers = 8 # min 4, 8KB each + +# - Checkpoints - + +checkpoint_segments = 125 # in logfile segments, min 1, 16MB each +checkpoint_timeout = 600 # range 30-3600, in seconds +#checkpoint_warning = 30 # 0 is off, in seconds +#commit_delay = 0 # range 0-100000, in microseconds +#commit_siblings = 5 # range 1-1000 + + + +# - Planner Method Enabling - + +#enable_hashagg = true +#enable_hashjoin = true +#enable_indexscan = true +#enable_mergejoin = true +#enable_nestloop = true +#enable_seqscan = true +#enable_sort = true +#enable_tidscan = true + +# - Planner Cost Constants - + +effective_cache_size = 262144 # =2GB typically 8KB each +#random_page_cost = 4 # units are one sequential page fetch cost +#cpu_tuple_cost = 0.01 # (same) +#cpu_index_tuple_cost = 0.001 # (same) +#cpu_operator_cost = 0.0025 # (same) + +# - Genetic Query Optimizer - + +#geqo = true +#geqo_threshold = 11 +#geqo_effort = 1 +#geqo_generations = 0 +#geqo_pool_size = 0 # default based on tables in statement, + # range 128-1024 +#geqo_selection_bias = 2.0 # range 1.5-2.0 + +# - Other Planner Options - + +#default_statistics_target = 10 # range 1-1000 +#from_collapse_limit = 8 +#join_collapse_limit = 8 # 1 disables collapsing of explicit JOINs + + + + +From pgsql-hackers-owner@postgresql.org Wed Sep 28 10:17:56 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A83A9D990A; + Tue, 27 Sep 2005 12:22:02 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 35240-10; Tue, 27 Sep 2005 15:21:52 +0000 (GMT) +Received: from gwmta.wicourts.gov (gwmta.wicourts.gov [165.219.244.91]) + by svr1.postgresql.org (Postfix) with ESMTP id A97ACD9201; + Tue, 27 Sep 2005 12:21:50 -0300 (ADT) +Received: from Courts-MTA by gwmta.wicourts.gov + with Novell_GroupWise; Tue, 27 Sep 2005 10:21:49 -0500 +Message-Id: +X-Mailer: Novell GroupWise Internet Agent 6.5.4 +Date: Tue, 27 Sep 2005 10:21:37 -0500 +From: "Kevin Grittner" +To: , , + , +Subject: Re: [PERFORM] A Better External Sort? +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.004 required=5 tests=[AWL=0.004] +X-Spam-Level: +X-Archive-Number: 200509/1280 +X-Sequence-Number: 73677 + +I can't help wondering how a couple thousand context switches per +second would affect the attempt to load disk info into the L1 and +L2 caches. That's pretty much the low end of what I see when the +server is under any significant load. + + + +From pgsql-hackers-owner@postgresql.org Tue Sep 27 13:16:02 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AB65BD98F9; + Tue, 27 Sep 2005 13:15:18 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 52418-06; Tue, 27 Sep 2005 16:15:13 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 68720D98DB; + Tue, 27 Sep 2005 13:15:12 -0300 (ADT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [63.195.55.98] (HELO [192.168.0.37]) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 8161407; Tue, 27 Sep 2005 09:17:35 -0700 +Message-ID: <4339700A.2030803@agliodbs.com> +Date: Tue, 27 Sep 2005 09:15:06 -0700 +From: Josh Berkus +User-Agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Ron Peacetree +Cc: Dann Corbit , pgsql-hackers@postgresql.org, + pgsql-performance@postgresql.org +Subject: Re: [PERFORM] A Better External Sort? +References: + <19483839.1127783447942.JavaMail.root@elwamui-polski.atl.sa.earthlink.net> +In-Reply-To: + <19483839.1127783447942.JavaMail.root@elwamui-polski.atl.sa.earthlink.net> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/1240 +X-Sequence-Number: 73637 + +Ron, + +I've somehow missed part of this thread, which is a shame since this is +an area of primary concern for me. + +Your suggested algorithm seems to be designed to relieve I/O load by +making more use of the CPU. (if I followed it correctly). However, +that's not PostgreSQL's problem; currently for us external sort is a +*CPU-bound* operation, half of which is value comparisons. (oprofiles +available if anyone cares) + +So we need to look, instead, at algorithms which make better use of +work_mem to lower CPU activity, possibly even at the expense of I/O. + +--Josh Berkus + +From pgsql-performance-owner@postgresql.org Tue Sep 27 13:21:24 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EF9D7D993E + for ; + Tue, 27 Sep 2005 13:21:21 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 69815-01 + for ; + Tue, 27 Sep 2005 16:21:16 +0000 (GMT) +Received: from netbox.unitech.com.ar (unknown [200.32.92.34]) + by svr1.postgresql.org (Postfix) with ESMTP id C7F93D9964 + for ; + Tue, 27 Sep 2005 13:21:11 -0300 (ADT) +Received: from dariop (dariop.unitech.com.ar [192.168.1.237]) + by netbox.unitech.com.ar (8.11.6/8.11.6) with ESMTP id j8RHTpG20764; + Tue, 27 Sep 2005 13:29:52 -0400 +Received: from 127.0.0.1 (AVG SMTP 7.0.344 [267.11.7]); + Tue, 27 Sep 2005 13:21:07 -0300 +From: "Dario" +To: "Stef" , "Bruno Wolff III" +Cc: "Markus Benne" , + +Subject: Re: VACUUM FULL vs CLUSTER +Date: Tue, 27 Sep 2005 13:21:07 -0300 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) +In-Reply-To: <20050923191803.14fff2a1@svb.ucs.co.za> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506 +Importance: Normal +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.054 required=5 tests=[AWL=0.054] +X-Spam-Level: +X-Archive-Number: 200509/381 +X-Sequence-Number: 14689 + +you can see that at the end of vacuum log (sorry for my english) +... +INFO: free space map: 930 relations, 48827 pages stored; 60240 total pages +needed -- NEEDED! +-- I have already configured in postgresql.conf, you can see it below +DETAIL: Allocated FSM size: 1000 relations + 70000 pages = 475 kB shared +memory. -- ALLOCATED ACCORDING TO max_fsm_pages , etc +VACUUM + +You probably must adjust your shared memory, coz the database need it, but +it depends on your database... + +(I could be wrong, I'm learning postgresql, please, feel free to correct me) + +-----Mensaje original----- +De: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org]En nombre de Stef +Enviado el: viernes, 23 de septiembre de 2005 14:18 +Para: Bruno Wolff III +CC: Markus Benne; pgsql-performance@postgresql.org +Asunto: Re: [PERFORM] VACUUM FULL vs CLUSTER + + + +Bruno Wolff III mentioned : +=> > => If you have a proper FSM setting you shouldn't need to do vacuum +fulls +=> > => (unless you have an older version of postgres where index bloat +might +=> > => be an issue). + +Thanks Alvaro and Bruno + +I just want to clarify something that I also couldn't +find a clear cut answer for before. + +What is a proper fsm setting? + +Someone told me to set max_fsm_relations to the number of +relations in pg_class plus a few more to allow for new relations. +And max_fsm_pages to the number of rows in the biggest table I +want to vacuum, plus a few 1000's for extra room? + +Where does this free space map sit? On the disk somewhere, +or in memory, or both. + +I once set the max_fsm_pages very high by mistake, and postgres +then started up and used a _lot_ of shared memory, and I had to +increase shmmax. Is there abything to watch out for when bumping this +setting up a lot? + +Kind Regards +Stefan + +---------------------------(end of broadcast)--------------------------- +TIP 5: don't forget to increase your free space map settings + + +From pgsql-hackers-owner@postgresql.org Wed Sep 28 10:22:49 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 745B9D95DD; + Tue, 27 Sep 2005 14:15:55 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 58169-01; Tue, 27 Sep 2005 17:15:51 +0000 (GMT) +Received: from pop-knobcone.atl.sa.earthlink.net + (pop-knobcone.atl.sa.earthlink.net [207.69.195.64]) + by svr1.postgresql.org (Postfix) with ESMTP id 4B9E8D777B; + Tue, 27 Sep 2005 14:15:46 -0300 (ADT) +Received: from elwamui-polski.atl.sa.earthlink.net ([209.86.224.45]) + by pop-knobcone.atl.sa.earthlink.net with esmtp (Exim 3.36 #10) + id 1EKJ3K-000692-00; Tue, 27 Sep 2005 13:15:38 -0400 +Message-ID: + <6620549.1127841338151.JavaMail.root@elwamui-polski.atl.sa.earthlink.net> +Date: Tue, 27 Sep 2005 13:15:38 -0400 (EDT) +From: Ron Peacetree +Reply-To: Ron Peacetree +To: Josh Berkus , pgsql-hackers@postgresql.org, + pgsql-performance@postgresql.org +Subject: Re: [PERFORM] A Better External Sort? +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Mailer: Earthlink Zoo Mail 1.0 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.26 required=5 tests=[AWL=-0.114, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200509/1286 +X-Sequence-Number: 73683 + +>From: Josh Berkus +>ent: Sep 27, 2005 12:15 PM +>To: Ron Peacetree +>Subject: Re: [HACKERS] [PERFORM] A Better External Sort? +> +>I've somehow missed part of this thread, which is a shame since this is +>an area of primary concern for me. +> +>Your suggested algorithm seems to be designed to relieve I/O load by +>making more use of the CPU. (if I followed it correctly). +> +The goal is to minimize all IO load. Not just HD IO load, but also RAM +IO load. Particularly random access IO load of any type (for instance: +"the pointer chasing problem"). + +In addition, the design replaces explicit data or explicit key manipulation +with the creation of a smaller, far more CPU and IO efficient data +structure (essentially a CPU cache friendly Btree index) of the sorted +order of the data. + +That Btree can be used to generate a physical reordering of the data +in one pass, but that's the weakest use for it. The more powerful +uses involve allowing the Btree to persist and using it for more +efficient re-searches or combining it with other such Btrees (either as +a step in task distribution across multiple CPUs or as a more efficient +way to do things like joins by manipulating these Btrees rather than +the actual records.) + + +>However, that's not PostgreSQL's problem; currently for us external +>sort is a *CPU-bound* operation, half of which is value comparisons. +>(oprofiles available if anyone cares) +> +>So we need to look, instead, at algorithms which make better use of +>work_mem to lower CPU activity, possibly even at the expense of I/O. +> +I suspect that even the highly efficient sorting code we have is +suffering more pessimal CPU IO behavior than what I'm presenting. +Jim Gray's external sorting contest web site points out that memory IO +has become a serious problem for most of the contest entries. + +Also, I'll bet the current code manipulates more data. + +Finally, there's the possibilty of reusing the product of this work to a +degree and in ways that we can't with our current sorting code. + + +Now all we need is resources and time to create a prototype. +Since I'm not likely to have either any time soon, I'm hoping that +I'll be able to explain this well enough that others can test it. + +*sigh* I _never_ have enough time or resources any more... +Ron + + + +From pgsql-hackers-owner@postgresql.org Tue Sep 27 14:27:01 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E470CD989E; + Tue, 27 Sep 2005 14:26:46 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 61047-02; Tue, 27 Sep 2005 17:26:37 +0000 (GMT) +Received: from gghcwest.com (adsl-71-128-90-172.dsl.pltn13.pacbell.net + [71.128.90.172]) + by svr1.postgresql.org (Postfix) with ESMTP id 254E8D967F; + Tue, 27 Sep 2005 14:26:35 -0300 (ADT) +Received: from toonses.gghcwest.com (toonses.gghcwest.com [192.168.168.115]) + by gghcwest.com (8.12.10/8.12.9) with ESMTP id j8RHQRmd027746; + Tue, 27 Sep 2005 10:26:28 -0700 +Received: from jwb by toonses.gghcwest.com with local (Exim 4.52) + id 1EKJDo-0002N9-Ox; Tue, 27 Sep 2005 10:26:28 -0700 +Subject: Re: [PERFORM] A Better External Sort? +From: "Jeffrey W. Baker" +To: Ron Peacetree +Cc: Josh Berkus , pgsql-hackers@postgresql.org, + pgsql-performance@postgresql.org +In-Reply-To: + <6620549.1127841338151.JavaMail.root@elwamui-polski.atl.sa.earthlink.net> +References: + <6620549.1127841338151.JavaMail.root@elwamui-polski.atl.sa.earthlink.net> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Date: Tue, 27 Sep 2005 10:26:28 -0700 +Message-Id: <1127841988.8965.3.camel@toonses.gghcwest.com> +Mime-Version: 1.0 +X-Mailer: Evolution 2.4.0 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=-0.544 required=5 tests=[AWL=-0.594, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/1245 +X-Sequence-Number: 73642 + +On Tue, 2005-09-27 at 13:15 -0400, Ron Peacetree wrote: + +> That Btree can be used to generate a physical reordering of the data +> in one pass, but that's the weakest use for it. The more powerful +> uses involve allowing the Btree to persist and using it for more +> efficient re-searches or combining it with other such Btrees (either as +> a step in task distribution across multiple CPUs or as a more efficient +> way to do things like joins by manipulating these Btrees rather than +> the actual records.) + +Maybe you could describe some concrete use cases. I can see what you +are getting at, and I can imagine some advantageous uses, but I'd like +to know what you are thinking. + +Specifically I'd like to see some cases where this would beat sequential +scan. I'm thinking that in your example of a terabyte table with a +column having only two values, all the queries I can think of would be +better served with a sequential scan. + +Perhaps I believe this because you can now buy as much sequential I/O as +you want. Random I/O is the only real savings. + +-jwb + + + +From pgsql-performance-owner@postgresql.org Tue Sep 27 15:23:38 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 672F9D9946 + for ; + Tue, 27 Sep 2005 15:23:36 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 84902-01 + for ; + Tue, 27 Sep 2005 18:23:26 +0000 (GMT) +Received: from covilha.procergs.com.br (covilha.procergs.com.br + [200.198.128.212]) + by svr1.postgresql.org (Postfix) with ESMTP id B7B92D9945 + for ; + Tue, 27 Sep 2005 15:23:25 -0300 (ADT) +Received: from modem.sistemica (unknown [201.10.16.156]) + by covilha.procergs.com.br (Postfix) with ESMTP id 00C411D382344 + for ; + Tue, 27 Sep 2005 15:09:39 -0300 (BRST) +Received: from [192.168.200.41] (unknown [192.168.200.41]) + by modem.sistemica (Postfix) with ESMTP id 5239D13F614 + for ; + Tue, 27 Sep 2005 14:59:51 -0300 (BRT) +Received: from 127.0.0.1 (AVG SMTP 7.0.344 [267.11.5]); + Tue, 27 Sep 2005 15:01:24 -0300 +Message-ID: <001101c5c38d$793eefe0$29c8a8c0@sistemica> +Reply-To: "Everton" +From: "Everton" +To: +Subject: Delphi connection ADO is slow +Date: Tue, 27 Sep 2005 15:01:24 -0300 +Organization: =?iso-8859-1?Q?Sist=EAmica?= +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1409 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 +Mime-Version: 1.0 +Content-Type: multipart/mixed; boundary="=======AVGMAIL-433988F4541C=======" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.051 required=5 tests=[FORGED_RCVD_HELO=0.05, + HTML_MESSAGE=0.001] +X-Spam-Level: +X-Archive-Number: 200509/384 +X-Sequence-Number: 14692 + +--=======AVGMAIL-433988F4541C======= +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_000E_01C5C374.53E0EF00" + +------=_NextPart_000_000E_01C5C374.53E0EF00 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: quoted-printable + +Hello, + +My connection ADO is very, very, very slow....=20 + +My Delphi connection saw ADO is very slow. All SQL that I execute delay = +big, I tested in pgadmin and the reply is instantaned, the problem this = +in the Delphi? =20 + +Tanks! +------=_NextPart_000_000E_01C5C374.53E0EF00 +Content-Type: text/html; charset=iso-8859-1 +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
Hello,
+
 
+
My connection ADO is very, very, very = +slow....=20 +
+
 
+
My Delphi connection saw ADO is very = +slow. =20 +All SQL that I execute delay big, I tested in pgadmin and the reply = +is=20 +instantaned, the problem this in the Delphi? 
+
 
+
Tanks!
+ +------=_NextPart_000_000E_01C5C374.53E0EF00-- + +--=======AVGMAIL-433988F4541C======= +Content-Type: text/plain; x-avg=cert; charset=us-ascii +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +Content-Description: "AVG certification" + +No virus found in this outgoing message. +Checked by AVG Anti-Virus. +Version: 7.0.344 / Virus Database: 267.11.5/110 - Release Date: 22/09/2005 + +--=======AVGMAIL-433988F4541C=======-- + +From pgsql-performance-owner@postgresql.org Wed Sep 28 00:33:45 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DA418D8B43 + for ; + Wed, 28 Sep 2005 00:33:42 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 46632-05 + for ; + Wed, 28 Sep 2005 03:33:41 +0000 (GMT) +Received: from mail.nordicbet.com (mail.nordicbet.com [193.69.167.130]) + by svr1.postgresql.org (Postfix) with ESMTP id CC212D85EC + for ; + Wed, 28 Sep 2005 00:33:40 -0300 (ADT) +Received: from [80.203.125.83] (helo=tobias.nordicbet.invalid) + (Authenticated Sender=tobias@nordicbet.com) + by mail.nordicbet.com with esmtpa (Exim 4.50 #1 (Debian)) + id 1EKSdw-00079A-TO + for ; Wed, 28 Sep 2005 05:30:14 +0200 +Received: by tobias.nordicbet.invalid (Postfix, from userid 500) + id 531F0504C; Wed, 28 Sep 2005 05:33:28 +0200 (CEST) +Date: Wed, 28 Sep 2005 05:33:27 +0200 +From: Tobias Brox +To: pgsql-performance@postgresql.org +Subject: The need for full vacuum / reindex +Message-ID: <20050928033327.GU5679@tobias.lan> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +Organization: Group Nordicbet +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/385 +X-Sequence-Number: 14693 + +By occation, we dropped the whole production database and refreshed it from +a database backup - and all our performance problems seems to have gone. I +suppose this means that to keep the database efficient, one eventually does +have to do reindexing and/or full vacuum from time to time? + +-- +Notice of Confidentiality: This email is sent unencrypted over the network, +and may be stored on several email servers; it can be read by third parties +as easy as a postcard. Do not rely on email for confidential information. + +From pgsql-performance-owner@postgresql.org Wed Sep 28 01:15:54 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D58EED92E7 + for ; + Wed, 28 Sep 2005 01:15:53 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 56155-10 + for ; + Wed, 28 Sep 2005 04:15:51 +0000 (GMT) +Received: from wolff.to (wolff.to [66.93.197.194]) + by svr1.postgresql.org (Postfix) with SMTP id DE6F6D71EA + for ; + Wed, 28 Sep 2005 01:15:50 -0300 (ADT) +Received: (qmail 1136 invoked by uid 500); 28 Sep 2005 04:16:45 -0000 +Date: Tue, 27 Sep 2005 23:16:45 -0500 +From: Bruno Wolff III +To: Tobias Brox +Cc: pgsql-performance@postgresql.org +Subject: Re: The need for full vacuum / reindex +Message-ID: <20050928041645.GA956@wolff.to> +Mail-Followup-To: Bruno Wolff III , + Tobias Brox , pgsql-performance@postgresql.org +References: <20050928033327.GU5679@tobias.lan> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20050928033327.GU5679@tobias.lan> +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 required=5 tests=[AWL=0.007] +X-Spam-Level: +X-Archive-Number: 200509/386 +X-Sequence-Number: 14694 + +On Wed, Sep 28, 2005 at 05:33:27 +0200, + Tobias Brox wrote: +> By occation, we dropped the whole production database and refreshed it from +> a database backup - and all our performance problems seems to have gone. I +> suppose this means that to keep the database efficient, one eventually does +> have to do reindexing and/or full vacuum from time to time? + +Normally you only need to do that if you didn't vacuum often enough or with +high enough fsm setting and bloat has gotten out of hand to the point that +you need to recover some space. + +From pgsql-general-owner@postgresql.org Wed Sep 28 04:08:19 2005 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4D878D9A19 + for ; + Wed, 28 Sep 2005 04:07:13 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 94905-04 + for ; + Wed, 28 Sep 2005 07:07:08 +0000 (GMT) +Received: from qproxy.gmail.com (qproxy.gmail.com [72.14.204.195]) + by svr1.postgresql.org (Postfix) with ESMTP id 81B71D987E + for ; + Wed, 28 Sep 2005 04:07:08 -0300 (ADT) +Received: by qproxy.gmail.com with SMTP id v40so298352qbe + for ; + Wed, 28 Sep 2005 00:07:07 -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:mime-version:content-type; + b=bajyxqNhaBDUZBFaJMKk7g7Xz4LPzI5Eg9XxRwrOrY1AT0ZjrAbbgnayljAZlGusBPMNyOm8xGZZ0UAOLk3J2CHUTtxiBdGICbKmz7b1VokULk+X46V+eN6rrNJXTM8C98GT4n1AT1QoZXno+aHtn941HhgR8fVSWga7GdY4OVs= +Received: by 10.64.213.16 with SMTP id l16mr916101qbg; + Wed, 28 Sep 2005 00:07:07 -0700 (PDT) +Received: by 10.64.195.4 with HTTP; Wed, 28 Sep 2005 00:07:07 -0700 (PDT) +Message-ID: <9e4684ce05092800075d37d0cc@mail.gmail.com> +Date: Wed, 28 Sep 2005 09:07:07 +0200 +From: hubert depesz lubaczewski +Reply-To: hubert depesz lubaczewski +To: PostgreSQL General , + pgsqlperform +Subject: database bloat, but vacuums are done, and fsm seems to be setup ok +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_1249_15693059.1127891227369" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.995 required=5 tests=[HTML_00_10=0.138, + HTML_MESSAGE=0.001, RCVD_BY_IP=0.024, RCVD_IN_BL_SPAMCOP_NET=1.832] +X-Spam-Level: * +X-Archive-Number: 200509/1092 +X-Sequence-Number: 84107 + +------=_Part_1249_15693059.1127891227369 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +hi +setup: +postgresql 8.0.3 put on debian on dual xeon, 8GB ram, hardware raid. + +database just after recreation from dump takes 15gigabytes. +after some time (up to 3 weeks) it gets really slow and has to be dump'ed +and restored. + +as for fsm: +end of vacuum info: +INFO: free space map: 248 relations, 1359140 pages stored; 1361856 total +pages needed +DETAIL: Allocated FSM size: 1000 relations + 10000000 pages =3D 58659 kB +shared memory. + +so it looks i have plenty of space in fsm. + +vacuums run constantly. +4 different tasks, 3 of them doing: +while true +vacuum table +sleep 15m +done +with different tables (i have chooses the most updated tables in system). + +and the fourth vacuum task does the same, but without specifying table - so +it vacuumes whole database. + +after last dump/restore cycle i noticed that doing reindex on all indices i= +n +database made it drop in side from 40G to about 20G - so it might be that i +will be using reindex instead of drop/restore. +anyway - i'm not using any special indices - just some (117 to be exact) +indices of btree type. we use simple, multi-column, partial and multi-colum= +n +partial indices. we do not have functional indices. + +database has quite huge load of updates, but i thought that vacum will guar= +d +me from database bloat, but from what i observed it means that vacuuming of +b-tree indices is somewhat faulty. + +any suggestions? what else can i supply you with to help you help me? + +best regards + +depesz + +------=_Part_1249_15693059.1127891227369 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +hi
+setup:
+postgresql 8.0.3 put on debian on dual xeon, 8GB ram, hardware raid.
+
+database just after recreation from dump takes 15gigabytes.
+after some time (up to 3 weeks) it gets really slow and has to be dump'ed a= +nd restored.
+
+as for fsm:
+end of vacuum info:
+INFO:  free space map: 248 relations, 1359140 pages stored; 1361856 to= +tal pages needed
+DETAIL:  Allocated FSM size: 1000 relations + 10000000 pages =3D 58659= + kB shared memory.
+
+so it looks i have plenty of space in fsm.
+
+vacuums run constantly.
+4 different tasks, 3 of them doing:
+while true
+vacuum table
+sleep 15m
+done
+with different tables (i have chooses the most updated tables in system). +
+and the fourth vacuum task does the same, but without specifying table - so= + it vacuumes whole database.
+
+after last dump/restore cycle i noticed that doing reindex on all +indices in database made it drop in side from 40G to about 20G - so it +might be that i will be using reindex instead of drop/restore.
+anyway - i'm not using any special indices - just some (117 to be +exact) indices of btree type. we use simple, multi-column, partial and +multi-column partial indices. we do not have functional indices.
+
+database has quite huge load of updates, but i thought that vacum will +guard me from database bloat, but from what i observed it means that +vacuuming of b-tree indices is somewhat faulty.
+
+any suggestions? what else can i supply you with to help you help me?
+
+best regards
+
+depesz
+ +------=_Part_1249_15693059.1127891227369-- + +From pgsql-performance-owner@postgresql.org Wed Sep 28 09:27:42 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5C352D9A80 + for ; + Wed, 28 Sep 2005 09:27:41 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 94838-03 + for ; + Wed, 28 Sep 2005 12:27:31 +0000 (GMT) +Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.202]) + by svr1.postgresql.org (Postfix) with ESMTP id 3A8E0D9A93 + for ; + Wed, 28 Sep 2005 09:27:32 -0300 (ADT) +Received: by xproxy.gmail.com with SMTP id i30so1467487wxd + for ; + Wed, 28 Sep 2005 05:27:37 -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:mime-version:content-type:content-transfer-encoding:content-disposition; + b=EBmqXakAEXHu0SB9IrKEHxJUpCPBjyMtSRd/S1KdPi6mU25i/ylXxxUqwl/DdQyyU3gJNVO/VzaYwmu8Ff9wno8ZYVkGrWV6XnsRq2iaptCsJnZ1legyhLYtb9EgcreIb3dk//xK8HJcyqaHYdcDuTP4oSM115sBc8i+0+bPI/E= +Received: by 10.70.102.12 with SMTP id z12mr3447356wxb; + Wed, 28 Sep 2005 05:27:37 -0700 (PDT) +Received: by 10.70.75.4 with HTTP; Wed, 28 Sep 2005 05:27:36 -0700 (PDT) +Message-ID: +Date: Wed, 28 Sep 2005 17:57:36 +0530 +From: Rajesh Kumar Mallah +Reply-To: Rajesh Kumar Mallah +To: pgsql-performance@postgresql.org +Subject: Slow concurrent update of same row in a given table +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.398 required=5 tests=[AWL=-0.458, RCVD_BY_IP=0.024, + RCVD_IN_BL_SPAMCOP_NET=1.832] +X-Spam-Level: * +X-Archive-Number: 200509/388 +X-Sequence-Number: 14696 + +Hi + +While doing some stress testing for updates in a small sized table +we found the following results. We are not too happy about the speed +of the updates particularly at high concurrency (10 clients). + +Initially we get 119 updates / sec but it drops to 10 updates/sec +as concurrency is increased. + +PostgreSQL: 8.0.3 +------------------------------- +TABLE STRUCTURE: general.stress +------------------------------- +| dispatch_id | integer | not null | +| query_id | integer | | +| generated | timestamp with time zone | | +| unsubscribes | integer | | +| read_count | integer | | +| status | character varying(10) | | +| bounce_tracking | boolean | | +| dispatch_hour | integer | | +| dispatch_date_id | integer | | ++------------------+--------------------------+-----------+ +Indexes: + "stress_pkey" PRIMARY KEY, btree (dispatch_id) + +UPDATE STATEMENT: +update general.stress set read_count=3Dread_count+1 where dispatch_id=3D114 +TOOL USED: Perl/DBI , with prepared statement handlers +CONCURRENCY METHOD: executing multiple copies of same program +from different shells (linux enviornment) +CLIENT SERVER LINK : 10/100 Mbits , LAN + +CLIENT CODE: stress.pl +------------------------------------------------------------------------- +#!/opt/perl/bin/perl -I/usr/local/masonapache/lib/perl +################################################ +#overview: update the table as fast as possible (while(1){}) +#on every 100th commit , print the average update frequency +#of last 100 updates +########################################## +use strict; +use Time::HiRes qw(gettimeofday tv_interval); +use Utils; +my $dbh =3D &Utils::db_connect(); +my $sth =3D $dbh -> prepare("update general.stress set +read_count=3Dread_count+1 where dispatch_id=3D114"); +my $cnt=3D0; +my $t0 =3D [ gettimeofday ]; +while(1) { + $sth -> execute(); + $dbh->commit(); + $cnt++; + if ($cnt % 100 =3D=3D 0) + { + my $t1 =3D [ gettimeofday ]; + my $elapsed =3D tv_interval ( $t0 , $t1 ); + $t0 =3D $t1; + printf "Rate: %d updates / sec\n" , 100.0/$elapsed ; + } +} +$sth->finish(); +$dbh->disconnect(); +---------------------------------------------------------------------------= +----------- + +---------------------------------------------------------------------------= +----------- +RESULTS: +---------------------------------------------------------------------------= +----------- + +Number of Copies | Update perl Sec + +1 --> 119 +2 ---> 59 +3 ---> 38 +4 ---> 28 +5 --> 22 +6 --> 19 +7 --> 16 +8 --> 14 +9 --> 11 +10 --> 11 +11 --> 10 + +---------------------------------------------------------------------------= +---------- +Note that the table was vacuum analyzed during the tests +total number of records in table: 93 +---------------------------------------------------------------------------= +---------- + +Regds +Rajesh Kumar Mallah. + +From pgsql-performance-owner@postgresql.org Wed Sep 28 09:54:23 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 93129D84C3 + for ; + Wed, 28 Sep 2005 09:54:22 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 97000-10 + for ; + Wed, 28 Sep 2005 12:53:46 +0000 (GMT) +Received: from linuxworld.com.au (unknown [203.34.46.50]) + by svr1.postgresql.org (Postfix) with ESMTP id F4006D9A48 + for ; + Wed, 28 Sep 2005 09:53:45 -0300 (ADT) +Received: from linuxworld.com.au (IDENT:swm@localhost.localdomain [127.0.0.1]) + by linuxworld.com.au (8.13.2/8.13.2) with ESMTP id j8SCrZlO019580; + Wed, 28 Sep 2005 22:53:35 +1000 +Received: from localhost (swm@localhost) + by linuxworld.com.au (8.13.2/8.13.2/Submit) with ESMTP id + j8SCrZl4019577; Wed, 28 Sep 2005 22:53:35 +1000 +X-Authentication-Warning: linuxworld.com.au: swm owned process doing -bs +Date: Wed, 28 Sep 2005 22:53:35 +1000 (EST) +From: Gavin Sherry +X-X-Sender: swm@linuxworld.com.au +To: Rajesh Kumar Mallah +Cc: pgsql-performance@postgresql.org +Subject: Re: Slow concurrent update of same row in a given table +In-Reply-To: +Message-ID: +References: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.001 required=5 tests=[AWL=0.001] +X-Spam-Level: +X-Archive-Number: 200509/389 +X-Sequence-Number: 14697 + +On Wed, 28 Sep 2005, Rajesh Kumar Mallah wrote: + +> Hi +> +> While doing some stress testing for updates in a small sized table +> we found the following results. We are not too happy about the speed +> of the updates particularly at high concurrency (10 clients). +> +> Initially we get 119 updates / sec but it drops to 10 updates/sec +> as concurrency is increased. +> +> PostgreSQL: 8.0.3 +> ------------------------------- +> TABLE STRUCTURE: general.stress +> ------------------------------- +> | dispatch_id | integer | not null | +> | query_id | integer | | +> | generated | timestamp with time zone | | +> | unsubscribes | integer | | +> | read_count | integer | | +> | status | character varying(10) | | +> | bounce_tracking | boolean | | +> | dispatch_hour | integer | | +> | dispatch_date_id | integer | | +> +------------------+--------------------------+-----------+ +> Indexes: +> "stress_pkey" PRIMARY KEY, btree (dispatch_id) +> +> UPDATE STATEMENT: +> update general.stress set read_count=read_count+1 where dispatch_id=114 + +This means you are updating only one row, correct? + +> Number of Copies | Update perl Sec +> +> 1 --> 119 +> 2 ---> 59 +> 3 ---> 38 +> 4 ---> 28 +> 5 --> 22 +> 6 --> 19 +> 7 --> 16 +> 8 --> 14 +> 9 --> 11 +> 10 --> 11 +> 11 --> 10 + +So, 11 instances result in 10 updated rows per second, database wide or +per instance? If it is per instance, then 11 * 10 is close to the +performance for one connection. + +That being said, when you've got 10 connections fighting over one row, I +wouldn't be surprised if you had bad performance. + +Also, at 119 updates a second, you're more than doubling the table's +initial size (dead tuples) each second. How often are you vacuuming and +are you using vacuum or vacuum full? + +Gavin + +From pgsql-performance-owner@postgresql.org Wed Sep 28 11:32:30 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C3098D994B + for ; + Wed, 28 Sep 2005 11:32:28 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18926-01 + for ; + Wed, 28 Sep 2005 14:32:23 +0000 (GMT) +Received: from mail.androme.com (mail.androme.com [62.58.96.145]) + by svr1.postgresql.org (Postfix) with ESMTP id 0DDE8D8D49 + for ; + Wed, 28 Sep 2005 11:32:23 -0300 (ADT) +Received: from [127.0.0.1] ([192.168.10.56]) + by mail.androme.com (8.12.10/8.12.10) with ESMTP id j8SEW3Ux020124 + for ; Wed, 28 Sep 2005 16:32:07 +0200 +Message-ID: <433AA962.9020900@andromeiberica.com> +Date: Wed, 28 Sep 2005 16:32:02 +0200 +From: Arnau +Reply-To: arnaulist@andromeiberica.com +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: Monitoring Postgresql performance +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/390 +X-Sequence-Number: 14698 + +Hi all, + + I have been "googling" a bit searching info about a way to monitor +postgresql (CPU & Memory, num processes, ... ) and I haven't found +anything relevant. I'm using munin to monitor others parameters of my +servers and I'd like to include postgresql or have a similar tool. Any +of you is using anything like that? all kind of hints are welcome :-) + +Cheers! +-- +Arnau + + +From pgsql-hackers-owner@postgresql.org Thu Sep 29 10:03:05 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 57A0BD9AAD; + Wed, 28 Sep 2005 13:03:46 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 33016-10; Wed, 28 Sep 2005 16:03:41 +0000 (GMT) +Received: from pop-gadwall.atl.sa.earthlink.net + (pop-gadwall.atl.sa.earthlink.net [207.69.195.61]) + by svr1.postgresql.org (Postfix) with ESMTP id 4CEFBD9A6A; + Wed, 28 Sep 2005 13:03:38 -0300 (ADT) +Received: from elwamui-polski.atl.sa.earthlink.net ([209.86.224.45]) + by pop-gadwall.atl.sa.earthlink.net with esmtp (Exim 3.36 #10) + id 1EKeP8-0005pY-00; Wed, 28 Sep 2005 12:03:34 -0400 +Message-ID: + <21402654.1127923414088.JavaMail.root@elwamui-polski.atl.sa.earthlink.net> +Date: Wed, 28 Sep 2005 12:03:34 -0400 (EDT) +From: Ron Peacetree +Reply-To: Ron Peacetree +To: "Jeffrey W. Baker" , + pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: [PERFORM] A Better External Sort? +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Mailer: Earthlink Zoo Mail 1.0 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.259 required=5 tests=[AWL=-0.115, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200509/1357 +X-Sequence-Number: 73754 + +>From: "Jeffrey W. Baker" +>Sent: Sep 27, 2005 1:26 PM +>To: Ron Peacetree +>Subject: Re: [HACKERS] [PERFORM] A Better External Sort? +> +>On Tue, 2005-09-27 at 13:15 -0400, Ron Peacetree wrote: +> +>>That Btree can be used to generate a physical reordering of the data +>>in one pass, but that's the weakest use for it. The more powerful +>>uses involve allowing the Btree to persist and using it for more +>>efficient re-searches or combining it with other such Btrees (either as +>>a step in task distribution across multiple CPUs or as a more efficient +>>way to do things like joins by manipulating these Btrees rather than +>>the actual records.) +> +>Maybe you could describe some concrete use cases. I can see what +>you are getting at, and I can imagine some advantageous uses, but +>I'd like to know what you are thinking. +> +1= In a 4P box, we split the data in RAM into 4 regions and create +a CPU cache friendly Btree using the method I described for each CPU. +The 4 Btrees can be merged in a more time and space efficient manner +than the original records to form a Btree that represents the sorted order +of the entire data set. Any of these Btrees can be allowed to persist to +lower the cost of doing similar operations in the future (Updating the +Btrees during inserts and deletes is cheaper than updating the original +data files and then redoing the same sort from scratch in the future.) +Both the original sort and future such sorts are made more efficient +than current methods. + +2= We use my method to sort two different tables. We now have these +very efficient representations of a specific ordering on these tables. A +join operation can now be done using these Btrees rather than the +original data tables that involves less overhead than many current +methods. + +3= We have multiple such Btrees for the same data set representing +sorts done using different fields (and therefore different Keys). +Calculating a sorted order for the data based on a composition of +those Keys is now cheaper than doing the sort based on the composite +Key from scratch. When some of the Btrees exist and some of them +do not, there is a tradeoff calculation to be made. Sometimes it will be +cheaper to do the sort from scratch using the composite Key. + + +>Specifically I'd like to see some cases where this would beat sequential +>scan. I'm thinking that in your example of a terabyte table with a +>column having only two values, all the queries I can think of would be +>better served with a sequential scan. +> +In my original example, a sequential scan of the 1TB of 2KB or 4KB +records, => 250M or 500M records of data, being sorted on a binary +value key will take ~1000x more time than reading in the ~1GB Btree +I described that used a Key+RID (plus node pointers) representation +of the data. + +Just to clarify the point further, +1TB of 1B records => 2^40 records of at most 256 distinct values. +1TB of 2B records => 2^39 records of at most 2^16 distinct values. +1TB of 4B records => 2^38 records of at most 2^32 distinct values. +1TB of 5B records => 200B records of at most 200B distinct values. +>From here on, the number of possible distinct values is limited by the +number of records. +100B records are used in the "Indy" version of Jim Gray's sorting +contests, so 1TB => 10B records. +2KB-4KB is the most common record size I've seen in enterprise +class DBMS (so I used this value to make my initial example more +realistic). + +Therefore the vast majority of the time representing a data set by Key +will use less space that the original record. Less space used means +less IO to scan the data set, which means faster scan times. + +This is why index files work in the first place, right? + + +>Perhaps I believe this because you can now buy as much sequential I/O +>as you want. Random I/O is the only real savings. +> +1= No, you can not "buy as much sequential IO as you want". Even if +with an infinite budget, there are physical and engineering limits. Long +before you reach those limits, you will pay exponentially increasing costs +for linearly increasing performance gains. So even if you _can_ buy a +certain level of sequential IO, it may not be the most efficient way to +spend money. + +2= Most RW IT professionals have far from an infinite budget. Just traffic +on these lists shows how severe the typical cost constraints usually are. +OTOH, if you have an inifinite IT budget, care to help a few less fortunate +than yourself? After all, a even a large constant substracted from infinity +is still infinity... ;-) + +3= No matter how fast you can do IO, IO remains the most expensive +part of the performance equation. The fastest and cheapest IO you can +do is _no_ IO. As long as we trade cheaper RAM and even cheaoer CPU +operations for IO correctly, more space efficient data representations will +always be a Win because of this. + +From pgsql-performance-owner@postgresql.org Wed Sep 28 14:22:30 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A59C2D9A53 + for ; + Wed, 28 Sep 2005 14:22:28 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 54211-03 + for ; + Wed, 28 Sep 2005 17:22:25 +0000 (GMT) +Received: from crestone.coronasolutions.com (crestone.coronasolutions.com + [66.45.104.24]) + by svr1.postgresql.org (Postfix) with ESMTP id B07D5D9A1E + for ; + Wed, 28 Sep 2005 14:22:22 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by crestone.coronasolutions.com (Postfix) with ESMTP id 62B916441AD + for ; + Wed, 28 Sep 2005 11:22: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 05820-04 for ; + Wed, 28 Sep 2005 11:22:19 -0600 (MDT) +Received: from [192.168.1.2] (c-67-165-220-189.hsd1.co.comcast.net + [67.165.220.189]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by crestone.coronasolutions.com (Postfix) with ESMTP id 689556441A7 + for ; + Wed, 28 Sep 2005 11:22:19 -0600 (MDT) +Mime-Version: 1.0 (Apple Message framework v734) +In-Reply-To: <433AA962.9020900@andromeiberica.com> +References: <433AA962.9020900@andromeiberica.com> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <154802AB-A224-4A73-B518-3353CBB38D4B@drivefaster.net> +Content-Transfer-Encoding: 7bit +From: Dan Harris +Subject: Re: Monitoring Postgresql performance +Date: Wed, 28 Sep 2005 11:22:18 -0600 +To: pgsql-performance@postgresql.org +X-Mailer: Apple Mail (2.734) +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at drivefaster.net +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/392 +X-Sequence-Number: 14700 + + +On Sep 28, 2005, at 8:32 AM, Arnau wrote: + +> Hi all, +> +> I have been "googling" a bit searching info about a way to +> monitor postgresql (CPU & Memory, num processes, ... ) + +You didn't mention your platform, but I have an xterm open pretty +much continuously for my DB server that runs plain old top. I have +customized my settings enough that I can pretty much see anything I +need to from there. + +-Dan + + +From pgsql-performance-owner@postgresql.org Wed Sep 28 14:44:34 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 92E3ED9A53 + for ; + Wed, 28 Sep 2005 14:44:16 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 54474-08 + for ; + Wed, 28 Sep 2005 17:44:12 +0000 (GMT) +Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.204]) + by svr1.postgresql.org (Postfix) with ESMTP id 71B9ED9AAA + for ; + Wed, 28 Sep 2005 14:44:11 -0300 (ADT) +Received: by xproxy.gmail.com with SMTP id i30so1511660wxd + for ; + Wed, 28 Sep 2005 10:44: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:content-transfer-encoding:content-disposition:references; + b=P7yna/SUMTTDes1m9Q0QLLIHZFPqsAqO8Wk9ZPZ5UaC6tgiK8pptcAhiS+J5U+AVIo2qe2WKrFBfOyohYj40xjKGGlVWBhJClyMGWLrVHiPLuLqkxXz1/wAcJOT7u+vbRK9eH7Nv2Ks+4CnxL7WdO2TEotHFYyp+TVMsxPTE/L8= +Received: by 10.70.28.8 with SMTP id b8mr15932wxb; + Wed, 28 Sep 2005 10:44:12 -0700 (PDT) +Received: by 10.70.75.4 with HTTP; Wed, 28 Sep 2005 10:44:12 -0700 (PDT) +Message-ID: +Date: Wed, 28 Sep 2005 23:14:12 +0530 +From: Rajesh Kumar Mallah +Reply-To: Rajesh Kumar Mallah +To: Gavin Sherry +Subject: Re: Slow concurrent update of same row in a given table +Cc: pgsql-performance@postgresql.org +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.574 required=5 tests=[AWL=0.550, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200509/393 +X-Sequence-Number: 14701 + +On 9/28/05, Gavin Sherry wrote: +> On Wed, 28 Sep 2005, Rajesh Kumar Mallah wrote: +> +> > Hi +> > +> > While doing some stress testing for updates in a small sized table +> > we found the following results. We are not too happy about the speed +> > of the updates particularly at high concurrency (10 clients). +> > +> > Initially we get 119 updates / sec but it drops to 10 updates/sec +> > as concurrency is increased. +> > +> > PostgreSQL: 8.0.3 +> > ------------------------------- +> > TABLE STRUCTURE: general.stress +> > ------------------------------- +> > | dispatch_id | integer | not null | +> > | query_id | integer | | +> > | generated | timestamp with time zone | | +> > | unsubscribes | integer | | +> > | read_count | integer | | +> > | status | character varying(10) | | +> > | bounce_tracking | boolean | | +> > | dispatch_hour | integer | | +> > | dispatch_date_id | integer | | +> > +------------------+--------------------------+-----------+ +> > Indexes: +> > "stress_pkey" PRIMARY KEY, btree (dispatch_id) +> > +> > UPDATE STATEMENT: +> > update general.stress set read_count=3Dread_count+1 where dispatch_id= +=3D114 +> +> This means you are updating only one row, correct? + +Correct. + + +> +> > Number of Copies | Update perl Sec +> > +> > 1 --> 119 +> > 2 ---> 59 +> > 3 ---> 38 +> > 4 ---> 28 +> > 5 --> 22 +> > 6 --> 19 +> > 7 --> 16 +> > 8 --> 14 +> > 9 --> 11 +> > 10 --> 11 +> > 11 --> 10 +> +> So, 11 instances result in 10 updated rows per second, database wide or +> per instance? If it is per instance, then 11 * 10 is close to the +> performance for one connection. + + +Sorry do not understand the difference between "database wide" +and "per instance" + +> +> That being said, when you've got 10 connections fighting over one row, I +> wouldn't be surprised if you had bad performance. +> +> Also, at 119 updates a second, you're more than doubling the table's +> initial size (dead tuples) each second. How often are you vacuuming and +> are you using vacuum or vacuum full? + + +Yes I realize the obvious phenomenon now, (and the uselessness of the scrip= +t) + , we should not consider it a performance degradation. + +I am having performance issue in my live database thats why i tried to +simulate the situation(may the the script was overstresser). + +My original problem is that i send 100 000s of emails carrying a +beacon for tracking readership every tuesday and on wednesday i see +lot of the said query in pg_stat_activity each of these query update +the SAME row that corresponds to the dispatch of last day and it is +then i face the performance problem. + +I think i can only post further details next wednesday , please lemme +know how should i be dealing with the situation if each the updates takes +100times more time that normal update duration. + +Best Regards +Mallah. + + +> +> Gavin +> + +From pgsql-performance-owner@postgresql.org Wed Sep 28 14:56:36 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4D012D8F56 + for ; + Wed, 28 Sep 2005 14:56:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 60375-06 + for ; + Wed, 28 Sep 2005 17:56:28 +0000 (GMT) +Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.205]) + by svr1.postgresql.org (Postfix) with ESMTP id 07BD9D8C50 + for ; + Wed, 28 Sep 2005 14:56:28 -0300 (ADT) +Received: by xproxy.gmail.com with SMTP id i30so1513209wxd + for ; + Wed, 28 Sep 2005 10:56:28 -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=EpMRvsPY2q41zKyKspCJMEYrEPWINYP8zcJz99bAjpi0Pqd6smH2t4lcx6btiroSQg3bj5BTFMhAh6Td6zdc6D1USg6EDyKZGb7sZV9S6A3bUOOpjTbBe/QoFybWTW9+YP/d3bSGjrnLIFgLpzvAcGPLOs2oTX876PxbpCUlnbI= +Received: by 10.70.74.9 with SMTP id w9mr15190wxa; + Wed, 28 Sep 2005 10:56:28 -0700 (PDT) +Received: by 10.70.128.19 with HTTP; Wed, 28 Sep 2005 10:56:28 -0700 (PDT) +Message-ID: +Date: Wed, 28 Sep 2005 12:56:28 -0500 +From: Matthew Nuzum +Reply-To: newz@bearfruit.org +To: arnaulist@andromeiberica.com +Subject: Re: Monitoring Postgresql performance +Cc: pgsql-performance@postgresql.org +In-Reply-To: <433AA962.9020900@andromeiberica.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <433AA962.9020900@andromeiberica.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.228 required=5 tests=[AWL=-0.628, RCVD_BY_IP=0.024, + RCVD_IN_BL_SPAMCOP_NET=1.832] +X-Spam-Level: * +X-Archive-Number: 200509/394 +X-Sequence-Number: 14702 + +On 9/28/05, Arnau wrote: +> Hi all, +> +> I have been "googling" a bit searching info about a way to monitor +> postgresql (CPU & Memory, num processes, ... ) and I haven't found +> anything relevant. I'm using munin to monitor others parameters of my +> servers and I'd like to include postgresql or have a similar tool. Any +> of you is using anything like that? all kind of hints are welcome :-) +> +> Cheers! +> -- +> Arnau + +I have a cronjob that runs every 5 minutes and checks the number of +processes. When things get unruly I get a text message sent to my cell +phone. It also creates a detailed log entry. I'll paste in an example +of one of my scripts that does this below. This is on a dual purpose +server and monitors both cpu load average and postgres. You can have +the text message sent to multiple email addresses, just put a space +separated list of e-mail addresses between quotes in the CONTACTS=3D +line. It's simple, but it works and its always nice to know when +there's a problem *before the boss discovers it* ;-) + +# Create some messages +HOSTNAME=3D`hostname` +WARNING_DB=3D"Database connections on $HOSTNAME is rather high" +WARNING_CPU=3D"CPU load on $HOSTNAME is rather high" +CONTACTS=3D"cellphone@mmode.com matt@blah.net newz@blah.net" +WARN=3D0 + +#calculate the db load +DB_LOAD=3D`ps -ax | grep postgres | wc -l` +if (($DB_LOAD > 150)) +then + WARN=3D1 + echo "$WARNING_DB ($DB_LOAD) " | mail -s "db_load is high +($DB_LOAD)" $CONTACTS +fi + +#calculate the processor load +CPU_LOAD=3D`cat /proc/loadavg | cut --delimiter=3D" " -f 2 | cut +--delimiter=3D"." -f 1` +if (($CPU_LOAD > 8)) +then + WARN=3D1 + echo "$WARNING_CPU ($CPU_LOAD) " | mail -s "CPU_load is high +($CPU_LOAD)" $CONTACTS +fi + +if (($WARN > 0)) +then + echo -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- W A R N I N G -=3D-=3D-=3D-=3D-=3D= +-=3D-=3D-=3D- >> /tmp/warn.txt + NOW=3D`date` + echo -=3D-=3D-=3D-=3D-=3D-$NOW-=3D-=3D-=3D-=3D-=3D- >> /tmp/warn.txt + echo CPU LOAD: $CPU_LOAD DB LOAD: $DB_LOAD >> /tmp/warn.txt + echo >> /tmp/warn.txt + top -bn 1 >> /tmp/warn.txt + echo >> /tmp/warn.txt +fi + +NOW=3D`date` +CPU_LOAD=3D`cat /proc/loadavg | cut --delimiter=3D" " -f 1,2,3 +--output-delimiter=3D\|` +echo -e $NOW\|$CPU_LOAD\|$DB_LOAD >> ~/LOAD_MONITOR.LOG + +-- +Matthew Nuzum +www.bearfruit.org + +From pgsql-performance-owner@postgresql.org Wed Sep 28 17:03:00 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B798BD9AE4 + for ; + Wed, 28 Sep 2005 17:02:58 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 92633-09 + for ; + Wed, 28 Sep 2005 20:02:51 +0000 (GMT) +Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.199]) + by svr1.postgresql.org (Postfix) with ESMTP id E4E2BD9A8B + for ; + Wed, 28 Sep 2005 17:02:49 -0300 (ADT) +Received: by xproxy.gmail.com with SMTP id i30so1528984wxd + for ; + Wed, 28 Sep 2005 13:02:51 -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:mime-version:content-type:content-transfer-encoding:content-disposition; + b=Up7KFzVInNHXFC9bXmTmAQ+oYi3fgrMCu2sbyyrHZKYg0QdloPgqlEwIrJmm6Ao9SOmgLFg6fk5s4BNslGRvQnFB6lgicv0IsdsjzGYdXhtnIXsMeXpyPWo5g6urHUWqFXQ8BojdIVq51/ashahYyHh+Sm7o7/y0pZCKaF8msTM= +Received: by 10.70.72.11 with SMTP id u11mr56470wxa; + Wed, 28 Sep 2005 13:02:51 -0700 (PDT) +Received: by 10.70.128.19 with HTTP; Wed, 28 Sep 2005 13:02:51 -0700 (PDT) +Message-ID: +Date: Wed, 28 Sep 2005 15:02:51 -0500 +From: Matthew Nuzum +Reply-To: newz@bearfruit.org +To: Postgresql Performance list +Subject: Logarithmic change (decrease) in performance +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.437 required=5 tests=[AWL=0.413, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200509/395 +X-Sequence-Number: 14703 + +Something interesting is going on. I wish I could show you the graphs, +but I'm sure this will not be a surprise to the seasoned veterans. + +A particular application server I have has been running for over a +year now. I've been logging cpu load since mid-april. + +It took 8 months or more to fall from excellent performance to +"acceptable." Then, over the course of about 5 weeks it fell from +"acceptable" to "so-so." Then, in the last four weeks it's gone from +"so-so" to alarming. + +I've been working on this performance drop since Friday but it wasn't +until I replied to Arnau's post earlier today that I remembered I'd +been logging the server load. I grabbed the data and charted it in +Excel and to my surprise, the graph of the server's load average looks +kind of like the graph of y=3Dx^2. + +I've got to make a recomendation for a solution to the PHB and my +analysis is showing that as the dataset becomes larger, the amount of +time the disk spends seeking is increasing. This causes processes to +take longer to finish, which causes more processes to pile up, which +cuases processes to take longer to finish, which causes more processes +to pile up etc. It is this growing dataset that seems to be the source +of the sharp decrease in performance. + +I knew this day would come, but I'm actually quite surprised that when +it came, there was little time between the warning and the grande +finale. I guess this message is being sent to the list to serve as a +warning to other data warehouse admins that when you reach your +capacity, the downward spiral happens rather quickly. + +Crud... Outlook just froze while composing the PHB memo. I've been +working on that for an hour. What a bad day. +-- +Matthew Nuzum +www.bearfruit.org + +From pgsql-performance-owner@postgresql.org Wed Sep 28 18:41:12 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A1B03D97A0 + for ; + Wed, 28 Sep 2005 18:36:33 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 17258-08 + for ; + Wed, 28 Sep 2005 21:36:30 +0000 (GMT) +Received: from smtp-out3.blueyonder.co.uk (smtp-out3.blueyonder.co.uk + [195.188.213.6]) + by svr1.postgresql.org (Postfix) with ESMTP id 10AA1D9346 + for ; + Wed, 28 Sep 2005 18:36:27 -0300 (ADT) +Received: from [192.168.1.10] ([82.43.93.192]) by smtp-out3.blueyonder.co.uk + with Microsoft SMTPSVC(5.0.2195.6713); + Wed, 28 Sep 2005 22:37:19 +0100 +In-Reply-To: <433AA962.9020900@andromeiberica.com> +References: <433AA962.9020900@andromeiberica.com> +Mime-Version: 1.0 (Apple Message framework v734) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <006CFF08-1869-45DA-9998-B99E9F18C564@advfn.com> +Cc: pgsql-performance@postgresql.org +Content-Transfer-Encoding: 7bit +From: Alex Stapleton +Subject: Re: Monitoring Postgresql performance +Date: Wed, 28 Sep 2005 22:36:29 +0100 +To: arnaulist@andromeiberica.com +X-Mailer: Apple Mail (2.734) +X-OriginalArrivalTime: 28 Sep 2005 21:37:19.0665 (UTC) + FILETIME=[CDB94A10:01C5C474] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/396 +X-Sequence-Number: 14704 + + +On 28 Sep 2005, at 15:32, Arnau wrote: + + +> Hi all, +> +> I have been "googling" a bit searching info about a way to +> monitor postgresql (CPU & Memory, num processes, ... ) and I +> haven't found anything relevant. I'm using munin to monitor others +> parameters of my servers and I'd like to include postgresql or have +> a similar tool. Any of you is using anything like that? all kind of +> hints are welcome :-) +> +> Cheers! +> + +Have you looked at SNMP? It's a bit complex but there's lots of tools +for monitoring system data / sending alerts based on SNMP already. + + +From pgsql-performance-owner@postgresql.org Wed Sep 28 19:02:14 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D86D5D9B0C + for ; + Wed, 28 Sep 2005 19:02:11 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 60614-07 + for ; + Wed, 28 Sep 2005 22:02:07 +0000 (GMT) +Received: from linuxworld.com.au (unknown [203.34.46.50]) + by svr1.postgresql.org (Postfix) with ESMTP id 760F4D9B20 + for ; + Wed, 28 Sep 2005 19:02:06 -0300 (ADT) +Received: from linuxworld.com.au (IDENT:swm@localhost.localdomain [127.0.0.1]) + by linuxworld.com.au (8.13.2/8.13.2) with ESMTP id j8SM1ucE022355; + Thu, 29 Sep 2005 08:01:56 +1000 +Received: from localhost (swm@localhost) + by linuxworld.com.au (8.13.2/8.13.2/Submit) with ESMTP id + j8SM1t5R022352; Thu, 29 Sep 2005 08:01:56 +1000 +X-Authentication-Warning: linuxworld.com.au: swm owned process doing -bs +Date: Thu, 29 Sep 2005 08:01:55 +1000 (EST) +From: Gavin Sherry +X-X-Sender: swm@linuxworld.com.au +To: Rajesh Kumar Mallah +Cc: pgsql-performance@postgresql.org +Subject: Re: Slow concurrent update of same row in a given table +In-Reply-To: +Message-ID: +References: + + +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.001 required=5 tests=[AWL=0.001] +X-Spam-Level: +X-Archive-Number: 200509/397 +X-Sequence-Number: 14705 + +On Wed, 28 Sep 2005, Rajesh Kumar Mallah wrote: + +> > > Number of Copies | Update perl Sec +> > > +> > > 1 --> 119 +> > > 2 ---> 59 +> > > 3 ---> 38 +> > > 4 ---> 28 +> > > 5 --> 22 +> > > 6 --> 19 +> > > 7 --> 16 +> > > 8 --> 14 +> > > 9 --> 11 +> > > 10 --> 11 +> > > 11 --> 10 +> > +> > So, 11 instances result in 10 updated rows per second, database wide or +> > per instance? If it is per instance, then 11 * 10 is close to the +> > performance for one connection. +> +> +> Sorry do not understand the difference between "database wide" +> and "per instance" + +Per instance. + +> +> > +> > That being said, when you've got 10 connections fighting over one row, I +> > wouldn't be surprised if you had bad performance. +> > +> > Also, at 119 updates a second, you're more than doubling the table's +> > initial size (dead tuples) each second. How often are you vacuuming and +> > are you using vacuum or vacuum full? +> +> +> Yes I realize the obvious phenomenon now, (and the uselessness of the script) +> , we should not consider it a performance degradation. +> +> I am having performance issue in my live database thats why i tried to +> simulate the situation(may the the script was overstresser). +> +> My original problem is that i send 100 000s of emails carrying a +> beacon for tracking readership every tuesday and on wednesday i see +> lot of the said query in pg_stat_activity each of these query update +> the SAME row that corresponds to the dispatch of last day and it is +> then i face the performance problem. +> +> I think i can only post further details next wednesday , please lemme +> know how should i be dealing with the situation if each the updates takes +> 100times more time that normal update duration. + +I see. These problems regularly come up in database design. The best thing +you can do is modify your database design/application such that instead of +incrementing a count in a single row, you insert a row into a table, +recording the 'dispatch_id'. Counting the number of rows for a given +dispatch id will give you your count. + +Thanks, + +Gavin + +From pgsql-performance-owner@postgresql.org Wed Sep 28 19:03:10 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 66D94D9346 + for ; + Wed, 28 Sep 2005 19:03:08 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 64170-01 + for ; + Wed, 28 Sep 2005 22:03:03 +0000 (GMT) +Received: from pop-gadwall.atl.sa.earthlink.net + (pop-gadwall.atl.sa.earthlink.net [207.69.195.61]) + by svr1.postgresql.org (Postfix) with ESMTP id 405FFD6EAF + for ; + Wed, 28 Sep 2005 19:03:02 -0300 (ADT) +Received: from elwamui-polski.atl.sa.earthlink.net ([209.86.224.45]) + by pop-gadwall.atl.sa.earthlink.net with esmtp (Exim 3.36 #10) + id 1EKk11-00017e-00; Wed, 28 Sep 2005 18:03:03 -0400 +Message-ID: + <12381712.1127944983296.JavaMail.root@elwamui-polski.atl.sa.earthlink.net> +Date: Wed, 28 Sep 2005 18:03:03 -0400 (EDT) +From: Ron Peacetree +Reply-To: Ron Peacetree +To: Matthew Nuzum , newz@bearfruit.org, + Postgresql Performance list +Subject: Re: Logarithmic change (decrease) in performance +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Mailer: Earthlink Zoo Mail 1.0 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.261 required=5 tests=[AWL=-0.113, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200509/398 +X-Sequence-Number: 14706 + +>From: Matthew Nuzum +>Sent: Sep 28, 2005 4:02 PM +>Subject: [PERFORM] Logarithmic change (decrease) in performance +> +Small nit-pick: A "logarithmic decrease" in performance would be +a relatively good thing, being better than either a linear or +exponential decrease in performance. What you are describing is +the worst kind: an _exponential_ decrease in performance. + +>Something interesting is going on. I wish I could show you the graphs, +>but I'm sure this will not be a surprise to the seasoned veterans. +> +>A particular application server I have has been running for over a +>year now. I've been logging cpu load since mid-april. +> +>It took 8 months or more to fall from excellent performance to +>"acceptable." Then, over the course of about 5 weeks it fell from +>"acceptable" to "so-so." Then, in the last four weeks it's gone from +>"so-so" to alarming. +> +>I've been working on this performance drop since Friday but it wasn't +>until I replied to Arnau's post earlier today that I remembered I'd +>been logging the server load. I grabbed the data and charted it in +>Excel and to my surprise, the graph of the server's load average looks +>kind of like the graph of y=x^2. +> +>I've got to make a recomendation for a solution to the PHB and my +>analysis is showing that as the dataset becomes larger, the amount of +>time the disk spends seeking is increasing. This causes processes to +>take longer to finish, which causes more processes to pile up, which +>causes processes to take longer to finish, which causes more processes +>to pile up etc. It is this growing dataset that seems to be the source +>of the sharp decrease in performance. +> +>I knew this day would come, but I'm actually quite surprised that when +>it came, there was little time between the warning and the grande +>finale. I guess this message is being sent to the list to serve as a +>warning to other data warehouse admins that when you reach your +>capacity, the downward spiral happens rather quickly. +> +Yep, definitely been where you are. Bottom line: you have to reduce +the sequential seeking behavior of the system to within an acceptable +window and then keep it there. + +1= keep more of the data set in RAM +2= increase the size of your HD IO buffers +3= make your RAID sets wider (more parallel vs sequential IO) +4= reduce the atomic latency of your RAID sets +(time for Fibre Channel 15Krpm HD's vs 7.2Krpm SATA ones?) +5= make sure your data is as unfragmented as possible +6= change you DB schema to minimize the problem +a= overall good schema design +b= partitioning the data so that the system only has to manipulate a +reasonable chunk of it at a time. + +In many cases, there's a number of ways to accomplish the above. +Unfortunately, most of them require CapEx. + +Also, ITRW world such systems tend to have this as a chronic +problem. This is not a "fix it once and it goes away forever". This +is a part of the regular maintenance and upgrade plan(s). + +Good Luck, +Ron + +From pgsql-hackers-owner@postgresql.org Thu Sep 29 10:03:19 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0944DD9AC8; + Wed, 28 Sep 2005 20:49:59 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 90012-01; Wed, 28 Sep 2005 23:49:54 +0000 (GMT) +Received: from pop-gadwall.atl.sa.earthlink.net + (pop-gadwall.atl.sa.earthlink.net [207.69.195.61]) + by svr1.postgresql.org (Postfix) with ESMTP id 2CD81D9A84; + Wed, 28 Sep 2005 20:49:55 -0300 (ADT) +Received: from elwamui-polski.atl.sa.earthlink.net ([209.86.224.45]) + by pop-gadwall.atl.sa.earthlink.net with esmtp (Exim 3.36 #10) + id 1EKlgV-0002ej-00; Wed, 28 Sep 2005 19:49:59 -0400 +Message-ID: + <16891246.1127951399015.JavaMail.root@elwamui-polski.atl.sa.earthlink.net> +Date: Wed, 28 Sep 2005 19:49:59 -0400 (EDT) +From: Ron Peacetree +Reply-To: Ron Peacetree +To: pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: [PERFORM] A Better External Sort? +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Mailer: Earthlink Zoo Mail 1.0 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.262 required=5 tests=[AWL=-0.112, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200509/1358 +X-Sequence-Number: 73755 + +In the interest of efficiency and "not reinventing the wheel", does anyone know +where I can find C or C++ source code for a Btree variant with the following +properties: + +A= Data elements (RIDs) are only stored in the leaves, Keys (actually +KeyPrefixes; see "D" below) and Node pointers are only stored in the internal +nodes of the Btree. + +B= Element redistribution is done as an alternative to node splitting in overflow +conditions during Inserts whenever possible. + +C= Variable length Keys are supported. + +D= Node buffering with a reasonable replacement policy is supported. + +E= Since we will know beforehand exactly how many RID's will be stored, we +will know apriori how much space will be needed for leaves, and will know the +worst case for how much space will be required for the Btree internal nodes +as well. This implies that we may be able to use an array, rather than linked +list, implementation of the Btree. Less pointer chasing at the expense of more +CPU calculations, but that's a trade-off in the correct direction. + +Such source would be a big help in getting a prototype together. + +Thanks in advance for any pointers or source, +Ron + +From pgsql-hackers-owner@postgresql.org Thu Sep 29 09:58:22 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 599A8D90EC; + Wed, 28 Sep 2005 21:25:33 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 99914-01; Thu, 29 Sep 2005 00:25:27 +0000 (GMT) +Received: from pop-gadwall.atl.sa.earthlink.net + (pop-gadwall.atl.sa.earthlink.net [207.69.195.61]) + by svr1.postgresql.org (Postfix) with ESMTP id 611C8D9B16; + Wed, 28 Sep 2005 21:25:28 -0300 (ADT) +Received: from elwamui-polski.atl.sa.earthlink.net ([209.86.224.45]) + by pop-gadwall.atl.sa.earthlink.net with esmtp (Exim 3.36 #10) + id 1EKmEt-0004Pw-00; Wed, 28 Sep 2005 20:25:31 -0400 +Message-ID: + <12692871.1127953531542.JavaMail.root@elwamui-polski.atl.sa.earthlink.net> +Date: Wed, 28 Sep 2005 20:25:31 -0400 (EDT) +From: Ron Peacetree +Reply-To: Ron Peacetree +To: Kevin Grittner , + pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: [PERFORM] A Better External Sort? +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Mailer: Earthlink Zoo Mail 1.0 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.263 required=5 tests=[AWL=-0.111, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200509/1356 +X-Sequence-Number: 73753 + +If I've done this correctly, there should not be anywhere near +the number of context switches we currently see while sorting. + +Each unscheduled context switch represents something unexpected +occuring or things not being where they are needed when they are +needed. Reducing such circumstances to the absolute minimum +was one of the design goals. + +Reducing the total amount of IO to the absolute minimum should +help as well. + +Ron + + +-----Original Message----- +From: Kevin Grittner +Sent: Sep 27, 2005 11:21 AM +Subject: Re: [HACKERS] [PERFORM] A Better External Sort? + +I can't help wondering how a couple thousand context switches per +second would affect the attempt to load disk info into the L1 and +L2 caches. That's pretty much the low end of what I see when the +server is under any significant load. + + + + +From pgsql-performance-owner@postgresql.org Thu Sep 29 00:05:53 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BC8F0D9B94 + for ; + Thu, 29 Sep 2005 00:05:41 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 44892-06 + for ; + Thu, 29 Sep 2005 03:05:37 +0000 (GMT) +Received: from cluster1.echolabs.net (mail.atlanticbb.net [216.52.118.222]) + by svr1.postgresql.org (Postfix) with ESMTP id 39F86D9B63 + for ; + Wed, 28 Sep 2005 23:00:02 -0300 (ADT) +X-Scanned-By: RAE MPP/Clamd http://www.messagepartners.com +X-Scanned-By: RAE MPP/Cloudmark http://www.messagepartners.com +Received: from [209.187.134.170] (account jma@atlanticbb.net HELO [127.0.0.1]) + by fe2.cluster1.echolabs.net (CommuniGate Pro SMTP 4.3.7) + with ESMTPA id 82545909 for pgsql-performance@postgresql.org; + Wed, 28 Sep 2005 22:00:00 -0400 +Message-ID: <433B4AA4.9080008@freedomcircle.net> +Date: Wed, 28 Sep 2005 22:00:04 -0400 +From: Joe +Organization: Freedom Circle, LLC +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Comparative performance +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.037 required=5 tests=[AWL=-0.013, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/403 +X-Sequence-Number: 14711 + +I'm converting a relatively small database (2 MB) from MySQL to PostgreSQL. It +is used to generate web pages using PHP. Although the actual website runs under +Linux, the development is done under XP. I've completed most of the data +conversion and rewrite of the PHP scripts, so now I'm comparing relative +performance. + +It appears that PostgreSQL is two to three times slower than MySQL. For +example, some pages that have some 30,000 characters (when saved as HTML) take 1 +to 1 1/2 seconds with MySQL but 3 to 4 seconds with PostgreSQL. I had read that +the former was generally faster than the latter, particularly for simple web +applications but I was hoping that Postgres' performance would not be that +noticeably slower. + +I'm trying to determine if the difference can be attributed to anything that +I've done or missed. I've run VACUUM ANALYZE on the two main tables and I'm +looking at the results of EXPLAIN on the query that drives the retrieval of +probably 80% of the data for the pages in question. + +Before I post the EXPLAIN and the table schema I'd appreciate confirmation that +this list is the appropriate forum. I'm a relative newcomer to PostgreSQL (but +not to relational databases), so I'm not sure if this belongs in the novice or +general lists. + +Joe + + +From pgsql-performance-owner@postgresql.org Wed Sep 28 23:29:36 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E629ED9B8D + for ; + Wed, 28 Sep 2005 23:29:33 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 29944-04 + for ; + Thu, 29 Sep 2005 02:29:28 +0000 (GMT) +Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.204]) + by svr1.postgresql.org (Postfix) with ESMTP id 6BDC8D9B8B + for ; + Wed, 28 Sep 2005 23:29:29 -0300 (ADT) +Received: by xproxy.gmail.com with SMTP id i30so1578063wxd + for ; + Wed, 28 Sep 2005 19:29:34 -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=gycJXw4xo9Uo9ai5eSyi3A7CmQUlOniRb6my7CgPe+BeF4SrCIooFmCJgoTlOUtjt/XSFpAkdWP4nUbrcCSVsZS0bkTkUg0Ezmx1wIKNSQkkF6SUTKHe6qQE4K0MW4yA5VmLETxpKbEKXh7dXB86vqA7BHlf18B/nwxJfUMU7o8= +Received: by 10.70.74.5 with SMTP id w5mr281416wxa; + Wed, 28 Sep 2005 19:29:34 -0700 (PDT) +Received: by 10.70.75.4 with HTTP; Wed, 28 Sep 2005 19:29:34 -0700 (PDT) +Message-ID: +Date: Thu, 29 Sep 2005 07:59:34 +0530 +From: Rajesh Kumar Mallah +Reply-To: Rajesh Kumar Mallah +To: Gavin Sherry +Subject: Re: Slow concurrent update of same row in a given table +Cc: pgsql-performance@postgresql.org +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: + + + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.482 required=5 tests=[AWL=0.458, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200509/401 +X-Sequence-Number: 14709 + +On 9/29/05, Gavin Sherry wrote: +> On Wed, 28 Sep 2005, Rajesh Kumar Mallah wrote: +> +> > > > Number of Copies | Update perl Sec +> > > > +> > > > 1 --> 119 +> > > > 2 ---> 59 +> > > > 3 ---> 38 +> > > > 4 ---> 28 +> > > > 5 --> 22 +> > > > 6 --> 19 +> > > > 7 --> 16 +> > > > 8 --> 14 +> > > > 9 --> 11 +> > > > 10 --> 11 +> > > > 11 --> 10 +> > > +> > > So, 11 instances result in 10 updated rows per second, database wide = +or +> > > per instance? If it is per instance, then 11 * 10 is close to the +> > > performance for one connection. +> > +> > +> > Sorry do not understand the difference between "database wide" +> > and "per instance" +> +> Per instance. +> +> > +> > > +> > > That being said, when you've got 10 connections fighting over one row= +, I +> > > wouldn't be surprised if you had bad performance. +> > > +> > > Also, at 119 updates a second, you're more than doubling the table's +> > > initial size (dead tuples) each second. How often are you vacuuming a= +nd +> > > are you using vacuum or vacuum full? +> > +> > +> > Yes I realize the obvious phenomenon now, (and the uselessness of the s= +cript) +> > , we should not consider it a performance degradation. +> > +> > I am having performance issue in my live database thats why i tried to +> > simulate the situation(may the the script was overstresser). +> > +> > My original problem is that i send 100 000s of emails carrying a +> > beacon for tracking readership every tuesday and on wednesday i see +> > lot of the said query in pg_stat_activity each of these query update +> > the SAME row that corresponds to the dispatch of last day and it is +> > then i face the performance problem. +> > +> > I think i can only post further details next wednesday , please lemme +> > know how should i be dealing with the situation if each the updates tak= +es +> > 100times more time that normal update duration. +> +> I see. These problems regularly come up in database design. The best thin= +g +> you can do is modify your database design/application such that instead o= +f +> incrementing a count in a single row, you insert a row into a table, +> recording the 'dispatch_id'. Counting the number of rows for a given +> dispatch id will give you your count. +> + +sorry i will be accumulating huge amount of rows in seperate table +with no extra info when i really want just the count. Do you have +a better database design in mind? + +Also i encounter same problem in implementing read count of +articles in sites and in counting banner impressions where same +row get updated by multiple processes frequently. + + +Thanks & Regds +mallah. + + + + + + + +> Thanks, +> +> Gavin +> + +From pgsql-performance-owner@postgresql.org Wed Sep 28 23:35:58 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1EEF7D9B83 + for ; + Wed, 28 Sep 2005 23:35:53 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 31438-06 + for ; + Thu, 29 Sep 2005 02:35:48 +0000 (GMT) +Received: from linuxworld.com.au (unknown [203.34.46.50]) + by svr1.postgresql.org (Postfix) with ESMTP id 1C4DCD930B + for ; + Wed, 28 Sep 2005 23:35:48 -0300 (ADT) +Received: from linuxworld.com.au (IDENT:swm@localhost.localdomain [127.0.0.1]) + by linuxworld.com.au (8.13.2/8.13.2) with ESMTP id j8T2ZoAk024041; + Thu, 29 Sep 2005 12:35:50 +1000 +Received: from localhost (swm@localhost) + by linuxworld.com.au (8.13.2/8.13.2/Submit) with ESMTP id + j8T2ZnTt024038; Thu, 29 Sep 2005 12:35:49 +1000 +X-Authentication-Warning: linuxworld.com.au: swm owned process doing -bs +Date: Thu, 29 Sep 2005 12:35:49 +1000 (EST) +From: Gavin Sherry +X-X-Sender: swm@linuxworld.com.au +To: Rajesh Kumar Mallah +Cc: pgsql-performance@postgresql.org +Subject: Re: Slow concurrent update of same row in a given table +In-Reply-To: +Message-ID: +References: + + + + +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.001 required=5 tests=[AWL=0.001] +X-Spam-Level: +X-Archive-Number: 200509/402 +X-Sequence-Number: 14710 + +On Thu, 29 Sep 2005, Rajesh Kumar Mallah wrote: + +> On 9/29/05, Gavin Sherry wrote: +> > On Wed, 28 Sep 2005, Rajesh Kumar Mallah wrote: +> > +> > > > > Number of Copies | Update perl Sec +> > > > > +> > > > > 1 --> 119 +> > > > > 2 ---> 59 +> > > > > 3 ---> 38 +> > > > > 4 ---> 28 +> > > > > 5 --> 22 +> > > > > 6 --> 19 +> > > > > 7 --> 16 +> > > > > 8 --> 14 +> > > > > 9 --> 11 +> > > > > 10 --> 11 +> > > > > 11 --> 10 +> > > > +> > > > So, 11 instances result in 10 updated rows per second, database wide or +> > > > per instance? If it is per instance, then 11 * 10 is close to the +> > > > performance for one connection. +> > > +> > > +> > > Sorry do not understand the difference between "database wide" +> > > and "per instance" +> > +> > Per instance. +> > +> > > +> > > > +> > > > That being said, when you've got 10 connections fighting over one row, I +> > > > wouldn't be surprised if you had bad performance. +> > > > +> > > > Also, at 119 updates a second, you're more than doubling the table's +> > > > initial size (dead tuples) each second. How often are you vacuuming and +> > > > are you using vacuum or vacuum full? +> > > +> > > +> > > Yes I realize the obvious phenomenon now, (and the uselessness of the script) +> > > , we should not consider it a performance degradation. +> > > +> > > I am having performance issue in my live database thats why i tried to +> > > simulate the situation(may the the script was overstresser). +> > > +> > > My original problem is that i send 100 000s of emails carrying a +> > > beacon for tracking readership every tuesday and on wednesday i see +> > > lot of the said query in pg_stat_activity each of these query update +> > > the SAME row that corresponds to the dispatch of last day and it is +> > > then i face the performance problem. +> > > +> > > I think i can only post further details next wednesday , please lemme +> > > know how should i be dealing with the situation if each the updates takes +> > > 100times more time that normal update duration. +> > +> > I see. These problems regularly come up in database design. The best thing +> > you can do is modify your database design/application such that instead of +> > incrementing a count in a single row, you insert a row into a table, +> > recording the 'dispatch_id'. Counting the number of rows for a given +> > dispatch id will give you your count. +> > +> +> sorry i will be accumulating huge amount of rows in seperate table +> with no extra info when i really want just the count. Do you have +> a better database design in mind? +> +> Also i encounter same problem in implementing read count of +> articles in sites and in counting banner impressions where same +> row get updated by multiple processes frequently. + +As I said in private email, accumulating large numbers of rows is not a +problem. In your current application, you are write bound, not read bound. +I've designed many similar systems which have hundred of millions of rows. +It takes a while to generate the count, but you just do it periodically in +non-busy periods. + +With 8.1, constraint exclusion will give you significantly better +performance with this system, as well. + +Thanks, + +Gavin + +From pgsql-performance-owner@postgresql.org Thu Sep 29 00:47:09 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DCAE7D8D9F + for ; + Thu, 29 Sep 2005 00:47:05 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 49613-10 + for ; + Thu, 29 Sep 2005 03:47:02 +0000 (GMT) +Received: from linuxworld.com.au (unknown [203.34.46.50]) + by svr1.postgresql.org (Postfix) with ESMTP id 7CF08D9B46 + for ; + Thu, 29 Sep 2005 00:46:59 -0300 (ADT) +Received: from linuxworld.com.au (IDENT:swm@localhost.localdomain [127.0.0.1]) + by linuxworld.com.au (8.13.2/8.13.2) with ESMTP id j8T3ksMd024370; + Thu, 29 Sep 2005 13:46:54 +1000 +Received: from localhost (swm@localhost) + by linuxworld.com.au (8.13.2/8.13.2/Submit) with ESMTP id + j8T3ksr9024367; Thu, 29 Sep 2005 13:46:54 +1000 +X-Authentication-Warning: linuxworld.com.au: swm owned process doing -bs +Date: Thu, 29 Sep 2005 13:46:54 +1000 (EST) +From: Gavin Sherry +X-X-Sender: swm@linuxworld.com.au +To: Joe +Cc: pgsql-performance@postgresql.org +Subject: Re: Comparative performance +In-Reply-To: <433B4AA4.9080008@freedomcircle.net> +Message-ID: +References: <433B4AA4.9080008@freedomcircle.net> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.001 required=5 tests=[AWL=0.001] +X-Spam-Level: +X-Archive-Number: 200509/404 +X-Sequence-Number: 14712 + +On Wed, 28 Sep 2005, Joe wrote: + +> I'm converting a relatively small database (2 MB) from MySQL to PostgreSQL. It +> is used to generate web pages using PHP. Although the actual website runs under +> Linux, the development is done under XP. I've completed most of the data +> conversion and rewrite of the PHP scripts, so now I'm comparing relative +> performance. +> +> It appears that PostgreSQL is two to three times slower than MySQL. For +> example, some pages that have some 30,000 characters (when saved as HTML) take 1 +> to 1 1/2 seconds with MySQL but 3 to 4 seconds with PostgreSQL. I had read that +> the former was generally faster than the latter, particularly for simple web +> applications but I was hoping that Postgres' performance would not be that +> noticeably slower. + +Are you comparing PostgreSQL on XP to MySQL on XP or PostgreSQL on Linux +to MySQL on Linux? Our performance on XP is not great. Also, which version +of PostgreSQL are you using? + +> +> I'm trying to determine if the difference can be attributed to anything that +> I've done or missed. I've run VACUUM ANALYZE on the two main tables and I'm +> looking at the results of EXPLAIN on the query that drives the retrieval of +> probably 80% of the data for the pages in question. + +Good. + +> +> Before I post the EXPLAIN and the table schema I'd appreciate confirmation that +> this list is the appropriate forum. I'm a relative newcomer to PostgreSQL (but +> not to relational databases), so I'm not sure if this belongs in the novice or +> general lists. + +You can post the results of EXPLAIN ANALYZE here. Please including schema +definitions and the query string(s) themselves. + +Thanks, + +Gavin + +From pgsql-hackers-owner@postgresql.org Thu Sep 29 01:27:28 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5F77AD9BCC + for ; + Thu, 29 Sep 2005 01:27:27 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 62915-05 + for ; + Thu, 29 Sep 2005 04:27:23 +0000 (GMT) +Received: from mail21.sea5.speakeasy.net (mail21.sea5.speakeasy.net + [69.17.117.23]) + by svr1.postgresql.org (Postfix) with ESMTP id 2F0A4D9BC8 + for ; + Thu, 29 Sep 2005 01:27:22 -0300 (ADT) +Received: (qmail 10048 invoked from network); 29 Sep 2005 04:27:21 -0000 +Received: from dsl081-060-184.sfo1.dsl.speakeasy.net (HELO noodles) + ([64.81.60.184]) (envelope-sender ) + by mail21.sea5.speakeasy.net (qmail-ldap-1.03) with RC4-MD5 encrypted + SMTP for ; 29 Sep 2005 04:27:21 -0000 +Subject: Re: [PERFORM] A Better External Sort? +From: "Jeffrey W. Baker" +To: Ron Peacetree +Cc: pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org +In-Reply-To: + <21402654.1127923414088.JavaMail.root@elwamui-polski.atl.sa.earthlink.net> +References: + <21402654.1127923414088.JavaMail.root@elwamui-polski.atl.sa.earthlink.net> +Content-Type: text/plain +Date: Wed, 28 Sep 2005 21:27:20 -0700 +Message-Id: <1127968040.8954.12.camel@noodles> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.1.1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.034 required=5 tests=[AWL=0.034] +X-Spam-Level: +X-Archive-Number: 200509/1341 +X-Sequence-Number: 73738 + +On Wed, 2005-09-28 at 12:03 -0400, Ron Peacetree wrote: +> >From: "Jeffrey W. Baker" +> >Sent: Sep 27, 2005 1:26 PM +> >To: Ron Peacetree +> >Subject: Re: [HACKERS] [PERFORM] A Better External Sort? +> > +> >On Tue, 2005-09-27 at 13:15 -0400, Ron Peacetree wrote: +> > +> >>That Btree can be used to generate a physical reordering of the data +> >>in one pass, but that's the weakest use for it. The more powerful +> >>uses involve allowing the Btree to persist and using it for more +> >>efficient re-searches or combining it with other such Btrees (either as +> >>a step in task distribution across multiple CPUs or as a more efficient +> >>way to do things like joins by manipulating these Btrees rather than +> >>the actual records.) +> > +> >Maybe you could describe some concrete use cases. I can see what +> >you are getting at, and I can imagine some advantageous uses, but +> >I'd like to know what you are thinking. +> > +> >Specifically I'd like to see some cases where this would beat sequential +> >scan. I'm thinking that in your example of a terabyte table with a +> >column having only two values, all the queries I can think of would be +> >better served with a sequential scan. +> > +> In my original example, a sequential scan of the 1TB of 2KB or 4KB +> records, => 250M or 500M records of data, being sorted on a binary +> value key will take ~1000x more time than reading in the ~1GB Btree +> I described that used a Key+RID (plus node pointers) representation +> of the data. + +You are engaging in a length and verbose exercise in mental +masturbation, because you have not yet given a concrete example of a +query where this stuff would come in handy. A common, general-purpose +case would be the best. + +We can all see that the method you describe might be a good way to sort +a very large dataset with some known properties, which would be fine if +you are trying to break the terasort benchmark. But that's not what +we're doing here. We are designing and operating relational databases. +So please explain the application. + +Your main example seems to focus on a large table where a key column has +constrained values. This case is interesting in proportion to the +number of possible values. If I have billions of rows, each having one +of only two values, I can think of a trivial and very fast method of +returning the table "sorted" by that key: make two sequential passes, +returning the first value on the first pass and the second value on the +second pass. This will be faster than the method you propose. + +I think an important aspect you have failed to address is how much of +the heap you must visit after the sort is complete. If you are +returning every tuple in the heap then the optimal plan will be very +different from the case when you needn't. + +-jwb + +PS: Whatever mailer you use doesn't understand or respect threading nor +attribution. Out of respect for the list's readers, please try a mailer +that supports these 30-year-old fundamentals of electronic mail. + + +From pgsql-performance-owner@postgresql.org Thu Sep 29 01:33:51 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E183BD921C + for ; + Thu, 29 Sep 2005 01:33:50 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 66696-02 + for ; + Thu, 29 Sep 2005 04:33:48 +0000 (GMT) +Received: from mail24.sea5.speakeasy.net (mail24.sea5.speakeasy.net + [69.17.117.26]) + by svr1.postgresql.org (Postfix) with ESMTP id 22EF3D8E31 + for ; + Thu, 29 Sep 2005 01:33:47 -0300 (ADT) +Received: (qmail 8085 invoked from network); 29 Sep 2005 04:33:47 -0000 +Received: from dsl081-060-184.sfo1.dsl.speakeasy.net (HELO noodles) + ([64.81.60.184]) (envelope-sender ) + by mail24.sea5.speakeasy.net (qmail-ldap-1.03) with RC4-MD5 encrypted + SMTP for ; 29 Sep 2005 04:33:47 -0000 +Subject: Sequential I/O Cost (was Re: A Better External Sort?) +From: "Jeffrey W. Baker" +To: Ron Peacetree +Cc: pgsql-performance@postgresql.org +In-Reply-To: + <21402654.1127923414088.JavaMail.root@elwamui-polski.atl.sa.earthlink.net> +References: + <21402654.1127923414088.JavaMail.root@elwamui-polski.atl.sa.earthlink.net> +Content-Type: text/plain +Date: Wed, 28 Sep 2005 21:33:46 -0700 +Message-Id: <1127968426.8954.19.camel@noodles> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.1.1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.03 required=5 tests=[AWL=0.030] +X-Spam-Level: +X-Archive-Number: 200509/406 +X-Sequence-Number: 14714 + +On Wed, 2005-09-28 at 12:03 -0400, Ron Peacetree wrote: +> >From: "Jeffrey W. Baker" +> >Perhaps I believe this because you can now buy as much sequential I/O +> >as you want. Random I/O is the only real savings. +> > +> 1= No, you can not "buy as much sequential IO as you want". Even if +> with an infinite budget, there are physical and engineering limits. Long +> before you reach those limits, you will pay exponentially increasing costs +> for linearly increasing performance gains. So even if you _can_ buy a +> certain level of sequential IO, it may not be the most efficient way to +> spend money. + +This is just false. You can buy sequential I/O for linear money up to +and beyond your platform's main memory bandwidth. Even 1GB/sec will +severely tax memory bandwidth of mainstream platforms, and you can +achieve this rate for a modest cost. + +I have one array that can supply this rate and it has only 15 disks. It +would fit on my desk. I think your dire talk about the limits of +science and engineering may be a tad overblown. + + +From pgsql-performance-owner@postgresql.org Thu Sep 29 02:38:50 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EB881D9BCA + for ; + Thu, 29 Sep 2005 02:38:48 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 78871-04 + for ; + Thu, 29 Sep 2005 05:38:42 +0000 (GMT) +Received: from zigo.dhs.org (ua-83-227-204-174.cust.bredbandsbolaget.se + [83.227.204.174]) + by svr1.postgresql.org (Postfix) with ESMTP id 09EB6D9BA7 + for ; + Thu, 29 Sep 2005 02:38:42 -0300 (ADT) +Received: from zigo.zigo.dhs.org (zigo.zigo.dhs.org [192.168.0.1]) + by zigo.dhs.org (Postfix) with ESMTP + id F2C568467; Thu, 29 Sep 2005 07:38:38 +0200 (CEST) +Date: Thu, 29 Sep 2005 07:38:38 +0200 (CEST) +From: Dennis Bjorklund +To: Joe +Cc: pgsql-performance@postgresql.org +Subject: Re: Comparative performance +In-Reply-To: <433B4AA4.9080008@freedomcircle.net> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=ISO-8859-1 +Content-Transfer-Encoding: 8BIT +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.324 required=5 tests=[AWL=-0.100, + DNS_FROM_RFC_ABUSE=0.374, FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/407 +X-Sequence-Number: 14715 + +On Wed, 28 Sep 2005, Joe wrote: + +> Before I post the EXPLAIN and the table schema I'd appreciate +> confirmation that this list is the appropriate forum. + +It is and and useful things to show are + + * the slow query + * EXPLAIN ANALYZE of the query + * the output of \d for each table involved in the query + * the output of SHOW ALL; + * The amount of memory the machine have + +The settings that are the most important to tune in postgresql.conf for +performance is in my opinion; shared_buffers, effective_cache_size and +(to a lesser extent) work_mem. + +-- +/Dennis Bj�rklund + + +From pgsql-hackers-owner@postgresql.org Thu Sep 29 09:58:13 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0923CD9BCA; + Thu, 29 Sep 2005 03:21:19 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 92248-02; Thu, 29 Sep 2005 06:21:13 +0000 (GMT) +Received: from pop-knobcone.atl.sa.earthlink.net + (pop-knobcone.atl.sa.earthlink.net [207.69.195.64]) + by svr1.postgresql.org (Postfix) with ESMTP id 0A52FD8F22; + Thu, 29 Sep 2005 03:21:13 -0300 (ADT) +Received: from elwamui-polski.atl.sa.earthlink.net ([209.86.224.45]) + by pop-knobcone.atl.sa.earthlink.net with esmtp (Exim 3.36 #10) + id 1EKrn4-0007Cz-00; Thu, 29 Sep 2005 02:21:10 -0400 +Message-ID: + <11604324.1127974870565.JavaMail.root@elwamui-polski.atl.sa.earthlink.net> +Date: Thu, 29 Sep 2005 02:21:10 -0400 (EDT) +From: Ron Peacetree +Reply-To: Ron Peacetree +To: "Jeffrey W. Baker" , + pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: [PERFORM] A Better External Sort? +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Mailer: Earthlink Zoo Mail 1.0 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.264 required=5 tests=[AWL=-0.110, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200509/1354 +X-Sequence-Number: 73751 + +>From: "Jeffrey W. Baker" +>Sent: Sep 29, 2005 12:27 AM +>To: Ron Peacetree +>Cc: pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org +>Subject: Re: [HACKERS] [PERFORM] A Better External Sort? +> +>You are engaging in a length and verbose exercise in mental +>masturbation, because you have not yet given a concrete example of a +>query where this stuff would come in handy. A common, general-purpose +>case would be the best. +> +??? I posted =3= specific classes of common, general-purpose query +operations where OES and the OES Btrees look like they should be +superior to current methods: +1= when splitting sorting or other operations across multiple CPUs +2= when doing joins of different tables by doing the join on these Btrees +rather than the original tables. +3= when the opportunity arises to reuse OES Btree results of previous +sorts for different keys in the same table. Now we can combine the +existing Btrees to obtain the new order based on the composite key +without ever manipulating the original, much larger, table. + +In what way are these examples not "concrete"? + + +>We can all see that the method you describe might be a good way to sort +>a very large dataset with some known properties, which would be fine if +>you are trying to break the terasort benchmark. But that's not what +>we're doing here. We are designing and operating relational databases. +>So please explain the application. +> +This is a GENERAL method. It's based on CPU cache efficient Btrees that +use variable length prefix keys and RIDs. +It assumes NOTHING about the data or the system in order to work. +I gave some concrete examples for the sake of easing explanation, NOT +as an indication of assumptions or limitations of the method. I've even +gone out of my way to prove that no such assumptions or limitations exist. +Where in the world are you getting such impressions? + + +>Your main example seems to focus on a large table where a key column has +>constrained values. This case is interesting in proportion to the +>number of possible values. If I have billions of rows, each having one +>of only two values, I can think of a trivial and very fast method of +>returning the table "sorted" by that key: make two sequential passes, +>returning the first value on the first pass and the second value on the +>second pass. This will be faster than the method you propose. +> +1= No that was not my main example. It was the simplest example used to +frame the later more complicated examples. Please don't get hung up on it. + +2= You are incorrect. Since IO is the most expensive operation we can do, +any method that makes two passes through the data at top scanning speed +will take at least 2x as long as any method that only takes one such pass. + + +>I think an important aspect you have failed to address is how much of +>the heap you must visit after the sort is complete. If you are +>returning every tuple in the heap then the optimal plan will be very +>different from the case when you needn't. +> +Hmmm. Not sure which "heap" you are referring to, but the OES Btree +index is provably the lowest (in terms of tree height) and smallest +possible CPU cache efficient data structure that one can make and still +have all of the traditional benefits associated with a Btree representation +of a data set. + +Nonetheless, returning a RID, or all RIDs with(out) the same Key, or all +RIDs (not) within a range of Keys, or simply all RIDs in sorted order is +efficient. Just as should be for a Btree (actually it's a B+ tree variant to +use Knuth's nomenclature). I'm sure someone posting from acm.org +recognizes how each of these Btree operations maps to various SQL +features... + +I haven't been talking about query plans because they are orthogonal to +the issue under discussion? If we use a layered model for PostgreSQL's +architecture, this functionality is more primal than that of a query +planner. ALL query plans that currently involve sorts will benefit from a +more efficient way to do, or avoid, sorts. + + +>PS: Whatever mailer you use doesn't understand or respect threading nor +>attribution. Out of respect for the list's readers, please try a mailer +>that supports these 30-year-old fundamentals of electronic mail. +> +That is an issue of infrastructure on the recieving side, not on the sending +(my) side since even my web mailer seems appropriately RFC conformant. +Everything seems to be going in the correct places and being properly +organized on archival.postgres.org ... + +Ron + +From pgsql-performance-owner@postgresql.org Thu Sep 29 03:29:15 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9C0DFD9BD9 + for ; + Thu, 29 Sep 2005 03:29:13 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 94718-01 + for ; + Thu, 29 Sep 2005 06:29:10 +0000 (GMT) +Received: from mx-2.sollentuna.net (mx-2.sollentuna.net [195.84.163.199]) + by svr1.postgresql.org (Postfix) with ESMTP id C1E12D9BD3 + for ; + Thu, 29 Sep 2005 03:29:09 -0300 (ADT) +Received: from ALGOL.sollentuna.se (janus.sollentuna.se [62.65.68.67]) + by mx-2.sollentuna.net (Postfix) with ESMTP + id 2E0448F287; Thu, 29 Sep 2005 08:29:10 +0200 (CEST) +Subject: Re: Comparative performance +MIME-Version: 1.0 +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: quoted-printable +Date: Thu, 29 Sep 2005 08:29:09 +0200 +Content-class: urn:content-classes:message +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Message-ID: <6BCB9D8A16AC4241919521715F4D8BCE92E6D6@algol.sollentuna.se> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Comparative performance +Thread-Index: AcXEqSNtnTTKs8kPS72bXeJ/I099lQAFIhKg +From: "Magnus Hagander" +To: "Gavin Sherry" , "Joe" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.061 required=5 tests=[AWL=0.011, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/409 +X-Sequence-Number: 14717 + +> > It appears that PostgreSQL is two to three times slower=20 +> than MySQL. =20 +> > For example, some pages that have some 30,000 characters=20 +> (when saved=20 +> > as HTML) take 1 to 1 1/2 seconds with MySQL but 3 to 4 seconds with=20 +> > PostgreSQL. I had read that the former was generally=20 +> faster than the=20 +> > latter, particularly for simple web applications but I was=20 +> hoping that=20 +> > Postgres' performance would not be that noticeably slower. +>=20 +> Are you comparing PostgreSQL on XP to MySQL on XP or=20 +> PostgreSQL on Linux to MySQL on Linux? Our performance on XP=20 +> is not great. Also, which version of PostgreSQL are you using? + +That actually depends a lot on *how* you use it. I've seen pg-on-windows +deployments that come within a few percent of the linux performance. +I've also seen those that are absolutely horrible compared. + +One sure way to kill the performance is to do a lot of small +connections. Using persistent connection is even more important on +Windows than it is on Unix. It could easily explain a difference like +this. + +//Magnus + +From pgsql-performance-owner@postgresql.org Thu Sep 29 04:43:06 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4964FD8F22 + for ; + Thu, 29 Sep 2005 04:43:04 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 07135-07 + for ; + Thu, 29 Sep 2005 07:42:57 +0000 (GMT) +Received: from pop-knobcone.atl.sa.earthlink.net + (pop-knobcone.atl.sa.earthlink.net [207.69.195.64]) + by svr1.postgresql.org (Postfix) with ESMTP id 36461D9BCF + for ; + Thu, 29 Sep 2005 04:42:57 -0300 (ADT) +Received: from elwamui-polski.atl.sa.earthlink.net ([209.86.224.45]) + by pop-knobcone.atl.sa.earthlink.net with esmtp (Exim 3.36 #10) + id 1EKt4A-0004im-00; Thu, 29 Sep 2005 03:42:54 -0400 +Message-ID: + <2944051.1127979774218.JavaMail.root@elwamui-polski.atl.sa.earthlink.net> +Date: Thu, 29 Sep 2005 03:42:54 -0400 (EDT) +From: Ron Peacetree +Reply-To: Ron Peacetree +To: "Jeffrey W. Baker" , + pgsql-performance@postgresql.org +Subject: Re: Sequential I/O Cost (was Re: A Better External Sort?) +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Mailer: Earthlink Zoo Mail 1.0 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.265 required=5 tests=[AWL=-0.109, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200509/410 +X-Sequence-Number: 14718 + +>From: "Jeffrey W. Baker" +>Sent: Sep 29, 2005 12:33 AM +>Subject: Sequential I/O Cost (was Re: [PERFORM] A Better External Sort?) +> +>On Wed, 2005-09-28 at 12:03 -0400, Ron Peacetree wrote: +>>>From: "Jeffrey W. Baker" +>>>Perhaps I believe this because you can now buy as much sequential I/O +>>>as you want. Random I/O is the only real savings. +>>> +>> 1= No, you can not "buy as much sequential IO as you want". Even if +>> with an infinite budget, there are physical and engineering limits. Long +>> before you reach those limits, you will pay exponentially increasing costs +>> for linearly increasing performance gains. So even if you _can_ buy a +>> certain level of sequential IO, it may not be the most efficient way to +>> spend money. +> +>This is just false. You can buy sequential I/O for linear money up to +>and beyond your platform's main memory bandwidth. Even 1GB/sec will +>severely tax memory bandwidth of mainstream platforms, and you can +>achieve this rate for a modest cost. +> +I don't think you can prove this statement. +A= www.pricewatch.com lists 7200rpm 320GB SATA II HDs for ~$160. +ASTR according to www.storagereview.com is ~50MBps. Average access +time is ~12-13ms. +Absolute TOTL 15Krpm 147GB U320 or FC HDs cost ~4x as much per GB, +yet only deliver ~80-90MBps ASTR and average access times of +~5.5-6.0ms. +Your statement is clearly false in terms of atomic raw HD performance. + +B= low end RAID controllers can be obtained for a few $100's. But even +amongst them, a $600+ card does not perform 3-6x better than a +$100-$200 card. When the low end HW is not enough, the next step in +price is to ~$10K+ (ie Xyratex), and the ones after that are to ~$100K+ +(ie NetApps) and ~$1M+ (ie EMC, IBM, etc). None of these ~10x steps +in price results in a ~10x increase in performance. +Your statement is clearly false in terms of HW based RAID performance. + +C= A commodity AMD64 mainboard with a dual channel DDR PC3200 +RAM subsystem has 6.4GBps of bandwidth. These are as common +as weeds and almost as cheap: www.pricewatch.com +Your statement about commodity systems main memory bandwidth +being "severely taxed at 1GBps" is clearly false. + +D= Xyratecs makes RAID HW for NetApps and EMC. NONE of their +current HW can deliver 1GBps. More like 600-700MBps. Engino and +Dot Hill have similar limitations on their current products. No PCI or +PCI-X based HW could ever do more than ~800-850MBps since +that's the RW limit of those busses. Next Gen products are likely to +2x those limits and cross the 1GBps barrier based on ~90MBps SAS +or FC HD's and PCI-Ex8 (2GBps max) and PCI-Ex16 (4GBps max). +Note that not even next gen or 2 gens from now RAID HW will be +able to match the memory bandwidth of the current commodity +memory subsystem mentioned in "C" above. +Your statement that one can achieve a HD IO rate that will tax RAM +bandwidth at modest cost is clearly false. + +QED Your statement is false on all counts and in all respects. + + +>I have one array that can supply this rate and it has only 15 disks. It +>would fit on my desk. I think your dire talk about the limits of +>science and engineering may be a tad overblown. +> +Name it and post its BOM, configuration specs, price and ordering +information. Then tell us what it's plugged into and all the same +details on _that_. + +If all 15 HD's are being used for one RAID set, then you can't be +using RAID 10, which means any claims re: write performance in +particular should be closely examined. + +A 15 volume RAID 5 made of the fastest 15Krpm U320 or FC HDs, +each with ~85.9MBps ASTR, could in theory do ~14*85.9= +~1.2GBps raw ASTR for at least reads, but no one I know of makes +commodity RAID HW that can keep up with this, nor can any one +PCI-X bus support it even if such commodity RAID HW did exist. + +Hmmm. SW RAID on at least a PCI-Ex8 bus might be able to do it if +we can multiplex enough 4Gbps FC lines (4Gbps= 400MBps => max +of 4 of the above HDs per line and 4 FC lines) with low enough latency +and have enough CPU driving it...Won't be easy nor cheap though. + +From pgsql-performance-owner@postgresql.org Thu Sep 29 07:45:00 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7F071D9BA3 + for ; + Thu, 29 Sep 2005 07:44:59 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 57636-04 + for ; + Thu, 29 Sep 2005 10:44:54 +0000 (GMT) +Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 4A235D9BF4 + for ; + Thu, 29 Sep 2005 07:44:54 -0300 (ADT) +Received: (qmail 23064 invoked from network); 29 Sep 2005 12:45:47 +0200 +Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) + by boutiquenumerique.com with SMTP; 29 Sep 2005 12:45:47 +0200 +To: Joe , pgsql-performance@postgresql.org +Subject: Re: Comparative performance +References: <433B4AA4.9080008@freedomcircle.net> +Message-ID: +Date: Thu, 29 Sep 2005 12:44:55 +0200 +From: PFC +Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= +Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +In-Reply-To: <433B4AA4.9080008@freedomcircle.net> +User-Agent: Opera M2/8.0 (Linux, build 1095) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/411 +X-Sequence-Number: 14719 + + +> It appears that PostgreSQL is two to three times slower than MySQL. For +> example, some pages that have some 30,000 characters (when saved as +> HTML) take 1 to 1 1/2 seconds with MySQL but 3 to 4 seconds with +> PostgreSQL. I had read that the former was generally faster than the +> latter, particularly for simple web applications but I was hoping that +> Postgres' performance would not be that noticeably slower. + + From my experience, the postgres libraries in PHP are a piece of crap, +and add a lot of overhead even from small queries. + For instance, a simple query like "SELECT * FROM table WHERE +primary_key_id=1234" can take the following time, on my laptop, with data +in the filesystem cache of course : + +EXPLAIN ANALYZE <0.1 ms +python + psycopg 2 0.1 ms (damn fast) +php + mysql 0.3 ms +php + postgres 1-2 ms (damn slow) + + So, if your pages are designed in The PHP Way (ie. a large number of +small queries), I might suggest using a language with a decent postgres +interface (python, among others), or rewriting your bunches of small +queries as Stored Procedures or Joins, which will provide large speedups. +Doing >50 queries on a page is always a bad idea, but it's tolerable in +php-mysql, not in php-postgres. + + If it's only one large query, there is a problem, as postgres is usually +a lot smarter about query optimization. + + If you use the usual mysql techniques (like, storing a page counter in a +row in a table, or storing sessions in a table) beware, these are no-nos +for postgres, these things should NOT be done with a database anyway, try +memcached for instance. + +From pgsql-hackers-owner@postgresql.org Thu Sep 29 08:12:01 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 98647D9420; + Thu, 29 Sep 2005 08:12:00 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 63392-05; Thu, 29 Sep 2005 11:11:56 +0000 (GMT) +Received: from mail.rilk.com (mail.rilk.com [193.19.217.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 49F4FD80D7; + Thu, 29 Sep 2005 08:11:56 -0300 (ADT) +Received: from [193.248.93.254] + (Mix-St-Amand-107-2-254.w193-248.abo.wanadoo.fr + [193.248.93.254]) (authenticated bits=0) + by mail.rilk.com (8.13.0/8.13.0) with ESMTP id j8TBBlSP027543 + (version=TLSv1/SSLv3 cipher=EDH-DSS-DES-CBC3-SHA bits=168 verify=NO); + Thu, 29 Sep 2005 13:11:57 +0200 (CEST) +Mime-Version: 1.0 (Apple Message framework v734) +In-Reply-To: + <11604324.1127974870565.JavaMail.root@elwamui-polski.atl.sa.earthlink.net> +References: + <11604324.1127974870565.JavaMail.root@elwamui-polski.atl.sa.earthlink.net> +Content-Type: text/plain; charset=ISO-8859-1; delsp=yes; format=flowed +Message-Id: <5A8CC216-2E25-4B8C-910A-69224D0A66CE@rilk.com> +Cc: Pg Hackers , + pgsql-performance@postgresql.org +Content-Transfer-Encoding: quoted-printable +From: Pailloncy Jean-Gerard +Subject: Re: [PERFORM] A Better External Sort? +Date: Thu, 29 Sep 2005 13:11:45 +0200 +X-Mailer: Apple Mail (2.734) +X-DCC-Servercave-Metrics: mail.rilk.com 1183; Body=2 Fuz1=2 Fuz2=2 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/1352 +X-Sequence-Number: 73749 + +>> Your main example seems to focus on a large table where a key =20 +>> column has +>> constrained values. This case is interesting in proportion to the +>> number of possible values. If I have billions of rows, each =20 +>> having one +>> of only two values, I can think of a trivial and very fast method of +>> returning the table "sorted" by that key: make two sequential passes, +>> returning the first value on the first pass and the second value =20 +>> on the +>> second pass. This will be faster than the method you propose. +>> +>> +> 1=3D No that was not my main example. It was the simplest example =20 +> used to +> frame the later more complicated examples. Please don't get hung =20 +> up on it. +> +> 2=3D You are incorrect. Since IO is the most expensive operation we =20= + +> can do, +> any method that makes two passes through the data at top scanning =20 +> speed +> will take at least 2x as long as any method that only takes one =20 +> such pass. +You do not get the point. +As the time you get the sorted references to the tuples, you need to =20 +fetch the tuples themself, check their visbility, etc. and returns =20 +them to the client. + +So, +if there is only 2 values in the column of big table that is larger =20 +than available RAM, +two seq scans of the table without any sorting +is the fastest solution. + +Cordialement, +Jean-G=E9rard Pailloncy + + +From pgsql-performance-owner@postgresql.org Thu Sep 29 09:16:12 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 75C5CD8C54 + for ; + Thu, 29 Sep 2005 09:16:11 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 78703-07 + for ; + Thu, 29 Sep 2005 12:16:06 +0000 (GMT) +Received: from cluster1.echolabs.net (mail.atlanticbb.net [216.52.118.222]) + by svr1.postgresql.org (Postfix) with ESMTP id 99936D706A + for ; + Thu, 29 Sep 2005 09:16:05 -0300 (ADT) +X-Scanned-By: RAE MPP/Clamd http://www.messagepartners.com +X-Scanned-By: RAE MPP/Cloudmark http://www.messagepartners.com +Received: from [209.187.134.170] (account jma@atlanticbb.net HELO [127.0.0.1]) + by fe2.cluster1.echolabs.net (CommuniGate Pro SMTP 4.3.7) + with ESMTPA id 82616899; Thu, 29 Sep 2005 08:16:08 -0400 +Message-ID: <433BDB0B.8010002@freedomcircle.net> +Date: Thu, 29 Sep 2005 08:16:11 -0400 +From: Joe +Organization: Freedom Circle, LLC +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Magnus Hagander +Cc: Gavin Sherry , + pgsql-performance@postgresql.org +Subject: Re: Comparative performance +References: <6BCB9D8A16AC4241919521715F4D8BCE92E6D6@algol.sollentuna.se> +In-Reply-To: <6BCB9D8A16AC4241919521715F4D8BCE92E6D6@algol.sollentuna.se> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.042 required=5 tests=[AWL=-0.008, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/413 +X-Sequence-Number: 14721 + +Magnus Hagander wrote: +> That actually depends a lot on *how* you use it. I've seen pg-on-windows +> deployments that come within a few percent of the linux performance. +> I've also seen those that are absolutely horrible compared. +> +> One sure way to kill the performance is to do a lot of small +> connections. Using persistent connection is even more important on +> Windows than it is on Unix. It could easily explain a difference like +> this. + +I just tried using pg_pconnect() and I didn't notice any significant +improvement. What bothers me most is that with Postgres I tend to see jerky +behavior on almost every page: the upper 1/2 or 2/3 of the page is displayed +first and you can see a blank bottom (or you can see a half-filled completion +bar). With MySQL each page is generally displayed in one swoop. + +Joe + + +From pgsql-performance-owner@postgresql.org Thu Sep 29 09:30:37 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EE45AD9B21 + for ; + Thu, 29 Sep 2005 09:30:36 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 78703-09 + for ; + Thu, 29 Sep 2005 12:30:32 +0000 (GMT) +Received: from cassarossa.samfundet.no (cassarossa.samfundet.no + [129.241.93.19]) + by svr1.postgresql.org (Postfix) with ESMTP id 2CA8CD9B69 + for ; + Thu, 29 Sep 2005 09:30:33 -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 1EKxYY-0006UI-8H + for pgsql-performance@postgresql.org; Thu, 29 Sep 2005 14:30:35 +0200 +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1EKxYU-00050y-00 + for ; Thu, 29 Sep 2005 14:30:30 +0200 +Date: Thu, 29 Sep 2005 14:30:30 +0200 +From: "Steinar H. Gunderson" +To: pgsql-performance@postgresql.org +Subject: Re: Comparative performance +Message-ID: <20050929123030.GA15026@uio.no> +Mail-Followup-To: pgsql-performance@postgresql.org +References: <6BCB9D8A16AC4241919521715F4D8BCE92E6D6@algol.sollentuna.se> + <433BDB0B.8010002@freedomcircle.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Disposition: inline +In-Reply-To: <433BDB0B.8010002@freedomcircle.net> +X-Operating-System: Linux 2.6.11.8 on a i686 +X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.014 required=5 tests=[AWL=0.014] +X-Spam-Level: +X-Archive-Number: 200509/414 +X-Sequence-Number: 14722 + +On Thu, Sep 29, 2005 at 08:16:11AM -0400, Joe wrote: +> I just tried using pg_pconnect() and I didn't notice any significant +> improvement. + +PHP persistent connections are not really persistent -- or so I've been told. + +Anyhow, what was discussed here was pg_query, not pg_connect. You really want +to reduce the number of pg_query() calls in any case; you haven't told us how +many there are yet, but it sounds like there are a lot of them. + +> What bothers me most is that with Postgres I tend to see jerky behavior on +> almost every page: the upper 1/2 or 2/3 of the page is displayed first and +> you can see a blank bottom (or you can see a half-filled completion bar). +> With MySQL each page is generally displayed in one swoop. + +This might just be your TCP/IP stack finding out that the rest of the page +isn't likely to come anytime soon, and start sending it out... or something +else. I wouldn't put too much weight on it, it's likely to go away as soon as +you fix the rest of the problem. + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-performance-owner@postgresql.org Thu Sep 29 09:31:15 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C111FD8C54 + for ; + Thu, 29 Sep 2005 09:31:13 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 78897-09 + for ; + Thu, 29 Sep 2005 12:31:07 +0000 (GMT) +Received: from linuxworld.com.au (unknown [203.34.46.50]) + by svr1.postgresql.org (Postfix) with ESMTP id 4E6D4D8B50 + for ; + Thu, 29 Sep 2005 09:31:08 -0300 (ADT) +Received: from linuxworld.com.au (IDENT:swm@localhost.localdomain [127.0.0.1]) + by linuxworld.com.au (8.13.2/8.13.2) with ESMTP id j8TCV6pR026605; + Thu, 29 Sep 2005 22:31:06 +1000 +Received: from localhost (swm@localhost) + by linuxworld.com.au (8.13.2/8.13.2/Submit) with ESMTP id + j8TCV619026602; Thu, 29 Sep 2005 22:31:06 +1000 +X-Authentication-Warning: linuxworld.com.au: swm owned process doing -bs +Date: Thu, 29 Sep 2005 22:31:06 +1000 (EST) +From: Gavin Sherry +X-X-Sender: swm@linuxworld.com.au +To: Joe +Cc: Magnus Hagander , + pgsql-performance@postgresql.org +Subject: Re: Comparative performance +In-Reply-To: <433BDB0B.8010002@freedomcircle.net> +Message-ID: +References: <6BCB9D8A16AC4241919521715F4D8BCE92E6D6@algol.sollentuna.se> + <433BDB0B.8010002@freedomcircle.net> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.001 required=5 tests=[AWL=0.001] +X-Spam-Level: +X-Archive-Number: 200509/415 +X-Sequence-Number: 14723 + +On Thu, 29 Sep 2005, Joe wrote: + +> Magnus Hagander wrote: +> > That actually depends a lot on *how* you use it. I've seen pg-on-windows +> > deployments that come within a few percent of the linux performance. +> > I've also seen those that are absolutely horrible compared. +> > +> > One sure way to kill the performance is to do a lot of small +> > connections. Using persistent connection is even more important on +> > Windows than it is on Unix. It could easily explain a difference like +> > this. +> +> I just tried using pg_pconnect() and I didn't notice any significant +> improvement. What bothers me most is that with Postgres I tend to see jerky +> behavior on almost every page: the upper 1/2 or 2/3 of the page is displayed +> first and you can see a blank bottom (or you can see a half-filled completion +> bar). With MySQL each page is generally displayed in one swoop. + +Please post the table definitions, queries and explain analyze results so +we can tell you why the performance is poor. + +Gavin + +From pgsql-performance-owner@postgresql.org Thu Sep 29 09:37:03 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A7C3ED706A + for ; + Thu, 29 Sep 2005 09:37:01 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81252-09 + for ; + Thu, 29 Sep 2005 12:36:56 +0000 (GMT) +Received: from cluster1.echolabs.net (smtp-out.echolabs.net [216.52.118.200]) + by svr1.postgresql.org (Postfix) with ESMTP id BF2E4D6ECD + for ; + Thu, 29 Sep 2005 09:36:58 -0300 (ADT) +X-Scanned-By: RAE MPP/Clamd http://www.messagepartners.com +X-Scanned-By: RAE MPP/Cloudmark http://www.messagepartners.com +Received: from [209.187.134.170] (account jma@atlanticbb.net HELO [127.0.0.1]) + by fe3.cluster1.echolabs.net (CommuniGate Pro SMTP 4.3.7) + with ESMTPA id 1656554; Thu, 29 Sep 2005 08:32:41 -0400 +Message-ID: <433BDFF3.3090402@freedomcircle.net> +Date: Thu, 29 Sep 2005 08:37:07 -0400 +From: Joe +Organization: Freedom Circle, LLC +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: PFC +Cc: pgsql-performance@postgresql.org +Subject: Re: Comparative performance +References: <433B4AA4.9080008@freedomcircle.net> +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-15; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.018 required=5 tests=[AWL=0.018] +X-Spam-Level: +X-Archive-Number: 200509/416 +X-Sequence-Number: 14724 + +PFC wrote: +> From my experience, the postgres libraries in PHP are a piece of +> crap, and add a lot of overhead even from small queries. +> For instance, a simple query like "SELECT * FROM table WHERE +> primary_key_id=1234" can take the following time, on my laptop, with +> data in the filesystem cache of course : +> +> EXPLAIN ANALYZE <0.1 ms +> python + psycopg 2 0.1 ms (damn fast) +> php + mysql 0.3 ms +> php + postgres 1-2 ms (damn slow) + +As a Trac user I was considering moving to Python, so it's good to know that, +but the rewrite is a longer term project. + +> So, if your pages are designed in The PHP Way (ie. a large number +> of small queries), I might suggest using a language with a decent +> postgres interface (python, among others), or rewriting your bunches of +> small queries as Stored Procedures or Joins, which will provide large +> speedups. Doing >50 queries on a page is always a bad idea, but it's +> tolerable in php-mysql, not in php-postgres. + +The pages do use a number of queries to collect all the data for display but +nowhere near 50. I'd say it's probably less than a dozen. As an aside, one of +my tasks (before the conversion) was to analyze the queries and see where they +could be tweaked for performance, but with MySQL that was never a top priority. + +The schema is fairly simple having two main tables: topic and entry (sort of +like account and transaction in an accounting scenario). There are two +additional tables that perhaps could be merged into the entry table (and that +would reduce the number of queries) but I do not want to make major changes to +the schema (and the app) for the PostgreSQL conversion. + +Joe + + +From pgsql-performance-owner@postgresql.org Thu Sep 29 09:44:18 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BAA8ED9BF4 + for ; + Thu, 29 Sep 2005 09:44:17 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 83880-10 + for ; + Thu, 29 Sep 2005 12:44:06 +0000 (GMT) +Received: from cluster1.echolabs.net (mail.atlanticbb.net [216.52.118.222]) + by svr1.postgresql.org (Postfix) with ESMTP id 2B046D90A5 + for ; + Thu, 29 Sep 2005 09:44:07 -0300 (ADT) +X-Scanned-By: RAE MPP/Clamd http://www.messagepartners.com +X-Scanned-By: RAE MPP/Cloudmark http://www.messagepartners.com +Received: from [209.187.134.170] (account jma@atlanticbb.net HELO [127.0.0.1]) + by fe2.cluster1.echolabs.net (CommuniGate Pro SMTP 4.3.7) + with ESMTPA id 82621431; Thu, 29 Sep 2005 08:44:11 -0400 +Message-ID: <433BE1A0.5000807@freedomcircle.net> +Date: Thu, 29 Sep 2005 08:44:16 -0400 +From: Joe +Organization: Freedom Circle, LLC +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Gavin Sherry +Cc: Magnus Hagander , + pgsql-performance@postgresql.org +Subject: Re: Comparative performance +References: <6BCB9D8A16AC4241919521715F4D8BCE92E6D6@algol.sollentuna.se> + <433BDB0B.8010002@freedomcircle.net> + +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.04 required=5 tests=[AWL=-0.010, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/417 +X-Sequence-Number: 14725 + +Gavin Sherry wrote: +> Please post the table definitions, queries and explain analyze results so +> we can tell you why the performance is poor. + +I did try to post that last night but apparently my reply didn't make it to the +list. Here it is again: + +Matthew Nuzum wrote: + + > This is the right list. Post detail and I'm sure you'll get some suggestions. + + +Thanks, Matthew (and Chris and Gavin). + +The main table used in the query is defined as follows: + +CREATE TABLE entry ( + entry_id serial PRIMARY KEY, + title VARCHAR(128) NOT NULL, + subtitle VARCHAR(128), + subject_type SMALLINT, + subject_id INTEGER REFERENCES topic, + actor_type SMALLINT, + actor_id INTEGER REFERENCES topic, + actor VARCHAR(64), + actor_role VARCHAR(64), + rel_entry_id INTEGER, + rel_entry VARCHAR(64), + description VARCHAR(255), + quote text, + url VARCHAR(255), + entry_date CHAR(10), + created DATE NOT NULL DEFAULT CURRENT_DATE, + updated TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP) +WITHOUT OIDS; +CREATE INDEX entry_actor_id ON entry (actor_id); +CREATE INDEX entry_subject_id ON entry (subject_id); + +It has 3422 rows at this time. + +The query for one of the pages is the following: + +SELECT entry_id, subject_type AS type, subject_type, subject_id, actor_type, +actor_id, actor, actor_role, rel_entry_id, rel_entry, title, subtitle, +description, url, quote AS main_quote, NULL AS rel_quote, substring(entry_date +from 8) AS dom, substring(entry_date from 1) AS date_ymd, substring(entry_date +from 1 for 7) AS date_ym, substring(entry_date from 1 for 4) AS date_y, created, +updated FROM entry WHERE subject_id = 1079 +UNION SELECT entry_id, actor_type AS type, subject_type, subject_id, actor_type, +actor_id, actor, actor_role, rel_entry_id, rel_entry, title, subtitle, +description, url, quote AS main_quote, NULL AS rel_quote, substring(entry_date +from 8) AS dom, substring(entry_date from 1) AS date_ymd, substring(entry_date +from 1 for 7) AS date_ym, substring(entry_date from 1 for 4) AS date_y, created, +updated FROM entry WHERE actor_id = 1079 ORDER BY type, title, subtitle; + +The output of EXPLAIN ANALYZE is: + + Sort (cost=158.98..159.14 rows=62 width=568) (actual time=16.000..16.000 +rows=59 loops=1) + Sort Key: "type", title, subtitle + -> Unique (cost=153.57..157.14 rows=62 width=568) (actual +time=16.000..16.000 rows=59 loops=1) + -> Sort (cost=153.57..153.73 rows=62 width=568) (actual +time=16.000..16.000 rows=59 loops=1) + Sort Key: entry_id, "type", subject_type, subject_id, +actor_type, actor_id, actor, actor_role, rel_entry_id, rel_entry, title, +subtitle, description, url, main_quote, rel_quote, dom, date_ymd, date_ym, +date_y, created, updated + -> Append (cost=0.00..151.73 rows=62 width=568) (actual +time=0.000..16.000 rows=59 loops=1) + -> Subquery Scan "*SELECT* 1" (cost=0.00..17.21 rows=4 +width=568) (actual time=0.000..0.000 rows=3 loops=1) + -> Index Scan using entry_subject_id on entry +(cost=0.00..17.17 rows=4 width=568) (actual time=0.000..0.000 rows=3 loops=1) + Index Cond: (subject_id = 1079) + -> Subquery Scan "*SELECT* 2" (cost=0.00..134.52 rows=58 +width=568) (actual time=0.000..16.000 rows=56 loops=1) + -> Seq Scan on entry (cost=0.00..133.94 rows=58 +width=568) (actual time=0.000..16.000 rows=56 loops=1) + Filter: (actor_id = 1079) + Total runtime: 16.000 ms +(13 rows) + +What I don't quite understand is why it's doing a sequential scan on actor_id +instead of using the entry_actor_id index. Note that actor_id has 928 non-null +values (27%), whereas subject_id has 3089 non-null values (90%). + +Note that the entry_date column was originally a MySQL date but it had partial +dates, i.e., some days and months are set to zero. Eventually I hope to define +a PostgreSQL datatype for it and to simplify the substring retrievals. However, +I don't think the extra computational time should affect the overall runtime +significantly. + +Gavin, I'm using PostgreSQL 8.0.3, Apache 1.3.28, PHP 4.3.4, MySQL 4.0.16 and +I'm comparing both databases on XP (on a Pentium 4, 1.6 GHz, 256 MB RAM). + +Thanks for any feedback. + +Joe + + +From pgsql-hackers-owner@postgresql.org Thu Sep 29 10:07:47 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 95999D9C41; + Thu, 29 Sep 2005 10:05:24 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 93986-05; Thu, 29 Sep 2005 13:05:15 +0000 (GMT) +Received: from bgerelbas01.asiapac.hp.net (bgerelbas01.asiapac.hp.net + [15.219.201.134]) + by svr1.postgresql.org (Postfix) with ESMTP id 16D1AD81CE; + Thu, 29 Sep 2005 10:05:14 -0300 (ADT) +Received: from bgeexg11.asiapacific.cpqcorp.net + (bgeexg11.asiapacific.cpqcorp.net [16.150.33.26]) + by bgerelbas01.asiapac.hp.net (Postfix) with ESMTP id 872FC32E7A; + Thu, 29 Sep 2005 09:05:15 -0400 (EDT) +Received: from bgeexc01.asiapacific.cpqcorp.net ([16.150.33.37]) by + bgeexg11.asiapacific.cpqcorp.net with Microsoft + SMTPSVC(6.0.3790.211); Thu, 29 Sep 2005 18:35:15 +0530 +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: Query in SQL statement +Date: Thu, 29 Sep 2005 18:35:14 +0530 +Message-ID: + <5CBFB210D9870F40B9E5A0FBD31F3A770283AC48@bgeexc01.asiapacific.cpqcorp.net> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: Query in SQL statement +Thread-Index: AcXE9hbXfCDuWjtARrmx+ilCVi6EIgAABk7g +From: "R, Rajesh (STSD)" +To: , + +X-OriginalArrivalTime: 29 Sep 2005 13:05:15.0393 (UTC) + FILETIME=[6F0B2F10:01C5C4F6] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.207 required=5 tests=[UPPERCASE_25_50=0.207] +X-Spam-Level: +X-Archive-Number: 200509/1359 +X-Sequence-Number: 73756 + +=20 +Am trying to port a mysql statement to postgres. + +Please help me in finding the error in this, + + +CREATE SEQUENCE ai_id; +CREATE TABLE badusers ( + id int DEFAULT nextval('ai_id') NOT NULL, + UserName varchar(30), + Date datetime DEFAULT '0000-00-00 00:00:00' NOT NULL, + Reason varchar(200), + Admin varchar(30) DEFAULT '-', + PRIMARY KEY (id), + KEY UserName (UserName), + KEY Date (Date) +); + + +Am always getting foll. Errors, + +ERROR: relation "ai_id" already exists +ERROR: syntax error at or near "(" at character 240 + +Thanks, +Rajesh R + +From pgsql-performance-owner@postgresql.org Thu Sep 29 10:22:09 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0EA64D9C29 + for ; + Thu, 29 Sep 2005 10:22:06 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 98211-10 + for ; + Thu, 29 Sep 2005 13:22:01 +0000 (GMT) +Received: from moutng.kundenserver.de (moutng.kundenserver.de + [212.227.126.186]) + by svr1.postgresql.org (Postfix) with ESMTP id 7420ED9B7D + for ; + Thu, 29 Sep 2005 10:22:02 -0300 (ADT) +Received: from p548F2309.dip0.t-ipconnect.de [84.143.35.9] + (helo=pse.dyndns.org) + by mrelayeu.kundenserver.de with ESMTP (Nemesis), + id 0ML2Dk-1EKyMP1clJ-0005i6; Thu, 29 Sep 2005 15:22:05 +0200 +Received: from pse1 ([192.168.0.3]) by pse.dyndns.org with esmtp (Exim 4.44) + id 1EKyMN-0006uR-QE; Thu, 29 Sep 2005 15:22:03 +0200 +Message-ID: <433BEA7B.1050405@pse-consulting.de> +Date: Thu, 29 Sep 2005 15:22:03 +0200 +From: Andreas Pflug +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Joe +Cc: pgsql-performance@postgresql.org +Subject: Re: Comparative performance +References: <433B4AA4.9080008@freedomcircle.net> + <433BDFF3.3090402@freedomcircle.net> +In-Reply-To: <433BDFF3.3090402@freedomcircle.net> +X-Enigmail-Version: 0.89.5.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=ISO-8859-15; format=flowed +Content-Transfer-Encoding: 7bit +X-Provags-ID: kundenserver.de abuse@kundenserver.de + login:0ce7ee5c3478b8d72edd8e05ccd40b70 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.186 required=5 tests=[AWL=0.136, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/418 +X-Sequence-Number: 14726 + +Joe wrote: + +> +> +> The pages do use a number of queries to collect all the data for display +> but nowhere near 50. I'd say it's probably less than a dozen. +> +> The schema is fairly simple having two main tables: topic and entry +> (sort of like account and transaction in an accounting scenario). There +> are two additional tables that perhaps could be merged into the entry +> table + +Hm, if you only have 4 tables, why do you need 12 queries? +To reduce queries, join them in the query; no need to merge them +physically. If you have only two main tables, I'd bet you only need 1-2 +queries for the whole page. + +Regards, +Andreas + +From pgsql-hackers-owner@postgresql.org Thu Sep 29 10:35:48 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 92E15D9C0A; + Thu, 29 Sep 2005 10:28:31 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 03574-06; Thu, 29 Sep 2005 13:28:27 +0000 (GMT) +Received: from smxsat1.smxs.net (smxsat1.smxs.net [213.150.10.1]) + by svr1.postgresql.org (Postfix) with ESMTP id 42171D9BF4; + Thu, 29 Sep 2005 10:28:27 -0300 (ADT) +Received: from m01x1.s-mxs.net [10.3.55.201] by smxsat1.smxs.net + over TLS secured channel with XWall v3.35a. ; + Thu, 29 Sep 2005 15:28:30 +0200 +Received: from m0102.s-mxs.net [10.3.55.2] by m01x1.s-mxs.net + with XWall v3.35a. ; Thu, 29 Sep 2005 15:29:29 +0200 +Received: from m0143.s-mxs.net ([10.252.53.143]) by m0102.s-mxs.net with + Microsoft SMTPSVC(6.0.3790.1830); Thu, 29 Sep 2005 15:29:29 +0200 +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 +Date: Thu, 29 Sep 2005 15:28:27 +0200 +Message-ID: +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [HACKERS] [PERFORM] A Better External Sort? [heur] +Thread-Index: AcXE9oGI6LpDirwpR9+sqoPJVDwmVgAAb8wQ +From: "Zeugswetter Andreas DAZ SD" +To: "Ron Peacetree" , + "Jeffrey W. Baker" , , + +X-OriginalArrivalTime: 29 Sep 2005 13:29:29.0187 (UTC) + FILETIME=[D1928B30:01C5C4F9] +Subject: Re: [PERFORM] A Better External Sort? +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.065 required=5 tests=[AWL=0.065] +X-Spam-Level: +X-Archive-Number: 200509/1362 +X-Sequence-Number: 73759 + + +> In my original example, a sequential scan of the 1TB of 2KB=20 +> or 4KB records, =3D> 250M or 500M records of data, being sorted=20 +> on a binary value key will take ~1000x more time than reading=20 +> in the ~1GB Btree I described that used a Key+RID (plus node=20 +> pointers) representation of the data. + +Imho you seem to ignore the final step your algorithm needs of +collecting the +data rows. After you sorted the keys the collect step will effectively +access the=20 +tuples in random order (given a sufficiently large key range). + +This random access is bad. It effectively allows a competing algorithm +to read the +whole data at least 40 times sequentially, or write the set 20 times +sequentially.=20 +(Those are the random/sequential ratios of modern discs) + +Andreas + +From pgsql-hackers-owner@postgresql.org Thu Sep 29 10:34:56 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E2525D8F14; + Thu, 29 Sep 2005 10:28:38 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 11070-03; Thu, 29 Sep 2005 13:28:35 +0000 (GMT) +Received: from vscan03.westnet.com.au (vscan03.westnet.com.au [203.10.1.142]) + by svr1.postgresql.org (Postfix) with ESMTP id 10F82D706A; + Thu, 29 Sep 2005 10:28:35 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by localhost (Postfix) with ESMTP id 4CABAB601AD; + Thu, 29 Sep 2005 21:28:38 +0800 (WST) +Received: from vscan03.westnet.com.au ([127.0.0.1]) + by localhost (vscan03.westnet.com.au [127.0.0.1]) (amavisd-new, + port 10024) + with ESMTP id 29906-09; Thu, 29 Sep 2005 21:28:38 +0800 (WST) +Received: from [202.72.133.22] (dsl-202-72-133-22.wa.westnet.com.au + [202.72.133.22]) + by vscan03.westnet.com.au (Postfix) with ESMTP id B9089B6006B; + Thu, 29 Sep 2005 21:28:37 +0800 (WST) +Message-ID: <433BEC06.40004@familyhealth.com.au> +Date: Thu, 29 Sep 2005 21:28:38 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "R, Rajesh (STSD)" +Cc: pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: Query in SQL statement +References: + <5CBFB210D9870F40B9E5A0FBD31F3A770283AC48@bgeexc01.asiapacific.cpqcorp.net> +In-Reply-To: + <5CBFB210D9870F40B9E5A0FBD31F3A770283AC48@bgeexc01.asiapacific.cpqcorp.net> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.112 required=5 tests=[AWL=-0.095, + UPPERCASE_25_50=0.207] +X-Spam-Level: +X-Archive-Number: 200509/1361 +X-Sequence-Number: 73758 + + +> CREATE SEQUENCE ai_id; +> CREATE TABLE badusers ( +> id int DEFAULT nextval('ai_id') NOT NULL, +> UserName varchar(30), +> Date datetime DEFAULT '0000-00-00 00:00:00' NOT NULL, +> Reason varchar(200), +> Admin varchar(30) DEFAULT '-', +> PRIMARY KEY (id), +> KEY UserName (UserName), +> KEY Date (Date) +> ); +> +> +> Am always getting foll. Errors, +> +> ERROR: relation "ai_id" already exists +> ERROR: syntax error at or near "(" at character 240 + +You have just copied the Mysql code to Postgresql. It will in no way +work. Your default for 'Date' is illegal in postgresql and hence it +must allow NULLs. There is no such thing as a 'datetime' type. There +is no such thing as 'Key'. Also your mixed case identifiers won't be +preserved. You want: + +CREATE TABLE badusers ( + id SERIAL PRIMARY KEY, + UserName varchar(30), + Date timestamp, + Reason varchar(200), + Admin varchar(30) DEFAULT '-' +); + +CREATE INDEX UserName_Idx ON badusers(Username); +CREATE INDEX Date_Idx ON badusers(Date); + + +From pgsql-performance-owner@postgresql.org Thu Sep 29 10:30:45 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A23B3D9BA3 + for ; + Thu, 29 Sep 2005 10:29:38 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 07559-02 + for ; + Thu, 29 Sep 2005 13:29:34 +0000 (GMT) +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8D4B8D9AF0 + for ; + Thu, 29 Sep 2005 10:29:35 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id B560831F51; Thu, 29 Sep 2005 15:29:39 +0200 (MET DST) +From: Gaetano Mendola +X-Newsgroups: pgsql.performance +Subject: Re: Delete query takes exorbitant amount of time +Date: Thu, 29 Sep 2005 15:29:30 +0200 +Organization: Hub.Org Networking Services +Lines: 14 +Message-ID: <433BEC3A.40404@bigfoot.com> +References: <1111709457.9085.127.camel@k2.cet.nau.edu> + <2630.1111711927@sss.pgh.pa.us> + <1111713798.23412.3.camel@amateljan.mirlogic.com> + <4009.1111717976@sss.pgh.pa.us> + <1112031350.23412.131.camel@amateljan.mirlogic.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +To: Mark Lewis +User-Agent: Thunderbird 1.4 (Windows/20050908) +In-Reply-To: <1112031350.23412.131.camel@amateljan.mirlogic.com> +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/419 +X-Sequence-Number: 14727 + +Mark Lewis wrote: +> I imported my test dataset +> and was almost immediately able to track down the cause of my +> performance problem. + +Why don't you tell us what the problem was :-) ? + +Regards +Gaetano Mendola + + + + + + +From pgsql-hackers-owner@postgresql.org Thu Sep 29 10:31:23 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3C33AD9AF0; + Thu, 29 Sep 2005 10:30:44 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 08226-05; Thu, 29 Sep 2005 13:30:38 +0000 (GMT) +Received: from ci.boston.ma.us (justice.ci.boston.ma.us [140.241.2.200]) + by svr1.postgresql.org (Postfix) with ESMTP id 9C29ED8F14; + Thu, 29 Sep 2005 10:30:38 -0300 (ADT) +Received: from ([140.241.103.61]) + by justice.ci.boston.ma.us with ESMTP id KP-BRCKH.6109915; + Thu, 29 Sep 2005 09:30:13 -0400 +Received: by zxci.cityhall.boston.cob with Internet Mail Service (5.5.2653.19) + id ; Thu, 29 Sep 2005 09:32:25 -0400 +Message-ID: <35F9812087218F47B050D41D1B58298B086F3D@dnd5.dnd.boston.cob> +From: "Obe, Regina DND\\MIS" +To: "'R, Rajesh (STSD)'" , + "'pgsql-hackers@postgresql.org'" , + "'pgsql-performance@postgresql.org'" , + "'pgsql-novice@postgresql.org'" +Subject: Re: Query in SQL statement +Date: Thu, 29 Sep 2005 09:30:17 -0400 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2653.19) +Content-Type: text/plain +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.043 required=5 tests=[AWL=0.043] +X-Spam-Level: +X-Archive-Number: 200509/1360 +X-Sequence-Number: 73757 + +I think this question may be more appropriate for +pgsql-novice@postgresql.org. + +Anyrate for the below. Sounds like you maybe already have a table or +sequence called ai_id; + +Try doing a DROP SEQUENCE ai_id; + +First + +Also if you plan to use this sequence only for this table it would be better +to use serial8 which will automatically create the sequence for you. Then +you don't even need that first part. Also you should avoid naming fields +things like Date which tend to be keywords in many kinds of databases. + +Try changing your logic to something like + +CREATE TABLE badusers ( + id serial8, + UserName varchar(30), + Date timestamp DEFAULT now() NOT NULL, + Reason varchar(200), + Admin varchar(30) DEFAULT '-', + PRIMARY KEY (id) +); + +CREATE INDEX badusers_username + ON badusers + USING btree + (username); + +CREATE INDEX badusers_date + ON badusers + USING btree + (date); + +-----Original Message----- +From: R, Rajesh (STSD) [mailto:rajesh.r2@hp.com] +Sent: Thursday, September 29, 2005 9:05 AM +To: pgsql-hackers@postgresql.org; pgsql-performance@postgresql.org +Subject: [HACKERS] Query in SQL statement + + + +Am trying to port a mysql statement to postgres. + +Please help me in finding the error in this, + + +CREATE SEQUENCE ai_id; +CREATE TABLE badusers ( + id int DEFAULT nextval('ai_id') NOT NULL, + UserName varchar(30), + Date datetime DEFAULT '0000-00-00 00:00:00' NOT NULL, + Reason varchar(200), + Admin varchar(30) DEFAULT '-', + PRIMARY KEY (id), + KEY UserName (UserName), + KEY Date (Date) +); + + +Am always getting foll. Errors, + +ERROR: relation "ai_id" already exists +ERROR: syntax error at or near "(" at character 240 + +Thanks, +Rajesh R + +---------------------------(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 + +From pgsql-performance-owner@postgresql.org Thu Sep 29 10:47:01 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0DA84D9C40 + for ; + Thu, 29 Sep 2005 10:46:59 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 14094-09 + for ; + Thu, 29 Sep 2005 13:46:54 +0000 (GMT) +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 21841D9C49 + for ; + Thu, 29 Sep 2005 10:46:57 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id A325B31F51; Thu, 29 Sep 2005 15:47:01 +0200 (MET DST) +From: Gaetano Mendola +X-Newsgroups: pgsql.performance +Subject: Re: Monitoring Postgresql performance +Date: Thu, 29 Sep 2005 15:46:52 +0200 +Organization: Hub.Org Networking Services +Lines: 18 +Message-ID: +References: <433AA962.9020900@andromeiberica.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Thunderbird 1.4 (Windows/20050908) +In-Reply-To: <433AA962.9020900@andromeiberica.com> +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/421 +X-Sequence-Number: 14729 + +Arnau wrote: +> Hi all, +> +> I have been "googling" a bit searching info about a way to monitor +> postgresql (CPU & Memory, num processes, ... ) and I haven't found +> anything relevant. I'm using munin to monitor others parameters of my +> servers and I'd like to include postgresql or have a similar tool. Any +> of you is using anything like that? all kind of hints are welcome :-) +> +> Cheers! + +We use Cricket + Nagios ( new Netsaint release ). + + +Regards +Gaetano Mendola + + + +From pgsql-performance-owner@postgresql.org Thu Sep 29 11:24:23 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5EC87D9B69 + for ; + Thu, 29 Sep 2005 11:24:21 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 48329-01 + for ; + Thu, 29 Sep 2005 14:24:13 +0000 (GMT) +Received: from mxout5.netvision.net.il (mxout5.netvision.net.il [194.90.9.29]) + by svr1.postgresql.org (Postfix) with ESMTP id 7AAE5D706A + for ; + Thu, 29 Sep 2005 11:24:12 -0300 (ADT) +Received: from [192.168.0.50] ([194.90.15.25]) by mxout5.netvision.net.il + (Sun Java System Messaging Server 6.1 HotFix 0.11 (built Jan 28 2005)) + with ESMTP id <0INL002Q21CFYG10@mxout5.netvision.net.il> for + pgsql-performance@postgresql.org; Thu, 29 Sep 2005 17:24:15 +0300 (IDT) +Date: Thu, 29 Sep 2005 17:25:49 +0300 +From: Michael Ben-Nes +Subject: Re: Advice on RAID card +In-reply-to: + <19340086.1127732519601.JavaMail.root@elwamui-polski.atl.sa.earthlink.net> +To: Ron Peacetree +Cc: PFC , + pgsql-performance@postgresql.org +Message-id: <433BF96D.8080103@canaan.co.il> +Organization: Canaan Surfing Ltd +MIME-version: 1.0 +Content-type: text/plain; charset=ISO-8859-1; format=flowed +Content-transfer-encoding: 7BIT +X-Accept-Language: en-us, en +References: + <19340086.1127732519601.JavaMail.root@elwamui-polski.atl.sa.earthlink.net> +User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.082 required=5 tests=[AWL=0.082] +X-Spam-Level: +X-Archive-Number: 200509/422 +X-Sequence-Number: 14730 + +I think the answer is simple + + +if the question is low end Raid card or software ? go on the software +and youll get better performance. + +If this is a high end server i wouldnt think twice. HW RAID is a must +and not only because the performance but because the easynes ( hot swap +and such ) and the battery + + +Ron Peacetree wrote: + +>While I understand being economical, at some point one crosses the line +>to being penny wise and pound foolish. +> +>How much is the data on this server going to be worth? +>How much much will it cost you to recover or restore it (assuming that +>is even possible if you lose it)? +> +>If your data is worth nothing or the cost to recover or restore it is +>negligible, then you don't need (nor should want) a DB server. You'll +>get higher performance at less cost via a number of other methods. +> +>OTOH, if you data _does_ have value by any of the above metrics, +>then it is worth it to pay attention to reliable, safe, fast, physical IO. +> +>Battery backed HD caches of appropriate size are usually well worth +>the $, as they pay for themselves (and then some) with the first data +>loss they prevent. +> +>RAID 5 means you are _always_ only 2 HDs from data loss, and 1 HD +>from a serious performance hit. Part of the trade-off with using SATA +>HDs that cost 1/3-1/4 their U320 15Krpm brethren is that such +>circumstances are +FAR+ more likely with SATA HDs. +> +>If you are not going to use RAID 10 because of cost issues, then +>spend the $ to get the biggest battery backed cache you can afford +>and justify as being cheaper than what the proper RAID 6 or RAID 10 +>setup would cost you. Even if you are going to use SW RAID and the +>controller will just be a JBOD controller. +> +>On the general subject of costs... +> +>At this writing, SODIMM RAM costs ~$100 (US) per GB. Standard +>DIMMs cost ~$75 per GB unless you buy 4GB ones, in which case +>they cost ~$100 per GB. +> +>The "sweet spot" in SATA HD pricing is ~$160 for 320GB at 7200rpm +>(don't buy the 36GB or 74GB WD Raptors, they are no longer worth +>it). If you are careful you can get SATA HD's with 16MB rather than +>8MB buffers for that price. Each such HD will give you ~50MB/s of +>raw Average Sustained Transfer Rate. +> +>Decent x86 compatible CPUs are available for ~$200-$400 apiece. +>Rarely will a commodity HW DB server need a more high end CPU. +> +>Some of the above numbers rate to either fall to 1/2 cost or 2x in value +>for the dollar within the next 6-9 months, and all of them will within the +>next 18 months. And so will RAID controller costs. +> +>Your salary will hopefully not degrade at that rate, and it is unlikely that +>your value for the dollar will increase at that rate. Nor is it likely that +>data worth putting on a DB server will do so. +> +>Figure out what your required performance and reliability for the next 18 +>months is going to be, and buy the stuff from the above list that will +>sustain that. No matter what. +> +>Anything less rates _highly_ to end up costing you and your organization +>more money within the next 18months than you will "save" in initial +>acquisition cost. +> +>Ron +> +> +> +> +> +>-----Original Message----- +>From: PFC +>Sent: Sep 24, 2005 12:27 PM +>Subject: Re: [PERFORM] Advice on RAID card +> +> +> +> +>>It looks like a rebranded low end Adaptec 64MB PCI-X <-> SATA RAID card. +>>Looks like the 64MB buffer is not upgradable. +>>Looks like it's SATA, not SATA II +>> +>> +> +> Yeah, that's exactly what it is. I can get one for 150 Euro, the Areca is +>at least 600. This is for a budget server so while it would be nice to +>have all the high-tech stuff, it's not the point. My question was raher, +>is it one of the crap RAID5 cards which are actually SLOWER than plain IDE +>disks, or is it decent, even though low-end (and cheap), and worth it +>compared to software RAID5 ? +> +> +> +>>Assuming you are not building 1U boxes, get one of the full height +>>cards and order it with the maximum size buffer you can afford. +>>The cards take 1 SODIMM, so that will be a max of 1GB or 2GB +>>depending on whether 2GB SODIMMs are available to you yet. +>> +>> +> +> It's for a budget dev server which should have RAID5 for reliability, but +>not necessarily stellar performance (and price). I asked about this card +>because I can get one at a good price. +> +> Thanks for taking the time to answer. +> +> +>---------------------------(end of broadcast)--------------------------- +>TIP 4: Have you searched our list archives? +> +> http://archives.postgresql.org +> +> + +-- +-------------------------- +Canaan Surfing Ltd. +Internet Service Providers +Ben-Nes Michael - Manager +Tel: 972-4-6991122 +Cel: 972-52-8555757 +Fax: 972-4-6990098 +http://www.canaan.net.il +-------------------------- + + +From pgsql-hackers-owner@postgresql.org Fri Sep 30 10:13:29 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1A726D9C35 + for ; + Thu, 29 Sep 2005 13:10:38 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 74162-07 + for ; + Thu, 29 Sep 2005 16:10:33 +0000 (GMT) +Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 367E6D9BF4 + for ; + Thu, 29 Sep 2005 13:10:32 -0300 (ADT) +Received: (qmail 4924 invoked from network); 29 Sep 2005 18:11:22 +0200 +Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) + by boutiquenumerique.com with SMTP; 29 Sep 2005 18:11:22 +0200 +Date: Thu, 29 Sep 2005 18:10:29 +0200 +To: rjpeace@earthlink.net +Subject: Re: [PERFORM] A Better External Sort? +Cc: "Pg Hackers" , + pgsql-performance@postgresql.org +References: + <11604324.1127974870565.JavaMail.root@elwamui-polski.atl.sa.earthlink.net> + <5A8CC216-2E25-4B8C-910A-69224D0A66CE@rilk.com> +From: PFC +Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= +Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-ID: +In-Reply-To: <5A8CC216-2E25-4B8C-910A-69224D0A66CE@rilk.com> +User-Agent: Opera M2/8.0 (Linux, build 1095) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/1411 +X-Sequence-Number: 73808 + + + Just to add a little anarchy in your nice debate... + + Who really needs all the results of a sort on your terabyte table ? + + I guess not many people do a SELECT from such a table and want all the +results. So, this leaves : + - Really wanting all the results, to fetch using a cursor, + - CLUSTER type things, where you really want everything in order, + - Aggregates (Sort->GroupAggregate), which might really need to sort the +whole table. + - Complex queries where the whole dataset needs to be examined, in order +to return a few values + - Joins (again, the whole table is probably not going to be selected) + - And the ones I forgot. + + However, + + Most likely you only want to SELECT N rows, in some ordering : + - the first N (ORDER BY x LIMIT N) + - last N (ORDER BY x DESC LIMIT N) + - WHERE x>value ORDER BY x LIMIT N + - WHERE x; + Thu, 29 Sep 2005 13:12:57 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 74070-10 + for ; + Thu, 29 Sep 2005 16:12:55 +0000 (GMT) +Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id D1C3CD9C36 + for ; + Thu, 29 Sep 2005 13:12:54 -0300 (ADT) +Received: (qmail 5005 invoked from network); 29 Sep 2005 18:13:45 +0200 +Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) + by boutiquenumerique.com with SMTP; 29 Sep 2005 18:13:45 +0200 +To: Joe , + "Magnus Hagander" +Cc: "Gavin Sherry" , + pgsql-performance@postgresql.org +Subject: Re: Comparative performance +References: <6BCB9D8A16AC4241919521715F4D8BCE92E6D6@algol.sollentuna.se> + <433BDB0B.8010002@freedomcircle.net> +Message-ID: +Date: Thu, 29 Sep 2005 18:12:52 +0200 +From: PFC +Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= +Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +In-Reply-To: <433BDB0B.8010002@freedomcircle.net> +User-Agent: Opera M2/8.0 (Linux, build 1095) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/424 +X-Sequence-Number: 14732 + + + +> I just tried using pg_pconnect() and I didn't notice any significant +> improvement. What bothers me most is that with Postgres I tend to see +> jerky behavior on almost every page: the upper 1/2 or 2/3 of the page +> is displayed first and you can see a blank bottom (or you can see a +> half-filled completion bar). With MySQL each page is generally +> displayed in one swoop. + + Persistent connections are useful when your page is fast and the +connection time is an important part of your page time. It is mandatory if +you want to serve more than 20-50 hits/s without causing unnecessary load +on the database. This is not your case, which is why you don't notice any +improvement... + +From pgsql-performance-owner@postgresql.org Thu Sep 29 13:17:19 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 99D91D9C40 + for ; + Thu, 29 Sep 2005 13:17:16 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81607-04 + for ; + Thu, 29 Sep 2005 16:17:07 +0000 (GMT) +Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 248A1D9C3F + for ; + Thu, 29 Sep 2005 13:17:06 -0300 (ADT) +Received: (qmail 5214 invoked from network); 29 Sep 2005 18:17:57 +0200 +Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) + by boutiquenumerique.com with SMTP; 29 Sep 2005 18:17:57 +0200 +To: Joe , "Gavin Sherry" +Cc: "Magnus Hagander" , + pgsql-performance@postgresql.org +Subject: Re: Comparative performance +References: <6BCB9D8A16AC4241919521715F4D8BCE92E6D6@algol.sollentuna.se> + <433BDB0B.8010002@freedomcircle.net> + + <433BE1A0.5000807@freedomcircle.net> +Message-ID: +Date: Thu, 29 Sep 2005 18:17:05 +0200 +From: PFC +Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= +Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +In-Reply-To: <433BE1A0.5000807@freedomcircle.net> +User-Agent: Opera M2/8.0 (Linux, build 1095) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/425 +X-Sequence-Number: 14733 + + +> Total runtime: 16.000 ms + + Even though this query isn't that optimized, it's still only 16 +milliseconds. + Why does it take this long for PHP to get the results ? + + Can you try pg_query'ing this exact same query, FROM PHP, and timing it +with getmicrotime() ? + + You can even do an EXPLAIN ANALYZE from pg_query and display the results +in your webpage, to check how long the query takes on the server. + + You can also try it on a Linux box. + + This smells like a TCP communication problem. + +From pgsql-hackers-owner@postgresql.org Thu Sep 29 13:54:11 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0828FD9C36; + Thu, 29 Sep 2005 13:54:10 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91818-01; Thu, 29 Sep 2005 16:54:08 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 21138D9C35; + Thu, 29 Sep 2005 13:54:07 -0300 (ADT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [64.81.245.111] (HELO [192.168.1.38]) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 8173506; Thu, 29 Sep 2005 09:56:31 -0700 +Message-ID: <433C1C2D.7090908@agliodbs.com> +Date: Thu, 29 Sep 2005 09:54:05 -0700 +From: Josh Berkus +User-Agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "Jeffrey W. Baker" +Cc: Ron Peacetree , + pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: [PERFORM] A Better External Sort? +References: + <21402654.1127923414088.JavaMail.root@elwamui-polski.atl.sa.earthlink.net> + <1127968040.8954.12.camel@noodles> +In-Reply-To: <1127968040.8954.12.camel@noodles> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/1378 +X-Sequence-Number: 73775 + +Jeff, Ron, + +First off, Jeff, please take it easy. We're discussing 8.2 features at +this point and there's no reason to get stressed out at Ron. You can +get plenty stressed out when 8.2 is near feature freeze. ;-) + + +Regarding use cases for better sorts: + +The biggest single area where I see PostgreSQL external sort sucking is + on index creation on large tables. For example, for free version of +TPCH, it takes only 1.5 hours to load a 60GB Lineitem table on OSDL's +hardware, but over 3 hours to create each index on that table. This +means that over all our load into TPCH takes 4 times as long to create +the indexes as it did to bulk load the data. + +Anyone restoring a large database from pg_dump is in the same situation. + Even worse, if you have to create a new index on a large table on a +production database in use, because the I/O from the index creation +swamps everything. + +Following an index creation, we see that 95% of the time required is the +external sort, which averages 2mb/s. This is with seperate drives for +the WAL, the pg_tmp, the table and the index. I've confirmed that +increasing work_mem beyond a small minimum (around 128mb) had no benefit +on the overall index creation speed. + + +--Josh Berkus + + + +From pgsql-hackers-owner@postgresql.org Thu Sep 29 14:07:14 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3440BD9C43; + Thu, 29 Sep 2005 14:07:12 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 93415-04; Thu, 29 Sep 2005 17:07:09 +0000 (GMT) +Received: from mail.mi8.com (d01gw04.mi8.com [63.240.6.44]) + by svr1.postgresql.org (Postfix) with ESMTP id 3BB1ED9C6B; + Thu, 29 Sep 2005 14:07:08 -0300 (ADT) +Received: from 172.16.1.118 by mail.mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D4)); Thu, 29 Sep 2005 13:06:54 -0400 +X-Server-Uuid: C8FB4D43-1108-484A-A898-3CBCC7906230 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.175]) by + d01smtp03.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Thu, 29 Sep + 2005 13:06:53 -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 ; Thu, 29 Sep + 2005 13:06:53 -0500 +User-Agent: Microsoft-Entourage/11.2.0.050811 +Date: Thu, 29 Sep 2005 10:06:52 -0700 +Subject: Re: [PERFORM] A Better External Sort? +From: "Luke Lonergan" +To: "Josh Berkus" , + "Jeffrey W. Baker" +Cc: "Ron Peacetree" , + pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org +Message-ID: +Thread-Topic: [HACKERS] [PERFORM] A Better External Sort? +Thread-Index: AcXFGC+xbkyDzDELEdq3eAANk63kWA== +In-Reply-To: <433C1C2D.7090908@agliodbs.com> +MIME-Version: 1.0 +X-OriginalArrivalTime: 29 Sep 2005 17:06:53.0999 (UTC) + FILETIME=[30E2E3F0:01C5C518] +X-WSS-ID: 6F22C0A434O1934798-01-01 +Content-Type: text/plain; + charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.574 required=5 tests=[AWL=-0.007, + FORGED_RCVD_HELO=0.05, RCVD_NUMERIC_HELO=1.531] +X-Spam-Level: * +X-Archive-Number: 200509/1379 +X-Sequence-Number: 73776 + +Josh, + +On 9/29/05 9:54 AM, "Josh Berkus" wrote: + +> Following an index creation, we see that 95% of the time required is the +> external sort, which averages 2mb/s. This is with seperate drives for +> the WAL, the pg_tmp, the table and the index. I've confirmed that +> increasing work_mem beyond a small minimum (around 128mb) had no benefit +> on the overall index creation speed. + +Yuuuup! That about sums it up - regardless of taking 1 or 2 passes through +the heap being sorted, 1.5 - 2 MB/s is the wrong number. This is not +necessarily an algorithmic problem, but is a optimization problem with +Postgres that must be fixed before it can be competitive. + +We read/write to/from disk at 240MB/s and so 2 passes would run at a net +rate of 120MB/s through the sort set if it were that efficient. + +Anyone interested in tackling the real performance issue? (flame bait, but +for a worthy cause :-) + +- Luke + + + +From pgsql-hackers-owner@postgresql.org Thu Sep 29 14:18:30 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C2F31D9C3D; + Thu, 29 Sep 2005 14:18:26 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 97225-03; Thu, 29 Sep 2005 17:18:23 +0000 (GMT) +Received: from fetter.org (dsl092-188-065.sfo1.dsl.speakeasy.net + [66.92.188.65]) + by svr1.postgresql.org (Postfix) with ESMTP id C9834D9C65; + Thu, 29 Sep 2005 14:18:23 -0300 (ADT) +Received: from fetter.org (localhost.localdomain [127.0.0.1]) + by fetter.org (8.13.4/8.12.10) with ESMTP id j8THHvJL004010; + Thu, 29 Sep 2005 10:17:57 -0700 +Received: (from shackle@localhost) + by fetter.org (8.13.4/8.13.4/Submit) id j8THHv65004009; + Thu, 29 Sep 2005 10:17:57 -0700 +Date: Thu, 29 Sep 2005 10:17:57 -0700 +From: David Fetter +To: Luke Lonergan +Cc: Josh Berkus , "Jeffrey W. Baker" , + Ron Peacetree , pgsql-hackers@postgresql.org, + pgsql-performance@postgresql.org +Subject: Re: [PERFORM] A Better External Sort? +Message-ID: <20050929171757.GC7534@fetter.org> +References: <433C1C2D.7090908@agliodbs.com> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.06 required=5 tests=[AWL=0.010, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/1380 +X-Sequence-Number: 73777 + +On Thu, Sep 29, 2005 at 10:06:52AM -0700, Luke Lonergan wrote: +> Josh, +> +> On 9/29/05 9:54 AM, "Josh Berkus" wrote: +> +> > Following an index creation, we see that 95% of the time required +> > is the external sort, which averages 2mb/s. This is with seperate +> > drives for the WAL, the pg_tmp, the table and the index. I've +> > confirmed that increasing work_mem beyond a small minimum (around +> > 128mb) had no benefit on the overall index creation speed. +> +> Yuuuup! That about sums it up - regardless of taking 1 or 2 passes +> through the heap being sorted, 1.5 - 2 MB/s is the wrong number. +> This is not necessarily an algorithmic problem, but is a +> optimization problem with Postgres that must be fixed before it can +> be competitive. +> +> We read/write to/from disk at 240MB/s and so 2 passes would run at a +> net rate of 120MB/s through the sort set if it were that efficient. +> +> Anyone interested in tackling the real performance issue? (flame +> bait, but for a worthy cause :-) + +I'm not sure that it's flamebait, but what do I know? Apart from the +nasty number (1.5-2 MB/s), what other observations do you have to +hand? Any ideas about what things are not performing here? Parts of +the code that could bear extra scrutiny? Ideas on how to fix same in +a cross-platform way? + +Cheers, +D +-- +David Fetter david@fetter.org http://fetter.org/ +phone: +1 510 893 6100 mobile: +1 415 235 3778 + +Remember to vote! + +From pgsql-hackers-owner@postgresql.org Thu Sep 29 14:44:46 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 49DD0D9C58 + for ; + Thu, 29 Sep 2005 14:44:27 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 02822-09 + for ; + Thu, 29 Sep 2005 17:44:24 +0000 (GMT) +Received: from mail26.sea5.speakeasy.net (mail26.sea5.speakeasy.net + [69.17.117.28]) + by svr1.postgresql.org (Postfix) with ESMTP id 3CBEFD9AF7 + for ; + Thu, 29 Sep 2005 14:44:24 -0300 (ADT) +Received: (qmail 20535 invoked from network); 29 Sep 2005 17:44:24 -0000 +Received: from dsl081-060-184.sfo1.dsl.speakeasy.net (HELO noodles) + ([64.81.60.184]) (envelope-sender ) + by mail26.sea5.speakeasy.net (qmail-ldap-1.03) with RC4-MD5 encrypted + SMTP for ; 29 Sep 2005 17:44:24 -0000 +Subject: Re: [PERFORM] A Better External Sort? +From: "Jeffrey W. Baker" +To: Luke Lonergan +Cc: Josh Berkus , + Ron Peacetree , pgsql-hackers@postgresql.org, + pgsql-performance@postgresql.org +In-Reply-To: +References: +Content-Type: text/plain +Date: Thu, 29 Sep 2005 10:44:23 -0700 +Message-Id: <1128015863.11474.9.camel@noodles> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.1.1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.026 required=5 tests=[AWL=0.026] +X-Spam-Level: +X-Archive-Number: 200509/1381 +X-Sequence-Number: 73778 + +On Thu, 2005-09-29 at 10:06 -0700, Luke Lonergan wrote: +> Josh, +> +> On 9/29/05 9:54 AM, "Josh Berkus" wrote: +> +> > Following an index creation, we see that 95% of the time required is the +> > external sort, which averages 2mb/s. This is with seperate drives for +> > the WAL, the pg_tmp, the table and the index. I've confirmed that +> > increasing work_mem beyond a small minimum (around 128mb) had no benefit +> > on the overall index creation speed. +> +> Yuuuup! That about sums it up - regardless of taking 1 or 2 passes through +> the heap being sorted, 1.5 - 2 MB/s is the wrong number. + +Yeah this is really bad ... approximately the speed of GNU sort. + +Josh, do you happen to know how many passes are needed in the multiphase +merge on your 60GB table? + +Looking through tuplesort.c, I have a couple of initial ideas. Are we +allowed to fork here? That would open up the possibility of using the +CPU and the I/O in parallel. I see that tuplesort.c also suffers from +the kind of postgresql-wide disease of calling all the way up and down a +big stack of software for each tuple individually. Perhaps it could be +changed to work on vectors. + +I think the largest speedup will be to dump the multiphase merge and +merge all tapes in one pass, no matter how large M. Currently M is +capped at 6, so a sort of 60GB with 1GB sort memory needs 13 passes over +the tape. It could be done in a single pass heap merge with N*log(M) +comparisons, and, more importantly, far less input and output. + +I would also recommend using an external processes to asynchronously +feed the tuples into the heap during the merge. + +What's the timeframe for 8.2? + +-jwb + + + + +From pgsql-hackers-owner@postgresql.org Thu Sep 29 14:59:43 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B15D1D9C79; + Thu, 29 Sep 2005 14:59:40 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 07799-04; Thu, 29 Sep 2005 17:59:38 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id DD7DAD9C70; + Thu, 29 Sep 2005 14:59:38 -0300 (ADT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [64.81.245.111] (account josh@agliodbs.com HELO + temoku.sf.agliodbs.com) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 8173944; Thu, 29 Sep 2005 11:02:03 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: "Jeffrey W. Baker" +Subject: Re: [PERFORM] A Better External Sort? +Date: Thu, 29 Sep 2005 11:03:27 -0700 +User-Agent: KMail/1.8 +Cc: Luke Lonergan , + Ron Peacetree , pgsql-hackers@postgresql.org, + pgsql-performance@postgresql.org +References: + <1128015863.11474.9.camel@noodles> +In-Reply-To: <1128015863.11474.9.camel@noodles> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200509291103.27344.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.047 required=5 tests=[AWL=-0.003, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/1382 +X-Sequence-Number: 73779 + +Jeff, + +> Josh, do you happen to know how many passes are needed in the multiphase +> merge on your 60GB table? + +No, any idea how to test that? + +> I think the largest speedup will be to dump the multiphase merge and +> merge all tapes in one pass, no matter how large M. Currently M is +> capped at 6, so a sort of 60GB with 1GB sort memory needs 13 passes over +> the tape. It could be done in a single pass heap merge with N*log(M) +> comparisons, and, more importantly, far less input and output. + +Yes, but the evidence suggests that we're actually not using the whole 1GB +of RAM ... maybe using only 32MB of it which would mean over 200 passes +(I'm not sure of the exact match). Just fixing our algorithm so that it +used all of the work_mem permitted might improve things tremendously. + +> I would also recommend using an external processes to asynchronously +> feed the tuples into the heap during the merge. +> +> What's the timeframe for 8.2? + +Too far out to tell yet. Probably 9mo to 1 year, that's been our history. + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-hackers-owner@postgresql.org Thu Sep 29 15:16:04 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DBEC9D8EA1 + for ; + Thu, 29 Sep 2005 15:16:02 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 12139-05 + for ; + Thu, 29 Sep 2005 18:15:45 +0000 (GMT) +Received: from mail23.sea5.speakeasy.net (mail23.sea5.speakeasy.net + [69.17.117.25]) + by svr1.postgresql.org (Postfix) with ESMTP id B361ED9C51 + for ; + Thu, 29 Sep 2005 15:15:44 -0300 (ADT) +Received: (qmail 4512 invoked from network); 29 Sep 2005 18:15:42 -0000 +Received: from dsl081-060-184.sfo1.dsl.speakeasy.net (HELO noodles) + ([64.81.60.184]) (envelope-sender ) + by mail23.sea5.speakeasy.net (qmail-ldap-1.03) with RC4-MD5 encrypted + SMTP for ; 29 Sep 2005 18:15:41 -0000 +Subject: Re: [PERFORM] A Better External Sort? +From: "Jeffrey W. Baker" +To: josh@agliodbs.com +Cc: pgsql-hackers@postgresql.org +In-Reply-To: <200509291103.27344.josh@agliodbs.com> +References: + <1128015863.11474.9.camel@noodles> + <200509291103.27344.josh@agliodbs.com> +Content-Type: text/plain +Date: Thu, 29 Sep 2005 11:15:41 -0700 +Message-Id: <1128017741.11474.13.camel@noodles> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.1.1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.023 required=5 tests=[AWL=0.023] +X-Spam-Level: +X-Archive-Number: 200509/1383 +X-Sequence-Number: 73780 + +On Thu, 2005-09-29 at 11:03 -0700, Josh Berkus wrote: +> Jeff, +> +> > Josh, do you happen to know how many passes are needed in the multiphase +> > merge on your 60GB table? +> +> No, any idea how to test that? + +I would just run it under the profiler and see how many times +beginmerge() is called. + +-jwb + + +From pgsql-hackers-owner@postgresql.org Thu Sep 29 15:24:12 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7759AD93BB + for ; + Thu, 29 Sep 2005 15:24:10 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 11245-08 + for ; + Thu, 29 Sep 2005 18:24:07 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 85C25D939F + for ; + Thu, 29 Sep 2005 15:24:06 -0300 (ADT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [64.81.245.111] (account josh@agliodbs.com HELO + temoku.sf.agliodbs.com) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 8174074; Thu, 29 Sep 2005 11:26:32 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: pgsql-hackers@postgresql.org +Subject: Re: [PERFORM] A Better External Sort? +Date: Thu, 29 Sep 2005 11:27:56 -0700 +User-Agent: KMail/1.8 +Cc: "Jeffrey W. Baker" +References: + <200509291103.27344.josh@agliodbs.com> + <1128017741.11474.13.camel@noodles> +In-Reply-To: <1128017741.11474.13.camel@noodles> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200509291127.56531.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.047 required=5 tests=[AWL=-0.003, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/1384 +X-Sequence-Number: 73781 + +Jeff, + +> I would just run it under the profiler and see how many times +> beginmerge() is called. + +Hmm, I'm not seeing it at all in the oprofile results on a 100million-row +sort. + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Thu Sep 29 16:58:42 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 51B45D9C58 + for ; + Thu, 29 Sep 2005 16:55:54 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34272-06 + for ; + Thu, 29 Sep 2005 19:55:51 +0000 (GMT) +Received: from mailhub.doruk.net.tr (mailhub.doruk.net.tr [212.58.5.105]) + by svr1.postgresql.org (Postfix) with ESMTP id 8EBDED9C47 + for ; + Thu, 29 Sep 2005 16:55:51 -0300 (ADT) +Received: from mail3.doruk.net.tr ([212.58.5.9]) + by mailhub.doruk.net.tr with smtp (Exim 4.24) id 1EL4Vb-0007yi-V6 + for pgsql-performance@postgresql.org; Thu, 29 Sep 2005 22:55:59 +0300 +Received: from [85.105.24.123] (account adnandursun@asrinbilisim.com.tr) + by mail3.doruk.net.tr (CommuniGate Pro WebUser 4.2.5) + with HTTP id 145786064 for pgsql-performance@postgresql.org; + Thu, 29 Sep 2005 22:54:58 +0300 +From: +Subject: SQL Function performance +To: pgsql-performance@postgresql.org +X-Mailer: CommuniGate Pro WebUser Interface v.4.2.5 +Date: Thu, 29 Sep 2005 22:54:58 +0300 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; charset="ISO-8859-9" +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.348 required=5 tests=[AWL=-0.037, + NO_REAL_NAME=0.178, UPPERCASE_25_50=0.207] +X-Spam-Level: +X-Archive-Number: 200509/430 +X-Sequence-Number: 14738 + +Hi All, + + I have a SQL function like : + +CREATE OR REPLACE FUNCTION +fn_get_yetkili_inisyer_listesi(int4, int4) + RETURNS SETOF kod_adi_liste_type AS +$BODY$ + SELECT Y.KOD,Y.ADI + FROM T_YER Y + WHERE EXISTS (SELECT 1 + FROM T_GUZER G + WHERE (G.BIN_YER_KOD = $1 OR COALESCE($1,0)=0) + AND FN_FIRMA_ISVISIBLE(G.FIRMA_NO,$2) = 1 + AND G.IN_YER_KOD = Y.KOD) + AND Y.IPTAL = 'H'; +$BODY$ + LANGUAGE 'sql' VOLATILE; + + When i use like "SELECT * FROM +fn_get_yetkili_inisyer_listesi(1, 3474)" and +planner result is "Function Scan on +fn_get_yetkili_inisyer_listesi (cost=0.00..12.50 rows=1000 +width=36) (1 row) " and it runs very slow. + + But when i use like + + "SELECT Y.KOD,Y.ADI + FROM T_YER Y + WHERE EXISTS (SELECT 1 + FROM T_GUZER G + WHERE (G.BIN_YER_KOD += 1 OR COALESCE(1,0)=0) + AND FN_FIRMA_ISVISIBLE(G.FIRMA_NO,3474) = 1 + AND G.IN_YER_KOD = Y.KOD) + AND Y.IPTAL = 'H';" + +planner result : + +" + QUERY PLAN + +-------------------------------------------------------------------------------- +----------------------------- + Seq Scan on t_yer y (cost=0.00..3307.79 rows=58 width=14) + Filter: (((iptal)::text = 'H'::text) AND (subplan)) + SubPlan + -> Index Scan using +t_guzer_ucret_giris_performans_idx on t_guzer g (cost +=0.00..28.73 rows=1 width=0) + Index Cond: ((bin_yer_kod = 1) AND (in_yer_kod = +$0)) + Filter: (fn_firma_isvisible(firma_no, 3474) = 1) +(6 rows) +" + and it runs very fast. + +Any idea ? + +Adnan DURSUN +ASRIN Bili�im Hiz.Ltd. + +From pgsql-performance-owner@postgresql.org Thu Sep 29 17:08:09 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2FFF2D9C47 + for ; + Thu, 29 Sep 2005 17:02:06 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 36927-02 + for ; + Thu, 29 Sep 2005 20:02:02 +0000 (GMT) +Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.205]) + by svr1.postgresql.org (Postfix) with ESMTP id 1848AD9C43 + for ; + Thu, 29 Sep 2005 17:02:01 -0300 (ADT) +Received: by zproxy.gmail.com with SMTP id 40so176527nzk + for ; + Thu, 29 Sep 2005 13:02:03 -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=oqjiQl6wTw1l9vtgc3SbejEovKbYzayEKNZMcUKpk+MG8YlCxob0q8+kOTiWP/yCiYD3sAMvuXPTPbzsDV3GmxNBLeL2wLl4G0zQ2sjdhoPgzqeEthlSBRwTAxSacJtHwI8GPVB2YzdCg2GhQbte6Vl9Mn4hfdLOY3A+E3qwESM= +Received: by 10.37.22.45 with SMTP id z45mr2792844nzi; + Thu, 29 Sep 2005 13:02:03 -0700 (PDT) +Received: by 10.37.14.69 with HTTP; Thu, 29 Sep 2005 13:02:03 -0700 (PDT) +Message-ID: <6d8daee3050929130275807ff2@mail.gmail.com> +Date: Thu, 29 Sep 2005 13:02:03 -0700 +From: Tony Wasson +Reply-To: Tony Wasson +To: pgsql-performance@postgresql.org +Subject: Re: Monitoring Postgresql performance +Cc: arnaulist@andromeiberica.com, newz@bearfruit.org +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <433AA962.9020900@andromeiberica.com> + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.116 required=5 tests=[AWL=0.092, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200509/431 +X-Sequence-Number: 14739 + +On 9/28/05, Matthew Nuzum wrote: +> On 9/28/05, Arnau wrote: +> > Hi all, +> > +> > I have been "googling" a bit searching info about a way to monitor +> > postgresql (CPU & Memory, num processes, ... ) and I haven't found +> > anything relevant. I'm using munin to monitor others parameters of my +> > servers and I'd like to include postgresql or have a similar tool. Any +> > of you is using anything like that? all kind of hints are welcome :-) + +We are also using cricket + nagios. + +On each DB server: Setup snmpd and use snmpd.conf to set disk quotas +and mark processes that need to be running (like +postmaster,syslog,sshd) + +On the monitoring server(s): Use cricket for long term trends & +graphs. Use nagios for current status and alerting and some trending. +(Nagios has plugins over SNMP for load,cpu,memory,disk and processes) + +Here's the nagios plugins I have hacked up over the past few months +and what they do. I'd imagine some could use better names. I can +provide these of package them up if anyone is interested. + +check_pgconn.pl - Shows percentage of connections available. It uses +"SELECT COUNT(*) FROM pg_stat_activity" / "SHOW max_connections". It +can also alert when less than a certain number of connections are +available. + +check_pgqueries.pl - If you have query logging enabled this summarizes +the types of queries running (SELECT ,INSERT ,DELETE ,UPDATE ,ALTER +,CREATE ,TRUNCATE, VACUUM, COPY) and warns if any queries have been +running longer than 5 minutes (configurable). + +check_pglocks.pl - Look for locks that block and for baselining lock activi= +ty. + +check_pgtime.pl - Makes sure that postgresql's time is in sync with +the monitoring server. + +check_pgqueries.pl - Whines if any queries are in the "waiting" state. +The script that runs on each DB server does "ps auxww | grep postgres +| grep -i "[W]aiting"" and exposes that through SNMP using the exec +functionality. Nagios then alerts if queries are being blocked. + +From pgsql-performance-owner@postgresql.org Thu Sep 29 17:39:42 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5233ED706A + for ; + Thu, 29 Sep 2005 17:39:40 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 56460-03 + for ; + Thu, 29 Sep 2005 20:39:35 +0000 (GMT) +Received: from cluster1.echolabs.net (mail.atlanticbb.net [216.52.118.222]) + by svr1.postgresql.org (Postfix) with ESMTP id A5D17D6F5D + for ; + Thu, 29 Sep 2005 17:39:33 -0300 (ADT) +X-Scanned-By: RAE MPP/Clamd http://www.messagepartners.com +X-Scanned-By: RAE MPP/Cloudmark http://www.messagepartners.com +Received: from [209.187.134.170] (account jma@atlanticbb.net HELO [127.0.0.1]) + by fe1.cluster1.echolabs.net (CommuniGate Pro SMTP 4.3.8) + with ESMTPA id 282630; Thu, 29 Sep 2005 16:39:14 -0400 +Message-ID: <433C5108.6070202@freedomcircle.net> +Date: Thu, 29 Sep 2005 16:39:36 -0400 +From: Joe +Organization: Freedom Circle, LLC +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Andreas Pflug +Cc: pgsql-performance@postgresql.org +Subject: Re: Comparative performance +References: <433B4AA4.9080008@freedomcircle.net> + <433BDFF3.3090402@freedomcircle.net> + <433BEA7B.1050405@pse-consulting.de> +In-Reply-To: <433BEA7B.1050405@pse-consulting.de> +Content-Type: text/plain; charset=ISO-8859-15; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.042 required=5 tests=[AWL=-0.008, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/432 +X-Sequence-Number: 14740 + +Andreas Pflug wrote: +> Hm, if you only have 4 tables, why do you need 12 queries? +> To reduce queries, join them in the query; no need to merge them +> physically. If you have only two main tables, I'd bet you only need 1-2 +> queries for the whole page. + +There are more than four tables and the queries are not functionally +overlapping. As an example, allow me to refer to the page +www.freedomcircle.com/topic.php/Economists. + +The top row of navigation buttons (Life, Liberty, etc.) is created from a query +of the 'topic' table. It could've been hard-coded as a PHP array, but with less +flexibility. The alphabetical links are from a SELECT DISTINCT substring from +topic. It could've been generated by a PHP for loop (originally implemented +that way) but again with less flexibility. The listing of economists is another +SELECT from topic. The subheadings (Articles, Books) come from a SELECT of an +entry_type table --which currently has 70 rows-- and is read into a PHP array +since we don't know what headings will be used in a given page. The detail of +the entries comes from that query that I posted earlier, but there are three +additional queries that are used for specialized entry types (relationships +between topics --e.g., Prof. Williams teaches at George Mason, events, and +multi-author or multi-subject articles and books). And there's yet another +table for the specific book information. Once the data is retrieved it's sorted +internally with PHP, at the heading level, before display. + +Maybe there is some way to merge all the queries (some already fairly complex) +that fetch the data for the entries box but I believe it would be a monstrosity +with over 100 lines of SQL. + +Thanks, + +Joe + + +From pgsql-performance-owner@postgresql.org Thu Sep 29 17:50:53 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 77BB0D9C75 + for ; + Thu, 29 Sep 2005 17:50:49 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 57527-03 + for ; + Thu, 29 Sep 2005 20:50:46 +0000 (GMT) +Received: from cluster1.echolabs.net (mail.atlanticbb.net [216.52.118.222]) + by svr1.postgresql.org (Postfix) with ESMTP id F28A5D9C51 + for ; + Thu, 29 Sep 2005 17:50:47 -0300 (ADT) +X-Scanned-By: RAE MPP/Clamd http://www.messagepartners.com +X-Scanned-By: RAE MPP/Cloudmark http://www.messagepartners.com +Received: from [209.187.134.170] (account jma@atlanticbb.net HELO [127.0.0.1]) + by fe2.cluster1.echolabs.net (CommuniGate Pro SMTP 4.3.7) + with ESMTPA id 82726440; Thu, 29 Sep 2005 16:50:49 -0400 +Message-ID: <433C53AE.4090808@freedomcircle.net> +Date: Thu, 29 Sep 2005 16:50:54 -0400 +From: Joe +Organization: Freedom Circle, LLC +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: PFC +Cc: Gavin Sherry , Magnus Hagander , + pgsql-performance@postgresql.org +Subject: Re: Comparative performance +References: <6BCB9D8A16AC4241919521715F4D8BCE92E6D6@algol.sollentuna.se> + <433BDB0B.8010002@freedomcircle.net> + + <433BE1A0.5000807@freedomcircle.net> +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-15; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.043 required=5 tests=[AWL=-0.007, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/433 +X-Sequence-Number: 14741 + +PFC wrote: +> Even though this query isn't that optimized, it's still only 16 +> milliseconds. +> Why does it take this long for PHP to get the results ? +> +> Can you try pg_query'ing this exact same query, FROM PHP, and timing +> it with getmicrotime() ? + +Thanks, that's what I was looking for. It's microtime(), BTW. It'll take me +some time to instrument it, but that way I can pinpoint what is really slow. + +> You can even do an EXPLAIN ANALYZE from pg_query and display the +> results in your webpage, to check how long the query takes on the server. +> +> You can also try it on a Linux box. + +My current host only supports MySQL. I contacted hub.org to see if they could +assist in this transition but I haven't heard back. + +> This smells like a TCP communication problem. + +I'm puzzled by that remark. How much does TCP get into the picture in a local +Windows client/server environment? + +Joe + + +From pgsql-performance-owner@postgresql.org Thu Sep 29 17:56:51 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6BF1ED9B7D + for ; + Thu, 29 Sep 2005 17:56:49 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 58098-08 + for ; + Thu, 29 Sep 2005 20:56:46 +0000 (GMT) +Received: from golem.tn.proaut.org (213.215.117.53.adsl.mbc.sk + [213.215.117.53]) + by svr1.postgresql.org (Postfix) with ESMTP id 90EA9D9A65 + for ; + Thu, 29 Sep 2005 17:56:45 -0300 (ADT) +Received: from [10.230.0.2] ([10.230.0.2]) + by golem.tn.proaut.org (8.13.4/8.13.4/Debian-3) with ESMTP id + j8TL0Bqm004666; Thu, 29 Sep 2005 21:00:13 GMT +Subject: Re: Monitoring Postgresql performance +From: Juraj Holtak +To: Tony Wasson +Cc: pgsql-performance@postgresql.org +In-Reply-To: <6d8daee3050929130275807ff2@mail.gmail.com> +References: <433AA962.9020900@andromeiberica.com> + + <6d8daee3050929130275807ff2@mail.gmail.com> +Content-Type: text/plain +Date: Thu, 29 Sep 2005 22:56:42 +0200 +Message-Id: <1128027402.10516.25.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.4 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 required=5 tests=[FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/434 +X-Sequence-Number: 14742 + +Hi, + +impressive + +But you forgot to include those scipts as attachment or they got lost +somehow ;-) + +could you post them (again)? + +thanx, +Juraj + +Am Donnerstag, den 29.09.2005, 13:02 -0700 schrieb Tony Wasson: +> On 9/28/05, Matthew Nuzum wrote: +> > On 9/28/05, Arnau wrote: +> > > Hi all, +> > > +> > > I have been "googling" a bit searching info about a way to monitor +> > > postgresql (CPU & Memory, num processes, ... ) and I haven't found +> > > anything relevant. I'm using munin to monitor others parameters of my +> > > servers and I'd like to include postgresql or have a similar tool. Any +> > > of you is using anything like that? all kind of hints are welcome :-) +> +> We are also using cricket + nagios. +> +> On each DB server: Setup snmpd and use snmpd.conf to set disk quotas +> and mark processes that need to be running (like +> postmaster,syslog,sshd) +> +> On the monitoring server(s): Use cricket for long term trends & +> graphs. Use nagios for current status and alerting and some trending. +> (Nagios has plugins over SNMP for load,cpu,memory,disk and processes) +> +> Here's the nagios plugins I have hacked up over the past few months +> and what they do. I'd imagine some could use better names. I can +> provide these of package them up if anyone is interested. +> +> check_pgconn.pl - Shows percentage of connections available. It uses +> "SELECT COUNT(*) FROM pg_stat_activity" / "SHOW max_connections". It +> can also alert when less than a certain number of connections are +> available. +> +> check_pgqueries.pl - If you have query logging enabled this summarizes +> the types of queries running (SELECT ,INSERT ,DELETE ,UPDATE ,ALTER +> ,CREATE ,TRUNCATE, VACUUM, COPY) and warns if any queries have been +> running longer than 5 minutes (configurable). +> +> check_pglocks.pl - Look for locks that block and for baselining lock activity. +> +> check_pgtime.pl - Makes sure that postgresql's time is in sync with +> the monitoring server. +> +> check_pgqueries.pl - Whines if any queries are in the "waiting" state. +> The script that runs on each DB server does "ps auxww | grep postgres +> | grep -i "[W]aiting"" and exposes that through SNMP using the exec +> functionality. Nagios then alerts if queries are being blocked. +> +> ---------------------------(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 +> + + +From pgsql-performance-owner@postgresql.org Thu Sep 29 20:05:58 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D46F7D8E61 + for ; + Thu, 29 Sep 2005 20:05:44 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 98190-07 + for ; + Thu, 29 Sep 2005 23:05:40 +0000 (GMT) +Received: from TWMAIL.ESNCC.COM (static-66-173-159-28.t1.cavtel.net + [66.173.159.28]) + by svr1.postgresql.org (Postfix) with ESMTP id 01712D8CF6 + for ; + Thu, 29 Sep 2005 20:05:38 -0300 (ADT) +Received: from spawar2i8uvlb9 ([150.125.117.63]) by TWMAIL.ESNCC.COM with + Microsoft SMTPSVC(5.0.2195.6713); Thu, 29 Sep 2005 19:05:46 -0400 +From: "Lane Van Ingen" +To: +Subject: How to Trigger An Automtic Vacuum on Selected Tables +Date: Thu, 29 Sep 2005 19:05:36 -0400 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.181 +Importance: Normal +X-OriginalArrivalTime: 29 Sep 2005 23:05:46.0730 (UTC) + FILETIME=[5364E4A0:01C5C54A] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.058 required=5 tests=[AWL=0.008, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/436 +X-Sequence-Number: 14744 + +I am running version 8.0.1 on Windows 2003. I have an application that +subjects PostgreSQL to sudden bursts of activity at times which cannot be +predicted. The bursts are significant enough to cause performance +degradation, which can be fixed by a 'vacuum analyze'. + +I am aware of the existence and contents of tables like pg_class. + +QUESTION: I would like to trigger a vacuum analyze process on a table +whenever it gets a large enough burst of activity to warrant it. Using the +data in pg_class (like the number of pages the system found the last time it +was vacuumed / analyzed), I would like to compare those statistics to +current size, and trigger a vacuum/analyze on a table if needed. + +Does anyone know of any available tools, or an approach I could use, to +determine what the CURRENT SIZE is ? + + + +From pgsql-performance-owner@postgresql.org Thu Sep 29 18:15:15 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 06240D9A65 + for ; + Thu, 29 Sep 2005 18:15:13 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 70562-01 + for ; + Thu, 29 Sep 2005 21:15:09 +0000 (GMT) +Received: from smtp0.libero.it (smtp0.libero.it [193.70.192.33]) + by svr1.postgresql.org (Postfix) with ESMTP id D216AD706A + for ; + Thu, 29 Sep 2005 18:15:08 -0300 (ADT) +Received: from localhost (172.16.1.47) by smtp0.libero.it (7.0.027-DD01) + id 431C399301BD60B6; Thu, 29 Sep 2005 23:15:02 +0200 +Received: from smtp3.libero.it ([172.16.1.53]) + by localhost (asav7.libero.it [193.70.193.93]) (amavisd-new, port 10024) + with ESMTP id 15673-07; Thu, 29 Sep 2005 23:15:01 +0200 (CEST) +Received: from [151.25.72.68] (ppp-68-72.25-151.libero.it [151.25.72.68]) + by smtp3.libero.it (Postfix) with ESMTP id 09785ABE0D; + Thu, 29 Sep 2005 23:15:00 +0200 (MEST) +Message-ID: <433C7687.20700@streppone.it> +Date: Thu, 29 Sep 2005 23:19:35 +0000 +From: Cosimo Streppone +User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) +X-Accept-Language: it, it-it, en-us, en +MIME-Version: 1.0 +To: arnaulist@andromeiberica.com +Cc: Postgresql Performance list +Subject: Re: Monitoring Postgresql performance +References: <433AA962.9020900@andromeiberica.com> +In-Reply-To: <433AA962.9020900@andromeiberica.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Scanned: with antispam and antivirus automated system at libero.it +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.03 required=5 tests=[AWL=0.030] +X-Spam-Level: +X-Archive-Number: 200509/435 +X-Sequence-Number: 14743 + +Arnau wrote: + +> Hi all, +> +> I have been "googling" a bit searching info about a way to monitor +> postgresql (CPU & Memory, num processes, ... ) and I haven't found +> anything relevant. I'm using munin to monitor others parameters of my +> servers and I'd like to include postgresql or have a similar tool. Any +> of you is using anything like that? all kind of hints are welcome :-) + +Probably, as you said, this is not so much relevant, +as it is something at *early* stages of usability :-) +but have you looked at pgtop? + +The basic requirement is that you enable your postmaster +stats collector and query command strings. + +Here is the first announcement email: + http://archives.postgresql.org/pgsql-announce/2005-05/msg00000.php + +And its home on the CPAN: + http://search.cpan.org/dist/pgtop/pgtop + +-- +Cosimo + + +From pgsql-performance-owner@postgresql.org Thu Sep 29 20:21:12 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0DA27D90C4 + for ; + Thu, 29 Sep 2005 20:21:10 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 06532-02 + for ; + Thu, 29 Sep 2005 23:21:06 +0000 (GMT) +Received: from TWMAIL.ESNCC.COM (static-66-173-159-28.t1.cavtel.net + [66.173.159.28]) + by svr1.postgresql.org (Postfix) with ESMTP id 0A068D8EBF + for ; + Thu, 29 Sep 2005 20:21:07 -0300 (ADT) +Received: from spawar2i8uvlb9 ([150.125.117.63]) by TWMAIL.ESNCC.COM with + Microsoft SMTPSVC(5.0.2195.6713); Thu, 29 Sep 2005 19:21:10 -0400 +From: "Lane Van Ingen" +To: +Subject: Is There Any Way .... +Date: Thu, 29 Sep 2005 19:21:08 -0400 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.181 +Importance: Normal +X-OriginalArrivalTime: 29 Sep 2005 23:21:10.0566 (UTC) + FILETIME=[7A0B1460:01C5C54C] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.058 required=5 tests=[AWL=0.008, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/437 +X-Sequence-Number: 14745 + +... to do the following: + (1) Make a table memory-resident only ? + (2) Set up user variables in memory that are persistent across all +sessions, for + as long as the database is up and running ? + (3) Assure that a disk-based table is always in memory (outside of keeping +it in + memory buffers as a result of frequent activity which would prevent +LRU + operations from taking it out) ? + + + +From pgsql-performance-owner@postgresql.org Thu Sep 29 21:05:28 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5C11DD87B3 + for ; + Thu, 29 Sep 2005 21:05:26 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18831-01 + for ; + Fri, 30 Sep 2005 00:05:20 +0000 (GMT) +Received: from netbox.unitech.com.ar (unknown [200.32.92.34]) + by svr1.postgresql.org (Postfix) with ESMTP id 107F0D7E90 + for ; + Thu, 29 Sep 2005 21:05:20 -0300 (ADT) +Received: from dariop (dariop.unitech.com.ar [192.168.1.237]) + by netbox.unitech.com.ar (8.11.6/8.11.6) with ESMTP id j8U156p20001 + for ; Thu, 29 Sep 2005 21:05:06 -0400 +Received: from 127.0.0.1 (AVG SMTP 7.0.344 [267.11.8]); + Thu, 29 Sep 2005 21:05:45 -0300 +From: "Dario" +To: +Subject: Re: How to Trigger An Automtic Vacuum on Selected Tables +Date: Thu, 29 Sep 2005 21:05:45 -0300 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) +Importance: Normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506 +In-Reply-To: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.046 required=5 tests=[AWL=0.046] +X-Spam-Level: +X-Archive-Number: 200509/438 +X-Sequence-Number: 14746 + +Autovacuum does exactly what I understood you want :-) + +-----Mensaje original----- +De: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org]En nombre de Lane Van +Ingen +Enviado el: jueves, 29 de septiembre de 2005 20:06 +Para: pgsql-performance@postgresql.org +Asunto: [PERFORM] How to Trigger An Automtic Vacuum on Selected Tables + + +I am running version 8.0.1 on Windows 2003. I have an application that +subjects PostgreSQL to sudden bursts of activity at times which cannot be +predicted. The bursts are significant enough to cause performance +degradation, which can be fixed by a 'vacuum analyze'. + +I am aware of the existence and contents of tables like pg_class. + +QUESTION: I would like to trigger a vacuum analyze process on a table +whenever it gets a large enough burst of activity to warrant it. Using the +data in pg_class (like the number of pages the system found the last time it +was vacuumed / analyzed), I would like to compare those statistics to +current size, and trigger a vacuum/analyze on a table if needed. + +Does anyone know of any available tools, or an approach I could use, to +determine what the CURRENT SIZE is ? + + + +---------------------------(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 Sep 29 21:22:23 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 85E8BD9C96 + for ; + Thu, 29 Sep 2005 21:22:20 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 21386-06 + for ; + Fri, 30 Sep 2005 00:22:16 +0000 (GMT) +Received: from netbox.unitech.com.ar (unknown [200.32.92.34]) + by svr1.postgresql.org (Postfix) with ESMTP id D3B7DD9C92 + for ; + Thu, 29 Sep 2005 21:22:16 -0300 (ADT) +Received: from dariop (dariop.unitech.com.ar [192.168.1.237]) + by netbox.unitech.com.ar (8.11.6/8.11.6) with ESMTP id j8U1M3p20044 + for ; Thu, 29 Sep 2005 21:22:03 -0400 +Received: from 127.0.0.1 (AVG SMTP 7.0.344 [267.11.8]); + Thu, 29 Sep 2005 21:22:42 -0300 +From: "Dario" +To: +Subject: Re: Is There Any Way .... +Date: Thu, 29 Sep 2005 21:22:42 -0300 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) +Importance: Normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506 +In-Reply-To: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.045 required=5 tests=[AWL=0.045] +X-Spam-Level: +X-Archive-Number: 200509/439 +X-Sequence-Number: 14747 + +1) AFAIK, no. Just in case you are thinking "There should be a way coz I +know it will be used all the time", you must know that postgresql philosophy +is "I'm smarter than you". If table is used all the time, it will be in +memory, if not, it won't waste memory. +2) don't know. +3) see number 1) Of course, you could run into a pathological case where +table is queried just before being taken out of memory. But it means, the +table isn't queried all the time... + +Greetings... + + + +-----Mensaje original----- +De: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org]En nombre de Lane Van +Ingen +Enviado el: jueves, 29 de septiembre de 2005 20:21 +Para: pgsql-performance@postgresql.org +Asunto: [PERFORM] Is There Any Way .... + + +... to do the following: + (1) Make a table memory-resident only ? + (2) Set up user variables in memory that are persistent across all +sessions, for + as long as the database is up and running ? + (3) Assure that a disk-based table is always in memory (outside of keeping +it in + memory buffers as a result of frequent activity which would prevent +LRU + operations from taking it out) ? + + + +---------------------------(end of broadcast)--------------------------- +TIP 6: explain analyze is your friend + + +From pgsql-performance-owner@postgresql.org Thu Sep 29 21:57:22 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A867AD8DFB + for ; + Thu, 29 Sep 2005 21:57:20 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 29015-01 + for ; + Fri, 30 Sep 2005 00:57:16 +0000 (GMT) +Received: from mail0.rawbw.com (mail0.rawbw.com [198.144.192.41]) + by svr1.postgresql.org (Postfix) with ESMTP id 6AA79D6F5D + for ; + Thu, 29 Sep 2005 21:57:17 -0300 (ADT) +Received: (from www@localhost) + by mail0.rawbw.com (8.11.6p2/8.11.6) id j8U0vLe71904; + Thu, 29 Sep 2005 17:57:21 -0700 (PDT) +Received: from cybs-gw.ic3.com (cybs-gw.ic3.com [66.185.177.10]) + by webmail.rawbw.com (IMP) with HTTP + for ; Thu, 29 Sep 2005 17:57:21 -0700 +Message-ID: <1128041841.433c8d713bc8d@webmail.rawbw.com> +Date: Thu, 29 Sep 2005 17:57:21 -0700 +From: mudfoot@rawbw.com +To: pgsql-performance@postgresql.org +Cc: pgsql-performance@postgresql.org +Subject: Re: Is There Any Way .... +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 8bit +User-Agent: Internet Messaging Program (IMP) 3.2.1 +X-Originating-IP: 66.185.177.10 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.178 required=5 tests=[NO_REAL_NAME=0.178] +X-Spam-Level: +X-Archive-Number: 200509/440 +X-Sequence-Number: 14748 + +Quoting Lane Van Ingen : + +> ... to do the following: +> (1) Make a table memory-resident only ? + +Put it on a RAM filesystem. On Linux, shmfs. On *BSD, mfs. Solaris, tmpfs. + +> (2) Set up user variables in memory that are persistent across all +> sessions, for +> as long as the database is up and running ? + +This sounds like a client thing? Dunno. + +> (3) Assure that a disk-based table is always in memory (outside of +> keeping +> it in +> memory buffers as a result of frequent activity which would prevent +> LRU +> operations from taking it out) ? +> + +Put on RAM fs (like question 1). + +Basically, RAM filesystems are on RAM, meaning you need to have enough physical +memory to support them. And of course their contents completely disappear +between reboots, so you'll need a way to populate them on bootup and make sure +that your updates go to a real nonvolatile storage medium (like disks). And you +might get swapping on some types of memory filesystems--Solaris' tmpfs is carved +out of virtual memory, which means it will cause swapping if tmpfs contents plus +the rest of your applications exceed physical memory. + +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 6: explain analyze is your friend +> + + + +From pgsql-performance-owner@postgresql.org Thu Sep 29 22:46:19 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 40363D9797 + for ; + Thu, 29 Sep 2005 22:46:17 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 32271-10 + for ; + Fri, 30 Sep 2005 01:46:11 +0000 (GMT) +Received: from cassarossa.samfundet.no (cassarossa.samfundet.no + [129.241.93.19]) + by svr1.postgresql.org (Postfix) with ESMTP id 72A8ED9493 + for ; + Thu, 29 Sep 2005 22:46:10 -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 1EL9yY-0003TZ-1S + for pgsql-performance@postgresql.org; Fri, 30 Sep 2005 03:46:14 +0200 +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1EL9yW-00065G-00 + for ; Fri, 30 Sep 2005 03:46:12 +0200 +Date: Fri, 30 Sep 2005 03:46:12 +0200 +From: "Steinar H. Gunderson" +To: pgsql-performance@postgresql.org +Subject: Re: Is There Any Way .... +Message-ID: <20050930014612.GA21908@uio.no> +Mail-Followup-To: pgsql-performance@postgresql.org +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Disposition: inline +In-Reply-To: +X-Operating-System: Linux 2.6.11.8 on a i686 +X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.013 required=5 tests=[AWL=0.013] +X-Spam-Level: +X-Archive-Number: 200509/441 +X-Sequence-Number: 14749 + +On Thu, Sep 29, 2005 at 07:21:08PM -0400, Lane Van Ingen wrote: +> (1) Make a table memory-resident only ? + +You might want to look into memcached, but it's impossible to say whether it +will fit your needs or not without more details. + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-hackers-owner@postgresql.org Fri Sep 30 10:03:32 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9271DD930E; + Thu, 29 Sep 2005 23:03:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 61053-02; Fri, 30 Sep 2005 02:03:21 +0000 (GMT) +Received: from pop-knobcone.atl.sa.earthlink.net + (pop-knobcone.atl.sa.earthlink.net [207.69.195.64]) + by svr1.postgresql.org (Postfix) with ESMTP id 8A41DD8D15; + Thu, 29 Sep 2005 23:03:22 -0300 (ADT) +Received: from elwamui-polski.atl.sa.earthlink.net ([209.86.224.45]) + by pop-knobcone.atl.sa.earthlink.net with esmtp (Exim 3.36 #10) + id 1ELAFC-0002Fo-00; Thu, 29 Sep 2005 22:03:26 -0400 +Message-ID: + <22984551.1128045806542.JavaMail.root@elwamui-polski.atl.sa.earthlink.net> +Date: Thu, 29 Sep 2005 22:03:26 -0400 (EDT) +From: Ron Peacetree +Reply-To: Ron Peacetree +To: Pailloncy Jean-Gerard , + pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: [PERFORM] A Better External Sort? +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Mailer: Earthlink Zoo Mail 1.0 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.259 required=5 tests=[AWL=-0.115, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200509/1405 +X-Sequence-Number: 73802 + +>From: Pailloncy Jean-Gerard +>Sent: Sep 29, 2005 7:11 AM +>Subject: Re: [HACKERS] [PERFORM] A Better External Sort? +>>>Jeff Baker: +>>>Your main example seems to focus on a large table where a key +>>>column has constrained values. This case is interesting in +>>>proportion to the number of possible values. If I have billions +>>>of rows, each having one of only two values, I can think of a +>>>trivial and very fast method of returning the table "sorted" by +>>>that key: make two sequential passes, returning the first value +>>>on the first pass and the second value on the second pass. +>>> This will be faster than the method you propose. +>> +>>Ron Peacetree: +>>1= No that was not my main example. It was the simplest example +>>used to frame the later more complicated examples. Please don't +>>get hung up on it. +>> +>>2= You are incorrect. Since IO is the most expensive operation we +>>can do, any method that makes two passes through the data at top +>>scanning speed will take at least 2x as long as any method that only +>>takes one such pass. +> +>You do not get the point. +>As the time you get the sorted references to the tuples, you need to +>fetch the tuples themself, check their visbility, etc. and returns +>them to the client. +> +As PFC correctly points out elsewhere in this thread, =maybe= you +have to do all that. The vast majority of the time people are not +going to want to look at a detailed record by record output of that +much data. + +The most common usage is to calculate or summarize some quality +or quantity of the data and display that instead or to use the tuples +or some quality of the tuples found as an intermediate step in a +longer query process such as a join. + +Sometimes there's a need to see _some_ of the detailed records; a +random sample or a region in a random part of the table or etc. +It's rare that there is a RW need to actually list every record in a +table of significant size. + +On the rare occasions where one does have to return or display all +records in such large table, network IO and/or display IO speeds +are the primary performance bottleneck. Not HD IO. + +Nonetheless, if there _is_ such a need, there's nothing stopping us +from rearranging the records in RAM into sorted order in one pass +through RAM (using at most space for one extra record) after +constructing the cache conscious Btree index. Then the sorted +records can be written to HD in RAM buffer sized chunks very +efficiently. +Repeating this process until we have stepped through the entire +data set will take no more HD IO than one HD scan of the data +and leave us with a permanent result that can be reused for +multiple purposes. If the sorted records are written in large +enough chunks, rereading them at any later time can be done +at maximum HD throughput + +In a total of two HD scans (one to read the original data, one +to write out the sorted data) we can make a permanent +rearrangement of the data. We've essentially created a +cluster index version of the data. + + +>So, if there is only 2 values in the column of big table that is larger +>than available RAM, two seq scans of the table without any sorting +>is the fastest solution. +> +If you only need to do this once, yes this wins. OTOH, if you have +to do this sort even twice, my method is better. + +regards, +Ron + +From pgsql-hackers-owner@postgresql.org Fri Sep 30 10:08:05 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 978F4D6EBB; + Thu, 29 Sep 2005 23:57:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 71213-04; Fri, 30 Sep 2005 02:57:19 +0000 (GMT) +Received: from pop-knobcone.atl.sa.earthlink.net + (pop-knobcone.atl.sa.earthlink.net [207.69.195.64]) + by svr1.postgresql.org (Postfix) with ESMTP id AFC9DD6E1F; + Thu, 29 Sep 2005 23:57:21 -0300 (ADT) +Received: from elwamui-polski.atl.sa.earthlink.net ([209.86.224.45]) + by pop-knobcone.atl.sa.earthlink.net with esmtp (Exim 3.36 #10) + id 1ELB5L-0000Mg-00; Thu, 29 Sep 2005 22:57:19 -0400 +Message-ID: + <6812451.1128049039096.JavaMail.root@elwamui-polski.atl.sa.earthlink.net> +Date: Thu, 29 Sep 2005 22:57:19 -0400 (EDT) +From: Ron Peacetree +Reply-To: Ron Peacetree +To: Zeugswetter Andreas DAZ SD , + pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: [PERFORM] A Better External Sort? +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Mailer: Earthlink Zoo Mail 1.0 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.26 required=5 tests=[AWL=-0.114, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200509/1406 +X-Sequence-Number: 73803 + +>From: Zeugswetter Andreas DAZ SD +>Sent: Sep 29, 2005 9:28 AM +>Subject: RE: [HACKERS] [PERFORM] A Better External Sort? +> +>>In my original example, a sequential scan of the 1TB of 2KB +>>or 4KB records, => 250M or 500M records of data, being sorted +>>on a binary value key will take ~1000x more time than reading +>>in the ~1GB Btree I described that used a Key+RID (plus node +>>pointers) representation of the data. +> +>Imho you seem to ignore the final step your algorithm needs of +>collecting the data rows. After you sorted the keys the collect +>step will effectively access the tuples in random order (given a +>sufficiently large key range). +> +"Collecting" the data rows can be done for each RAM buffer full of +of data in one pass through RAM after we've built the Btree. Then +if desired those data rows can be read out to HD in sorted order +in essentially one streaming burst. This combination of index build ++ RAM buffer rearrangement + write results to HD can be repeat +as often as needed until we end up with an overall Btree index and +a set of sorted sublists on HD. Overall HD IO for the process is only +two effectively sequential passes through the data. + +Subsequent retrieval of the sorted information from HD can be +done at full HD streaming speed and whatever we've decided to +save to HD can be reused later if we desire. + +Hope this helps, +Ron + +From pgsql-hackers-owner@postgresql.org Fri Sep 30 01:22:53 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6B151D7283; + Fri, 30 Sep 2005 01:22:50 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 33766-07; Fri, 30 Sep 2005 04:22:45 +0000 (GMT) +Received: from mail.mi8.com (d01gw04.mi8.com [63.240.6.44]) + by svr1.postgresql.org (Postfix) with ESMTP id 146FBD6F2C; + Fri, 30 Sep 2005 01:22:39 -0300 (ADT) +Received: from 172.16.1.110 by mail.mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D4)); Fri, 30 Sep 2005 00:22:29 -0400 +X-Server-Uuid: C8FB4D43-1108-484A-A898-3CBCC7906230 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.175]) by + D01SMTP01.Mi8.com with Microsoft SMTPSVC(6.0.3790.211); Fri, 30 Sep + 2005 00:22:29 -0400 +Received: from 69.181.100.71 ([69.181.100.71]) by MI8NYCMAIL06.Mi8.com ( + [172.16.1.219]) via Exchange Front-End Server mi8owa.mi8.com ( + [172.16.1.106]) with Microsoft Exchange Server HTTP-DAV ; Fri, 30 Sep + 2005 00:22:28 -0500 +User-Agent: Microsoft-Entourage/11.2.0.050811 +Date: Thu, 29 Sep 2005 21:22:27 -0700 +Subject: Re: [PERFORM] A Better External Sort? +From: "Luke Lonergan" +To: "Jeffrey W. Baker" +Cc: "Josh Berkus" , + "Ron Peacetree" , + pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org +Message-ID: +Thread-Topic: [HACKERS] [PERFORM] A Better External Sort? +Thread-Index: AcXFdpBwzwcGjTFpEdqrvAANk63kWA== +In-Reply-To: <1128015863.11474.9.camel@noodles> +MIME-Version: 1.0 +X-OriginalArrivalTime: 30 Sep 2005 04:22:29.0198 (UTC) + FILETIME=[91BF66E0:01C5C576] +X-WSS-ID: 6F22620F34O2388611-01-01 +Content-Type: text/plain; + charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.531 required=5 tests=[RCVD_NUMERIC_HELO=1.531] +X-Spam-Level: * +X-Archive-Number: 200509/1395 +X-Sequence-Number: 73792 + +Jeff, + +On 9/29/05 10:44 AM, "Jeffrey W. Baker" wrote: + +> On Thu, 2005-09-29 at 10:06 -0700, Luke Lonergan wrote: +> Looking through tuplesort.c, I have a couple of initial ideas. Are we +> allowed to fork here? That would open up the possibility of using the +> CPU and the I/O in parallel. I see that tuplesort.c also suffers from +> the kind of postgresql-wide disease of calling all the way up and down a +> big stack of software for each tuple individually. Perhaps it could be +> changed to work on vectors. + +Yes! + +> I think the largest speedup will be to dump the multiphase merge and +> merge all tapes in one pass, no matter how large M. Currently M is +> capped at 6, so a sort of 60GB with 1GB sort memory needs 13 passes over +> the tape. It could be done in a single pass heap merge with N*log(M) +> comparisons, and, more importantly, far less input and output. + +Yes again, see above. + +> I would also recommend using an external processes to asynchronously +> feed the tuples into the heap during the merge. + +Simon Riggs is working this idea a bit - it's slightly less interesting to +us because we already have a multiprocessing executor. Our problem is that +4 x slow is still far too slow. + +> What's the timeframe for 8.2? + +Let's test it out in Bizgres! + +- Luke + + + +From pgsql-hackers-owner@postgresql.org Fri Sep 30 10:09:51 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A86EFD80C2; + Fri, 30 Sep 2005 02:24:38 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 89051-04; Fri, 30 Sep 2005 05:24:35 +0000 (GMT) +Received: from pop-knobcone.atl.sa.earthlink.net + (pop-knobcone.atl.sa.earthlink.net [207.69.195.64]) + by svr1.postgresql.org (Postfix) with ESMTP id 04259D7283; + Fri, 30 Sep 2005 02:24:33 -0300 (ADT) +Received: from elwamui-polski.atl.sa.earthlink.net ([209.86.224.45]) + by pop-knobcone.atl.sa.earthlink.net with esmtp (Exim 3.36 #10) + id 1ELDNm-0002aD-00; Fri, 30 Sep 2005 01:24:30 -0400 +Message-ID: + <28561251.1128057870608.JavaMail.root@elwamui-polski.atl.sa.earthlink.net> +Date: Fri, 30 Sep 2005 01:24:30 -0400 (EDT) +From: Ron Peacetree +Reply-To: Ron Peacetree +To: Josh Berkus , pgsql-hackers@postgresql.org, + pgsql-performance@postgresql.org +Subject: Re: [PERFORM] A Better External Sort? +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Mailer: Earthlink Zoo Mail 1.0 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.26 required=5 tests=[AWL=-0.114, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200509/1407 +X-Sequence-Number: 73804 + +>From: Josh Berkus +>Sent: Sep 29, 2005 12:54 PM +>Subject: Re: [HACKERS] [PERFORM] A Better External Sort? +> +>The biggest single area where I see PostgreSQL external +>sort sucking is on index creation on large tables. For +>example, for free version of TPCH, it takes only 1.5 hours to +>load a 60GB Lineitem table on OSDL's hardware, but over 3 +>hours to create each index on that table. This means that +>over all our load into TPCH takes 4 times as long to create +>the indexes as it did to bulk load the data. +> +Hmmm. +60GB/5400secs= 11MBps. That's ssllooww. So the first +problem is evidently our physical layout and/or HD IO layer +sucks. + +Creating the table and then creating the indexes on the table +is going to require more physical IO than if we created the +table and the indexes concurrently in chunks and then +combined the indexes on the chunks into the overall indexes +for the whole table, so there's a potential speed-up. + +The method I've been talking about is basically a recipe for +creating indexes as fast as possible with as few IO operations, +HD or RAM, as possible and nearly no random ones, so it +could help as well. + +OTOH, HD IO rate is the fundamental performance metric. +As long as our HD IO rate is pessimal, so will the performance +of everything else be. Why can't we load a table at closer to +the peak IO rate of the HDs? + + +>Anyone restoring a large database from pg_dump is in the +>same situation. Even worse, if you have to create a new +>index on a large table on a production database in use, +>because the I/O from the index creation swamps everything. +> +Fix for this in the works ;-) + + +>Following an index creation, we see that 95% of the time +>required is the external sort, which averages 2mb/s. +> +Assuming decent HD HW, this is HORRIBLE. + +What's kind of instrumenting and profiling has been done of +the code involved? + + +>This is with seperate drives for the WAL, the pg_tmp, the table +>and the index. I've confirmed that increasing work_mem +>beyond a small minimum (around 128mb) had no benefit on +>the overall index creation speed. +> +No surprise. The process is severely limited by the abyssmally +slow HD IO. + +Ron + +From pgsql-performance-owner@postgresql.org Fri Sep 30 02:58:29 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 140A1D792D + for ; + Fri, 30 Sep 2005 02:58:26 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 14349-02 + for ; + Fri, 30 Sep 2005 05:58:23 +0000 (GMT) +Received: from mx-2.sollentuna.net (mx-2.sollentuna.net [195.84.163.199]) + by svr1.postgresql.org (Postfix) with ESMTP id E1DCFD6DA7 + for ; + Fri, 30 Sep 2005 02:58:23 -0300 (ADT) +Received: from ALGOL.sollentuna.se (janus.sollentuna.se [62.65.68.67]) + by mx-2.sollentuna.net (Postfix) with ESMTP + id 2B4F28F287; Fri, 30 Sep 2005 07:58:24 +0200 (CEST) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Comparative performance +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Date: Fri, 30 Sep 2005 07:58:23 +0200 +Message-ID: <6BCB9D8A16AC4241919521715F4D8BCE92E6E3@algol.sollentuna.se> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Comparative performance +Thread-Index: AcXFN3xRIshoGbxXTwq+8b+CER+CuwATGSvA +From: "Magnus Hagander" +To: "Joe" , + "PFC" +Cc: "Gavin Sherry" , + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.061 required=5 tests=[AWL=0.011, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/446 +X-Sequence-Number: 14754 + +> > This smells like a TCP communication problem. +>=20 +> I'm puzzled by that remark. How much does TCP get into the=20 +> picture in a local Windows client/server environment? + +Windows has no Unix Domain Sockets (no surprise there), so TCP +connections over the loopback interface are used to connect to the +server. + +//Magnus + +From pgsql-performance-owner@postgresql.org Fri Sep 30 04:20:28 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3CFE5D79CF + for ; + Fri, 30 Sep 2005 04:20:23 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 72136-01 + for ; + Fri, 30 Sep 2005 07:20:18 +0000 (GMT) +Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) + by svr1.postgresql.org (Postfix) with ESMTP id 27852D8CBC + for ; + Fri, 30 Sep 2005 04:20:15 -0300 (ADT) +Received: from mainbox.archonet.com + (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) + by smtp.metronet.co.uk (MetroNet Mail) with ESMTP + id 72A064074A5; Fri, 30 Sep 2005 08:20:11 +0100 (BST) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mainbox.archonet.com (Postfix) with ESMTP id B22F215F1F; + Fri, 30 Sep 2005 08:14:41 +0100 (BST) +Received: from mainbox.archonet.com ([127.0.0.1]) + by localhost (mainbox [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 05177-05; Fri, 30 Sep 2005 08:14:39 +0100 (BST) +Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP id D543915F1C; + Fri, 30 Sep 2005 08:14:38 +0100 (BST) +Message-ID: <433CE5DE.8090004@archonet.com> +Date: Fri, 30 Sep 2005 08:14:38 +0100 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Lane Van Ingen +Cc: pgsql-performance@postgresql.org +Subject: Re: Is There Any Way .... +References: +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.058 required=5 tests=[AWL=0.008, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/447 +X-Sequence-Number: 14755 + +Lane Van Ingen wrote: +> (2) Set up user variables in memory that are persistent across all +> sessions, for +> as long as the database is up and running ? + +You could probably write "C" functions (or possibly Perl) to store data +in shared memory. Of course you'd have to deal with concurrency issues +yourself. + +Storing the values in a table and having cached access to them during +the session is probably your best bet. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Fri Sep 30 06:16:05 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8F0D4D7FB8 + for ; + Fri, 30 Sep 2005 06:16:04 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 10725-03 + for ; + Fri, 30 Sep 2005 09:16:00 +0000 (GMT) +Received: from ms005msg.fastwebnet.it (ms005msg.fastwebnet.it [213.140.2.50]) + by svr1.postgresql.org (Postfix) with ESMTP id A222FD87EC + for ; + Fri, 30 Sep 2005 06:15:59 -0300 (ADT) +Received: from lyra (1.17.192.122) by ms005msg.fastwebnet.it (7.2.060.2) + id 43224E3900499090 for pgsql-performance@postgresql.org; + Fri, 30 Sep 2005 11:16:00 +0200 +Received: from localhost (lyra [127.0.0.1]) + by lyra (Postfix) with ESMTP id DD5E0197368 + for ; + Fri, 30 Sep 2005 11:16:23 +0200 (CEST) +Received: from lyra ([127.0.0.1]) + by localhost (lyra [127.0.0.1]) (amavisd-new, port 10024) with ESMTP + id 09037-05 for ; + Fri, 30 Sep 2005 11:16:22 +0200 (CEST) +Received: by lyra (Postfix, from userid 1003) + id 00D95197367; Fri, 30 Sep 2005 11:16:21 +0200 (CEST) +Subject: Lists or external TABLE? +From: xchris +To: pgsql-performance@postgresql.org +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Date: Fri, 30 Sep 2005 11:16:21 +0200 +Message-Id: <1128071781.8112.32.camel@lyra> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.3 +X-Virus-Scanned: by amavisd-new at lyra +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.744 required=5 tests=[DNS_FROM_RFC_ABUSE=0.374, + RCVD_ILLEGAL_IP=1.37] +X-Spam-Level: * +X-Archive-Number: 200509/448 +X-Sequence-Number: 14756 + +Hi list, +i'm a postgres noob and before designing a new Database Schema i would +like to ask you a simple question because preformance will be a critical +point. + +My question regards performance comparison between a Table which +includes a list or a Table without list and with an external table. + +1 - TABLE A has several fields (most of which are types defined by me) +for a total of 30-40 field (counting fields in my new types) and could +contain 5000 rows. + +2 - TABLE A will be accessed several times with several views or query. + (many SELECT,few UPDATE) + + +Let's suppose i need to add an info about addresses (which includes +country,city,cap....etc etc). +Addresses can vary from 1 to 20 entries.. + +Talking about performance is it better to include a list of addresses in +TABLE A or is it better to create an external TABLE B? + +I'm afraid that including those addresses will decrease performance in +doing many SELECT. + +On the other side i'm afraid of doing JOIN with TABLE B. + +What do you think? +Thank you! + +xchris + + +From pgsql-performance-owner@postgresql.org Fri Sep 30 06:35:32 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 65DF5D921C + for ; + Fri, 30 Sep 2005 06:35:31 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 13476-08 + for ; + Fri, 30 Sep 2005 09:35:24 +0000 (GMT) +Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) + by svr1.postgresql.org (Postfix) with ESMTP id 9D89FD91EB + for ; + Fri, 30 Sep 2005 06:35:24 -0300 (ADT) +Received: from mainbox.archonet.com + (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) + by smtp.metronet.co.uk (MetroNet Mail) with ESMTP + id 36FBA41496F; Fri, 30 Sep 2005 10:35:21 +0100 (BST) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mainbox.archonet.com (Postfix) with ESMTP id 6B27515F1D; + Fri, 30 Sep 2005 10:34:38 +0100 (BST) +Received: from mainbox.archonet.com ([127.0.0.1]) + by localhost (mainbox [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 12748-01; Fri, 30 Sep 2005 10:34:35 +0100 (BST) +Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP id 9712E15F1C; + Fri, 30 Sep 2005 10:34:35 +0100 (BST) +Message-ID: <433D06AB.3020409@archonet.com> +Date: Fri, 30 Sep 2005 10:34:35 +0100 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: xchris +Cc: pgsql-performance@postgresql.org +Subject: Re: Lists or external TABLE? +References: <1128071781.8112.32.camel@lyra> +In-Reply-To: <1128071781.8112.32.camel@lyra> +Content-Type: text/plain; charset=ISO-8859-15; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.058 required=5 tests=[AWL=0.008, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/449 +X-Sequence-Number: 14757 + +xchris wrote: +> +> Let's suppose i need to add an info about addresses (which includes +> country,city,cap....etc etc). +> Addresses can vary from 1 to 20 entries.. +> +> Talking about performance is it better to include a list of addresses in +> TABLE A or is it better to create an external TABLE B? + +Don't optimise before you have to. + +Do the addresses belong in "A"? If so, put them there. On the other +hand, if you want items in "A" to have more than one address, or to +share addresses then clearly you will want a separate address table. +It's difficult to say more without a clear example of your requirements. + +Even if you choose to alter your design for performance reasons, you +should make sure you run tests with realistic workloads and hardware. +But first, trust PG to do its job and design your database according to +the problem requirements. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-hackers-owner@postgresql.org Fri Sep 30 14:23:35 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C0BB4D9239; + Fri, 30 Sep 2005 14:23:32 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 42322-03; Fri, 30 Sep 2005 17:23:29 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 307B0D922B; + Fri, 30 Sep 2005 14:23:29 -0300 (ADT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [64.81.245.111] (HELO [192.168.1.38]) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 8179910; Fri, 30 Sep 2005 10:25:54 -0700 +Message-ID: <433D7492.7000307@agliodbs.com> +Date: Fri, 30 Sep 2005 10:23:30 -0700 +From: Josh Berkus +User-Agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Ron Peacetree +Cc: pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: [PERFORM] A Better External Sort? +References: + <28561251.1128057870608.JavaMail.root@elwamui-polski.atl.sa.earthlink.net> +In-Reply-To: + <28561251.1128057870608.JavaMail.root@elwamui-polski.atl.sa.earthlink.net> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/1419 +X-Sequence-Number: 73816 + +Ron, + +> Hmmm. +> 60GB/5400secs= 11MBps. That's ssllooww. So the first +> problem is evidently our physical layout and/or HD IO layer +> sucks. + +Actually, it's much worse than that, because the sort is only dealing +with one column. As I said, monitoring the iostat our top speed was +2.2mb/s. + +--Josh + +From pgsql-hackers-owner@postgresql.org Fri Sep 30 14:44:41 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DEB05D99AE; + Fri, 30 Sep 2005 14:44:39 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 47439-05; Fri, 30 Sep 2005 17:44:37 +0000 (GMT) +Received: from postal.corporate.connx.com (postal.corporate.connx.com + [65.212.159.187]) + by svr1.postgresql.org (Postfix) with SMTP id D52C1D990B; + Fri, 30 Sep 2005 14:44:36 -0300 (ADT) +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: [PERFORM] A Better External Sort? +Date: Fri, 30 Sep 2005 10:44:34 -0700 +Message-ID: + +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [HACKERS] [PERFORM] A Better External Sort? +Thread-Index: AcXFwPIexbIF0ZpvQdylIH8ShHdPrgAIu1vw +From: "Dann Corbit" +To: "PFC" , +Cc: "Pg Hackers" , + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.012 required=5 tests=[AWL=0.012] +X-Spam-Level: +X-Archive-Number: 200509/1421 +X-Sequence-Number: 73818 + +> -----Original Message----- +> From: pgsql-hackers-owner@postgresql.org [mailto:pgsql-hackers- +> owner@postgresql.org] On Behalf Of PFC +> Sent: Thursday, September 29, 2005 9:10 AM +> To: rjpeace@earthlink.net +> Cc: Pg Hackers; pgsql-performance@postgresql.org +> Subject: Re: [HACKERS] [PERFORM] A Better External Sort? +>=20 +>=20 +> Just to add a little anarchy in your nice debate... +>=20 +> Who really needs all the results of a sort on your terabyte +table ? + +Reports with ORDER BY/GROUP BY, and many other possibilities. 40% of +mainframe CPU cycles are spent sorting. That is because huge volumes of +data require lots of energy to be meaningfully categorized. Let's +suppose that instead of a terabyte of data (or a petabyte or whatever) +we have 10% of it. That's still a lot of data. + +> I guess not many people do a SELECT from such a table and want +all +> the +> results.=20 + +What happens when they do? The cases where it is already fast are not +very important. The cases where things go into the crapper are the ones +that need attention. + +>So, this leaves : +> - Really wanting all the results, to fetch using a cursor, +> - CLUSTER type things, where you really want everything in +order, +> - Aggregates (Sort->GroupAggregate), which might really need to +sort +> the +> whole table. +> - Complex queries where the whole dataset needs to be examined, +in +> order +> to return a few values +> - Joins (again, the whole table is probably not going to be +> selected) +> - And the ones I forgot. +>=20 +> However, +>=20 +> Most likely you only want to SELECT N rows, in some ordering : +> - the first N (ORDER BY x LIMIT N) +> - last N (ORDER BY x DESC LIMIT N) + +For these, the QuickSelect algorithm is what is wanted. For example: +#include +typedef double Etype; + +extern Etype RandomSelect(Etype * A, size_t p, size_t r, size_t i); +extern size_t RandRange(size_t a, size_t b); +extern size_t RandomPartition(Etype * A, size_t p, size_t r); +extern size_t Partition(Etype * A, size_t p, size_t r); + +/* +** +** In the following code, every reference to CLR means: +** +** "Introduction to Algorithms" +** By Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest +** ISBN 0-07-013143-0 +*/ + + +/* +** CLR, page 187 +*/ +Etype RandomSelect(Etype A[], size_t p, size_t r, size_t i) +{ + size_t q, + k; + if (p =3D=3D r) + return A[p]; + q =3D RandomPartition(A, p, r); + k =3D q - p + 1; + + if (i <=3D k) + return RandomSelect(A, p, q, i); + else + return RandomSelect(A, q + 1, r, i - k); +} + +size_t RandRange(size_t a, size_t b) +{ + size_t c =3D (size_t) ((double) rand() / ((double) RAND_MAX = ++ +1) * (b - a)); + return c + a; +} + +/* +** CLR, page 162 +*/ +size_t RandomPartition(Etype A[], size_t p, size_t r) +{ + size_t i =3D RandRange(p, r); + Etype Temp; + Temp =3D A[p]; + A[p] =3D A[i]; + A[i] =3D Temp; + return Partition(A, p, r); +} + +/* +** CLR, page 154 +*/ +size_t Partition(Etype A[], size_t p, size_t r) +{ + Etype x, + temp; + size_t i, + j; + + x =3D A[p]; + i =3D p - 1; + j =3D r + 1; + + for (;;) { + do { + j--; + } while (!(A[j] <=3D x)); + do { + i++; + } while (!(A[i] >=3D x)); + if (i < j) { + temp =3D A[i]; + A[i] =3D A[j]; + A[j] =3D temp; + } else + return j; + } +} + +> - WHERE x>value ORDER BY x LIMIT N +> - WHERE x - and other variants +>=20 +> Or, you are doing a Merge JOIN against some other table ; in +that +> case, +> yes, you might need the whole sorted terabyte table, but most likely +there +> are WHERE clauses in the query that restrict the set, and thus, maybe +we +> can get some conditions or limit values on the column to sort. + +Where clause filters are to be applied AFTER the join operations, +according to the SQL standard. + +> Also the new, optimized hash join, which is more memory +efficient, +> might +> cover this case. + +For =3D=3D joins. Not every order by is applied to joins. And not = +every +join is an equal join. + +> Point is, sometimes, you only need part of the results of your +sort. +> And +> the bigger the sort, the most likely it becomes that you only want +part of +> the results. + +That is an assumption that will sometimes be true, and sometimes not. +It is not possible to predict usage patterns for a general purpose +database system. + +> So, while we're in the fun hand-waving, new algorithm trying +> mode, why not consider this right from the start ? (I know I'm totally +in +> hand-waving mode right now, so slap me if needed). +>=20 +> I'd say your new, fancy sort algorithm needs a few more input +values +> : +>=20 +> - Range of values that must appear in the final result of the +sort : +> none, minimum, maximum, both, or even a set of values +from the +> other +> side of the join, hashed, or sorted. + +That will already happen (or it certainly ought to) + +> - LIMIT information (first N, last N, none) + +That will already happen (or it certainly ought to -- I would be pretty +surprised if it does not happen) + +> - Enhanced Limit information (first/last N values of the second +> column to +> sort, for each value of the first column) (the infamous "top10 by +> category" query) +> - etc. + +All the filters will (at some point) be applied to the data unless they +cannot be applied to the data by formal rule. +=20 +> With this, the amount of data that needs to be kept in memory is +> dramatically reduced, from the whole table (even using your compressed +> keys, that's big) to something more manageable which will be closer to +the +> size of the final result set which will be returned to the client, and +> avoid a lot of effort. + +Sorting the minimal set is a good idea. Sometimes there is a big +savings there. I would be pretty surprised if a large fraction of data +that does not have to be included is actually processed during the +sorts. +=20 +> So, this would not be useful in all cases, but when it applies, +it +> would +> be really useful. + +No argument there. And if an algorithm is being reworked, it is a good +idea to look at things like filtering to see if all filtering that is +allowed by the language standard before the sort takes place is applied. + +From pgsql-general-owner@postgresql.org Fri Sep 30 16:35:10 2005 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 16A01D7FC4; + Fri, 30 Sep 2005 16:35:09 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 72318-02; Fri, 30 Sep 2005 19:35:02 +0000 (GMT) +Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 5042CD95E4; + Fri, 30 Sep 2005 16:35:02 -0300 (ADT) +Received: by flake.decibel.org (Postfix, from userid 1001) + id 34F631525C; Fri, 30 Sep 2005 14:34:59 -0500 (CDT) +Date: Fri, 30 Sep 2005 14:34:59 -0500 +From: "Jim C. Nasby" +To: hubert depesz lubaczewski +Cc: PostgreSQL General , + pgsqlperform +Subject: Re: database bloat, but vacuums are done, + and fsm seems to be setup ok +Message-ID: <20050930193459.GC40138@pervasive.com> +References: <9e4684ce05092800075d37d0cc@mail.gmail.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <9e4684ce05092800075d37d0cc@mail.gmail.com> +X-Operating-System: FreeBSD 4.11-RELEASE-p10 i386 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.9i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.004 required=5 tests=[AWL=0.004] +X-Spam-Level: +X-Archive-Number: 200509/1209 +X-Sequence-Number: 84224 + +Looks like it's definately an issue with index bloat. Note that it's +normal to have some amount of empty space depending on vacuum and update +frequency, so 15G -> 20G isn't terribly surprising. I would suggest +using pg_autovacuum instead of the continuous vacuum; it's very possible +that some of your tables need more frequent vacuuming than they're +getting now. If you go this route, you might want to change the default +settings a bit to make pg_autovacuum more agressive. + +Also, I'd suggest posting to -hackers about the index bloat. Would you +be able to make a filesystem copy (ie: tar -cjf database.tar.bz2 +$PGDATA) available? It might also be useful to keep an eye on index size +in pg_class.relpages and see exactly what indexes are bloating. + +On Wed, Sep 28, 2005 at 09:07:07AM +0200, hubert depesz lubaczewski wrote: +> hi +> setup: +> postgresql 8.0.3 put on debian on dual xeon, 8GB ram, hardware raid. +> +> database just after recreation from dump takes 15gigabytes. +> after some time (up to 3 weeks) it gets really slow and has to be dump'ed +> and restored. +> +> as for fsm: +> end of vacuum info: +> INFO: free space map: 248 relations, 1359140 pages stored; 1361856 total +> pages needed +> DETAIL: Allocated FSM size: 1000 relations + 10000000 pages = 58659 kB +> shared memory. +> +> so it looks i have plenty of space in fsm. +> +> vacuums run constantly. +> 4 different tasks, 3 of them doing: +> while true +> vacuum table +> sleep 15m +> done +> with different tables (i have chooses the most updated tables in system). +> +> and the fourth vacuum task does the same, but without specifying table - so +> it vacuumes whole database. +> +> after last dump/restore cycle i noticed that doing reindex on all indices in +> database made it drop in side from 40G to about 20G - so it might be that i +> will be using reindex instead of drop/restore. +> anyway - i'm not using any special indices - just some (117 to be exact) +> indices of btree type. we use simple, multi-column, partial and multi-column +> partial indices. we do not have functional indices. +> +> database has quite huge load of updates, but i thought that vacum will guard +> me from database bloat, but from what i observed it means that vacuuming of +> b-tree indices is somewhat faulty. +> +> any suggestions? what else can i supply you with to help you help me? +> +> best regards +> +> depesz + +-- +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 Fri Sep 30 20:10:29 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 50261D95E4; + Fri, 30 Sep 2005 17:21:02 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 78362-10; Fri, 30 Sep 2005 20:20:59 +0000 (GMT) +Received: from pop-tawny.atl.sa.earthlink.net (pop-tawny.atl.sa.earthlink.net + [207.69.195.67]) + by svr1.postgresql.org (Postfix) with ESMTP id 74D20D8BED; + Fri, 30 Sep 2005 17:20:59 -0300 (ADT) +Received: from elwamui-polski.atl.sa.earthlink.net ([209.86.224.45]) + by pop-tawny.atl.sa.earthlink.net with esmtp (Exim 3.36 #10) + id 1ELRNC-0000CV-00; Fri, 30 Sep 2005 16:20:50 -0400 +Message-ID: + <31833713.1128111650174.JavaMail.root@elwamui-polski.atl.sa.earthlink.net> +Date: Fri, 30 Sep 2005 16:20:50 -0400 (EDT) +From: Ron Peacetree +Reply-To: Ron Peacetree +To: Josh Berkus , pgsql-hackers@postgresql.org, + pgsql-performance@postgresql.org +Subject: Re: [PERFORM] A Better External Sort? +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Mailer: Earthlink Zoo Mail 1.0 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.257 required=5 tests=[AWL=-0.117, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200509/1443 +X-Sequence-Number: 73840 + +That 11MBps was your =bulk load= speed. If just loading a table +is this slow, then there are issues with basic physical IO, not just +IO during sort operations. + +As I said, the obvious candidates are inefficient physical layout +and/or flawed IO code. + +Until the basic IO issues are addressed, we could replace the +present sorting code with infinitely fast sorting code and we'd +still be scrod performance wise. + +So why does basic IO suck so badly? + +Ron + + +-----Original Message----- +From: Josh Berkus +Sent: Sep 30, 2005 1:23 PM +To: Ron Peacetree +Cc: pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: [HACKERS] [PERFORM] A Better External Sort? + +Ron, + +> Hmmm. +> 60GB/5400secs= 11MBps. That's ssllooww. So the first +> problem is evidently our physical layout and/or HD IO layer +> sucks. + +Actually, it's much worse than that, because the sort is only dealing +with one column. As I said, monitoring the iostat our top speed was +2.2mb/s. + +--Josh + + +From pgsql-hackers-owner@postgresql.org Fri Sep 30 20:10:25 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B3253D9CAD + for ; + Fri, 30 Sep 2005 17:37:56 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 87975-01 + for ; + Fri, 30 Sep 2005 20:37:53 +0000 (GMT) +Received: from brmea-mail-3.sun.com (brmea-mail-3.Sun.COM [192.18.98.34]) + by svr1.postgresql.org (Postfix) with ESMTP id 5F335D9CA2 + for ; + Fri, 30 Sep 2005 17:37:53 -0300 (ADT) +Received: from phys-bur-1 ([129.148.9.72]) + by brmea-mail-3.sun.com (8.12.10/8.12.9) with ESMTP id j8UKbs1P025267 + for ; + Fri, 30 Sep 2005 14:37:55 -0600 (MDT) +Received: from conversion-daemon.bur-mail1.east.sun.com by + bur-mail1.east.sun.com + (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) + id <0INN00G01D5LGM@bur-mail1.east.sun.com> + (original mail from J.K.Shah@Sun.COM) for pgsql-hackers@postgresql.org; + Fri, 30 Sep 2005 16:37:54 -0400 (EDT) +Received: from [129.150.35.4] (vpn-129-150-35-4.Central.Sun.COM + [129.150.35.4]) + by bur-mail1.east.sun.com + (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) + with ESMTPA id <0INN00F97DB481@bur-mail1.east.sun.com>; Fri, + 30 Sep 2005 16:37:54 -0400 (EDT) +Date: Fri, 30 Sep 2005 16:38:00 -0400 +From: "Jignesh K. Shah" +Subject: Re: [PERFORM] A Better External Sort? +In-reply-to: + <31833713.1128111650174.JavaMail.root@elwamui-polski.atl.sa.earthlink.net> +To: Ron Peacetree +Cc: Josh Berkus , pgsql-hackers@postgresql.org, + pgsql-performance@postgresql.org +Message-id: <433DA228.4060103@sun.com> +MIME-version: 1.0 +Content-type: text/plain; charset=ISO-8859-1; format=flowed +Content-transfer-encoding: 7BIT +X-Accept-Language: en-us, en +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +References: + <31833713.1128111650174.JavaMail.root@elwamui-polski.atl.sa.earthlink.net> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200509/1442 +X-Sequence-Number: 73839 + +I have seen similar performance as Josh and my reasoning is as follows: + +* WAL is the biggest bottleneck with its default size of 16MB. Many +people hate to recompile the code to change its default, and +increasing checkpoint segments help but still there is lot of overhead +in the rotation of WAL files (Even putting WAL on tmpfs shows that it is +still slow). Having an option for bigger size is helpful to a small +extent percentagewise (and frees up CPU a bit in doing file rotation) + +* Growing files: Even though this is OS dependent but it does spend lot +of time doing small 8K block increases to grow files. If we can signal +bigger chunks to grow or "pre-grow" to expected size of data files +that will help a lot in such cases. + +* COPY command had restriction but that has been fixed to a large +extent.(Great job) + +But ofcourse I have lost touch with programming and can't begin to +understand PostgreSQL code to change it myself. + +Regards, +Jignesh + + + + +Ron Peacetree wrote: + +>That 11MBps was your =bulk load= speed. If just loading a table +>is this slow, then there are issues with basic physical IO, not just +>IO during sort operations. +> +>As I said, the obvious candidates are inefficient physical layout +>and/or flawed IO code. +> +>Until the basic IO issues are addressed, we could replace the +>present sorting code with infinitely fast sorting code and we'd +>still be scrod performance wise. +> +>So why does basic IO suck so badly? +> +>Ron +> +> +>-----Original Message----- +>From: Josh Berkus +>Sent: Sep 30, 2005 1:23 PM +>To: Ron Peacetree +>Cc: pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org +>Subject: Re: [HACKERS] [PERFORM] A Better External Sort? +> +>Ron, +> +> +> +>>Hmmm. +>>60GB/5400secs= 11MBps. That's ssllooww. So the first +>>problem is evidently our physical layout and/or HD IO layer +>>sucks. +>> +>> +> +>Actually, it's much worse than that, because the sort is only dealing +>with one column. As I said, monitoring the iostat our top speed was +>2.2mb/s. +> +>--Josh +> +> +>---------------------------(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 +> +> + +From pgsql-hackers-owner@postgresql.org Fri Sep 30 17:39:21 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A132BD9CB8; + Fri, 30 Sep 2005 17:39:17 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 86511-04; Fri, 30 Sep 2005 20:39:14 +0000 (GMT) +Received: from mail.Mi8.com (d01gw01.mi8.com [63.240.6.47]) + by svr1.postgresql.org (Postfix) with ESMTP id 12CFCD97E0; + Fri, 30 Sep 2005 17:39:14 -0300 (ADT) +Received: from 172.16.1.118 by mail.Mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D1)); Fri, 30 Sep 2005 16:38:58 -0400 +X-Server-Uuid: 241911D6-425B-44B9-A073-E3FE0F8FC774 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.175]) by + d01smtp03.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Fri, 30 Sep + 2005 16:38:57 -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 ; Fri, 30 Sep + 2005 16:38:57 -0500 +User-Agent: Microsoft-Entourage/11.2.0.050811 +Date: Fri, 30 Sep 2005 13:38:54 -0700 +Subject: Re: [PERFORM] A Better External Sort? +From: "Luke Lonergan" +To: "Ron Peacetree" , + "Josh Berkus" , pgsql-hackers@postgresql.org, + pgsql-performance@postgresql.org +Message-ID: +Thread-Topic: [HACKERS] [PERFORM] A Better External Sort? +Thread-Index: AcXF/vkCN7B83DHyEdqX9QANk63kWA== +In-Reply-To: + <31833713.1128111650174.JavaMail.root@elwamui-polski.atl.sa.earthlink.net> +MIME-Version: 1.0 +X-OriginalArrivalTime: 30 Sep 2005 20:38:57.0804 (UTC) + FILETIME=[FB4734C0:01C5C5FE] +X-WSS-ID: 6F237DEB4IO122685-02-01 +Content-Type: text/plain; + charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.574 required=5 tests=[AWL=-0.007, + FORGED_RCVD_HELO=0.05, RCVD_NUMERIC_HELO=1.531] +X-Spam-Level: * +X-Archive-Number: 200509/1425 +X-Sequence-Number: 73822 + +Ron, + +On 9/30/05 1:20 PM, "Ron Peacetree" wrote: + +> That 11MBps was your =bulk load= speed. If just loading a table +> is this slow, then there are issues with basic physical IO, not just +> IO during sort operations. + +Bulk loading speed is irrelevant here - that is dominated by parsing, which +we have covered copiously (har har) previously and have sped up by 500%, +which still makes Postgres < 1/2 the loading speed of MySQL. + +> As I said, the obvious candidates are inefficient physical layout +> and/or flawed IO code. + +Yes. + +> Until the basic IO issues are addressed, we could replace the +> present sorting code with infinitely fast sorting code and we'd +> still be scrod performance wise. + +Postgres' I/O path has many problems that must be micro-optimized away. Too +small of an operand size compared to disk caches, memory, etc etc are the +common problem. Another is lack of micro-parallelism (loops) with long +enough runs to let modern processors pipeline and superscale. + +The net problem here is that a simple "select blah from blee order +by(blah.a);" runs at 1/100 of the sequential scan rate. + +- Luke + + + +From pgsql-hackers-owner@postgresql.org Fri Sep 30 17:37:39 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7EFD0D9CAD; + Fri, 30 Sep 2005 17:37:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 83576-06; Fri, 30 Sep 2005 20:37:32 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id E5033D9701; + Fri, 30 Sep 2005 17:37:32 -0300 (ADT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [64.81.245.111] (account josh@agliodbs.com HELO + temoku.sf.agliodbs.com) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 8180681; Fri, 30 Sep 2005 13:39:57 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Ron Peacetree +Subject: Re: [PERFORM] A Better External Sort? +Date: Fri, 30 Sep 2005 13:41:22 -0700 +User-Agent: KMail/1.8 +Cc: pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org +References: + <31833713.1128111650174.JavaMail.root@elwamui-polski.atl.sa.earthlink.net> +In-Reply-To: + <31833713.1128111650174.JavaMail.root@elwamui-polski.atl.sa.earthlink.net> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200509301341.22795.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.046 required=5 tests=[AWL=-0.004, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/1424 +X-Sequence-Number: 73821 + +Ron, + +> That 11MBps was your =bulk load= speed. If just loading a table +> is this slow, then there are issues with basic physical IO, not just +> IO during sort operations. + +Oh, yeah. Well, that's separate from sort. See multiple posts on this +list from the GreenPlum team, the COPY patch for 8.1, etc. We've been +concerned about I/O for a while. + +Realistically, you can't do better than about 25MB/s on a single-threaded +I/O on current Linux machines, because your bottleneck isn't the actual +disk I/O. It's CPU. Databases which "go faster" than this are all, to +my knowledge, using multi-threaded disk I/O. + +(and I'd be thrilled to get a consistent 25mb/s on PostgreSQL, but that's +another thread ... ) + +> As I said, the obvious candidates are inefficient physical layout +> and/or flawed IO code. + +Yeah, that's what I thought too. But try sorting an 10GB table, and +you'll see: disk I/O is practically idle, while CPU averages 90%+. We're +CPU-bound, because sort is being really inefficient about something. I +just don't know what yet. + +If we move that CPU-binding to a higher level of performance, then we can +start looking at things like async I/O, O_Direct, pre-allocation etc. that +will give us incremental improvements. But what we need now is a 5-10x +improvement and that's somewhere in the algorithms or the code. + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Fri Sep 30 17:57:42 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 89C43D9CAD + for ; + Fri, 30 Sep 2005 17:57:17 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 87100-06 + for ; + Fri, 30 Sep 2005 20:57:14 +0000 (GMT) +Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.204]) + by svr1.postgresql.org (Postfix) with ESMTP id EEB86D9B0A + for ; + Fri, 30 Sep 2005 17:57:13 -0300 (ADT) +Received: by zproxy.gmail.com with SMTP id 40so8778nzk + for ; + Fri, 30 Sep 2005 13:57: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:references; + b=sV5qMMZI0H3RfsV7/sq1YXZqW7yBLQ4JhAYynEpdNqUBXmNdyeCChspQGQokA9coSJVxwIQL7uG7GN+KjXQXrWPixyK90Vz8yJjtGd1/isdQMxvzK3Y4z2lO4n1zOb3X3fqkM4wKmd0ZhXdOx3qGugWgUzzCqawAPRg0jqh5uAk= +Received: by 10.36.224.42 with SMTP id w42mr6707530nzg; + Fri, 30 Sep 2005 13:57:16 -0700 (PDT) +Received: by 10.37.14.69 with HTTP; Fri, 30 Sep 2005 13:57:16 -0700 (PDT) +Message-ID: <6d8daee30509301357v36723307ifbc4ded1726dc245@mail.gmail.com> +Date: Fri, 30 Sep 2005 13:57:16 -0700 +From: Tony Wasson +Reply-To: Tony Wasson +To: Juraj Holtak , Jon Jensen , + Anjan Dave +Subject: Re: Monitoring Postgresql performance +Cc: pgsql-performance@postgresql.org +In-Reply-To: <1128027402.10516.25.camel@localhost.localdomain> +MIME-Version: 1.0 +Content-Type: multipart/mixed; + boundary="----=_Part_2116_5761522.1128113836231" +References: <433AA962.9020900@andromeiberica.com> + + <6d8daee3050929130275807ff2@mail.gmail.com> + <1128027402.10516.25.camel@localhost.localdomain> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.112 required=5 tests=[AWL=0.088, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200509/456 +X-Sequence-Number: 14764 + +------=_Part_2116_5761522.1128113836231 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +On 9/29/05, Juraj Holtak wrote: +> Hi, +> +> impressive +> +> But you forgot to include those scipts as attachment or they got lost +> somehow ;-) +> +> could you post them (again)? +> +> thanx, +> Juraj + +Attached you'll find the scripts I use in nagios to monitor +postgresql. I cleaned these up a bit but they are still rough. Please +let me know if you find these useful. I will see about getting these +are part of the nagios plugins package. + +Tony Wasson + +------=_Part_2116_5761522.1128113836231 +Content-Type: application/zip; name="pgnagios.zip" +Content-Transfer-Encoding: base64 +Content-Disposition: attachment; filename="pgnagios.zip" + +UEsDBBQAAAAIADtsPjPROxm73AIAAI0FAAAPABUAY2hlY2tfcGdjb25uLnBsVVQJAAMxoT1DZKI9 +Q1V4BAD0AfQBdVTbbtpAEH3GXzExjmK33JGqBgoSJWmKmkAEoXloqmgxC17F2O7ucqmS9Ns74xuk +SZ+83jnnzMzZ3SkeVddKVmciqEZc+lDeGmvF4ezzoG0Ylog6Vm988f1H7Sc8PcFJuexxPzppG9Z8 +FrAVT6P1JKo0kzoJooZMg40kKFxfbDhGjeIZX7C1r0GHMA0egnAbwEQzvVaGpeJvp0mw+mmjUv/w +sdKsnILmq8hnmtch0QHDEAuwsUA4+gPVu/n7qmM8GoVIikCDeS3DjZhzYDC4hlCCFypN9UK4AO1x +mIU7yu563H0ALSgQwFqJYAkRQpeSq18+TM4vz/s3MBzd2s5dYLaNAt8JDVjcs8F9xSlhMc044XLD +JQgFloqXCaHYD4OAu3GvZ0yzGUNawcJd6ICJLreul63My+TbpmI72BnxrbOZh0gElrtuImUTuwSp +ySU4OSnB45gJxc+lxF473fqzQ5bPBQdzGrCZzyk9c12uVF4FpOmoc8oI5CVTQKKZeOUuSDQl12sZ +8DlsmWqBWQGLSm9xKZWWeFYFC/26X7Fdx5x8Hd0Cru7TckUYqHbcCkHctZSISYztj6bDG/udA1/G +oyuIlvd0+vcMORuhf6ck7ZEuekBWlLuR5BGT3M4SOhmIlN9GUcQ50Cp3+Y67a81t2t16Av2xbWtF +BTskkeMWXLueDLe24wCedcHK+uokaKQ/H6T/j/AL3QT3Spi2U+UDYbZhws8SpqnLe2w7h0Qu3pg9 +upqj39VrNYLhac5jlIrv68I2j/FxLUy8R7ncS5ZDTzB7T1ds14I8XII+mb1nlqBHuVsHJaRbcO3q +1r5IOlKjEL/cfA8+QaNG9/WAHe85RiH2Jp0JjcQUfHiv+M03+M1/+fWcz18GakkAT1ctO+a+KxoW +ec/Q319nmKKbWEJm6rGDfRWhDre98XAwvMB1A/rjwc2g37vEnyZMh99wigyNbEBRqmycpGXQUPkL +UEsDBBQAAAAIADtsPjPUa7DFiQIAAFYEAAAQABUAY2hlY2tfcGdsb2Nrcy5wbFVUCQADMaE9Q2Si +PUNVeAQA9AH0AV1TbW/aMBD+nPyKK0QiUQkQqk0rKEgdsAq1A5SWVdM6TSYcYDU4me0AUtv99p2T +0Gn9kPji57l77i31s3auZHvJRTtDmYB/sHOFMPo86du2w7PQuYquv/3o/ISXF2j4/haTrNG3ndVS +sB1WaFCiSjOpS5BiyArsliCPE75HQu36CNcsTzToFBbiSaQHAXea6VzZjirO8MLQgstuK/j4qXXR +ugSNuyxhGgMo44DtJGn8pMIOyeHxn71Tm7BW69t8DS6lD2d/oP24Om979rNtZZILDbW5TPd8hcBg +ModUwjZV2lQD6Rr0FmGZHk1u8RbjJ9DcAAJyxcUGMqJuJKrfCdyNb8fDe5jOHlzvUZCkhUeugVJ/ +tTFRaATrleIdyj1K4AocVZilQ32YCoFx0YkR02zJyM1y6BZCqNEMevNN79Tp8uybZEOqzPg7o+WW +mET0B3EZyjXeTahG0IRGownPEeMKx1JSreEgePXMQFYcobYQbJmgkWdxjEq9ZQGVnKncKILpJVNg +gp6Ctx5FGVOizqXAFRyY6kGtBY5JvYdSKi1pkpZD/QprVcN26Qqbw9lieu8a04Mv0ewrZJtfxRDh +Opot5vD5e8GDWTQaR6evflGz0qZmU7o/yCRmTKJrBLwK9Ad4xDjX6Jqbw5ZTga7rFLJOnOZCe8a/ +YK5Rx1uZHlzPAxqXVWxNIRzS3uAxTmjse2zzErbeVu1knJcRSch6padaSuc9Vq6leUMR3q0SaZqK +yLHQrULCAIKOZ1tG8PQ/dEsardU75od3xOCNiP8DnQKo8ii9b4u374O5pUTq0IHZDR0BPFxF08n0 +muwuDKPJ/WR4dUsfF7CY3tDCT+3Tv2RcT5tfSZn9/wtQSwMEFAAAAAgAO2w+M1THmzWzBQAAPRAA +ABIAFQBjaGVja19wZ3F1ZXJpZXMucGxVVAkAAzGhPUNkoj1DVXgEAPQB9AGVV21z2jgQ/ox/xRbI +AFMIIZm7aeHIDBfcHtOEZHhp56b0OsYI0MSxXUkOzbXpb79dy45lEvfSfCD2avVotdI+z7ryoh1J +0V5yvx0y4UFrZ1UiyUAqwV3Vs+h5+OeoZ1lVHvarg8nb9x+PPsH371BrtbbMC2s9q7pa+s4NS0Y7 +elQqRyg9iBgiGTzWg+FGfvFw0KoM2dqJPAUqgLl/7Qc7H6bKUZG0bu6gKuPH/gl60uut40bRzWc3 +iHzVP+rFNsdTTORNUbhyFMvbuI9BqLxNMo+5ezYv8Dd85e3PfmTxAz8zatNKBGHeyRXsUSBKRL77 +yBrpveeNgknF/c0eZhDeZZbEZOIHyvHyU1ZMOdx72PU2wER8iZi4S+bfyE2/Vuulz3rss54lcyMx +rDaRrV7FRNPRN6vxnGZ1FQlH8cBvVqUX7JpVOnpyaPSsSuf18WHn91eHJ4evQbGb0MMsdIC7Hr9l +YFl8jXg8hBc/oL1YvWw3rG9WKRTcV1C+EsEtXzFwYHQFgYBtION1IVijDde4ZYKukLtl7jW0YBMo +cMRGduGom97ZJnS66Q1twnE3vZALv9yzSuwrV4D37N5inmS0dCVZe6rRuaQLQ496QuUs8H28PrTs +0FHO0sFpJUoUDkAfylg13atNN60N/b9HkfdxmwRBzsPlFp3Rt3XqasA6ATQhqZsm1GpN+DZxuGS2 +ELj3/mnnvkFVtOIMynPfWXqMgnBcl0n5EAskKwJGQ4sC5daRQKAp+OHC15iCqUj4bAU7B3NWPsS4 +MPouEwJ5AM86DhVLtl+e2uf22QzSc3cjIZifXKem4jcsWK+cu3qj252NLuzpbHBx1dL3KSaEJtTP +BlMbPvxlj+H/3eEURuOZPXk/OIfab3DD/UgxWYMZTZ9N5jbY54j2ZkC/9njYgMEU4puH24t3/2Zy +eQHhhuDUZ8dV/Jarux5mv0IxTGzI7QDGlzMYnY/e2VDTOz2owWA8LPY6+GM0PLdPD2q99ESlohOl +g22dhoKFjmB1yh2WQIkGW6fsK3NxH3Wy7LYcj6/+C5VE4DHMmil3K4JdvdEAvK+luIDIGfpYQp02 +b6CRBvSIDr3/o72IQ16cagftUdojvpcve2S+p5+4IDLHhE06Dw73eD9KlRmCUwViUW8Cwf9lQAty +Jq399f/RmTXiyzGxXpqAcWGaWRA7lUDdY/5GbRMHTE0fjhqQ4e5vyEA14hmNp/YkF4+pFj+bOb8a +Dma2OdPUniSJuYw9jfN+cDafX5g4ptQ9H+dsYifxwN6fRjUF6fmow8nlVTFmJnvPR8TSHZ/9NNK8 +TD4feXCOdGEm0ugPfiGPl1d/myCZ6BZhVGBE5AmOImkj2U6qwd2C49+lxQA7jvTgB6A7myY4IRGE +r7w7QAHi0q8p2AXiGgFi1NkWmVwHtubMW4EXBNcSPH5NarjEJG1JBGXouHGpPdrLx4VayE/tbC+5 +ruInKWHZnTabk6dnxLHiwtpKYikZboTBirYardcpCyTT+p0soKw90ak2FjF6lb6MlihGyc6aR83O +q4Z2etSywCHKL2SUiUHQeZhopIop5cI6IEVM+LacpsDspOJ40KhZfcVlotUkjflWsG9Oa1XNHrFk +6RTEr6hsJ5gCykDa5R7rNdITTN06e26dBzeWHzjSA8kqeT5HnKMUx2jkyvtu9ApEsdJs+MoaOcbN +XZ9C2LxX8vYYMsE06b8QMuekJeSJIBNEk8ALEXNOWgSKEU1iL0TMOWlxKEY0Kb4QMeekZaIY0eC6 +QkDTJybLYriM2QvRDBdSiWIsU3kK0XJOWsuKEfMKUYi555YqT+H9zqi+OMzMhYSiMMS0OclGG2Y9 +m5g5pxQj/jAr5/mFyN6kGEiYCJkLxUegKFCPy8yQnvioi/vfDnwYTMaj8Vt8PsZ0j2ajs8E5vpzA +fPxufPlhbKUfYISQfiQldEOfSv8BUEsDBBQAAAAIADtsPjO8CYTACgQAAOAIAAAPABUAY2hlY2tf +cGd0aW1lLnBsVVQJAAMxoT1DZKI9Q1V4BAD0AfQBrVZtT9tIEP4c/4oh8Sm2iB0nOa7FUZAoRL2o +EFBI2w+lOm2cDd7i2LndNSGi3G+/mV0HejR3p3uRIA4788wz88zMmsZeu1SyPRN5e8VlBsHaKRWH +0zejvuO4YjVwjydvP3yKPsPXr9AMgpRnq2bfceeznC15Ze1Yq9JMamvEGLIydq1RJJm442h1Gp3D +btj56XXYCw9B8+UqY5p3wDqA44gFeMgMe79B+3q+3/adB6e2kiLXUL+UxZ2Yc2AwuoRCQlooTYlA +sQCdcpgV96ALSFKe3IIWZMihVCK/gRW63kiufs3gang2PJnC+OKj51/n9b5T4/dCQ6/vPDo8U5wI +GxXjFZd3XIJQ4Crz1QIaJ0We80QT2ynTbMYQVnPxFAZQR/niy5t4K5J99inZAVZGePd0lqInOgZH +iQ3lEboFlXotaDZb8DBhQvGhlFjr4Kjz6JOWc8Gh/j5ns4wTPUsSrtRTFlDRUeXECKQlU0BBt8HD +69zGlFyXMudzWDMVQz0El1KPuZRKS+xVzUW9BvVvBWt9GE6uRhdjz++bQpSmQqie4Ggl+YpJ7hHK +r4zBEb/nSam5RyfrVGDWnudSc1ou6qlEkfsUwfguuE5SWaw93wfswlMbTt9MR+fDGAzOtqDW6EbR +QRD1gqgL0esYfw5wsF79GB10gugVOniu3CznLVemS+UP1CrDJrc/XavP7ZYN1LdOaVFK9FqKHD8V +T559Y+NK+MoVrS33l2eH0DrgceVg6/pS5rcvnbaE25IMbQwVPRA9/UVZAAWMbVxTbOMKG7WyE33H +pKDeK4y13KDWmBK4BubaUO5yzjb0MPO04YzO1vZsYx9CzZUm2bMiYRnF9cyH7/ehAVNcJcOVF+sw +DHEOajV3UWYZxaJemec+dA6jaOuflFJyrMuYcF34PUt0toFmXi5hIxXgFibcQMKmCVgFU+UMhw13 +3iTabfVoTp6tRq2FV/8h6s7rVTnWg6qEXS5kwDoAMztntxwZJIc1h5ThBaPXBW7QjdAqNFmgSLAr +yv4+mYwcp0LjnqVcchKDQKj5ThAZKubvQdii3SA0/CmIOroTRAZC7QJtvlemZ8WrlGlArxLhDzgz +CHSBPTU7IBECK7WhjCnbmOqs0/2AGFyxwU6AWVJzm5MP5Hg10T76ePpgVdRMl2rQ7Vt51M2gfjIZ +TUfHZzFdZ5zGqFgs9mAyPL+Y0vab9YKzixNyqdINYHuNGMJH/MVL3PAa8QyvUeuviD8eT8aj8dsY +fibMfyWmVhteau1L2s4u2nORl/9DxTSYhpgG8SVx9A3xlAIhW5IV+M74F3T876PnoDZ58k+DPzoN +iODiHT46UOmD37tgZgOxDk3v+/E7fB2Nne2/BsS7fZFXGdHr/HdQSwMEFAAAAAgAdG4+M8MyfX52 +BwAAKBQAABoAFQBjaGVja19wZ3dhaXRpbmdfcXVlcmllcy5wbFVUCQADW6U9Q2uiPUNVeAQA9AH0 +Ae1XW3fbNhJ+Jn/FRHKOpMaUSce5mI6cuorr6KSWXVludk+d6kAUJLGmCIYErWq93t++MyBIkbKy +bvdlX5YnVgDMffDNAKg/20uTeG/sh3sRjwOwlmDW4SSVcxEDuDAU4Qo+syQRITTZ70s1+n62YH7Q +9sSiBWOW8AkglcGcszs/WMGcebe45oloBWIK3px7t6MkXESjQLAJjFdwyWTse7dwGYsVNCHSUyYh +wpW2iGct06ynCYeEKPLIpHGfS9e96p9fZtMzLkWEKz+JcHaE7NBNEykW/j84TNH5lUhjCNnMFwn4 +YSJZECixwB9DTQUdCI8FexnLHi7zP7hXy3Sn0g8S+LpsPj8dDC4GV7Az7J2fXlwPW2TpMpXwd1I/ +4VOWBhLIKTQyFZiDmJuLFeyIEaZnkYa+XEEHalE6DnzUDkYdCoJmjEQskcdwXjtIRwZaQDO9KQUB +ExE2JCRcphGQixjBLYceTHzM8ZyFMw5y7idK2enfTrujq+HJ8PpqdN77gSy3nfbL9mv8PcC/fXvf +ab9t77cd28ZQN0Uueh9IZFMNcbedx/znV2f/QcRRIrgvHzEn4CeIkDEjWIQTX/oiNOvX3Q8Wpc5C +Adflf8ghGwc88w7/8H9U3esPT89OBy7YZn0HCEZLFtyCdeeA5aldtoqEWiFbcHAOUfL1WwzXga3R +P2W5atd5gj1z82o46PXPXKgtGUYXzqyvKY9XlgJ/7QkNL6saSuCkutyiEJ7SqP7KQTwZs+1UnYhE +ImcxT4C+wzeHbwEw1OznzZuD/QPYf+Psw3vQ3xX92IfuwUv637VtyDW4xQirOZ1O4VcV2xd07up0 +MAQdX64IzL8OjArIQhEvWFDG2f9h89/Cxv6rsOkLIIM+brZ24GmbW7bzMweP4YayscBeK+cce/I+ +Nr4Q4fQ/iYEgdhaIMQsSU7ftOaI669c0IgjlBB5EHSMN8XTI6EumOrhAkBEN3mvGOx6Pc0bio7nA +SBdikuuS/oJjCjoAr46g/CH7B336vEpgmLHlBwqPpx3FpZ0ovjpcpDLClBIL1UnocZgwySi+aRp6 +VDAYYZKO8Sj2QzlKE4YHzL1pqCnUrmnuwo4Nv1p3X8D6CO8o/GOwuvBOHfJFWR0jSwTv6DQ7/oLj +X77chHgiPGTq/SQM0wXco08DPNviEGScYglPgcUzquRQSKrmdDHmsWlQZMTfgWTuT/FGYCBnU6/9 +C/Z+a95MXty0399Mvmv9s/nbTRunrZ09aKGFONNvw9GDaeiJUziitmQd4E14qdvV1wBvPllv+pmK +CLpURCoGo5ScZkupqsOPeOvIt1CoNCv9tIROUACykzmf5Rbnu2iuRjHjNiG4J02NihYcgXYvuz7h +TYd2hvws33tctyvCqT9LsVaatTFud0BwRY+I7SITapqGYTTuGkbnGG60gV1ayXytriveeUOhRa9T +gnYV5ho0bBQQLNOV3Ec3aZTkMI9kJy8PJBplkhKJXL8kQlghU0TAIdKMMkVJdCtGCrTtGo1iXLK0 +pithWTGnq2s3D6ihFzKmR2xKwy/lfCWYX51KGj4iKQmv6nDsFwbV16AVH9t2xlbhU/LLivySxWFV +nla0LGzwKflpJRiq/Ko8rUQsRiRs8qE4QEvXmoYoNPWWt1Rt0QgrAG+mPgI6uy3f1677n/oXn/u1 +h4e8UJ+VIU7bT+L1DN2qgQILJzD1A8ljMI17qFbYN/WbuQ7qPeoOjl1NHfvabslsgQW0XZiAGl3n +lXQgZn6odDyjKv/TLlD1Fx+cn/T6oCemWSnfZit7qCiHZ+o4AQ0uagLKicSL+TKBNDJLSW8W748W +tQCq1GbtJGDxgh5NORFewCtV+4wohcyLV9ShgAcJXwuHorCcb6xbOnBQlWOvdalN16QXjp13PGw+ +IffwgBZqC+n4ae4kPFHYhx0exyJuYcsuXm7WsaaqnmQYVt4bFOzKjQFppQfUMTwqZWRQD6ccs+Ue +gbQ8jpym54qqgY9RUIrXCNG+ZTlWmz9t1tR+g4h4SAeBZnHhedJGjBRBYqK+AQ+VKmr+RB/dsaCz +jcesY7/G+zGTafaSw/MHz/ZRtoIpzJ2zjmdcjiTdXyiHP+DzW+BDkILceIIhFUG7EWJF7ZZAXbxV +IAJ9hVdQZqAUbOHEn4q6risziworkzNvrg7CW07vfvxN4PmGT2uI0tPSVby7yiuaVJnvifigYFrX +xaxqC3cqF9wqkZ3hlBnlCd0fNt/Be9QhMIWKaZsOOAYbeRSTsWVzu4PesNc9+YlyYRgPZt5uqQyL +yX0xUreznoRFiq1wjBeI2xJpm/6LT6Q558CLDf5D3d8MSj/W87jq0YwuOPg5+JA7pIedXX3d7dsb +rzvHdg+Q8dHrTinC1GAxbn/aobmd7ELU2ZrKo9x51Z8MSgO95IIAZkJMiPhgrqHnBXhpoYrp8yUo +HMIcz44Azw3LAskTZVLlIc8a8K+wZWNa5vraB/kyaFex/2+iu7ylD2ae7K1GPp8M+via2LChV9cm +Ni0UYk8aoO1vQVn5xadv683AkunkFam8Yp8o5X8DUEsDBBQAAAAIALJsPjO4BJq4sAMAAMUIAAAG +ABUAUkVBRE1FVVQJAAMQoj1DZKI9Q1V4BAD0AfQBlVVtb+I4EP7uXzFiKx2sIJTei0776XrAXiv1 +TRCuuk/IhCHx4tip7ZDNnu6/39gJlG17OhoJktiemWeeeWYSZ2gRuEH4UloHVucINjGicBauIdF6 +i2soC9AK8hp0pSKIM6yh0mYLG6EQNtpAjn2odUkPQiJPEXJew46bOmLsgVYohERHx2CrdAVi4097 +8zW4AKAJCaXFTSkjuHbBA6qEnAZ/CE43QQkJ2eQRfBr0GIu1quGRW0vLXf6lCk+/pTkXMkp0TieS +DJPtskgTrVRUSBjAPNOVhQJNgsp573oDfhcTJ7SywHdkzVcSAxDCZFlnPr2ZjmMY3y/u4u7HHnye +3d9CkS6t427JyXAnXN2BIXTmV/ePhP7r8shlx3tiCVfApdX0h8ZBlaEiWqylfPwOJLTKhQJV5is0 +r1AZZM/InvN6KtEItE1q1w2zGd8h+I0apE5ToVLi0tt5voUFW+Y5N+IbZUZcgqsLtD5e6wtMqZQ3 +6rZp96/v5tMZ3Sf0Hk+hv3iYXPr75U08nbH+eDYNr/FscTempz78eTleLG77RNjDXz3gVOiKG8qC +Ss+pYvtAAegKUbF9SKlVSskHSn4mPanS0bkuMbERKYmBkugdZS91sm1zvyGxBjWGNe/Bwco/h/B+ +Y0VClKIN49fbuh35cyLHxt0t36JnilojuCq0dalB+yR/IOd0DIhIqpatVQKVcFmgMtdKOG18CItm +h+bId8WFo43ldxV7zKiJXvHiG1IEoUOnNeuA1xpVfoZPpSAg0G4MQqEHIQoZ0SnpC00NgTzJYPL7 +M5K3LAaUY1Fo4wLmpg89Wf+NOrSFQlxb35RUOGD7YM8kwZo77gnfR4d9M8H87vYB8CsmsClVUDeX +vgoQa38ABJFdOmB+GJFcfbXEFhvlEilh0Byy6toeDNElQ6vyYh15ndBgkfiJMWiCjKIfo1+iUfQT +/S7OL0bRr9FFNDo/f5O/YWnNkMTB5XAl1PCNI4x99Be7QoOkBA6W54Vs5mCAFk7R7MlJdjZKNmnA +45ErngptGWMfaLvwNQ462gl+RBxbY5irrQf4m/JornZlqTgZ+fcjzb46JL0Pus4W1Lmjs+FLgZ9d +3c/jy8lkNp3Pz8Ah5UDqGh2AsH8I5h80tD/4wRA6Bdt51Ayk9+P01ifj3I/r9+Fcr5rufz+4xuxU +dIexcxK8z/5Dd9zeraxeoPx/kHu7U2G+NXGuvsd88HUAaiV9oknMfKW0ybl8+VV4N+rW/mTUR2hP +oZexfwFQSwMEFAAAAAgAPWw+M3/mbb2AAAAAqwAAABMAFQB3YWl0aW5nLXF1ZXJ5LWNoZWNrVVQJ +AAM2oT1DZKI9Q1V4BAD0AfQBPYwxCgIxFET7nGKMFlpI1DZ6BVsLEXaFb/wQsjH5IQvq3V0h2s3w +Zt58ZkpO5srBREpeLYYiscihixl9GWvFCy5RRByyTCH/+pqhz6dLz8LB6c4qvmHpKTi5o0mwx3aF +J2LiINDHAY9CiSdHbTcLGlmwsXgr8pn+42ZofPfl6gNQSwECFwMUAAAACAA7bD4z0TsZu9wCAACN +BQAADwANAAAAAAABAAAA7YEAAAAAY2hlY2tfcGdjb25uLnBsVVQFAAMxoT1DVXgAAFBLAQIXAxQA +AAAIADtsPjPUa7DFiQIAAFYEAAAQAA0AAAAAAAEAAADtgR4DAABjaGVja19wZ2xvY2tzLnBsVVQF +AAMxoT1DVXgAAFBLAQIXAxQAAAAIADtsPjNUx5s1swUAAD0QAAASAA0AAAAAAAEAAAD9geoFAABj +aGVja19wZ3F1ZXJpZXMucGxVVAUAAzGhPUNVeAAAUEsBAhcDFAAAAAgAO2w+M7wJhMAKBAAA4AgA +AA8ADQAAAAAAAQAAAO2B4gsAAGNoZWNrX3BndGltZS5wbFVUBQADMaE9Q1V4AABQSwECFwMUAAAA +CAB0bj4zwzJ9fnYHAAAoFAAAGgANAAAAAAABAAAA7YEuEAAAY2hlY2tfcGd3YWl0aW5nX3F1ZXJp +ZXMucGxVVAUAA1ulPUNVeAAAUEsBAhcDFAAAAAgAsmw+M7gEmriwAwAAxQgAAAYADQAAAAAAAQAA +AKSB8RcAAFJFQURNRVVUBQADEKI9Q1V4AABQSwECFwMUAAAACAA9bD4zf+ZtvYAAAACrAAAAEwAN +AAAAAAABAAAApIHaGwAAd2FpdGluZy1xdWVyeS1jaGVja1VUBQADNqE9Q1V4AABQSwUGAAAAAAcA +BwAQAgAAoBwAAAAA +------=_Part_2116_5761522.1128113836231-- + +From pgsql-hackers-owner@postgresql.org Fri Sep 30 18:31:41 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 38EC6D9B62; + Fri, 30 Sep 2005 18:31:38 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 07554-01; Fri, 30 Sep 2005 21:31:33 +0000 (GMT) +Received: from postal.corporate.connx.com (postal.corporate.connx.com + [65.212.159.187]) + by svr1.postgresql.org (Postfix) with SMTP id 9DE0FD95E0; + Fri, 30 Sep 2005 18:31:31 -0300 (ADT) +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: [PERFORM] A Better External Sort? +Date: Fri, 30 Sep 2005 14:31:32 -0700 +Message-ID: + +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [HACKERS] [PERFORM] A Better External Sort? +Thread-Index: AcXF/vkCN7B83DHyEdqX9QANk63kWAAByZAw +From: "Dann Corbit" +To: , + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.012 required=5 tests=[AWL=0.012] +X-Spam-Level: +X-Archive-Number: 200509/1428 +X-Sequence-Number: 73825 + +I see the following routines that seem to be related to sorting. + +If I were to examine these routines to consider ways to improve it, what +routines should I key in on? I am guessing that tuplesort.c is the hub +of activity for database sorting. + +Directory of U:\postgresql-snapshot\src\backend\access\nbtree + +08/11/2005 06:22 AM 24,968 nbtsort.c + 1 File(s) 24,968 bytes + + Directory of U:\postgresql-snapshot\src\backend\executor + +03/16/2005 01:38 PM 7,418 nodeSort.c + 1 File(s) 7,418 bytes + + Directory of U:\postgresql-snapshot\src\backend\utils\sort + +09/23/2005 08:36 AM 67,585 tuplesort.c + 1 File(s) 67,585 bytes + + Directory of U:\postgresql-snapshot\src\bin\pg_dump + +06/29/2005 08:03 PM 31,620 pg_dump_sort.c + 1 File(s) 31,620 bytes + + Directory of U:\postgresql-snapshot\src\port + +07/27/2005 09:03 PM 5,077 qsort.c + 1 File(s) 5,077 bytes + +From pgsql-hackers-owner@postgresql.org Fri Sep 30 20:02:39 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 55559D9CA2 + for ; + Fri, 30 Sep 2005 18:45:18 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 98662-07 + for ; + Fri, 30 Sep 2005 21:45:13 +0000 (GMT) +Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 43BDBD95E0 + for ; + Fri, 30 Sep 2005 18:45:13 -0300 (ADT) +Received: (qmail 29608 invoked from network); 30 Sep 2005 23:46:04 +0200 +Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) + by boutiquenumerique.com with SMTP; 30 Sep 2005 23:46:04 +0200 +To: "Luke Lonergan" , + "Ron Peacetree" , + "Josh Berkus" , pgsql-hackers@postgresql.org, + pgsql-performance@postgresql.org +Subject: Re: [PERFORM] A Better External Sort? +References: +Message-ID: +Date: Fri, 30 Sep 2005 23:45:10 +0200 +From: PFC +Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= +Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +In-Reply-To: +User-Agent: Opera M2/8.0 (Linux, build 1095) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200509/1441 +X-Sequence-Number: 73838 + + + +> Bulk loading speed is irrelevant here - that is dominated by parsing, +> which +> we have covered copiously (har har) previously and have sped up by 500%, +> which still makes Postgres < 1/2 the loading speed of MySQL. + + Let's ask MySQL 4.0 + +> LOAD DATA INFILE blah +0 errors, 666 warnings +> SHOW WARNINGS; +not implemented. upgrade to 4.1 + +duhhhhhhhhhhhhhhhhhhhhh + +From pgsql-performance-owner@postgresql.org Sat Oct 1 05:21:14 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 699A3D9D13; + Sat, 1 Oct 2005 05:21:11 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 83456-01; Sat, 1 Oct 2005 08:21:08 +0000 (GMT) +Received: from smtp.nildram.co.uk (smtp.nildram.co.uk [195.112.4.54]) + by svr1.postgresql.org (Postfix) with ESMTP id B5D7AD9D44; + Sat, 1 Oct 2005 05:21:06 -0300 (ADT) +Received: from 192.168.0.3 (unknown [84.12.173.204]) + by smtp.nildram.co.uk (Postfix) with ESMTP + id C48B12532AF; Sat, 1 Oct 2005 09:21:06 +0100 (BST) +Subject: Re: [HACKERS] A Better External Sort? +From: Simon Riggs +To: josh@agliodbs.com +Cc: Ron Peacetree , + pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org +In-Reply-To: <200509301341.22795.josh@agliodbs.com> +References: + <31833713.1128111650174.JavaMail.root@elwamui-polski.atl.sa.earthlink.net> + <200509301341.22795.josh@agliodbs.com> +Content-Type: text/plain +Organization: 2nd Quadrant +Date: Fri, 30 Sep 2005 23:21:16 +0100 +Message-Id: <1128118876.4045.53.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-3) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.261 required=5 tests=[DATE_IN_PAST_06_12=0.211, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200510/2 +X-Sequence-Number: 14770 + +On Fri, 2005-09-30 at 13:41 -0700, Josh Berkus wrote: +> Yeah, that's what I thought too. But try sorting an 10GB table, and +> you'll see: disk I/O is practically idle, while CPU averages 90%+. We're +> CPU-bound, because sort is being really inefficient about something. I +> just don't know what yet. +> +> If we move that CPU-binding to a higher level of performance, then we can +> start looking at things like async I/O, O_Direct, pre-allocation etc. that +> will give us incremental improvements. But what we need now is a 5-10x +> improvement and that's somewhere in the algorithms or the code. + +I'm trying to keep an open mind about what the causes are, and I think +we need to get a much better characterisation of what happens during a +sort before we start trying to write code. It is always too easy to jump +in and tune the wrong thing, which is not a good use of time. + +The actual sort algorithms looks damn fine to me and the code as it +stands is well optimised. That indicates to me that we've come to the +end of the current line of thinking and we need a new approach, possibly +in a number of areas. + +For myself, I don't wish to be drawn further on solutions at this stage +but I am collecting performance data, so any test results are most +welcome. + +Best Regards, Simon Riggs + + + + +From pgsql-performance-owner@postgresql.org Fri Sep 30 20:17:51 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1C55DD9CCF; + Fri, 30 Sep 2005 20:10:46 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25202-10; Fri, 30 Sep 2005 23:10:42 +0000 (GMT) +Received: from vms048pub.verizon.net (vms048pub.verizon.net [206.46.252.48]) + by svr1.postgresql.org (Postfix) with ESMTP id 27DF1D9CB8; + Fri, 30 Sep 2005 20:10:39 -0300 (ADT) +Received: from osgiliath.mathom.us ([70.108.61.78]) + by vms048.mailsrvcs.net (Sun Java System Messaging Server 6.2 HotFix + 0.04 (built Dec 24 2004)) with ESMTPA id + <0INN008VNKDLWIO0@vms048.mailsrvcs.net>; + Fri, 30 Sep 2005 18:10:34 -0500 (CDT) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id 427F56003B9; Fri, + 30 Sep 2005 19:10:33 -0400 (EDT) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 18924-06-7; Fri, 30 Sep 2005 19:10:33 -0400 (EDT) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id 1A0C76000E6; Fri, 30 Sep 2005 19:10:33 -0400 (EDT) +Date: Fri, 30 Sep 2005 19:10:32 -0400 +From: Michael Stone +Subject: Re: [HACKERS] A Better External Sort? +In-reply-to: <200509301341.22795.josh@agliodbs.com> +To: Josh Berkus +Cc: pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org +Mail-Followup-To: Josh Berkus , + pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org +Message-id: <20050930231032.GQ2241@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: by amavisd-new-20030616-p10 (Debian) at mathom.us +References: + <31833713.1128111650174.JavaMail.root@elwamui-polski.atl.sa.earthlink.net> + <200509301341.22795.josh@agliodbs.com> +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.004 required=5 tests=[AWL=0.004] +X-Spam-Level: +X-Archive-Number: 200509/458 +X-Sequence-Number: 14766 + +On Fri, Sep 30, 2005 at 01:41:22PM -0700, Josh Berkus wrote: +>Realistically, you can't do better than about 25MB/s on a single-threaded +>I/O on current Linux machines, + +What on earth gives you that idea? Did you drop a zero? + +Mike Stone + +From pgsql-hackers-owner@postgresql.org Fri Sep 30 20:19:09 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 90A61D9CCE + for ; + Fri, 30 Sep 2005 20:19:07 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 33486-06 + for ; + Fri, 30 Sep 2005 23:19:04 +0000 (GMT) +Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) + by svr1.postgresql.org (Postfix) with ESMTP id CFB6DD9CD5 + for ; + Fri, 30 Sep 2005 20:19:05 -0300 (ADT) +Received: by flake.decibel.org (Postfix, from userid 1001) + id B966E1525F; Fri, 30 Sep 2005 18:19:08 -0500 (CDT) +Date: Fri, 30 Sep 2005 18:19:08 -0500 +From: "Jim C. Nasby" +To: Gnanavel S +Cc: "Jonah H. Harris" , + pgsql-hackers@postgresql.org +Subject: Re: PostgreSQL overall design +Message-ID: <20050930231908.GP40138@pervasive.com> +References: + <20050927102701.GE1784@penne.toroid.org> + <36e682920509270600439cfc4a@mail.gmail.com> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +X-Operating-System: FreeBSD 4.11-RELEASE-p10 i386 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.9i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.004 required=5 tests=[AWL=0.004] +X-Spam-Level: +X-Archive-Number: 200509/1447 +X-Sequence-Number: 73844 + +On Tue, Sep 27, 2005 at 07:00:14PM +0530, Gnanavel S wrote: +> On 9/27/05, Jonah H. Harris wrote: +> > +> > Were you looking for a call graph? +> +> +> Yes. I want to know the list and sequence of files involved during a call. + +Total non-coder question, but is there an open-source utility that's +capable of generating that? Seems like a useful piece of documentation +to have. Also seems like it'd be completely impractical to maintain by +hand. +-- +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 Fri Sep 30 20:40:34 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A8B33D9CB9; + Fri, 30 Sep 2005 20:40:30 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34560-10; Fri, 30 Sep 2005 23:40:26 +0000 (GMT) +Received: from pop-tawny.atl.sa.earthlink.net (pop-tawny.atl.sa.earthlink.net + [207.69.195.67]) + by svr1.postgresql.org (Postfix) with ESMTP id CEC0DD9CB8; + Fri, 30 Sep 2005 20:40:27 -0300 (ADT) +Received: from elwamui-polski.atl.sa.earthlink.net ([209.86.224.45]) + by pop-tawny.atl.sa.earthlink.net with esmtp (Exim 3.36 #10) + id 1ELUU5-0006dc-00; Fri, 30 Sep 2005 19:40:09 -0400 +Message-ID: + <22251764.1128123609842.JavaMail.root@elwamui-polski.atl.sa.earthlink.net> +Date: Fri, 30 Sep 2005 19:40:09 -0400 (EDT) +From: Ron Peacetree +Reply-To: Ron Peacetree +To: josh@agliodbs.com, pgsql-hackers@postgresql.org, + pgsql-performance@postgresql.org +Subject: Re: [PERFORM] A Better External Sort? +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Mailer: Earthlink Zoo Mail 1.0 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.257 required=5 tests=[AWL=-0.117, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200509/1450 +X-Sequence-Number: 73847 + +25MBps should not be a CPU bound limit for IO, nor should it be +an OS limit. It should be something ~100x (Single channel RAM) +to ~200x (dual channel RAM) that. + +For an IO rate of 25MBps to be pegging the CPU at 100%, the CPU +is suffering some combination of +A= lot's of cache misses ("cache thrash"), +B= lot's of random rather than sequential IO (like pointer chasing) +C= lot's of wasteful copying +D= lot's of wasteful calculations + +In fact, this is crappy enough performance that the whole IO layer +should be rethought and perhaps reimplemented from scratch. +Optimization of the present code is unlikely to yield a 100-200x +improvement. + +On the HD side, the first thing that comes to mind is that DBs are +-NOT- like ordinary filesystems in a few ways: +1= the minimum HD IO is a record that is likely to be larger than +a HD sector. Therefore, the FS we use should be laid out with +physical segments of max(HD sector size, record size) + +2= DB files (tables) are usually considerably larger than any other +kind of files stored. Therefore the FS we should use should be laid +out using LARGE physical pages. 64KB-256KB at a _minimum_. + +3= The whole "2GB striping" of files idea needs to be rethought. +Our tables are significantly different in internal structure from the +usual FS entity. + +4= I'm sure we are paying all sorts of nasty overhead for essentially +emulating the pg "filesystem" inside another filesystem. That means +~2x as much overhead to access a particular piece of data. + +The simplest solution is for us to implement a new VFS compatible +filesystem tuned to exactly our needs: pgfs. + +We may be able to avoid that by some amount of hacking or +modifying of the current FSs we use, but I suspect it would be more +work for less ROI. + +Ron + + +-----Original Message----- +From: Josh Berkus +Sent: Sep 30, 2005 4:41 PM +To: Ron Peacetree +Cc: pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: [HACKERS] [PERFORM] A Better External Sort? + +Ron, + +> That 11MBps was your =bulk load= speed. If just loading a table +> is this slow, then there are issues with basic physical IO, not just +> IO during sort operations. + +Oh, yeah. Well, that's separate from sort. See multiple posts on this +list from the GreenPlum team, the COPY patch for 8.1, etc. We've been +concerned about I/O for a while. + +Realistically, you can't do better than about 25MB/s on a single-threaded +I/O on current Linux machines, because your bottleneck isn't the actual +disk I/O. It's CPU. Databases which "go faster" than this are all, to +my knowledge, using multi-threaded disk I/O. + +(and I'd be thrilled to get a consistent 25mb/s on PostgreSQL, but that's +another thread ... ) + +> As I said, the obvious candidates are inefficient physical layout +> and/or flawed IO code. + +Yeah, that's what I thought too. But try sorting an 10GB table, and +you'll see: disk I/O is practically idle, while CPU averages 90%+. We're +CPU-bound, because sort is being really inefficient about something. I +just don't know what yet. + +If we move that CPU-binding to a higher level of performance, then we can +start looking at things like async I/O, O_Direct, pre-allocation etc. that +will give us incremental improvements. But what we need now is a 5-10x +improvement and that's somewhere in the algorithms or the code. + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + + +From pgsql-hackers-owner@postgresql.org Fri Sep 30 20:48:59 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F2ABBD9CD2; + Fri, 30 Sep 2005 20:48:55 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34834-08; Fri, 30 Sep 2005 23:48:48 +0000 (GMT) +Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 94D2DD9CB9; + Fri, 30 Sep 2005 20:48:50 -0300 (ADT) +Received: by flake.decibel.org (Postfix, from userid 1001) + id A16361529A; Fri, 30 Sep 2005 18:48:53 -0500 (CDT) +Date: Fri, 30 Sep 2005 18:48:53 -0500 +From: "Jim C. Nasby" +To: Christopher Kings-Lynne +Cc: "R, Rajesh (STSD)" , + pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: Query in SQL statement +Message-ID: <20050930234853.GT40138@pervasive.com> +References: + <5CBFB210D9870F40B9E5A0FBD31F3A770283AC48@bgeexc01.asiapacific.cpqcorp.net> + <433BEC06.40004@familyhealth.com.au> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <433BEC06.40004@familyhealth.com.au> +X-Operating-System: FreeBSD 4.11-RELEASE-p10 i386 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.9i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.004 required=5 tests=[AWL=0.004] +X-Spam-Level: +X-Archive-Number: 200509/1452 +X-Sequence-Number: 73849 + +On Thu, Sep 29, 2005 at 09:28:38PM +0800, Christopher Kings-Lynne wrote: +> +> >CREATE SEQUENCE ai_id; +> >CREATE TABLE badusers ( +> > id int DEFAULT nextval('ai_id') NOT NULL, +> > UserName varchar(30), +> > Date datetime DEFAULT '0000-00-00 00:00:00' NOT NULL, +> > Reason varchar(200), +> > Admin varchar(30) DEFAULT '-', +> > PRIMARY KEY (id), +> > KEY UserName (UserName), +> > KEY Date (Date) +> >); +> > +> > +> >Am always getting foll. Errors, +> > +> >ERROR: relation "ai_id" already exists +> >ERROR: syntax error at or near "(" at character 240 +> +> You have just copied the Mysql code to Postgresql. It will in no way +> work. Your default for 'Date' is illegal in postgresql and hence it +> must allow NULLs. There is no such thing as a 'datetime' type. There +> is no such thing as 'Key'. Also your mixed case identifiers won't be +> preserved. You want: +> +> CREATE TABLE badusers ( +> id SERIAL PRIMARY KEY, +> UserName varchar(30), +> Date timestamp, +> Reason varchar(200), +> Admin varchar(30) DEFAULT '-' +> ); +> +> CREATE INDEX UserName_Idx ON badusers(Username); +> CREATE INDEX Date_Idx ON badusers(Date); + +Actually, to preserve the case you can wrap everything in quotes: +CREATE ... + "UserName" varchar(30) + +Of course that means that now you have to do that in every statement +that uses that field, too... + +SELECT username FROM badusers +ERROR + +SELECT "UserName" FROM badusers +bad user + +I suggest ditching the CamelCase and going with underline_seperators. +I'd also not use the bareword id, instead using bad_user_id. And I'd +name the table bad_user. But that's just me. :) +-- +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 Fri Sep 30 20:52:46 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9BEDDD9CB9; + Fri, 30 Sep 2005 20:52:43 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 36410-09; Fri, 30 Sep 2005 23:52:39 +0000 (GMT) +Received: from postal.corporate.connx.com (postal.corporate.connx.com + [65.212.159.187]) + by svr1.postgresql.org (Postfix) with SMTP id 85E6BD9CD2; + Fri, 30 Sep 2005 20:52:39 -0300 (ADT) +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: [PERFORM] A Better External Sort? +Date: Fri, 30 Sep 2005 16:52:42 -0700 +Message-ID: + +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [HACKERS] [PERFORM] A Better External Sort? +Thread-Index: AcXGFK4T9ygUnzX/TQeR6vWOQZxxDwAAT02g +From: "Dann Corbit" +To: "Jignesh K. Shah" , + "Ron Peacetree" +Cc: "Josh Berkus" , + , +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.012 required=5 tests=[AWL=0.012] +X-Spam-Level: +X-Archive-Number: 200509/1453 +X-Sequence-Number: 73850 + +I have perused the tuple sort stuff. + +The good: +The documentation of the sort algorithm from Knuth's TAOCP was +beautifully done. Everyone who writes an algorithm should credit the +original source like this, and also where it deviates. That was done +very nicely. + +The bad: +With random access, tape style merging is not necessary. A priority +queue based merge will be a lot faster. + +The UGLY: +Please, someone, tell me I was hallucinating. Is that code really +READING AND WRITING THE WHOLE TUPLE with every sort exchange?! Maybe +there is a layer of abstraction that I am somehow missing. I just can't +imagine that is what it is really doing. If (somehow) it really is +doing that, a pointer based sort which forms a permutation based upon +the keys, would be a lot better. + +The fundamental algorithm itself could also be improved somewhat. + +Here is a {public domain} outline for an introspective quick sort that +Pete Filander and I wrote some time ago and contributed to FastDB. It +is written as a C++ template, but it will take no effort to make it a +simple C routine. It assumes that e_type has comparison operators, so +in C you would use a compare function instead. + +/* +** Sorting stuff by Dann Corbit and Pete Filandr. +** (dcorbit@connx.com and pfilandr@mindspring.com) +** Use it however you like. +*/ + +// +// The insertion sort template is used for small partitions. +// + +template < class e_type > +void insertion_sort(e_type * array, size_t nmemb) +{ + e_type temp, + *last, + *first, + *middle; + if (nmemb > 1) { + first =3D middle =3D 1 + array; + last =3D nmemb - 1 + array; + while (first !=3D last) { + ++first; + if ((*(middle) > *(first))) { + middle =3D first; + } + } + if ((*(array) > *(middle))) { + ((void) ((temp) =3D *(array), *(array) =3D *(middle), = +*(middle) +=3D (temp))); + } + ++array; + while (array !=3D last) { + first =3D array++; + if ((*(first) > *(array))) { + middle =3D array; + temp =3D *middle; + do { + *middle-- =3D *first--; + } while ((*(first) > *(&temp))); + *middle =3D temp; + } + } + } +} + +// +// The median estimate is used to choose pivots for the quicksort +algorithm +// + +template < class e_type > +void median_estimate(e_type * array, size_t n) +{ + e_type temp; + long unsigned lu_seed =3D 123456789LU; + const size_t k =3D ((lu_seed) =3D 69069 * (lu_seed) + 362437) % = +--n; + ((void) ((temp) =3D *(array), *(array) =3D *(array + k), *(array + = +k) =3D +(temp))); + if ((*((array + 1)) > *((array)))) { + (temp) =3D *(array + 1); + if ((*((array + n)) > *((array)))) { + *(array + 1) =3D *(array); + if ((*(&(temp)) > *((array + n)))) { + *(array) =3D *(array + n); + *(array + n) =3D (temp); + } else { + *(array) =3D (temp); + } + } else { + *(array + 1) =3D *(array + n); + *(array + n) =3D (temp); + } + } else { + if ((*((array)) > *((array + n)))) { + if ((*((array + 1)) > *((array + n)))) { + (temp) =3D *(array + 1); + *(array + 1) =3D *(array + n); + *(array + n) =3D *(array); + *(array) =3D (temp); + } else { + ((void) (((temp)) =3D *((array)), *((array)) =3D = +*((array + +n)), *((array + n)) =3D ((temp)))); + } + } + } +} + + +// +// This is the heart of the quick sort algorithm used here. +// If the sort is going quadratic, we switch to heap sort. +// If the partition is small, we switch to insertion sort. +// + +template < class e_type > +void qloop(e_type * array, size_t nmemb, size_t d) +{ + e_type temp, + *first, + *last; + while (nmemb > 50) { + if (sorted(array, nmemb)) { + return; + } + if (!d--) { + heapsort(array, nmemb); + return; + } + median_estimate(array, nmemb); + first =3D 1 + array; + last =3D nmemb - 1 + array; + do { + ++first; + } while ((*(array) > *(first))); + do { + --last; + } while ((*(last) > *(array))); + while (last > first) { + ((void) ((temp) =3D *(last), *(last) =3D *(first), *(first) = +=3D +(temp))); + do { + ++first; + } while ((*(array) > *(first))); + do { + --last; + } while ((*(last) > *(array))); + } + ((void) ((temp) =3D *(array), *(array) =3D *(last), *(last) =3D +(temp))); + qloop(last + 1, nmemb - 1 + array - last, d); + nmemb =3D last - array; + } + insertion_sort(array, nmemb); +} + +// +// This heap sort is better than average because it uses Lamont's heap. +// + +template < class e_type > +void heapsort(e_type * array, size_t nmemb) +{ + size_t i, + child, + parent; + e_type temp; + if (nmemb > 1) { + i =3D --nmemb / 2; + do { + { + (parent) =3D (i); + (temp) =3D (array)[(parent)]; + (child) =3D (parent) * 2; + while ((nmemb) > (child)) { + if ((*((array) + (child) + 1) > *((array) + +(child)))) { + ++(child); + } + if ((*((array) + (child)) > *(&(temp)))) { + (array)[(parent)] =3D (array)[(child)]; + (parent) =3D (child); + (child) *=3D 2; + } else { + --(child); + break; + } + } + if ((nmemb) =3D=3D (child) && (*((array) + (child)) > +*(&(temp)))) { + (array)[(parent)] =3D (array)[(child)]; + (parent) =3D (child); + } + (array)[(parent)] =3D (temp); + } + } while (i--); + ((void) ((temp) =3D *(array), *(array) =3D *(array + nmemb), = +*(array ++ nmemb) =3D (temp))); + for (--nmemb; nmemb; --nmemb) { + { + (parent) =3D (0); + (temp) =3D (array)[(parent)]; + (child) =3D (parent) * 2; + while ((nmemb) > (child)) { + if ((*((array) + (child) + 1) > *((array) + +(child)))) { + ++(child); + } + if ((*((array) + (child)) > *(&(temp)))) { + (array)[(parent)] =3D (array)[(child)]; + (parent) =3D (child); + (child) *=3D 2; + } else { + --(child); + break; + } + } + if ((nmemb) =3D=3D (child) && (*((array) + (child)) > +*(&(temp)))) { + (array)[(parent)] =3D (array)[(child)]; + (parent) =3D (child); + } + (array)[(parent)] =3D (temp); + } + ((void) ((temp) =3D *(array), *(array) =3D *(array + nmemb), +*(array + nmemb) =3D (temp))); + } + } +} + +//=20 +// We use this to check to see if a partition is already sorted. +//=20 + +template < class e_type > +int sorted(e_type * array, size_t nmemb) +{ + for (--nmemb; nmemb; --nmemb) { + if ((*(array) > *(array + 1))) { + return 0; + } + ++array; + } + return 1; +} + +//=20 +// We use this to check to see if a partition is already reverse-sorted. +//=20 + +template < class e_type > +int rev_sorted(e_type * array, size_t nmemb) +{ + for (--nmemb; nmemb; --nmemb) { + if ((*(array + 1) > *(array))) { + return 0; + } + ++array; + } + return 1; +} + +//=20 +// We use this to reverse a reverse-sorted partition. +//=20 + +template < class e_type > +void rev_array(e_type * array, size_t nmemb) +{ + e_type temp, + *end; + for (end =3D array + nmemb - 1; end > array; ++array) { + ((void) ((temp) =3D *(array), *(array) =3D *(end), *(end) =3D +(temp))); + --end; + } +} + +//=20 +// Introspective quick sort algorithm user entry point. +// You do not need to directly call any other sorting template. +// This sort will perform very well under all circumstances. +//=20 + +template < class e_type > +void iqsort(e_type * array, size_t nmemb) +{ + size_t d, + n; + if (nmemb > 1 && !sorted(array, nmemb)) { + if (!rev_sorted(array, nmemb)) { + n =3D nmemb / 4; + d =3D 2; + while (n) { + ++d; + n /=3D 2; + } + qloop(array, nmemb, 2 * d); + } else { + rev_array(array, nmemb); + } + } +} + +> -----Original Message----- +> From: pgsql-hackers-owner@postgresql.org [mailto:pgsql-hackers- +> owner@postgresql.org] On Behalf Of Jignesh K. Shah +> Sent: Friday, September 30, 2005 1:38 PM +> To: Ron Peacetree +> Cc: Josh Berkus; pgsql-hackers@postgresql.org; pgsql- +> performance@postgresql.org +> Subject: Re: [HACKERS] [PERFORM] A Better External Sort? +>=20 +> I have seen similar performance as Josh and my reasoning is as +follows: +>=20 +> * WAL is the biggest bottleneck with its default size of 16MB. Many +> people hate to recompile the code to change its default, and +> increasing checkpoint segments help but still there is lot of overhead +> in the rotation of WAL files (Even putting WAL on tmpfs shows that it +is +> still slow). Having an option for bigger size is helpful to a small +> extent percentagewise (and frees up CPU a bit in doing file rotation) +>=20 +> * Growing files: Even though this is OS dependent but it does spend +lot +> of time doing small 8K block increases to grow files. If we can signal +> bigger chunks to grow or "pre-grow" to expected size of data files +> that will help a lot in such cases. +>=20 +> * COPY command had restriction but that has been fixed to a large +> extent.(Great job) +>=20 +> But ofcourse I have lost touch with programming and can't begin to +> understand PostgreSQL code to change it myself. +>=20 +> Regards, +> Jignesh +>=20 +>=20 +>=20 +>=20 +> Ron Peacetree wrote: +>=20 +> >That 11MBps was your =3Dbulk load=3D speed. If just loading a table +> >is this slow, then there are issues with basic physical IO, not just +> >IO during sort operations. +> > +> >As I said, the obvious candidates are inefficient physical layout +> >and/or flawed IO code. +> > +> >Until the basic IO issues are addressed, we could replace the +> >present sorting code with infinitely fast sorting code and we'd +> >still be scrod performance wise. +> > +> >So why does basic IO suck so badly? +> > +> >Ron +> > +> > +> >-----Original Message----- +> >From: Josh Berkus +> >Sent: Sep 30, 2005 1:23 PM +> >To: Ron Peacetree +> >Cc: pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org +> >Subject: Re: [HACKERS] [PERFORM] A Better External Sort? +> > +> >Ron, +> > +> > +> > +> >>Hmmm. +> >>60GB/5400secs=3D 11MBps. That's ssllooww. So the first +> >>problem is evidently our physical layout and/or HD IO layer +> >>sucks. +> >> +> >> +> > +> >Actually, it's much worse than that, because the sort is only dealing +> >with one column. As I said, monitoring the iostat our top speed was +> >2.2mb/s. +> > +> >--Josh +> > +> > +> >---------------------------(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 +> > +> > +>=20 +> ---------------------------(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 +