diff --git "a/pgsql-performance.200602" "b/pgsql-performance.200602" new file mode 100644--- /dev/null +++ "b/pgsql-performance.200602" @@ -0,0 +1,51434 @@ +From pgsql-performance-owner@postgresql.org Tue Jan 31 20:32:56 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 9E1B09DC827 + for ; + Tue, 31 Jan 2006 20:32:55 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 98017-08 + for ; + Tue, 31 Jan 2006 20:32:58 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.195]) + by postgresql.org (Postfix) with ESMTP id 771879DCB1A + for ; + Tue, 31 Jan 2006 20:32:53 -0400 (AST) +Received: by wproxy.gmail.com with SMTP id 37so244707wra + for ; + Tue, 31 Jan 2006 16:32:57 -0800 (PST) +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=VZCbyEWSVgTwnxDFKNk95GTNmx3gRd6aBFK2+FibPBvAaxPpakVKbEsQ1g/68Z0kRrH5DPCUX8BHC8DemlShBCAGD+T13F735QUGBbtB4pO4JMhtDdTmQA6emrvqM9uHYpmGWLFESLmsoQqBAoI3/3QtbO6v2HgLvIzkHVzA6uY= +Received: by 10.65.203.2 with SMTP id f2mr517914qbq; + Tue, 31 Jan 2006 16:32:56 -0800 (PST) +Received: by 10.65.203.17 with HTTP; Tue, 31 Jan 2006 16:32:56 -0800 (PST) +Message-ID: <3cf983d0601311632t4a2f068au1f958746c2b092a7@mail.gmail.com> +Date: Tue, 31 Jan 2006 16:32:56 -0800 +From: Rodrigo Madera +To: pgsql-performance@postgresql.org +Subject: Storing Digital Video +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, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200601/501 +X-Sequence-Number: 16979 + +I am concerned with performance issues involving the storage of DV on +a database. + +I though of some options, which would be the most advised for speed? + +1) Pack N frames inside a "container" and store the container to the db. +2) Store each frame in a separate record in the table "frames". +3) (type something here) + +Thanks for the help, + +Rodrigo + +From pgsql-performance-owner@postgresql.org Sat Feb 4 16:48:45 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 1ABA69DC861 + for ; + Tue, 31 Jan 2006 20:37:54 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 01352-03 + for ; + Tue, 31 Jan 2006 20:37:56 -0400 (AST) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id C3BFE9DC827 + for ; + Tue, 31 Jan 2006 20:37:51 -0400 (AST) +Received: from gghcwest.com (adsl-71-128-90-172.dsl.pltn13.pacbell.net + [71.128.90.172]) + by svr4.postgresql.org (Postfix) with ESMTP id A75105AF091 + for ; + Wed, 1 Feb 2006 00:37:55 +0000 (GMT) +Received: from toonses.gghcwest.com (toonses.gghcwest.com [192.168.168.115]) + by gghcwest.com (8.12.10/8.12.9) with ESMTP id k110bomd022127 + for ; Tue, 31 Jan 2006 16:37:50 -0800 +Received: from jwb by toonses.gghcwest.com with local (Exim 4.52) + id 1F460O-0001gm-A2 + for pgsql-performance@postgresql.org; Tue, 31 Jan 2006 16:37:52 -0800 +Subject: Re: Storing Digital Video +From: "Jeffrey W. Baker" +To: pgsql-performance@postgresql.org +In-Reply-To: <3cf983d0601311632t4a2f068au1f958746c2b092a7@mail.gmail.com> +References: <3cf983d0601311632t4a2f068au1f958746c2b092a7@mail.gmail.com> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Date: Tue, 31 Jan 2006 16:37:51 -0800 +Message-Id: <1138754271.6296.4.camel@toonses.gghcwest.com> +Mime-Version: 1.0 +X-Mailer: Evolution 2.4.1 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200602/43 +X-Sequence-Number: 17029 + +On Tue, 2006-01-31 at 16:32 -0800, Rodrigo Madera wrote: +> I am concerned with performance issues involving the storage of DV on +> a database. +> +> I though of some options, which would be the most advised for speed? +> +> 1) Pack N frames inside a "container" and store the container to the db. +> 2) Store each frame in a separate record in the table "frames". +> 3) (type something here) + +How about some more color? _Why_, for example, would you store video in +a relational database? + +-jwb + +From pgsql-performance-owner@postgresql.org Tue Jan 31 20:57:58 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 385F19DC861 + for ; + Tue, 31 Jan 2006 20:57:58 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 02400-08 + for ; + Tue, 31 Jan 2006 20:58:01 -0400 (AST) +X-Greylist: delayed 00:06:40.117134 by SQLgrey- +Received: from mx1.bastionits.com (65.105.157.222.ptr.us.xo.net + [65.105.157.222]) + by postgresql.org (Postfix) with SMTP id E7C6E9DC827 + for ; + Tue, 31 Jan 2006 20:57:55 -0400 (AST) +Received: (qmail 61225 invoked from network); 1 Feb 2006 00:46:10 -0000 +Received: from unknown (HELO ?10.0.0.110?) (10.0.0.110) + by mx1.bastionits.com with SMTP; 1 Feb 2006 00:46:10 -0000 +Message-ID: <43E00606.6030406@mattdavies.net> +Date: Tue, 31 Jan 2006 17:51:18 -0700 +From: Matt Davies | Postgresql List +User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +CC: pgsql-performance@postgresql.org +Subject: Re: Storing Digital Video +References: <3cf983d0601311632t4a2f068au1f958746c2b092a7@mail.gmail.com> +In-Reply-To: <3cf983d0601311632t4a2f068au1f958746c2b092a7@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, score=0.189 required=5 tests=[MISSING_HEADERS=0.189] +X-Spam-Score: 0.189 +X-Spam-Level: +X-Archive-Number: 200601/502 +X-Sequence-Number: 16980 + +Rodrigo Madera wrote: + +>I am concerned with performance issues involving the storage of DV on +>a database. +> +>I though of some options, which would be the most advised for speed? +> +>1) Pack N frames inside a "container" and store the container to the db. +>2) Store each frame in a separate record in the table "frames". +>3) (type something here) +> +>Thanks for the help, +> +> +> + +My experience has been that this is a very bad idea. Many people want to +store all sorts of data in a database such as email messages, pictures, +etc... The idea of a relational database is to perform queries against +data. If you are needing to just store data then store it on a disk and +use the database as the indexer of the data. + +Keep in mind the larger the database the slower some operations become. + +Unless you are operating on the frame data (which you either store as +blobs or hex-encoded data) I'd recommend you store the data on a hard +drive and let the database store meta data about the video such as path +information, run time, author, etc... + +We do this on an application storing close to a million images and the +performance is impressive. + 1. we don't have to do any sort of data manipulation storing the +data in or retrieving the data out of the database. + 2. our database is compact and extremely fast - it is using the +database for what it was designed for - relational queries. + +My $0.02 + +>Rodrigo +> +>---------------------------(end of broadcast)--------------------------- +>TIP 9: In versions below 8.0, the planner will ignore your desire to +> choose an index scan if your joining column's datatypes do not +> match +> +> +> +> + + +From pgsql-performance-owner@postgresql.org Tue Jan 31 21:26:18 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 3941A9DC861 + for ; + Tue, 31 Jan 2006 21:26:18 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 10287-03 + for ; + Tue, 31 Jan 2006 21:26:21 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from cassarossa.samfundet.no (cassarossa.samfundet.no + [129.241.93.19]) + by postgresql.org (Postfix) with ESMTP id 830F19DC827 + for ; + Tue, 31 Jan 2006 21:26:15 -0400 (AST) +Received: from trofast.sesse.net ([129.241.93.32]) + by cassarossa.samfundet.no with esmtp (Exim 4.50) + id 1F46lA-0000KW-51; Wed, 01 Feb 2006 02:26:12 +0100 +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1F46lD-0008R0-00; Wed, 01 Feb 2006 02:26:15 +0100 +Date: Wed, 1 Feb 2006 02:26:15 +0100 +From: "Steinar H. Gunderson" +To: Luke Lonergan +Cc: "Jeffrey W. Baker" , pgsql-performance@postgresql.org +Subject: Re: Huge Data sets, simple queries +Message-ID: <20060201012615.GA31927@uio.no> +Mail-Followup-To: Luke Lonergan , + "Jeffrey W. Baker" , + pgsql-performance@postgresql.org +References: <1138737838.5648.4.camel@toonses.gghcwest.com> + +MIME-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Disposition: inline +In-Reply-To: +X-Operating-System: Linux 2.6.14.3 on a x86_64 +X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ +User-Agent: Mutt/1.5.11 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.071 required=5 tests=[AWL=0.071] +X-Spam-Score: 0.071 +X-Spam-Level: +X-Archive-Number: 200601/503 +X-Sequence-Number: 16981 + +On Tue, Jan 31, 2006 at 12:47:10PM -0800, Luke Lonergan wrote: +>> Linux does balanced reads on software +>> mirrors. I'm not sure why you think this can't improve bandwidth. It +>> does improve streaming bandwidth as long as the platter STR is more than +>> the bus STR. +> ... Prove it. + +FWIW, this is on Ultra160 disks (Seagate 10000rpm) on a dual Opteron running +Linux 2.6.14.3: + +cassarossa:~# grep md1 /proc/mdstat +md1 : active raid1 sdf6[1] sda6[0] +cassarossa:~# dd if=/dev/sda6 of=/dev/null bs=8k count=400000 +[system at about 35% wait for I/O and 15% system, according to top] +400000+0 records in +400000+0 records out +3276800000 bytes transferred in 54,488154 seconds (60137842 bytes/sec) +[system at about 45% wait for I/O and 7% system -- whoa?] +400000+0 records in +400000+0 records out +3276800000 bytes transferred in 52,523771 seconds (62386990 bytes/sec) + +I'm not sure if it _refutes_ the assertion that the Linux RAID-1 driver can +do balancing of sequential reads, but it certainly doesn't present very much +evidence in that direction. BTW, sda and sdf are on different channels of a +dual-channel (onboard, connected via PCI-X) Adaptec board, so I doubt the bus +is the limiting factor. + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-performance-owner@postgresql.org Tue Jan 31 21:35:40 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 4BBB69DCC46 + for ; + Tue, 31 Jan 2006 21:35:40 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 12465-05 + for ; + Tue, 31 Jan 2006 21:35:43 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.mi8.com (d01gw04.mi8.com [63.240.6.44]) + by postgresql.org (Postfix) with ESMTP id 07AD29DCC3C + for ; + Tue, 31 Jan 2006 21:35:37 -0400 (AST) +Received: from 172.16.1.110 by mail.mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D4)); Tue, 31 Jan 2006 20:35:34 -0500 +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.1830); Tue, 31 Jan + 2006 20:35:34 -0500 +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.106]) with Microsoft Exchange Server HTTP-DAV ; Wed, 1 Feb + 2006 01:35:33 +0000 +User-Agent: Microsoft-Entourage/11.2.1.051004 +Date: Tue, 31 Jan 2006 17:35:32 -0800 +Subject: Re: Huge Data sets, simple queries +From: "Luke Lonergan" +To: "Steinar H. Gunderson" +cc: "Jeffrey W. Baker" , + pgsql-performance@postgresql.org +Message-ID: +Thread-Topic: [PERFORM] Huge Data sets, simple queries +Thread-Index: AcYmz8pBCOnQdpLDEdqBvAANk63kWA== +In-Reply-To: <20060201012615.GA31927@uio.no> +MIME-Version: 1.0 +X-OriginalArrivalTime: 01 Feb 2006 01:35:34.0352 (UTC) + FILETIME=[CBA82D00:01C626CF] +X-WSS-ID: 6FFECFEC20C1956816-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, score=1.316 required=5 tests=[AWL=0.063, + RCVD_NUMERIC_HELO=1.253] +X-Spam-Score: 1.316 +X-Spam-Level: * +X-Archive-Number: 200601/504 +X-Sequence-Number: 16982 + +Steinar, + +On 1/31/06 5:26 PM, "Steinar H. Gunderson" wrote: + +> cassarossa:~# grep md1 /proc/mdstat +> md1 : active raid1 sdf6[1] sda6[0] +> cassarossa:~# dd if=/dev/sda6 of=/dev/null bs=8k count=400000 +> [system at about 35% wait for I/O and 15% system, according to top] +> 400000+0 records in +> 400000+0 records out +> 3276800000 bytes transferred in 54,488154 seconds (60137842 bytes/sec) +> [system at about 45% wait for I/O and 7% system -- whoa?] +> 400000+0 records in +> 400000+0 records out +> 3276800000 bytes transferred in 52,523771 seconds (62386990 bytes/sec) +> +> I'm not sure if it _refutes_ the assertion that the Linux RAID-1 driver can +> do balancing of sequential reads, but it certainly doesn't present very much +> evidence in that direction. BTW, sda and sdf are on different channels of a +> dual-channel (onboard, connected via PCI-X) Adaptec board, so I doubt the bus +> is the limiting factor. + +Yep - 2MB/s is noise. Run a RAID0, you should get 120MB/s. + +Incidentally, before this thread took a turn to RAID10 vs. RAID5, the +question of HW RAID adapter versus SW RAID was the focus. I routinely see +numbers like 20MB/s coming from HW RAID adapters on Linux, so it's nice to +see someone post a decent number using SW RAID. + +We're very happy with the 3Ware HW RAID adapters, but so far they're the +only ones (I have two Arecas but I mistakenly ordered PCI-E so I can't test +them :-( + +- Luke + + + +From pgsql-performance-owner@postgresql.org Tue Jan 31 22:47:17 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 79EF69DC821 + for ; + Tue, 31 Jan 2006 22:47:16 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 19769-09 + for ; + Tue, 31 Jan 2006 22:47:20 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id D878D9DC817 + for ; + Tue, 31 Jan 2006 22:47:13 -0400 (AST) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 22F7F3983F; Tue, 31 Jan 2006 20:47:03 -0600 (CST) +Date: Tue, 31 Jan 2006 20:47:03 -0600 +From: "Jim C. Nasby" +To: Luke Lonergan +Cc: Mike Biamonte , pgsql-performance@postgresql.org +Subject: Re: Huge Data sets, simple queries +Message-ID: <20060201024703.GT95850@pervasive.com> +References: <20060131231227.GP95850@pervasive.com> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +X-Operating-System: FreeBSD 6.0-RELEASE amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.104 required=5 tests=[AWL=0.104] +X-Spam-Score: 0.104 +X-Spam-Level: +X-Archive-Number: 200601/505 +X-Sequence-Number: 16983 + +On Tue, Jan 31, 2006 at 03:19:38PM -0800, Luke Lonergan wrote: +> > Well, the only problem with that is if the machine crashes for any +> > reason you risk having the database corrupted (or at best losing some +> > committed transactions). +> +> So, do you routinely turn off Linux write caching? If not, then there's no +> difference. + +My thought was about fsync on WAL; if you're doing much writing then +a good raid write cache with BBU will improve performance. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue Jan 31 23:14:47 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 55A089DC85C + for ; + Tue, 31 Jan 2006 23:14:46 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 32117-01 + for ; + Tue, 31 Jan 2006 23:14:50 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from uproxy.gmail.com (uproxy.gmail.com [66.249.92.196]) + by postgresql.org (Postfix) with ESMTP id 938759DC827 + for ; + Tue, 31 Jan 2006 23:14:43 -0400 (AST) +Received: by uproxy.gmail.com with SMTP id s2so25325uge + for ; + Tue, 31 Jan 2006 19:14:47 -0800 (PST) +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=l5bmq9Vly9sk2g1StkNndxE0/AnZi8A7WgRA5E+na1e1wwsboitCA+udYXQwN7g5lJMJKCnZAeI7rNcX7EZ8PlkoBcQi74vcJ9hjOJb0BvFC79oCl02DkJXVIYN0yOktoW54brdkMUhIdWdUqvnJjTmu+OxI//zEpI8nu9cdbE8= +Received: by 10.48.143.5 with SMTP id q5mr1530413nfd; + Tue, 31 Jan 2006 19:14:47 -0800 (PST) +Received: by 10.49.59.5 with HTTP; Tue, 31 Jan 2006 19:14:47 -0800 (PST) +Message-ID: <3a3a16930601311914w5bd7d1d0hde7b4e495e0deb27@mail.gmail.com> +Date: Wed, 1 Feb 2006 12:14:47 +0900 +From: James Russell +To: pgsql-performance@postgresql.org +Subject: Sequential scan being used despite indexes +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_301_27951016.1138763687607" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=1.333 required=5 tests=[HTML_MESSAGE=0.001, + RCVD_IN_BL_SPAMCOP_NET=1.332] +X-Spam-Score: 1.333 +X-Spam-Level: * +X-Archive-Number: 200601/506 +X-Sequence-Number: 16984 + +------=_Part_301_27951016.1138763687607 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Hi there, + +I'm running a simple query with 2 inner joins (say A, B and C). Each of the +join columns has indexes. If I run queries that join just A and B, or just = +B +and C, postgres uses indexes. But if I run "A join B join C" then the "B +join C" part starts using a sequential scan and I can't figure out why. + +Here's the query, which basically retrieves all meta-data for all messages +in a given forum. The relationship is pretty simple. Forums contain threads= +, +which contain messages, which each have associated meta-data: + +SELECT message.message_id, message_meta_data.value +FROM thread + JOIN message USING (thread_id) + JOIN message_meta_data ON ( +message.message_id=3Dmessage_meta_data.message_id) +WHERE thread.forum_id=3D123; + +Explaining: +Hash Join (cost=3D337.93..1267.54 rows=3D180 width=3D35) +Hash Cond: ("outer".message_id =3D "inner".message_id) +-> Seq Scan on message_meta_data (cost=3D0.00..739.19 rows=3D37719 width= +=3D30) +-> Hash (cost=3D337.79..337.79 rows=3D57 width=3D13) + -> Nested Loop (cost=3D0.00..337.79 rows=3D57 width=3D13) + -> Index Scan using thread_forum_id_idx on thread (cost=3D +0.00..41.61 rows=3D13 width=3D4) + Index Cond: (forum_id =3D 6) + -> Index Scan using message_thread_id_idx on message (cost=3D +0.00..22.72 rows=3D5 width=3D17) + Index Cond: ("outer".thread_id =3D message.thread_id) + +As you can see, the message and message_meta_data tables use a Seq Scan. Th= +e +only way I can think of forcing it to use the Index Scan in all cases would +be to use two separate nested queries: The outer query would retrieve the +list of messages in the forum, and the inner query would retrieve the list +of metadata for an individual message. Obviously I want to avoid having to +do that if possible. + +Any ideas? + +Many thanks if you can help. + +James + +------=_Part_301_27951016.1138763687607 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Hi there,
+
+I'm running a simple query with 2 inner joins (say A, B and C). Each of +the join columns has indexes. If I run queries that join just A and B, +or just B and C, postgres uses indexes. But if I run "A join B join C&= +quot; +then the "B join C" part starts using a sequential scan and I can= +'t +figure out why.
+
+Here's the query, which basically retrieves all meta-data for all +messages in a given forum. The relationship is pretty simple. Forums +contain threads, which contain messages, which each have associated +meta-data:
+
+SELECT message.message_id, message_meta_data.value
+FROM thread
+    JOIN message USING (thread_id)
+    JOIN message_meta_data ON (message.message_id=3Dmessage_= +meta_data.message_id)
+WHERE thread.forum_id=3D123;
+
+Explaining:
+Hash Join  (cost=3D337.93..1267.54 rows=3D180 width=3D35)
+Hash Cond: ("outer".message_id =3D "inner".message_id)<= +br> +->  Seq Scan on message_meta_data  (cost=3D0.00..739.19 rows= +=3D37719 width=3D30)
+->  Hash  (cost=3D337.79..337.79 rows=3D57 width=3D13)
+    ->  Nested Loop  (cost=3D0.00..337.79 rows= +=3D57 width=3D13)
+          ->  +Index Scan using thread_forum_id_idx on thread (cost=3D0.00..41.61 +rows=3D13 width=3D4)
+            &nb= +sp;    Index Cond: (forum_id =3D 6)
+          ->  +Index Scan using message_thread_id_idx on message (cost=3D0.00..22.72 +rows=3D5 width=3D17)
+            &nb= +sp;    +Index Cond: ("outer".thread_id =3D message.thread_id)
+
+As you can see, the message and message_meta_data tables use a Seq +Scan. The only way I can think of forcing it to use the Index Scan in +all cases would be to use two separate nested queries: The outer query +would retrieve the list of messages in the forum, and the inner query +would retrieve the list of metadata for an individual message. +Obviously I want to avoid having to do that if possible.
+
+Any ideas?
+
+Many thanks if you can help.
+
+James
+ +------=_Part_301_27951016.1138763687607-- + +From pgsql-performance-owner@postgresql.org Tue Jan 31 23:29:44 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id CB1B09DCA58 + for ; + Tue, 31 Jan 2006 23:29:43 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34097-02 + for ; + Tue, 31 Jan 2006 23:29:48 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from hosting.commandprompt.com (128.commandprompt.com + [207.173.200.128]) + by postgresql.org (Postfix) with ESMTP id 4C49D9DC821 + for ; + Tue, 31 Jan 2006 23:29:41 -0400 (AST) +Received: from [192.168.1.100] (or-67-76-146-141.sta.sprint-hsd.net + [67.76.146.141]) (authenticated bits=0) + by hosting.commandprompt.com (8.13.4/8.13.4) with ESMTP id + k113JN1v020075; Tue, 31 Jan 2006 19:19:27 -0800 +Message-ID: <43E02B2F.9070202@commandprompt.com> +Date: Tue, 31 Jan 2006 19:29:51 -0800 +From: "Joshua D. Drake" +User-Agent: Thunderbird 1.5 (X11/20051201) +MIME-Version: 1.0 +To: James Russell +CC: pgsql-performance@postgresql.org +Subject: Re: Sequential scan being used despite indexes +References: <3a3a16930601311914w5bd7d1d0hde7b4e495e0deb27@mail.gmail.com> +In-Reply-To: <3a3a16930601311914w5bd7d1d0hde7b4e495e0deb27@mail.gmail.com> +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, 31 Jan 2006 19:19:27 -0800 (PST) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.085 required=5 tests=[AWL=0.085] +X-Spam-Score: 0.085 +X-Spam-Level: +X-Archive-Number: 200601/507 +X-Sequence-Number: 16985 + + +> +> Explaining: +> Hash Join (cost=337.93..1267.54 rows=180 width=35) +> Hash Cond: ("outer".message_id = "inner".message_id) +> -> Seq Scan on message_meta_data (cost=0.00..739.19 rows=37719 width=30) +> -> Hash (cost=337.79..337.79 rows=57 width=13) +> -> Nested Loop (cost=0.00..337.79 rows=57 width=13) +> -> Index Scan using thread_forum_id_idx on thread +> (cost=0.00..41.61 rows=13 width=4) +> Index Cond: (forum_id = 6) +> -> Index Scan using message_thread_id_idx on message +> (cost=0.00..22.72 rows=5 width=17) +> Index Cond: ("outer".thread_id = message.thread_id) +> +> As you can see, the message and message_meta_data tables use a Seq +> Scan. The only way I can think of forcing it to use the Index Scan in +> all cases would be to use two separate nested queries: The outer query +> would retrieve the list of messages in the forum, and the inner query +> would retrieve the list of metadata for an individual message. +> Obviously I want to avoid having to do that if possible. +> +> Any ideas? +What does explain analyze say? + +Joshua D. Drake + + +> +> Many thanks if you can help. +> +> James + + +-- +The PostgreSQL Company - Command Prompt, Inc. 1.503.667.4564 +PostgreSQL Replication, Consulting, Custom Development, 24x7 support +Managed Services, Shared and Dedicated Hosting +Co-Authors: PLphp, PLperl - http://www.commandprompt.com/ + + +From pgsql-performance-owner@postgresql.org Tue Jan 31 23:58:08 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 55CC39DC821 + for ; + Tue, 31 Jan 2006 23:58:08 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37943-03 + for ; + Tue, 31 Jan 2006 23:58:13 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) + by postgresql.org (Postfix) with ESMTP id EBD5A9DC817 + for ; + Tue, 31 Jan 2006 23:58:05 -0400 (AST) +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 k113w4Zx037793 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); + Tue, 31 Jan 2006 20:58:07 -0700 (MST) + (envelope-from mfuhr@winnie.fuhr.org) +Received: from winnie.fuhr.org (localhost [127.0.0.1]) + by winnie.fuhr.org (8.13.4/8.13.4) with ESMTP id k113w4Mw006361; + Tue, 31 Jan 2006 20:58:04 -0700 (MST) + (envelope-from mfuhr@winnie.fuhr.org) +Received: (from mfuhr@localhost) + by winnie.fuhr.org (8.13.4/8.13.4/Submit) id k113w4Yw006360; + Tue, 31 Jan 2006 20:58:04 -0700 (MST) (envelope-from mfuhr) +Date: Tue, 31 Jan 2006 20:58:04 -0700 +From: Michael Fuhr +To: "Joshua D. Drake" +Cc: James Russell , + pgsql-performance@postgresql.org +Subject: Re: Sequential scan being used despite indexes +Message-ID: <20060201035803.GA6324@winnie.fuhr.org> +References: <3a3a16930601311914w5bd7d1d0hde7b4e495e0deb27@mail.gmail.com> + <43E02B2F.9070202@commandprompt.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <43E02B2F.9070202@commandprompt.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.114 required=5 tests=[AWL=0.114] +X-Spam-Score: 0.114 +X-Spam-Level: +X-Archive-Number: 200601/508 +X-Sequence-Number: 16986 + +On Tue, Jan 31, 2006 at 07:29:51PM -0800, Joshua D. Drake wrote: +> > Any ideas? +> +> What does explain analyze say? + +Also, have the tables been vacuumed and analyzed? + +-- +Michael Fuhr + +From pgsql-performance-owner@postgresql.org Wed Feb 1 00:09:45 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 63F999DCBC5 + for ; + Wed, 1 Feb 2006 00:09:44 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 38833-06 + for ; + Wed, 1 Feb 2006 00:09:42 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail6.sea5.speakeasy.net (mail6.sea5.speakeasy.net + [69.17.117.8]) by postgresql.org (Postfix) with ESMTP id ED5769DCB70 + for ; + Wed, 1 Feb 2006 00:09:41 -0400 (AST) +Received: (qmail 22257 invoked from network); 1 Feb 2006 04:09:40 -0000 +Received: from dsl081-060-184.sfo1.dsl.speakeasy.net (HELO noodles) + (jwbaker@[64.81.60.184]) (envelope-sender ) + by mail6.sea5.speakeasy.net (qmail-ldap-1.03) with RC4-MD5 encrypted + SMTP for ; 1 Feb 2006 04:09:40 -0000 +Subject: Re: Huge Data sets, simple queries +From: "Jeffrey W. Baker" +To: Luke Lonergan +Cc: pgsql-performance@postgresql.org +In-Reply-To: +References: +Content-Type: text/plain +Date: Tue, 31 Jan 2006 20:09:40 -0800 +Message-Id: <1138766980.14051.24.camel@noodles> +Mime-Version: 1.0 +X-Mailer: Evolution 2.5.4 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200602/1 +X-Sequence-Number: 16987 + +On Tue, 2006-01-31 at 12:47 -0800, Luke Lonergan wrote: +> Jeffrey, +> +> On 1/31/06 12:03 PM, "Jeffrey W. Baker" wrote: +> > Linux does balanced reads on software +> > mirrors. I'm not sure why you think this can't improve bandwidth. It +> > does improve streaming bandwidth as long as the platter STR is more than +> > the bus STR. +> +> ... Prove it. + +It's clear that Linux software RAID1, and by extension RAID10, does +balanced reads, and that these balanced reads double the bandwidth. A +quick glance at the kernel source code, and a trivial test, proves the +point. + +In this test, sdf and sdg are Seagate 15k.3 disks on a single channel of +an Adaptec 39320, but the enclosure, and therefore the bus, is capable +of only Ultra160 operation. + +# grep md0 /proc/mdstat +md0 : active raid1 sdf1[0] sdg1[1] + +# dd if=/dev/md0 of=/dev/null bs=8k count=400000 skip=0 & + dd if=/dev/md0 of=/dev/null bs=8k count=400000 skip=400000 +400000+0 records in +400000+0 records out +3276800000 bytes transferred in 48.243362 seconds (67922298 bytes/sec) +400000+0 records in +400000+0 records out +3276800000 bytes transferred in 48.375897 seconds (67736211 bytes/sec) + +That's 136MB/sec, for those following along at home. With only two +disks in a RAID1, you can nearly max out the SCSI bus. + +# dd if=/dev/sdf1 of=/dev/null bs=8k count=400000 skip=0 & + dd if=/dev/sdf1 of=/dev/null bs=8k count=400000 skip=400000 +400000+0 records in +400000+0 records out +3276800000 bytes transferred in 190.413286 seconds (17208883 bytes/sec) +400000+0 records in +400000+0 records out +3276800000 bytes transferred in 192.096232 seconds (17058117 bytes/sec) + +That, on the other hand, is only 34MB/sec. With two threads, the RAID1 +is 296% faster. + +# dd if=/dev/md0 of=/dev/null bs=8k count=400000 skip=0 & + dd if=/dev/md0 of=/dev/null bs=8k count=400000 skip=400000 & + dd if=/dev/md0 of=/dev/null bs=8k count=400000 skip=800000 & + dd if=/dev/md0 of=/dev/null bs=8k count=400000 skip=1200000 & +400000+0 records in +400000+0 records out +3276800000 bytes transferred in 174.276585 seconds (18802296 bytes/sec) +400000+0 records in +400000+0 records out +3276800000 bytes transferred in 181.581893 seconds (18045852 bytes/sec) +400000+0 records in +400000+0 records out +3276800000 bytes transferred in 183.724243 seconds (17835425 bytes/sec) +400000+0 records in +400000+0 records out +3276800000 bytes transferred in 184.209018 seconds (17788489 bytes/sec) + +That's 71MB/sec with 4 threads... + +# dd if=/dev/sdf1 of=/dev/null bs=8k count=100000 skip=0 & + dd if=/dev/sdf1 of=/dev/null bs=8k count=100000 skip=400000 & + dd if=/dev/sdf1 of=/dev/null bs=8k count=100000 skip=800000 & + dd if=/dev/sdf1 of=/dev/null bs=8k count=100000 skip=1200000 & +100000+0 records in +100000+0 records out +819200000 bytes transferred in 77.489210 seconds (10571794 bytes/sec) +100000+0 records in +100000+0 records out +819200000 bytes transferred in 87.628000 seconds (9348610 bytes/sec) +100000+0 records in +100000+0 records out +819200000 bytes transferred in 88.912989 seconds (9213502 bytes/sec) +100000+0 records in +100000+0 records out +819200000 bytes transferred in 90.238705 seconds (9078144 bytes/sec) + +Only 36MB/sec for the single disk. 96% advantage for the RAID1. + +# dd if=/dev/md0 of=/dev/null bs=8k count=50000 skip=0 & + dd if=/dev/md0 of=/dev/null bs=8k count=50000 skip=400000 & + dd if=/dev/md0 of=/dev/null bs=8k count=50000 skip=800000 & + dd if=/dev/md0 of=/dev/null bs=8k count=50000 skip=1200000 & + dd if=/dev/md0 of=/dev/null bs=8k count=50000 skip=1600000 & + dd if=/dev/md0 of=/dev/null bs=8k count=50000 skip=2000000 & + dd if=/dev/md0 of=/dev/null bs=8k count=50000 skip=2400000 & + dd if=/dev/md0 of=/dev/null bs=8k count=50000 skip=2800000 & +50000+0 records in +50000+0 records out +409600000 bytes transferred in 35.289648 seconds (11606803 bytes/sec) +50000+0 records in +50000+0 records out +409600000 bytes transferred in 42.653475 seconds (9602969 bytes/sec) +50000+0 records in +50000+0 records out +409600000 bytes transferred in 43.524714 seconds (9410745 bytes/sec) +50000+0 records in +50000+0 records out +409600000 bytes transferred in 45.151705 seconds (9071640 bytes/sec) +50000+0 records in +50000+0 records out +409600000 bytes transferred in 47.741845 seconds (8579476 bytes/sec) +50000+0 records in +50000+0 records out +409600000 bytes transferred in 48.600533 seconds (8427891 bytes/sec) +50000+0 records in +50000+0 records out +409600000 bytes transferred in 48.758726 seconds (8400548 bytes/sec) +50000+0 records in +50000+0 records out +409600000 bytes transferred in 49.679275 seconds (8244887 bytes/sec) + +66MB/s with 8 threads. + +# dd if=/dev/sdf1 of=/dev/null bs=8k count=50000 skip=0 & + dd if=/dev/sdf1 of=/dev/null bs=8k count=50000 skip=400000 & + dd if=/dev/sdf1 of=/dev/null bs=8k count=50000 skip=800000 & + dd if=/dev/sdf1 of=/dev/null bs=8k count=50000 skip=1200000 & + dd if=/dev/sdf1 of=/dev/null bs=8k count=50000 skip=1600000 & + dd if=/dev/sdf1 of=/dev/null bs=8k count=50000 skip=2000000 & + dd if=/dev/sdf1 of=/dev/null bs=8k count=50000 skip=2400000 & + dd if=/dev/sdf1 of=/dev/null bs=8k count=50000 skip=2800000 & +50000+0 records in +50000+0 records out +409600000 bytes transferred in 73.873911 seconds (5544583 bytes/sec) +50000+0 records in +50000+0 records out +409600000 bytes transferred in 75.613093 seconds (5417051 bytes/sec) +50000+0 records in +50000+0 records out +409600000 bytes transferred in 79.988303 seconds (5120749 bytes/sec) +50000+0 records in +50000+0 records out +409600000 bytes transferred in 79.996440 seconds (5120228 bytes/sec) +50000+0 records in +50000+0 records out +409600000 bytes transferred in 84.885172 seconds (4825342 bytes/sec) +50000+0 records in +50000+0 records out +409600000 bytes transferred in 92.995892 seconds (4404496 bytes/sec) +50000+0 records in +50000+0 records out +409600000 bytes transferred in 99.180337 seconds (4129851 bytes/sec) +50000+0 records in +50000+0 records out +409600000 bytes transferred in 100.144752 seconds (4090080 bytes/sec) + +33MB/s. RAID1 gives a 100% advantage at 8 threads. + +I think I've proved my point. Software RAID1 read balancing provides +0%, 300%, 100%, and 100% speedup on 1, 2, 4, and 8 threads, +respectively. In the presence of random I/O, the results are even +better. + +Anyone who thinks they have a single-threaded workload has not yet +encountered the autovacuum daemon. + +-Jeff + + +From pgsql-performance-owner@postgresql.org Wed Feb 1 00:33:13 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id A634C9DCBFE + for ; + Wed, 1 Feb 2006 00:33:12 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 41079-09 + for ; + Wed, 1 Feb 2006 00:33:11 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from uproxy.gmail.com (uproxy.gmail.com [66.249.92.206]) + by postgresql.org (Postfix) with ESMTP id 642239DCBFF + for ; + Wed, 1 Feb 2006 00:33:09 -0400 (AST) +Received: by uproxy.gmail.com with SMTP id h2so138260ugf + for ; + Tue, 31 Jan 2006 20:33:09 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; + b=FcCi4c1RUxyVmaSBruxgElDlnmD25ecA4kdk91zBBkVaay/ixebOTwKJchdIflzZUMs5IEfmGTZjrUQjWlEjRKhejnT4aZ7GUqWpgR5YBdNhnEP/ZE4egNpgXsGb7hwWhtA40BomCSQq/yFql2Jp9wq4PqtsBexZfvUM7vACHDg= +Received: by 10.49.85.9 with SMTP id n9mr1547810nfl; + Tue, 31 Jan 2006 20:33:08 -0800 (PST) +Received: by 10.49.59.5 with HTTP; Tue, 31 Jan 2006 20:33:08 -0800 (PST) +Message-ID: <3a3a16930601312033w2e4e3186k8f502e5b8c2cc6f2@mail.gmail.com> +Date: Wed, 1 Feb 2006 13:33:08 +0900 +From: James Russell +To: Michael Fuhr +Subject: Re: Sequential scan being used despite indexes +Cc: "Joshua D. Drake" , pgsql-performance@postgresql.org +In-Reply-To: <20060201035803.GA6324@winnie.fuhr.org> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_725_20274905.1138768388962" +References: <3a3a16930601311914w5bd7d1d0hde7b4e495e0deb27@mail.gmail.com> + <43E02B2F.9070202@commandprompt.com> + <20060201035803.GA6324@winnie.fuhr.org> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=1.774 required=5 tests=[AWL=-0.201, HTML_00_10=0.642, + HTML_MESSAGE=0.001, RCVD_IN_BL_SPAMCOP_NET=1.332] +X-Spam-Score: 1.774 +X-Spam-Level: * +X-Archive-Number: 200602/2 +X-Sequence-Number: 16988 + +------=_Part_725_20274905.1138768388962 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +[Sorry, my last reply didn't go to the list] + +Reading about this issue further in the FAQ, it seems that I should ensure +that Postgres has adequate and accurate information about the tables in +question by regularly running VACUUM ANALYZE, something I don't do +currently. + +I disabled SeqScan as per the FAQ, and it indeed was a lot slower so +Postgres was making the right choice in this case. + +Many thanks, + +James + +------=_Part_725_20274905.1138768388962 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +[Sorry, my last reply didn't go to the list]
+
+Reading about this issue further in the FAQ, it seems that I should +ensure that Postgres has adequate and accurate information about the +tables in question by regularly running VACUUM ANALYZE, something I don't d= +o currently.
+ +
+ +I disabled SeqScan as per the FAQ, and it indeed was a lot slower so Postgr= +es was making the right choice in this case.

+Many thanks,
+
+James
+ +------=_Part_725_20274905.1138768388962-- + +From pgsql-performance-owner@postgresql.org Wed Feb 1 00:42:42 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id A67059DC85C + for ; + Wed, 1 Feb 2006 00:42:41 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 45932-05 + for ; + Wed, 1 Feb 2006 00:42:40 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from houston.familyhealth.com.au (houston.au.fhnetwork.com + [203.22.197.21]) + by postgresql.org (Postfix) with ESMTP id B78269DC871 + for ; + Wed, 1 Feb 2006 00:42:38 -0400 (AST) +Received: from houston.familyhealth.com.au (localhost [127.0.0.1]) + by houston.familyhealth.com.au (Postfix) with ESMTP id B492125075; + Wed, 1 Feb 2006 12:42:33 +0800 (WST) +Received: from [127.0.0.1] (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (Postfix) with ESMTP id 100052506B; + Wed, 1 Feb 2006 12:42:32 +0800 (WST) +Message-ID: <43E03C8D.4050305@familyhealth.com.au> +Date: Wed, 01 Feb 2006 12:43:57 +0800 +From: Christopher Kings-Lynne +User-Agent: Thunderbird 1.5 (Windows/20051201) +MIME-Version: 1.0 +To: James Russell +Cc: Michael Fuhr , "Joshua D. Drake" , + pgsql-performance@postgresql.org +Subject: Re: Sequential scan being used despite indexes +References: <3a3a16930601311914w5bd7d1d0hde7b4e495e0deb27@mail.gmail.com> + <43E02B2F.9070202@commandprompt.com> + <20060201035803.GA6324@winnie.fuhr.org> + <3a3a16930601312033w2e4e3186k8f502e5b8c2cc6f2@mail.gmail.com> +In-Reply-To: <3a3a16930601312033w2e4e3186k8f502e5b8c2cc6f2@mail.gmail.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-familyhealth-MailScanner-Information: Please contact the ISP for more + information +X-familyhealth-MailScanner: Found to be clean +X-familyhealth-MailScanner-From: chriskl@familyhealth.com.au +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.083 required=5 tests=[AWL=0.083] +X-Spam-Score: 0.083 +X-Spam-Level: +X-Archive-Number: 200602/3 +X-Sequence-Number: 16989 + +> Reading about this issue further in the FAQ, it seems that I should +> ensure that Postgres has adequate and accurate information about the +> tables in question by regularly running VACUUM ANALYZE, something I +> don't do currently. + +Well then you'll get rubbish performance always in PostgreSQL... + +I strongly suggest you run autovacuum if you don't really understand +PostgreSQL vacuuming/analyzing. + +Chris + + +From pgsql-performance-owner@postgresql.org Wed Feb 1 01:08:39 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 587C69DCAAF + for ; + Wed, 1 Feb 2006 01:08:39 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 52913-03 + for ; + Wed, 1 Feb 2006 01:08:38 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) + by postgresql.org (Postfix) with ESMTP id CF9769DC85C + for ; + Wed, 1 Feb 2006 01:08:36 -0400 (AST) +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 k1158TbW037854 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); + Tue, 31 Jan 2006 22:08:32 -0700 (MST) + (envelope-from mfuhr@winnie.fuhr.org) +Received: from winnie.fuhr.org (localhost [127.0.0.1]) + by winnie.fuhr.org (8.13.4/8.13.4) with ESMTP id k1158S7m006911; + Tue, 31 Jan 2006 22:08:28 -0700 (MST) + (envelope-from mfuhr@winnie.fuhr.org) +Received: (from mfuhr@localhost) + by winnie.fuhr.org (8.13.4/8.13.4/Submit) id k1158SVA006910; + Tue, 31 Jan 2006 22:08:28 -0700 (MST) (envelope-from mfuhr) +Date: Tue, 31 Jan 2006 22:08:28 -0700 +From: Michael Fuhr +To: James Russell +Cc: "Joshua D. Drake" , pgsql-performance@postgresql.org +Subject: Re: Sequential scan being used despite indexes +Message-ID: <20060201050828.GA6681@winnie.fuhr.org> +References: <3a3a16930601311914w5bd7d1d0hde7b4e495e0deb27@mail.gmail.com> + <43E02B2F.9070202@commandprompt.com> + <20060201035803.GA6324@winnie.fuhr.org> + <3a3a16930601312033w2e4e3186k8f502e5b8c2cc6f2@mail.gmail.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <3a3a16930601312033w2e4e3186k8f502e5b8c2cc6f2@mail.gmail.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.115 required=5 tests=[AWL=0.115] +X-Spam-Score: 0.115 +X-Spam-Level: +X-Archive-Number: 200602/4 +X-Sequence-Number: 16990 + +On Wed, Feb 01, 2006 at 01:33:08PM +0900, James Russell wrote: +> Reading about this issue further in the FAQ, it seems that I should ensure +> that Postgres has adequate and accurate information about the tables in +> question by regularly running VACUUM ANALYZE, something I don't do +> currently. + +Many people use a cron job (or the equivalent) to run VACUUM ANALYZE +at regular intervals; some also use the pg_autovacuum daemon, which +is a contrib module in 8.0 and earlier and part of the backend as of +8.1. + +How often to vacuum/analyze depends on usage. Once per day is +commonly cited, but busy tables might need it more often than that. +Just recently somebody had a table that could have used vacuuming +every five minutes or less (all records were updated every 30 +seconds); pg_autovacuum can be useful in such cases. + +> I disabled SeqScan as per the FAQ, and it indeed was a lot slower so +> Postgres was making the right choice in this case. + +The planner might be making the right choice given the statistics +it has, but it's possible that better statistics would lead to a +different plan, perhaps one where an index scan would be faster. + +What happens if you run VACUUM ANALYZE on all the tables, then run +the query again with EXPLAIN ANALYZE? + +-- +Michael Fuhr + +From pgsql-performance-owner@postgresql.org Wed Feb 1 01:49:47 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 557069DCA30 + for ; + Wed, 1 Feb 2006 01:49:46 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 59719-06 + for ; + Wed, 1 Feb 2006 01:49:45 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 7ABF79DC85C + for ; + Wed, 1 Feb 2006 01:49:43 -0400 (AST) +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 k115nhYI025858; + Wed, 1 Feb 2006 00:49:43 -0500 (EST) +To: "Marc Morin" +cc: pgsql-performance@postgresql.org +Subject: Re: partitioning and locking problems +In-reply-to: <2BCEB9A37A4D354AA276774EE13FB8C263B3DE@mailserver.sandvine.com> +References: <2BCEB9A37A4D354AA276774EE13FB8C263B3DE@mailserver.sandvine.com> +Comments: In-reply-to "Marc Morin" + message dated "Tue, 31 Jan 2006 18:25:01 -0500" +Date: Wed, 01 Feb 2006 00:49:43 -0500 +Message-ID: <25857.1138772983@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.102 required=5 tests=[AWL=0.102] +X-Spam-Score: 0.102 +X-Spam-Level: +X-Archive-Number: 200602/5 +X-Sequence-Number: 16991 + +"Marc Morin" writes: +> Would like to understand the implications of changing postgres' +> code/locking for rule changes and truncate to not require locking out +> select statements? + +It won't work... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Feb 1 01:53:19 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id A1F629DCA30 + for ; + Wed, 1 Feb 2006 01:53:18 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 61605-06 + for ; + Wed, 1 Feb 2006 01:53:17 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.mi8.com (d01gw04.mi8.com [63.240.6.44]) + by postgresql.org (Postfix) with ESMTP id 4A4B99DC861 + for ; + Wed, 1 Feb 2006 01:53:15 -0400 (AST) +Received: from 172.16.1.25 by mail.mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D4)); Wed, 01 Feb 2006 00:53:08 -0500 +X-Server-Uuid: C8FB4D43-1108-484A-A898-3CBCC7906230 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.175]) by + D01HOST03.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Wed, 1 Feb + 2006 00:53:08 -0500 +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.105]) with Microsoft Exchange Server HTTP-DAV ; Wed, 1 Feb + 2006 05:53:07 +0000 +User-Agent: Microsoft-Entourage/11.2.1.051004 +Date: Tue, 31 Jan 2006 21:53:06 -0800 +Subject: Re: Huge Data sets, simple queries +From: "Luke Lonergan" +To: "Jeffrey W. Baker" +cc: pgsql-performance@postgresql.org +Message-ID: +Thread-Topic: [PERFORM] Huge Data sets, simple queries +Thread-Index: AcYm5VcOVl+TP4B0TpC35mjjGG9dFgADm6Aw +In-Reply-To: <1138766980.14051.24.camel@noodles> +MIME-Version: 1.0 +X-OriginalArrivalTime: 01 Feb 2006 05:53:08.0510 (UTC) + FILETIME=[C70D8BE0:01C626F3] +X-WSS-ID: 6FFE934E20C2080458-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, score=1.349 required=5 tests=[AWL=0.096, + RCVD_NUMERIC_HELO=1.253] +X-Spam-Score: 1.349 +X-Spam-Level: * +X-Archive-Number: 200602/6 +X-Sequence-Number: 16992 + +Jeffrey, + +On 1/31/06 8:09 PM, "Jeffrey W. Baker" wrote: +>> ... Prove it. +> I think I've proved my point. Software RAID1 read balancing provides +> 0%, 300%, 100%, and 100% speedup on 1, 2, 4, and 8 threads, +> respectively. In the presence of random I/O, the results are even +> better. +> Anyone who thinks they have a single-threaded workload has not yet +> encountered the autovacuum daemon. + +Good data - interesting case. I presume from your results that you had to +make the I/Os non-overlapping (the "skip" option to dd) in order to get the +concurrent access to work. Why the particular choice of offset - 3.2GB in +this case? + +So - the bandwidth doubles in specific circumstances under concurrent +workloads - not relevant to "Huge Data sets, simple queries", but possibly +helpful for certain kinds of OLTP applications. + +- Luke + + + +From pgsql-performance-owner@postgresql.org Wed Feb 1 04:25:16 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 5889E9DC942 + for ; + Wed, 1 Feb 2006 04:25:15 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 92729-03 + for ; + Wed, 1 Feb 2006 04:25:15 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail4.sea5.speakeasy.net (mail4.sea5.speakeasy.net + [69.17.117.6]) by postgresql.org (Postfix) with ESMTP id 0B83B9DC837 + for ; + Wed, 1 Feb 2006 04:25:12 -0400 (AST) +Received: (qmail 19480 invoked from network); 1 Feb 2006 08:25:13 -0000 +Received: from dsl081-060-184.sfo1.dsl.speakeasy.net (HELO noodles) + (jwbaker@[64.81.60.184]) (envelope-sender ) + by mail4.sea5.speakeasy.net (qmail-ldap-1.03) with RC4-MD5 encrypted + SMTP for ; 1 Feb 2006 08:25:13 -0000 +Subject: Re: Huge Data sets, simple queries +From: "Jeffrey W. Baker" +To: Luke Lonergan +Cc: pgsql-performance@postgresql.org +In-Reply-To: +References: +Content-Type: text/plain +Date: Wed, 01 Feb 2006 00:25:13 -0800 +Message-Id: <1138782313.14732.1.camel@noodles> +Mime-Version: 1.0 +X-Mailer: Evolution 2.5.4 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200602/7 +X-Sequence-Number: 16993 + +On Tue, 2006-01-31 at 21:53 -0800, Luke Lonergan wrote: +> Jeffrey, +> +> On 1/31/06 8:09 PM, "Jeffrey W. Baker" wrote: +> >> ... Prove it. +> > I think I've proved my point. Software RAID1 read balancing provides +> > 0%, 300%, 100%, and 100% speedup on 1, 2, 4, and 8 threads, +> > respectively. In the presence of random I/O, the results are even +> > better. +> > Anyone who thinks they have a single-threaded workload has not yet +> > encountered the autovacuum daemon. +> +> Good data - interesting case. I presume from your results that you had to +> make the I/Os non-overlapping (the "skip" option to dd) in order to get the +> concurrent access to work. Why the particular choice of offset - 3.2GB in +> this case? + +No particular reason. 8k x 100000 is what the last guy used upthread. +> +> So - the bandwidth doubles in specific circumstances under concurrent +> workloads - not relevant to "Huge Data sets, simple queries", but possibly +> helpful for certain kinds of OLTP applications. + +Ah, but someday Pg will be able to concurrently read from two +datastreams to complete a single query. And that day will be glorious +and fine, and you'll want as much disk concurrency as you can get your +hands on. + +-jwb + + +From pgsql-performance-owner@postgresql.org Wed Feb 1 05:00:52 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 540549DC994 + for ; + Wed, 1 Feb 2006 05:00:51 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 00625-02 + for ; + Wed, 1 Feb 2006 05:00:52 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from peufeu.com (boutiquenumerique.com [82.67.9.10]) + by postgresql.org (Postfix) with ESMTP id B97849DC874 + for ; + Wed, 1 Feb 2006 05:00:48 -0400 (AST) +Received: (qmail 22256 invoked from network); 1 Feb 2006 10:01:41 +0100 +Received: from boutiquenumerique.com (HELO apollo13) (82.67.9.10) + by boutiquenumerique.com with SMTP; 1 Feb 2006 10:01:41 +0100 +To: "Jeffrey W. Baker" , + "Luke Lonergan" +Cc: pgsql-performance@postgresql.org +Subject: Re: Huge Data sets, simple queries +References: + <1138782313.14732.1.camel@noodles> +Message-ID: +Date: Wed, 01 Feb 2006 10:01:39 +0100 +From: PFC +Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +In-Reply-To: <1138782313.14732.1.camel@noodles> +User-Agent: Opera M2/8.51 (Linux, build 1462) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.072 required=5 tests=[AWL=0.072] +X-Spam-Score: 0.072 +X-Spam-Level: +X-Archive-Number: 200602/8 +X-Sequence-Number: 16994 + + + I did a little test on soft raid1 : + + I have two 800 Mbytes files, say A and B. (RAM is 512Mbytes). + + Test 1 : + 1- Read A, then read B : + 19 seconds per file + + 2- Read A and B simultaneously using two threads : + 22 seconds total (reads were paralleled by the RAID) + + 3- Read one block of A, then one block of B, then one block of A, etc. +Essentially this is the same as the threaded case, except there's only one +thread. + 53 seconds total (with heavy seeking noise from the hdd). + + I was half expecting 3 to take the same as 2. It simulates, for instance, +scanning a table and its index, or scanning 2 sort bins. Well, maybe one +day... + + It would be nice if the Kernel had an API for applications to tell it +"I'm gonna need these blocks in the next seconds, can you read them in the +order you like (fastest), from whatever disk you like, and cache them for +me please; so that I can read them in the order I like, but very fast ?" + + +On Wed, 01 Feb 2006 09:25:13 +0100, Jeffrey W. Baker +wrote: + +> On Tue, 2006-01-31 at 21:53 -0800, Luke Lonergan wrote: +>> Jeffrey, +>> +>> On 1/31/06 8:09 PM, "Jeffrey W. Baker" wrote: +>> >> ... Prove it. +>> > I think I've proved my point. Software RAID1 read balancing provides +>> > 0%, 300%, 100%, and 100% speedup on 1, 2, 4, and 8 threads, +>> > respectively. In the presence of random I/O, the results are even +>> > better. +>> > Anyone who thinks they have a single-threaded workload has not yet +>> > encountered the autovacuum daemon. +>> +>> Good data - interesting case. I presume from your results that you had +>> to +>> make the I/Os non-overlapping (the "skip" option to dd) in order to get +>> the +>> concurrent access to work. Why the particular choice of offset - 3.2GB +>> in +>> this case? +> +> No particular reason. 8k x 100000 is what the last guy used upthread. +>> +>> So - the bandwidth doubles in specific circumstances under concurrent +>> workloads - not relevant to "Huge Data sets, simple queries", but +>> possibly +>> helpful for certain kinds of OLTP applications. +> +> Ah, but someday Pg will be able to concurrently read from two +> datastreams to complete a single query. And that day will be glorious +> and fine, and you'll want as much disk concurrency as you can get your +> hands on. +> +> -jwb +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 4: Have you searched our list archives? +> +> http://archives.postgresql.org + + + +From pgsql-performance-owner@postgresql.org Wed Feb 1 05:39:07 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 871539DC857 + for ; + Wed, 1 Feb 2006 05:39:06 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 05003-07 + for ; + Wed, 1 Feb 2006 05:39:07 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) + by postgresql.org (Postfix) with ESMTP id 88B3B9DC837 + for ; + Wed, 1 Feb 2006 05:39:04 -0400 (AST) +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 3F7D3410EC9; Wed, 1 Feb 2006 09:39:06 +0000 (GMT) +Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP id F0A8415EA4; + Wed, 1 Feb 2006 09:39:05 +0000 (GMT) +Message-ID: <43E081B9.5050101@archonet.com> +Date: Wed, 01 Feb 2006 09:39:05 +0000 +From: Richard Huxton +User-Agent: Thunderbird 1.5 (X11/20051201) +MIME-Version: 1.0 +To: Marc Morin +Cc: pgsql-performance@postgresql.org +Subject: Re: partitioning and locking problems +References: <2BCEB9A37A4D354AA276774EE13FB8C263B3DE@mailserver.sandvine.com> +In-Reply-To: <2BCEB9A37A4D354AA276774EE13FB8C263B3DE@mailserver.sandvine.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, score=0.115 required=5 tests=[AWL=0.115] +X-Spam-Score: 0.115 +X-Spam-Level: +X-Archive-Number: 200602/9 +X-Sequence-Number: 16995 + +Marc Morin wrote: +> Under both these circumstances (truncate and create / replace rule) the +> locking behaviour of these commands can cause locking problems for us. +> The scenario is best illustrated as a series of steps: +> +> +> 1- long running report is running on view +> 2- continuous inserters into view into a table via a rule +> 3- truncate or rule change occurs, taking an exclusive lock. +> Must wait for #1 to finish. +> 4- new reports and inserters must now wait for #3. +> 5- now everyone is waiting for a single query in #1. Results +> in loss of insert data granularity (important for our application). + +How much would you get from splitting the view into two: reporting and +inserting? + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Wed Feb 1 06:15:06 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 1D1AF9DCCC0 + for ; + Wed, 1 Feb 2006 06:15:05 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 12230-06 + for ; + Wed, 1 Feb 2006 06:15:05 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from eads-av-smtp5.gmessaging.net (eads-av-smtp5.gmessaging.net + [194.51.201.54]) + by postgresql.org (Postfix) with ESMTP id 98D729DCCBE + for ; + Wed, 1 Feb 2006 06:14:57 -0400 (AST) +Received: from eads-relay5.cesson.gm-adm (localhost [127.0.0.1]) + by eads-av-smtp5.gmessaging.net + (iPlanet Messaging Server 5.2 HotFix 2.04 (built Feb 8 2005)) + with ESMTP id <0IU00064Z6XXDB@eads-av-smtp5.gmessaging.net> for + pgsql-performance@postgresql.org; Wed, 01 Feb 2006 11:14:59 +0100 (MET) +Received: from fr0-mailsp02.res.airbus.corp ([10.254.251.55]) + by eads-av-smtp5.gmessaging.net + (iPlanet Messaging Server 5.2 HotFix 2.04 (built Feb 8 2005)) + with ESMTP id <0IU000FHC74AFR@eads-av-smtp5.gmessaging.net> for + pgsql-performance@postgresql.org; Wed, 01 Feb 2006 11:14:45 +0100 (MET) +Received: from fr0-mailsp02.res.airbus.corp (localhost.localdomain + [127.0.0.1]) + by fr0-mailsp02.res.airbus.corp (8.12.11/8.12.10) with ESMTP id + k11AEVgR012124 + for ; Wed, 01 Feb 2006 11:14:31 +0100 +Received: from fr0-mailrt11.res.airbus.corp ([152.9.126.25]) + by fr0-mailsp02.res.airbus.corp (8.12.11/8.12.10) with ESMTP id + k11ADcxF010453 + for ; Wed, 01 Feb 2006 11:14:28 +0100 +Received: from fr0-mailrt03.res.airbus.corp ([152.9.126.22]) + by fr0-mailrt11.res.airbus.corp with Microsoft SMTPSVC(5.0.2195.6713); + Wed, 01 Feb 2006 11:13:22 +0100 +Received: from FR0-MAILMB20.res.airbus.corp ([152.9.126.74]) + by fr0-mailrt03.res.airbus.corp with Microsoft SMTPSVC(5.0.2195.6713); + Wed, 01 Feb 2006 11:13:18 +0100 +Date: Wed, 01 Feb 2006 11:11:33 +0100 +From: "FERREIRA, William (VALTECH)" +Subject: execution plan : Oracle vs PostgreSQL +To: pgsql-performance@postgresql.org +Message-id: + <414D259CE29DE54DAD534037C83CE4B726961D@FR0-MAILMB20.res.airbus.corp> +MIME-version: 1.0 +X-MIMEOLE: Produced By Microsoft Exchange V6.0.6603.0 +Content-type: text/plain; charset=iso-8859-1 +Content-transfer-encoding: 7BIT +Content-class: urn:content-classes:message +Thread-topic: [PERFORM] partitioning and locking problems +Thread-index: AcYnE63jmxmLwcotS0iBPfo7K/t3bgAAGWxA +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +X-OriginalArrivalTime: 01 Feb 2006 10:13:18.0729 (UTC) + FILETIME=[1F77EF90:01C62718] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.259 required=5 tests=[AWL=0.259] +X-Spam-Score: 0.259 +X-Spam-Level: +X-Archive-Number: 200602/10 +X-Sequence-Number: 16996 + + +hi, + +i have a database storing XML documents. +The main table contains the nodes of the document, the other tables contain data for each node (depending on the node's type : ELE, Text, PI, ...) + +My test document has 115000 nodes. +the export of the document(extracting all informations from database and writing XML file on disk) takes 30s with Oracle and 5mn with Postgresql. +The Oracle stored procedure is written in pl/sql and the Postgresql stored procedure in pl/perl (using spi_exec). +The export stored procedure use a SAX way algorithm : from a node, get all the children and for each child if it's an Element go in recursion else write data into a file. + +The tests have been made on different systems +- Sun systems : + - solaris8 : 16 cpu and 64Gb RAM + - solaris8 : 2cpu and 8Gb RAM +- Windows Systems : + - WinNT : 1 cpu(PIV) and 1Gb RAM + - WinXP : 1 cpu(centrino) and 512 RAM + +the times are always the same, except with the centrino for which it takes 1 min. + +So i don't understand such differences. + +here is my main query (on the main table for getting the children of a node) and the execution plan for PostgreSQL and Oracle : + +-Query : +SELECT * + FROM xdb_child c1 + WHERE c1.doc_id = 100 + AND c1.ele_id = 2589 + AND c1.isremoved = 0 + AND c1.evolution = + (SELECT + MAX (evolution) + FROM xdb_child c2 + WHERE c2.doc_id = c1.doc_id + AND c2.ele_id = c1.ele_id + AND c2.evolution <= 0 + AND c2.child_id = c1.child_id + AND c2.child_class = c1.child_class) ORDER BY c1.evolution, c1.indx + +-Oracle plan (cost 14): +Operation Object Name Rows Bytes Cost Object Node In/Out PStart PStop + +SELECT STATEMENT Optimizer Mode=CHOOSE 1 14 + SORT ORDER BY 1 4 K 14 + TABLE ACCESS BY INDEX ROWID XDB_CHILD 1 4 K 4 + INDEX RANGE SCAN INDEX_XDB_CHILD_1 1 3 + SORT AGGREGATE 1 65 + FIRST ROW 1 65 3 + INDEX RANGE SCAN (MIN/MAX) INDEX_XDB_CHILD_2 8 M 3 + +-PostgreSQL explain analyse : + {SORT + :startup_cost 9.65 + :total_cost 9.66 + :plan_rows 1 + :plan_width 28 + :targetlist ( + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 1 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 1 + } + :resno 1 + :resname child_id + :ressortgroupref 0 + :resorigtbl 34719 + :resorigcol 1 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 2 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 2 + } + :resno 2 + :resname evolution + :ressortgroupref 1 + :resorigtbl 34719 + :resorigcol 2 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 3 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 3 + } + :resno 3 + :resname isremoved + :ressortgroupref 0 + :resorigtbl 34719 + :resorigcol 3 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 4 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 4 + } + :resno 4 + :resname child_class + :ressortgroupref 0 + :resorigtbl 34719 + :resorigcol 4 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 5 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 5 + } + :resno 5 + :resname indx + :ressortgroupref 2 + :resorigtbl 34719 + :resorigcol 5 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 6 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 6 + } + :resno 6 + :resname ele_id + :ressortgroupref 0 + :resorigtbl 34719 + :resorigcol 6 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 7 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 7 + } + :resno 7 + :resname doc_id + :ressortgroupref 0 + :resorigtbl 34719 + :resorigcol 7 + :resjunk false + } + ) + :qual <> + :lefttree + {INDEXSCAN + :startup_cost 0.00 + :total_cost 9.64 + :plan_rows 1 + :plan_width 28 + :targetlist ( + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 1 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 1 + } + :resno 1 + :resname child_id + :ressortgroupref 0 + :resorigtbl 34719 + :resorigcol 1 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 2 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 2 + } + :resno 2 + :resname evolution + :ressortgroupref 1 + :resorigtbl 34719 + :resorigcol 2 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 3 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 3 + } + :resno 3 + :resname isremoved + :ressortgroupref 0 + :resorigtbl 34719 + :resorigcol 3 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 4 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 4 + } + :resno 4 + :resname child_class + :ressortgroupref 0 + :resorigtbl 34719 + :resorigcol 4 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 5 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 5 + } + :resno 5 + :resname indx + :ressortgroupref 2 + :resorigtbl 34719 + :resorigcol 5 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 6 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 6 + } + :resno 6 + :resname ele_id + :ressortgroupref 0 + :resorigtbl 34719 + :resorigcol 6 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 7 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 7 + } + :resno 7 + :resname doc_id + :ressortgroupref 0 + :resorigtbl 34719 + :resorigcol 7 + :resjunk false + } + ) + :qual ( + {OPEXPR + :opno 96 + :opfuncid 65 + :opresulttype 16 + :opretset false + :args ( + {VAR + :varno 1 + :varattno 2 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 2 + } + {SUBPLAN + :subLinkType 4 + :useOr false + :exprs <> + :paramIds <> + :plan + {AGG + :startup_cost 4.93 + :total_cost 4.94 + :plan_rows 1 + :plan_width 4 + :targetlist ( + {TARGETENTRY + :expr + {AGGREF + :aggfnoid 2116 + :aggtype 23 + :target + {VAR + :varno 0 + :varattno 2 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 2 + } + :agglevelsup 0 + :aggstar false + :aggdistinct false + } + :resno 1 + :resname max + :ressortgroupref 0 + :resorigtbl 0 + :resorigcol 0 + :resjunk false + } + ) + :qual <> + :lefttree + {INDEXSCAN + :startup_cost 0.00 + :total_cost 4.93 + :plan_rows 1 + :plan_width 4 + :targetlist ( + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 1 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 1 + } + :resno 1 + :resname <> + :ressortgroupref 0 + :resorigtbl 0 + :resorigcol 0 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 2 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 2 + } + :resno 2 + :resname <> + :ressortgroupref 0 + :resorigtbl 0 + :resorigcol 0 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 3 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 3 + } + :resno 3 + :resname <> + :ressortgroupref 0 + :resorigtbl 0 + :resorigcol 0 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 4 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 4 + } + :resno 4 + :resname <> + :ressortgroupref 0 + :resorigtbl 0 + :resorigcol 0 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 5 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 5 + } + :resno 5 + :resname <> + :ressortgroupref 0 + :resorigtbl 0 + :resorigcol 0 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 6 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 6 + } + :resno 6 + :resname <> + :ressortgroupref 0 + :resorigtbl 0 + :resorigcol 0 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 7 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 7 + } + :resno 7 + :resname <> + :ressortgroupref 0 + :resorigtbl 0 + :resorigcol 0 + :resjunk false + } + ) + :qual ( + {OPEXPR + :opno 96 + :opfuncid 65 + :opresulttype 16 + :opretset false + :args ( + {VAR + :varno 1 + :varattno 4 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 4 + } + {PARAM + :paramkind 15 + :paramid 3 + :paramname <> + :paramtype 23 + } + ) + } + ) + :lefttree <> + :righttree <> + :initPlan <> + :extParam (b 0 1 2 3) + :allParam (b 0 1 2 3) + :nParamExec 0 + :scanrelid 1 + :indexid 34737 + :indexqual ( + {OPEXPR + :opno 96 + :opfuncid 65 + :opresulttype 16 + :opretset false + :args ( + {VAR + :varno 1 + :varattno 1 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 7 + } + {PARAM + :paramkind 15 + :paramid 0 + :paramname <> + :paramtype 23 + } + ) + } + {OPEXPR + :opno 96 + :opfuncid 65 + :opresulttype 16 + :opretset false + :args ( + {VAR + :varno 1 + :varattno 2 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 6 + } + {PARAM + :paramkind 15 + :paramid 1 + :paramname <> + :paramtype 23 + } + ) + } + {OPEXPR + :opno 523 + :opfuncid 149 + :opresulttype 16 + :opretset false + :args ( + {VAR + :varno 1 + :varattno 4 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 2 + } + {CONST + :consttype 23 + :constlen 4 + :constbyval true + :constisnull false + :constvalue 4 [ 0 0 0 0 ] + } + ) + } + {OPEXPR + :opno 96 + :opfuncid 65 + :opresulttype 16 + :opretset false + :args ( + {VAR + :varno 1 + :varattno 5 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 1 + } + {PARAM + :paramkind 15 + :paramid 2 + :paramname <> + :paramtype 23 + } + ) + } + ) + :indexqualorig ( + {OPEXPR + :opno 96 + :opfuncid 65 + :opresulttype 16 + :opretset false + :args ( + {VAR + :varno 1 + :varattno 7 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 7 + } + {PARAM + :paramkind 15 + :paramid 0 + :paramname <> + :paramtype 23 + } + ) + } + {OPEXPR + :opno 96 + :opfuncid 65 + :opresulttype 16 + :opretset false + :args ( + {VAR + :varno 1 + :varattno 6 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 6 + } + {PARAM + :paramkind 15 + :paramid 1 + :paramname <> + :paramtype 23 + } + ) + } + {OPEXPR + :opno 523 + :opfuncid 149 + :opresulttype 16 + :opretset false + :args ( + {VAR + :varno 1 + :varattno 2 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 2 + } + {CONST + :consttype 23 + :constlen 4 + :constbyval true + :constisnull false + :constvalue 4 [ 0 0 0 0 ] + } + ) + } + {OPEXPR + :opno 96 + :opfuncid 65 + :opresulttype 16 + :opretset false + :args ( + {VAR + :varno 1 + :varattno 1 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 1 + } + {PARAM + :paramkind 15 + :paramid 2 + :paramname <> + :paramtype 23 + } + ) + } + ) + :indexstrategy (i 3 3 2 3) + :indexsubtype (o 0 0 0 0) + :indexorderdir 1 + } + :righttree <> + :initPlan <> + :extParam (b 0 1 2 3) + :allParam (b 0 1 2 3) + :nParamExec 0 + :aggstrategy 0 + :numCols 0 + :numGroups 0 + } + :plan_id 1 + :rtable ( + {RTE + :alias + {ALIAS + :aliasname c2 + :colnames <> + } + :eref + {ALIAS + :aliasname c2 + :colnames ("child_id" "evolution" "isremoved" "child_class" + "indx" "ele_id" "doc_id") + } + :rtekind 0 + :relid 34719 + :inh false + :inFromCl true + :requiredPerms 2 + :checkAsUser 0 + } + ) + :useHashTable false + :unknownEqFalse false + :setParam <> + :parParam (i 0 1 2 3) + :args ( + {VAR + :varno 1 + :varattno 7 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 7 + } + {VAR + :varno 1 + :varattno 6 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 6 + } + {VAR + :varno 1 + :varattno 1 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 1 + } + {VAR + :varno 1 + :varattno 4 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 4 + } + ) + } + ) + } + ) + :lefttree <> + :righttree <> + :initPlan <> + :extParam (b) + :allParam (b) + :nParamExec 0 + :scanrelid 1 + :indexid 34737 + :indexqual ( + {OPEXPR + :opno 96 + :opfuncid 65 + :opresulttype 16 + :opretset false + :args ( + {VAR + :varno 1 + :varattno 1 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 7 + } + {CONST + :consttype 23 + :constlen 4 + :constbyval true + :constisnull false + :constvalue 4 [ 0 0 0 100 ] + } + ) + } + {OPEXPR + :opno 96 + :opfuncid 65 + :opresulttype 16 + :opretset false + :args ( + {VAR + :varno 1 + :varattno 2 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 6 + } + {CONST + :consttype 23 + :constlen 4 + :constbyval true + :constisnull false + :constvalue 4 [ 0 0 10 29 ] + } + ) + } + {OPEXPR + :opno 96 + :opfuncid 65 + :opresulttype 16 + :opretset false + :args ( + {VAR + :varno 1 + :varattno 3 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 3 + } + {CONST + :consttype 23 + :constlen 4 + :constbyval true + :constisnull false + :constvalue 4 [ 0 0 0 0 ] + } + ) + } + ) + :indexqualorig ( + {OPEXPR + :opno 96 + :opfuncid 65 + :opresulttype 16 + :opretset false + :args ( + {VAR + :varno 1 + :varattno 7 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 7 + } + {CONST + :consttype 23 + :constlen 4 + :constbyval true + :constisnull false + :constvalue 4 [ 0 0 0 100 ] + } + ) + } + {OPEXPR + :opno 96 + :opfuncid 65 + :opresulttype 16 + :opretset false + :args ( + {VAR + :varno 1 + :varattno 6 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 6 + } + {CONST + :consttype 23 + :constlen 4 + :constbyval true + :constisnull false + :constvalue 4 [ 0 0 10 29 ] + } + ) + } + {OPEXPR + :opno 96 + :opfuncid 65 + :opresulttype 16 + :opretset false + :args ( + {VAR + :varno 1 + :varattno 3 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 3 + } + {CONST + :consttype 23 + :constlen 4 + :constbyval true + :constisnull false + :constvalue 4 [ 0 0 0 0 ] + } + ) + } + ) + :indexstrategy (i 3 3 3) + :indexsubtype (o 0 0 0) + :indexorderdir 1 + } + :righttree <> + :initPlan <> + :extParam (b) + :allParam (b) + :nParamExec 4 + :numCols 2 + :sortColIdx 2 5 + :sortOperators 97 97 + } + +Sort (cost=9.65..9.66 rows=1 width=28) (actual time=0.163..0.164 rows=1 loops=1) + Sort Key: evolution, indx + -> Index Scan using index_xdb_child on xdb_child c1 (cost=0.00..9.64 rows=1 width=28) (actual time=0.133..0.135 rows=1 loops=1) + Index Cond: ((doc_id = 100) AND (ele_id = 2589) AND (isremoved = 0)) + Filter: (evolution = (subplan)) + SubPlan + -> Aggregate (cost=4.93..4.94 rows=1 width=4) (actual time=0.048..0.048 rows=1 loops=1) + -> Index Scan using index_xdb_child on xdb_child c2 (cost=0.00..4.93 rows=1 width=4) (actual time=0.025..0.030 rows=1 loops=1) + Index Cond: ((doc_id = $0) AND (ele_id = $1) AND (evolution <= 0) AND (child_id = $2)) + Filter: (child_class = $3) +Total runtime: 0.418 ms + +the Postgresql cost is better but the query is two times slower. + +an other question about the procedural language : is pl/perl efficient with a such process knowing that it's just a test document : a real document contains between 1 and 3 millions of nodes. + + +Regards + + William + + +This e-mail is intended only for the above addressee. It may contain +privileged information. If you are not the addressee you must not copy, +distribute, disclose or use any of the information in it. If you have +received it in error please delete it and immediately notify the sender. +Security Notice: all e-mail, sent to or from this address, may be +accessed by someone other than the recipient, for system management and +security reasons. This access is controlled under Regulation of +Investigatory Powers Act 2000, Lawful Business Practises. + +From pgsql-performance-owner@postgresql.org Wed Feb 1 08:15:12 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 825BD9DC943 + for ; + Wed, 1 Feb 2006 08:15:11 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 31990-06 + for ; + Wed, 1 Feb 2006 08:15:14 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from vms044pub.verizon.net (vms044pub.verizon.net [206.46.252.44]) + by postgresql.org (Postfix) with ESMTP id 5B5519DC942 + for ; + Wed, 1 Feb 2006 08:15:08 -0400 (AST) +Received: from osgiliath.mathom.us ([70.108.47.21]) + by vms044.mailsrvcs.net (Sun Java System Messaging Server 6.2-4.02 + (built Sep + 9 2005)) with ESMTPA id <0IU0005WKCPBP0U1@vms044.mailsrvcs.net> for + pgsql-performance@postgresql.org; Wed, 01 Feb 2006 06:15:12 -0600 (CST) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id 33D686EA7E for + ; + Wed, 01 Feb 2006 07:15:10 -0500 (EST) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath.home.mathom.us [127.0.0.1]) (amavisd-new, + port 10024) + with LMTP id 05038-04-3 for ; Wed, + 01 Feb 2006 07:15:09 -0500 (EST) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id 8555E6EA81; Wed, 01 Feb 2006 07:15:09 -0500 (EST) +Date: Wed, 01 Feb 2006 07:15:09 -0500 +From: Michael Stone +Subject: Re: Huge Data sets, simple queries +In-reply-to: <1138766980.14051.24.camel@noodles> +To: pgsql-performance@postgresql.org +Mail-followup-to: pgsql-performance@postgresql.org +Message-id: <20060201121507.GB1293@mathom.us> +MIME-version: 1.0 +Content-type: text/plain; charset=us-ascii; format=flowed +Content-disposition: inline +X-Pgp-Fingerprint: 53 FF 38 00 E7 DD 0A 9C 84 52 84 C5 EE DF 7C 88 +X-Virus-Scanned: Debian amavisd-new at mathom.us +References: + <1138766980.14051.24.camel@noodles> +User-Agent: Mutt/1.5.11 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.109 required=5 tests=[AWL=0.109] +X-Spam-Score: 0.109 +X-Spam-Level: +X-Archive-Number: 200602/11 +X-Sequence-Number: 16997 + +On Tue, Jan 31, 2006 at 08:09:40PM -0800, Jeffrey W. Baker wrote: +>I think I've proved my point. Software RAID1 read balancing provides +>0%, 300%, 100%, and 100% speedup on 1, 2, 4, and 8 threads, +>respectively. In the presence of random I/O, the results are even +>better. + +Umm, the point *was* about single stream performance. I guess you did a +good job of proving it. + +>Anyone who thinks they have a single-threaded workload has not yet +>encountered the autovacuum daemon. + +On tables where my single stream performance matters you'd better +believe that the autovacuum daemon isn't running. + +Mike Stone + +From pgsql-performance-owner@postgresql.org Wed Feb 1 10:26:45 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 89B399DC9C2 + for ; + Wed, 1 Feb 2006 10:26:44 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 56443-04 + for ; + Wed, 1 Feb 2006 10:26:48 -0400 (AST) +X-Greylist: delayed 15:00:16.645393 by SQLgrey- +Received: from mailserver.sandvine.com (sandvine.com [199.243.201.138]) + by postgresql.org (Postfix) with ESMTP id E21C69DC95A + for ; + Wed, 1 Feb 2006 10:26:33 -0400 (AST) +X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: quoted-printable +Subject: Re: partitioning and locking problems +Date: Wed, 1 Feb 2006 09:25:10 -0500 +Message-ID: <2BCEB9A37A4D354AA276774EE13FB8C263B3E5@mailserver.sandvine.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] partitioning and locking problems +Thread-Index: AcYm8yR8SnYsjNKzRHWIzwA73vW9lgASBveA +From: "Marc Morin" +To: "Tom Lane" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200602/12 +X-Sequence-Number: 16998 + +Tom, + +Do you mean it would be impossible to change the code so that existing +selects continue to use the pre-truncated table until they commit? Or +just require a more extensive change? + +The update/insert rule change appears to be more more doable? No?=20 + +> -----Original Message----- +> From: Tom Lane [mailto:tgl@sss.pgh.pa.us]=20 +> Sent: Wednesday, February 01, 2006 12:50 AM +> To: Marc Morin +> Cc: pgsql-performance@postgresql.org +> Subject: Re: [PERFORM] partitioning and locking problems=20 +>=20 +> "Marc Morin" writes: +> > Would like to understand the implications of changing postgres' +> > code/locking for rule changes and truncate to not require=20 +> locking out=20 +> > select statements? +>=20 +> It won't work... +>=20 +> regards, tom lane +>=20 +>=20 + +From pgsql-performance-owner@postgresql.org Wed Feb 1 11:20:21 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 4DF679DC809 + for ; + Wed, 1 Feb 2006 11:20:20 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 66316-02 + for ; + Wed, 1 Feb 2006 11:20:24 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id ACEEC9DC803 + for ; + Wed, 1 Feb 2006 11:20:16 -0400 (AST) +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 k11FKLlu000308; + Wed, 1 Feb 2006 10:20:21 -0500 (EST) +To: "Marc Morin" +cc: pgsql-performance@postgresql.org +Subject: Re: partitioning and locking problems +In-reply-to: <2BCEB9A37A4D354AA276774EE13FB8C263B3E5@mailserver.sandvine.com> +References: <2BCEB9A37A4D354AA276774EE13FB8C263B3E5@mailserver.sandvine.com> +Comments: In-reply-to "Marc Morin" + message dated "Wed, 01 Feb 2006 09:25:10 -0500" +Date: Wed, 01 Feb 2006 10:20:21 -0500 +Message-ID: <307.1138807221@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.102 required=5 tests=[AWL=0.102] +X-Spam-Score: 0.102 +X-Spam-Level: +X-Archive-Number: 200602/13 +X-Sequence-Number: 16999 + +"Marc Morin" writes: +> Do you mean it would be impossible to change the code so that existing +> selects continue to use the pre-truncated table until they commit? + +Yes, because that table won't exist any more (as in the file's been +unlinked) once the TRUNCATE commits. + +> The update/insert rule change appears to be more more doable? No? + +You've still got race conditions there: do onlooker transactions see the +old set of rules, or the new set, or some unholy mixture? Removing the +lock as you suggest would make it possible for the rule rewriter to pick +up non-self-consistent data from the system catalogs, leading to +arbitrarily bad behavior ... if you're lucky, it'll just crash, if +you're not lucky the incorrect rule will do a fandango on your data. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Feb 1 12:04:51 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 4A6569DCA32 + for ; + Wed, 1 Feb 2006 12:04:50 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 73714-06 + for ; + Wed, 1 Feb 2006 12:04:47 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 6385D9DCA15 + for ; + Wed, 1 Feb 2006 12:04:46 -0400 (AST) +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 k11G4ida000902; + Wed, 1 Feb 2006 11:04:44 -0500 (EST) +To: "FERREIRA, William (VALTECH)" +cc: pgsql-performance@postgresql.org +Subject: Re: execution plan : Oracle vs PostgreSQL +In-reply-to: + <414D259CE29DE54DAD534037C83CE4B726961D@FR0-MAILMB20.res.airbus.corp> +References: + <414D259CE29DE54DAD534037C83CE4B726961D@FR0-MAILMB20.res.airbus.corp> +Comments: In-reply-to "FERREIRA, + William (VALTECH)" + message dated "Wed, 01 Feb 2006 11:11:33 +0100" +Date: Wed, 01 Feb 2006 11:04:44 -0500 +Message-ID: <901.1138809884@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.102 required=5 tests=[AWL=0.102] +X-Spam-Score: 0.102 +X-Spam-Level: +X-Archive-Number: 200602/14 +X-Sequence-Number: 17000 + +"FERREIRA, William (VALTECH)" writes: +> My test document has 115000 nodes. +> the export of the document(extracting all informations from database and writing XML file on disk) takes 30s with Oracle and 5mn with Postgresql. +> The Oracle stored procedure is written in pl/sql and the Postgresql stored procedure in pl/perl (using spi_exec). + +So the test case involves 115000 executions of the same query via spi_exec? +That means the query will be re-parsed and re-planned 115000 times. If +you want something that's a reasonably fair comparison against Oracle, +try plpgsql which has query plan caching. + + regards, tom lane + +PS: please do NOT post EXPLAIN VERBOSE output unless someone +specifically asks for it. It clutters the archives and it's usually +useless. EXPLAIN ANALYZE is what we normally want to see for +performance issues. + +From pgsql-performance-owner@postgresql.org Wed Feb 1 12:33:45 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 572859DC809 + for ; + Wed, 1 Feb 2006 12:33:45 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 78918-07 + for ; + Wed, 1 Feb 2006 12:33:42 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from eads-av-smtp4.gmessaging.net (eads-av-smtp4.gmessaging.net + [194.51.201.29]) + by postgresql.org (Postfix) with ESMTP id 02E259DC803 + for ; + Wed, 1 Feb 2006 12:33:40 -0400 (AST) +Received: from eads-relay4.cesson.gm-adm (localhost [127.0.0.1]) + by eads-av-smtp4.gmessaging.net + (iPlanet Messaging Server 5.2 HotFix 2.04 (built Feb 8 2005)) + with ESMTP id <0IU0007FYOMJU2@eads-av-smtp4.gmessaging.net> for + pgsql-performance@postgresql.org; Wed, 01 Feb 2006 17:33:39 +0100 (MET) +Received: from fr0-mailsp01.res.airbus.corp ([10.254.251.54]) + by eads-av-smtp4.gmessaging.net + (iPlanet Messaging Server 5.2 HotFix 2.04 (built Feb 8 2005)) + with ESMTP id <0IU00097HONKMT@eads-av-smtp4.gmessaging.net> for + pgsql-performance@postgresql.org; Wed, 01 Feb 2006 17:33:26 +0100 (MET) +Received: from fr0-mailsp01.res.airbus.corp (localhost.localdomain + [127.0.0.1]) + by fr0-mailsp01.res.airbus.corp (8.12.11/8.12.10) with ESMTP id + k11GXHYb002634 + for ; Wed, 01 Feb 2006 17:33:17 +0100 +Received: from fr0-mailrt10.res.airbus.corp ([152.9.126.24]) + by fr0-mailsp01.res.airbus.corp (8.12.11/8.12.10) + with ESMTP id k11GXAvF002536; Wed, 01 Feb 2006 17:33:16 +0100 +Received: from fr0-mailrt04.res.airbus.corp ([152.9.126.23]) + by fr0-mailrt10.res.airbus.corp with Microsoft SMTPSVC(5.0.2195.6713); + Wed, 01 Feb 2006 17:33:15 +0100 +Received: from FR0-MAILMB20.res.airbus.corp ([152.9.126.74]) + by fr0-mailrt04.res.airbus.corp with Microsoft SMTPSVC(5.0.2195.6713); + Wed, 01 Feb 2006 17:33:15 +0100 +Date: Wed, 01 Feb 2006 17:33:15 +0100 +From: "FERREIRA, William (VALTECH)" +Subject: Re: execution plan : Oracle vs PostgreSQL +To: Tom Lane +Cc: pgsql-performance@postgresql.org +Message-id: + <414D259CE29DE54DAD534037C83CE4B726961E@FR0-MAILMB20.res.airbus.corp> +MIME-version: 1.0 +X-MIMEOLE: Produced By Microsoft Exchange V6.0.6603.0 +Content-type: text/plain; charset=iso-8859-1 +Content-transfer-encoding: quoted-printable +Content-class: urn:content-classes:message +Thread-topic: [PERFORM] execution plan : Oracle vs PostgreSQL +Thread-index: AcYnSWs8cu4GD/YBTcyFIvKka3qdtgAAGf0Q +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +X-OriginalArrivalTime: 01 Feb 2006 16:33:15.0612 (UTC) + FILETIME=[337839C0:01C6274D] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.242 required=5 tests=[AWL=0.242] +X-Spam-Score: 0.242 +X-Spam-Level: +X-Archive-Number: 200602/15 +X-Sequence-Number: 17001 + + +my first implementation was in pl/pgsql but when i query the children of a= + node, i need to store them into an array because i need to iterate over= + all the children and for each child, I test the type of it. +if it's a PI or a TEXT, i write it into a file, but if it's an element, i= + call the same function with new parameters (recursive call) and in= + consequence i can't use a cursor. + +in pl/pgsql, the result of a query is returned into a cursor, and in my= + implementation the only solution i found was to iterate over the cursor= + and to add children into an array. +i didn't found any solution to get all the children directly into an array= + (like the oracle BULK COLLECT). +So we chose pl/perl. + +maybe there is an other way to query children directly into an array and= + having query plan caching ? + +-----Message d'origine----- +De : Tom Lane [mailto:tgl@sss.pgh.pa.us] +Envoy=E9 : mercredi 1 f=E9vrier 2006 17:05 +=C0 : FERREIRA, William (VALTECH) +Cc : pgsql-performance@postgresql.org +Objet : Re: [PERFORM] execution plan : Oracle vs PostgreSQL + + + +"FERREIRA, William (VALTECH)" writes: +> My test document has 115000 nodes. +> the export of the document(extracting all informations from database and= + writing XML file on disk) takes 30s with Oracle and 5mn with Postgresql. +> The Oracle stored procedure is written in pl/sql and the Postgresql= + stored procedure in pl/perl (using spi_exec). + +So the test case involves 115000 executions of the same query via spi_exec? +That means the query will be re-parsed and re-planned 115000 times. If +you want something that's a reasonably fair comparison against Oracle, +try plpgsql which has query plan caching. + + regards, tom lane + +PS: please do NOT post EXPLAIN VERBOSE output unless someone +specifically asks for it. It clutters the archives and it's usually +useless. EXPLAIN ANALYZE is what we normally want to see for +performance issues. + +=0D +This mail has originated outside your organization, +either from an external partner or the Global Internet. +Keep this in mind if you answer this message. + +=0D +This e-mail is intended only for the above addressee. It may contain +privileged information. If you are not the addressee you must not copy, +distribute, disclose or use any of the information in it. If you have +received it in error please delete it and immediately notify the sender. +Security Notice: all e-mail, sent to or from this address, may be +accessed by someone other than the recipient, for system management and +security reasons. This access is controlled under Regulation of +Investigatory Powers Act 2000, Lawful Business Practises. + +From pgsql-performance-owner@postgresql.org Wed Feb 1 13:42:29 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 64B379DCA20 + for ; + Wed, 1 Feb 2006 13:42:28 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 96697-02 + for ; + Wed, 1 Feb 2006 13:42:27 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.Mi8.com (d01gw01.mi8.com [63.240.6.47]) + by postgresql.org (Postfix) with ESMTP id 061A09DC949 + for ; + Wed, 1 Feb 2006 13:42:25 -0400 (AST) +Received: from 172.16.1.25 by mail.Mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D1)); Wed, 01 Feb 2006 12:42:16 -0500 +X-Server-Uuid: 241911D6-425B-44B9-A073-E3FE0F8FC774 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.175]) by + D01HOST03.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Wed, 1 Feb + 2006 12:42:15 -0500 +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.106]) with Microsoft Exchange Server HTTP-DAV ; Wed, 1 Feb + 2006 17:42:14 +0000 +User-Agent: Microsoft-Entourage/11.2.1.051004 +Date: Wed, 01 Feb 2006 09:42:12 -0800 +Subject: Re: Huge Data sets, simple queries +From: "Luke Lonergan" +To: "PFC" , + "Jeffrey W. Baker" +cc: pgsql-performance@postgresql.org +Message-ID: +Thread-Topic: [PERFORM] Huge Data sets, simple queries +Thread-Index: AcYnDgi8W6A/b6ncQWWiAoo3F5S6bAASMw0g +In-Reply-To: +MIME-Version: 1.0 +X-OriginalArrivalTime: 01 Feb 2006 17:42:15.0259 (UTC) + FILETIME=[D6E43AB0:01C62756] +X-WSS-ID: 6FFE2D7D32K2442867-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, score=1.318 required=5 tests=[AWL=0.065, + RCVD_NUMERIC_HELO=1.253] +X-Spam-Score: 1.318 +X-Spam-Level: * +X-Archive-Number: 200602/16 +X-Sequence-Number: 17002 + +PFC, + + +On 2/1/06 1:01 AM, "PFC" wrote: + +> 3- Read one block of A, then one block of B, then one block of A, etc. +> Essentially this is the same as the threaded case, except there's only one +> thread. +> 53 seconds total (with heavy seeking noise from the hdd). +> +> I was half expecting 3 to take the same as 2. It simulates, for +> instance, +> scanning a table and its index, or scanning 2 sort bins. Well, maybe one +> day... + +This is actually interesting overall - I think what this might be showing is +that the Linux SW RAID1 is alternating I/Os to the mirror disks from +different processes (LWP or HWP both maybe?), but not within one process. + +> It would be nice if the Kernel had an API for applications to tell it +> "I'm gonna need these blocks in the next seconds, can you read them in the +> order you like (fastest), from whatever disk you like, and cache them for +> me please; so that I can read them in the order I like, but very fast ?" + +More control is always good IMO, but for now there's I/O reordering in the +SCSI layer and readahead tuning. There is POSIX fadvise() also to tell the +underlying I/O layer what the access pattern looks like. + +- Luke + + + +From pgsql-performance-owner@postgresql.org Wed Feb 1 13:55:37 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id F39299DCDCE + for ; + Wed, 1 Feb 2006 13:55:36 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 98434-04 + for ; + Wed, 1 Feb 2006 13:55:33 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from cassarossa.samfundet.no (cassarossa.samfundet.no + [129.241.93.19]) + by postgresql.org (Postfix) with ESMTP id 88A2E9DCD17 + for ; + Wed, 1 Feb 2006 13:55:31 -0400 (AST) +Received: from trofast.sesse.net ([129.241.93.32]) + by cassarossa.samfundet.no with esmtp (Exim 4.50) id 1F4MCY-0004q9-W0 + for pgsql-performance@postgresql.org; Wed, 01 Feb 2006 18:55:31 +0100 +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1F4MCd-0004AE-00 + for ; Wed, 01 Feb 2006 18:55:35 +0100 +Date: Wed, 1 Feb 2006 18:55:35 +0100 +From: "Steinar H. Gunderson" +To: pgsql-performance@postgresql.org +Subject: Re: Huge Data sets, simple queries +Message-ID: <20060201175535.GA15442@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.14.3 on a x86_64 +X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ +User-Agent: Mutt/1.5.11 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.073 required=5 tests=[AWL=0.073] +X-Spam-Score: 0.073 +X-Spam-Level: +X-Archive-Number: 200602/17 +X-Sequence-Number: 17003 + +On Wed, Feb 01, 2006 at 09:42:12AM -0800, Luke Lonergan wrote: +> This is actually interesting overall - I think what this might be showing is +> that the Linux SW RAID1 is alternating I/Os to the mirror disks from +> different processes (LWP or HWP both maybe?), but not within one process. + +Having read the code, I'm fairly certain it doesn't really care what process +anything is coming from. + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-performance-owner@postgresql.org Wed Feb 1 13:57:51 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id A53309DC88C + for ; + Wed, 1 Feb 2006 13:57:50 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 97675-09 + for ; + Wed, 1 Feb 2006 13:57:49 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from uproxy.gmail.com (uproxy.gmail.com [66.249.92.192]) + by postgresql.org (Postfix) with ESMTP id 21C309DC85F + for ; + Wed, 1 Feb 2006 13:57:47 -0400 (AST) +Received: by uproxy.gmail.com with SMTP id j40so45829ugd + for ; + Wed, 01 Feb 2006 09:57:48 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=pinxwUwh3WJBiktAorOCTFsjmhxea1ksyZIk8GyG1WgCtkJxU1RXoe3vI8AMvX+fSwWYUB0M1a3Vwbfr4RonRGNAhTyYLYcSeJsALAvl9lfAAl86M28qMI7nTsJYyxB65SMyrgNk3jyW7cyBMvzMOtdjYKuWjULdGhZtt449R44= +Received: by 10.49.92.10 with SMTP id u10mr1193714nfl; + Wed, 01 Feb 2006 09:57:47 -0800 (PST) +Received: by 10.49.15.20 with HTTP; Wed, 1 Feb 2006 09:57:47 -0800 (PST) +Message-ID: +Date: Wed, 1 Feb 2006 17:57:47 +0000 +From: Mike Rylander +To: Luke Lonergan +Subject: Re: Huge Data sets, simple queries +Cc: PFC , "Jeffrey W. Baker" , + 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, score=1.062 required=5 tests=[AWL=-0.270, + RCVD_IN_BL_SPAMCOP_NET=1.332] +X-Spam-Score: 1.062 +X-Spam-Level: * +X-Archive-Number: 200602/18 +X-Sequence-Number: 17004 + +On 2/1/06, Luke Lonergan wrote: +[snip] +> This is actually interesting overall - I think what this might be showing= + is +> that the Linux SW RAID1 is alternating I/Os to the mirror disks from +> different processes (LWP or HWP both maybe?), but not within one process. + +I can confirm this behavior after looking at my multipathed fibre +channel SAN. To the best of my knowledge, the multipathing code uses +the same underlying I/O code as the Linux SW RAID logic. + +-- +Mike Rylander +mrylander@gmail.com +GPLS -- PINES Development +Database Developer +http://open-ils.org + +From pgsql-performance-owner@postgresql.org Wed Feb 1 14:33:11 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 9DDC09DCDDE + for ; + Wed, 1 Feb 2006 14:33:10 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 05769-03 + for ; + Wed, 1 Feb 2006 14:33:09 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from gwmta.wicourts.gov (gwmta.wicourts.gov [165.219.244.99]) + by postgresql.org (Postfix) with ESMTP id 8CB659DCDCE + for ; + Wed, 1 Feb 2006 14:33:07 -0400 (AST) +Received: from Courts-MTA by gwmta.wicourts.gov + with Novell_GroupWise; Wed, 01 Feb 2006 12:33:07 -0600 +Message-Id: <43E0AA7E.EE98.0025.0@wicourts.gov> +X-Mailer: Novell GroupWise Internet Agent 7.0 +Date: Wed, 01 Feb 2006 12:33:02 -0600 +From: "Kevin Grittner" +To: +Subject: Planner reluctant to start from subquery +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200602/19 +X-Sequence-Number: 17005 + +We're converting from a commercial database product to PostgreSQL, and +generally things are going well. While the licensing agreement with the +commercial vendor prohibits publication of benchmarks without their +written consent, I'll just say that on almost everything, PostgreSQL is +faster. + +We do have a few queries where PostgreSQL is several orders of +magnitude slower. It appears that the reason it is choosing a bad plan +is that it is reluctant to start from a subquery when there is an outer +join in the FROM clause. Pasted below are four logically equivalent +queries. The first is a much stripped down version of one of the +production queries. The second turns the EXISTS expression into an IN +expression. (In the full query this makes very little difference; as I +pared down the query, the planner started to do better with the IN form +before the EXISTS form.) The third query is the fastest, but isn't +portable enough for our mixed environment. The fourth is the best +workaround I've found, but I get a bit queasy when I have to use the +DISTINCT modifier on a query. + +Any other suggestions? + +-Kevin + + +explain analyze +SELECT "C".*, "P"."partyNo" + FROM "Case" "C" + JOIN "Party" "P" ON ("C"."caseNo" = "P"."caseNo" AND "C"."countyNo" = +"P"."countyNo") + LEFT OUTER JOIN "WccaPermCaseType" "WPCT" + ON ( "C"."caseType" = "WPCT"."caseType" + AND "C"."countyNo" = "WPCT"."countyNo" + AND "WPCT"."profileName" = 'PUBLIC' + ) + WHERE ( "WPCT"."profileName" IS NOT NULL + OR ("C"."caseType" = 'PA' AND "C"."isConfidential" = false) + ) + AND "C"."countyNo" = 66 + AND EXISTS + ( + SELECT * + FROM "DocImageMetaData" "D" + WHERE "D"."isEFiling" = true + AND "D"."insertedDate" BETWEEN '2006-01-01' AND '2006-01-07' + AND "D"."countyNo" = 66 + AND "D"."countyNo" = "C"."countyNo" + AND "D"."caseNo" = "C"."caseNo" + ) + ORDER BY "caseNo" +; + + QUERY PLAN + +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Sort (cost=786467.94..786504.40 rows=14584 width=210) (actual +time=7391.295..7391.418 rows=51 loops=1) + Sort Key: "C"."caseNo" + -> Hash Left Join (cost=49.35..785459.30 rows=14584 width=210) +(actual time=6974.819..7390.802 rows=51 loops=1) + Hash Cond: ((("outer"."caseType")::bpchar = +("inner"."caseType")::bpchar) AND (("outer"."countyNo")::smallint = +("inner"."countyNo")::smallint)) + Filter: (("inner"."profileName" IS NOT NULL) OR +((("outer"."caseType")::bpchar = 'PA'::bpchar) AND (NOT +"outer"."isConfidential"))) + -> Merge Join (cost=0.00..783366.38 rows=14584 width=210) +(actual time=6972.672..7388.329 rows=51 loops=1) + Merge Cond: (("outer"."caseNo")::bpchar = +("inner"."caseNo")::bpchar) + -> Index Scan using "Case_pkey" on "Case" "C" +(cost=0.00..624268.11 rows=65025 width=208) (actual +time=4539.588..4927.730 rows=22 loops=1) + Index Cond: (("countyNo")::smallint = 66) + Filter: (subplan) + SubPlan + -> Index Scan using "DocImageMetaData_pkey" on +"DocImageMetaData" "D" (cost=0.00..3.89 rows=1 width=212) (actual +time=0.012..0.012 rows=0 loops=203171) + Index Cond: ((("countyNo")::smallint = 66) +AND (("countyNo")::smallint = ($0)::smallint) AND (("caseNo")::bpchar = +($1)::bpchar)) + Filter: ("isEFiling" AND +(("insertedDate")::date >= '2006-01-01'::date) AND +(("insertedDate")::date <= '2006-01-07'::date)) + -> Index Scan using "Party_pkey" on "Party" "P" +(cost=0.00..158657.86 rows=191084 width=22) (actual time=0.769..1646.381 +rows=354058 loops=1) + Index Cond: (66 = ("countyNo")::smallint) + -> Hash (cost=49.22..49.22 rows=27 width=31) (actual +time=1.919..1.919 rows=28 loops=1) + -> Bitmap Heap Scan on "WccaPermCaseType" "WPCT" +(cost=2.16..49.22 rows=27 width=31) (actual time=0.998..1.782 rows=28 +loops=1) + Recheck Cond: ((("countyNo")::smallint = 66) AND +(("profileName")::text = 'PUBLIC'::text)) + -> Bitmap Index Scan on "WccaPermCaseType_pkey" +(cost=0.00..2.16 rows=27 width=0) (actual time=0.684..0.684 rows=28 +loops=1) + Index Cond: ((("countyNo")::smallint = 66) +AND (("profileName")::text = 'PUBLIC'::text)) + Total runtime: 7392.577 ms +(22 rows) + +explain analyze +SELECT "C".*, "P"."partyNo" + FROM "Case" "C" + JOIN "Party" "P" ON ("C"."caseNo" = "P"."caseNo" AND "C"."countyNo" = +"P"."countyNo") + LEFT OUTER JOIN "WccaPermCaseType" "WPCT" + ON ( "C"."caseType" = "WPCT"."caseType" + AND "C"."countyNo" = "WPCT"."countyNo" + AND "WPCT"."profileName" = 'PUBLIC' + ) + WHERE ( "WPCT"."profileName" IS NOT NULL + OR ("C"."caseType" = 'PA' AND "C"."isConfidential" = false) + ) + AND "C"."countyNo" = 66 + AND "C"."caseNo" IN + ( + SELECT "D"."caseNo" + FROM "DocImageMetaData" "D" + WHERE "D"."isEFiling" = true + AND "D"."insertedDate" BETWEEN '2006-01-01' AND '2006-01-07' + AND "D"."countyNo" = 66 + ) + ORDER BY + "caseNo" + +; + + QUERY PLAN + +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Sort (cost=284708.49..284708.50 rows=1 width=210) (actual +time=8962.995..8963.103 rows=51 loops=1) + Sort Key: "C"."caseNo" + -> Hash Join (cost=2359.31..284708.48 rows=1 width=210) (actual +time=8401.856..8962.606 rows=51 loops=1) + Hash Cond: (("outer"."caseNo")::bpchar = +("inner"."caseNo")::bpchar) + -> Hash Left Join (cost=49.35..282252.68 rows=29167 +width=228) (actual time=32.120..8184.880 rows=312718 loops=1) + Hash Cond: ((("outer"."caseType")::bpchar = +("inner"."caseType")::bpchar) AND (("outer"."countyNo")::smallint = +("inner"."countyNo")::smallint)) + Filter: (("inner"."profileName" IS NOT NULL) OR +((("outer"."caseType")::bpchar = 'PA'::bpchar) AND (NOT +"outer"."isConfidential"))) + -> Merge Join (cost=0.00..278116.34 rows=29167 +width=228) (actual time=0.596..6236.238 rows=362819 loops=1) + Merge Cond: (("outer"."caseNo")::bpchar = +("inner"."caseNo")::bpchar) + -> Index Scan using "Case_pkey" on "Case" "C" +(cost=0.00..118429.72 rows=130049 width=208) (actual +time=0.265..1303.409 rows=203171 loops=1) + Index Cond: (("countyNo")::smallint = 66) + -> Index Scan using "Party_pkey" on "Party" "P" +(cost=0.00..158657.86 rows=191084 width=22) (actual time=0.303..2310.735 +rows=362819 loops=1) + Index Cond: (66 = ("countyNo")::smallint) + -> Hash (cost=49.22..49.22 rows=27 width=31) (actual +time=31.406..31.406 rows=28 loops=1) + -> Bitmap Heap Scan on "WccaPermCaseType" "WPCT" +(cost=2.16..49.22 rows=27 width=31) (actual time=23.498..31.284 rows=28 +loops=1) + Recheck Cond: ((("countyNo")::smallint = 66) +AND (("profileName")::text = 'PUBLIC'::text)) + -> Bitmap Index Scan on +"WccaPermCaseType_pkey" (cost=0.00..2.16 rows=27 width=0) (actual +time=17.066..17.066 rows=28 loops=1) + Index Cond: ((("countyNo")::smallint = +66) AND (("profileName")::text = 'PUBLIC'::text)) + -> Hash (cost=2309.95..2309.95 rows=1 width=18) (actual +time=24.255..24.255 rows=22 loops=1) + -> HashAggregate (cost=2309.94..2309.95 rows=1 +width=18) (actual time=24.132..24.185 rows=22 loops=1) + -> Index Scan using +"DocImageMetaData_CountyNoInsertedDate" on "DocImageMetaData" "D" +(cost=0.00..2309.93 rows=6 width=18) (actual time=7.362..23.933 rows=29 +loops=1) + Index Cond: ((("countyNo")::smallint = 66) +AND (("insertedDate")::date >= '2006-01-01'::date) AND +(("insertedDate")::date <= '2006-01-07'::date)) + Filter: "isEFiling" + Total runtime: 8964.044 ms +(24 rows) + +explain analyze +SELECT "C".*, "P"."partyNo" + FROM "Case" "C" + JOIN "Party" "P" ON ("C"."caseNo" = "P"."caseNo" AND "C"."countyNo" = +"P"."countyNo") + JOIN + ( + SELECT "D"."caseNo" + FROM "DocImageMetaData" "D" + WHERE "D"."isEFiling" = true + AND "D"."insertedDate" BETWEEN '2006-01-01' AND '2006-01-07' + AND "D"."countyNo" = 66 + GROUP BY "D"."caseNo" + ) "DD" + ON ("DD"."caseNo" = "C"."caseNo") + LEFT OUTER JOIN "WccaPermCaseType" "WPCT" + ON ( "C"."caseType" = "WPCT"."caseType" + AND "C"."countyNo" = "WPCT"."countyNo" + AND "WPCT"."profileName" = 'PUBLIC' + ) + WHERE ( "WPCT"."profileName" IS NOT NULL + OR ("C"."caseType" = 'PA' AND "C"."isConfidential" = false) + ) + AND "C"."countyNo" = 66 + ORDER BY + "caseNo" +; + + QUERY PLAN + +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Sort (cost=2321.49..2321.50 rows=1 width=210) (actual +time=7.753..7.859 rows=51 loops=1) + Sort Key: "C"."caseNo" + -> Nested Loop Left Join (cost=2309.94..2321.48 rows=1 width=210) +(actual time=3.982..7.369 rows=51 loops=1) + Join Filter: (("outer"."countyNo")::smallint = +("inner"."countyNo")::smallint) + Filter: (("inner"."profileName" IS NOT NULL) OR +((("outer"."caseType")::bpchar = 'PA'::bpchar) AND (NOT +"outer"."isConfidential"))) + -> Nested Loop (cost=2309.94..2317.99 rows=1 width=210) +(actual time=3.906..5.717 rows=51 loops=1) + -> Nested Loop (cost=2309.94..2313.51 rows=1 +width=240) (actual time=3.847..4.660 rows=22 loops=1) + -> HashAggregate (cost=2309.94..2309.95 rows=1 +width=18) (actual time=3.775..3.830 rows=22 loops=1) + -> Index Scan using +"DocImageMetaData_CountyNoInsertedDate" on "DocImageMetaData" "D" +(cost=0.00..2309.93 rows=6 width=18) (actual time=0.732..3.601 rows=29 +loops=1) + Index Cond: ((("countyNo")::smallint = +66) AND (("insertedDate")::date >= '2006-01-01'::date) AND +(("insertedDate")::date <= '2006-01-07'::date)) + Filter: "isEFiling" + -> Index Scan using "Case_pkey" on "Case" "C" +(cost=0.00..3.53 rows=1 width=208) (actual time=0.020..0.022 rows=1 +loops=22) + Index Cond: ((("C"."countyNo")::smallint = +66) AND (("outer"."caseNo")::bpchar = ("C"."caseNo")::bpchar)) + -> Index Scan using "Party_pkey" on "Party" "P" +(cost=0.00..4.46 rows=2 width=22) (actual time=0.019..0.028 rows=2 +loops=22) + Index Cond: ((66 = ("P"."countyNo")::smallint) AND +(("outer"."caseNo")::bpchar = ("P"."caseNo")::bpchar)) + -> Index Scan using "WccaPermCaseType_ProfileName" on +"WccaPermCaseType" "WPCT" (cost=0.00..3.47 rows=1 width=31) (actual +time=0.015..0.018 rows=1 loops=51) + Index Cond: ((("WPCT"."profileName")::text = +'PUBLIC'::text) AND (("outer"."caseType")::bpchar = +("WPCT"."caseType")::bpchar) AND (("WPCT"."countyNo")::smallint = 66)) + Total runtime: 8.592 ms +(18 rows) + +explain analyze +SELECT DISTINCT "C".*, "P"."partyNo" + FROM "Case" "C" + JOIN "Party" "P" ON ("P"."countyNo" = "C"."countyNo" AND "P"."caseNo" += "C"."caseNo") + JOIN "DocImageMetaData" "D" ON ("D"."countyNo" = "C"."countyNo" AND +"D"."caseNo" = "C"."caseNo") + LEFT OUTER JOIN "WccaPermCaseType" "WPCT" + ON ( "C"."caseType" = "WPCT"."caseType" + AND "C"."countyNo" = "WPCT"."countyNo" + AND "WPCT"."profileName" = 'PUBLIC' + ) + WHERE ( "WPCT"."profileName" IS NOT NULL + OR ("C"."caseType" = 'PA' AND "C"."isConfidential" = false) + ) + AND "C"."countyNo" = 66 + AND "D"."countyNo" = 66 + AND "D"."isEFiling" = true + AND "D"."insertedDate" BETWEEN '2006-01-01' AND '2006-01-07' + ORDER BY + "caseNo" +; + + + + + QUERY PLAN + + + + +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Unique (cost=2339.19..2339.28 rows=1 width=210) (actual +time=9.539..10.044 rows=51 loops=1) + -> Sort (cost=2339.19..2339.19 rows=1 width=210) (actual +time=9.532..9.678 rows=68 loops=1) + Sort Key: "C"."caseNo", "C"."countyNo", "C"."caseType", +"C"."filingDate", "C"."isConfidential", "C"."isDomesticViolence", +"C"."isFiledWoCtofc", "C"."lastChargeSeqNo", "C"."lastCvJgSeqNo", +"C"."lastHistSeqNo", "C"."lastPartySeqNo", "C"."lastRelSeqNo", +"C"."statusCode", "C"."bondId", "C"."branchId", "C".caption, +"C"."daCaseNo", "C"."dispCtofcNo", "C"."fileCtofcDate", +"C"."filingCtofcNo", "C"."issAgencyNo", "C"."maintCode", +"C"."oldCaseNo", "C"."plntfAgencyNo", "C"."previousRespCo", +"C"."prosAgencyNo", "C"."prosAtty", "C"."respCtofcNo", +"C"."wcisClsCode", "C"."isSeal", "C"."isExpunge", +"C"."isElectronicFiling", "C"."isPartySeal", "P"."partyNo" + -> Nested Loop Left Join (cost=0.00..2339.18 rows=1 +width=210) (actual time=0.857..7.901 rows=68 loops=1) + Join Filter: (("outer"."countyNo")::smallint = +("inner"."countyNo")::smallint) + Filter: (("inner"."profileName" IS NOT NULL) OR +((("outer"."caseType")::bpchar = 'PA'::bpchar) AND (NOT +"outer"."isConfidential"))) + -> Nested Loop (cost=0.00..2335.68 rows=1 width=210) +(actual time=0.786..5.784 rows=68 loops=1) + -> Nested Loop (cost=0.00..2331.20 rows=1 +width=226) (actual time=0.728..4.313 rows=29 loops=1) + -> Index Scan using +"DocImageMetaData_CountyNoInsertedDate" on "DocImageMetaData" "D" +(cost=0.00..2309.93 rows=6 width=20) (actual time=0.661..3.266 rows=29 +loops=1) + Index Cond: ((("countyNo")::smallint = +66) AND (("insertedDate")::date >= '2006-01-01'::date) AND +(("insertedDate")::date <= '2006-01-07'::date)) + Filter: "isEFiling" + -> Index Scan using "Case_pkey" on "Case" +"C" (cost=0.00..3.53 rows=1 width=208) (actual time=0.018..0.021 rows=1 +loops=29) + Index Cond: +((("C"."countyNo")::smallint = 66) AND (("outer"."caseNo")::bpchar = +("C"."caseNo")::bpchar)) + -> Index Scan using "Party_pkey" on "Party" "P" +(cost=0.00..4.46 rows=2 width=22) (actual time=0.018..0.027 rows=2 +loops=29) + Index Cond: ((66 = +("P"."countyNo")::smallint) AND (("P"."caseNo")::bpchar = +("outer"."caseNo")::bpchar)) + -> Index Scan using "WccaPermCaseType_ProfileName" on +"WccaPermCaseType" "WPCT" (cost=0.00..3.47 rows=1 width=31) (actual +time=0.014..0.017 rows=1 loops=68) + Index Cond: ((("WPCT"."profileName")::text = +'PUBLIC'::text) AND (("outer"."caseType")::bpchar = +("WPCT"."caseType")::bpchar) AND (("WPCT"."countyNo")::smallint = 66)) + Total runtime: 10.748 ms +(18 rows) + + +From pgsql-performance-owner@postgresql.org Wed Feb 1 15:34:28 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id D87FF9DC866 + for ; + Wed, 1 Feb 2006 15:34:27 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 17889-03 + for ; + Wed, 1 Feb 2006 15:34:28 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 9A9739DC946 + for ; + Wed, 1 Feb 2006 15:34:23 -0400 (AST) +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 k11JYOqN003760; + Wed, 1 Feb 2006 14:34:24 -0500 (EST) +To: "Kevin Grittner" +cc: pgsql-performance@postgresql.org +Subject: Re: Planner reluctant to start from subquery +In-reply-to: <43E0AA7E.EE98.0025.0@wicourts.gov> +References: <43E0AA7E.EE98.0025.0@wicourts.gov> +Comments: In-reply-to "Kevin Grittner" + message dated "Wed, 01 Feb 2006 12:33:02 -0600" +Date: Wed, 01 Feb 2006 14:34:24 -0500 +Message-ID: <3759.1138822464@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.103 required=5 tests=[AWL=0.103] +X-Spam-Score: 0.103 +X-Spam-Level: +X-Archive-Number: 200602/20 +X-Sequence-Number: 17006 + +"Kevin Grittner" writes: +> We do have a few queries where PostgreSQL is several orders of +> magnitude slower. It appears that the reason it is choosing a bad plan +> is that it is reluctant to start from a subquery when there is an outer +> join in the FROM clause. + +AFAICT this case doesn't really hinge on the outer join at all. The +problem is that EXISTS subqueries aren't well optimized. I would have +expected an equivalent IN clause to work better. In fact, I'm not +clear why the planner isn't finding the cheapest plan (which it does +estimate as cheapest) from the IN version you posted. What PG version +is this exactly? + +> ... The third query is the fastest, but isn't +> portable enough for our mixed environment. + +Not really relevant to the problem, but what's wrong with it? Looks +like standard SQL to me. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Feb 1 16:00:21 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id A60649DC866 + for ; + Wed, 1 Feb 2006 16:00:20 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 22618-02 + for ; + Wed, 1 Feb 2006 16:00:20 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from gwmta.wicourts.gov (gwmta.wicourts.gov [165.219.244.99]) + by postgresql.org (Postfix) with ESMTP id EC79C9DC85F + for ; + Wed, 1 Feb 2006 16:00:14 -0400 (AST) +Received: from Courts-MTA by gwmta.wicourts.gov + with Novell_GroupWise; Wed, 01 Feb 2006 14:00:15 -0600 +Message-Id: <43E0BEDD.EE98.0025.0@wicourts.gov> +X-Mailer: Novell GroupWise Internet Agent 7.0 +Date: Wed, 01 Feb 2006 13:59:57 -0600 +From: "Kevin Grittner" +To: "Tom Lane" +Cc: +Subject: Re: Planner reluctant to start from subquery +References: + <43E0AA7E.EE98.0025.0@wicourts.gov><43E0AA7E.EE98.0025.0@wicourts.gov> + <3759.1138822464@sss.pgh.pa.us> +In-Reply-To: <3759.1138822464@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.016 required=5 tests=[AWL=0.016] +X-Spam-Score: 0.016 +X-Spam-Level: +X-Archive-Number: 200602/21 +X-Sequence-Number: 17007 + +>>> On Wed, Feb 1, 2006 at 1:34 pm, in message +<3759.1138822464@sss.pgh.pa.us>, +Tom Lane wrote: +> "Kevin Grittner" writes: +>> We do have a few queries where PostgreSQL is several orders of +>> magnitude slower. It appears that the reason it is choosing a bad +plan +>> is that it is reluctant to start from a subquery when there is an +outer +>> join in the FROM clause. +> +> AFAICT this case doesn't really hinge on the outer join at all. The +> problem is that EXISTS subqueries aren't well optimized. I would +have +> expected an equivalent IN clause to work better. In fact, I'm not +> clear why the planner isn't finding the cheapest plan (which it does +> estimate as cheapest) from the IN version you posted. + +All I know is that trying various permutations, I saw it pick a good +plan for the IN format when I eliminated the last outer join in the FROM +clause. I know it isn't conclusive, but it was a correlation which +suggested a possible causality to me. The EXISTS never chose a +reasonable plan on this one, although we haven't had a problem with them +in most cases. + +> What PG version is this exactly? + +select version() reports: + + PostgreSQL 8.1.2 on i686-pc-mingw32, compiled by GCC gcc.exe (GCC) +3.4.2 (mingw-special) + +However, this was actually built off the 8.1 stable branch as of Jan. +13th at about 3 p.m. This build does contain the implementation of +standard_conforming_strings for which I recently posted a patch. The +make was configured with: --enable-integer-datetimes --enable-debug +--disable-nls + +> +>> ... The third query is the fastest, but isn't +>> portable enough for our mixed environment. +> +> Not really relevant to the problem, but what's wrong with it? Looks +> like standard SQL to me. + +It is absolutely compliant with the standards. Unfortunately, we are +under a "lowest common denominator" portability mandate. I notice that +support for this syntax has improved since we last set our limits; I'll +try to get this added to our allowed techniques. + +I can't complain about the portability mandate -- without it, we would +undoubtedly have had product specific code for the commercial product +which would have made migration to PostgreSQL much more painful. + +-Kevin + + + +From pgsql-performance-owner@postgresql.org Wed Feb 1 16:18:14 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 50D839DC89F + for ; + Wed, 1 Feb 2006 16:18:13 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 26131-03 + for ; + Wed, 1 Feb 2006 16:18:13 -0400 (AST) +X-Greylist: delayed 00:05:06.651322 by SQLgrey- +Received: from nz.telogis.com (unknown [203.98.10.169]) + by postgresql.org (Postfix) with ESMTP id 1F5139DC85F + for ; + Wed, 1 Feb 2006 16:18:10 -0400 (AST) +Received: from [192.168.3.1] ([::ffff:192.168.3.1]) + by nz.telogis.com with esmtp; Thu, 02 Feb 2006 09:12:59 +1300 + id 00728B95.43E1164C.00004C5E +Message-ID: <43E1164B.7020104@telogis.com> +Date: Thu, 02 Feb 2006 09:12:59 +1300 +From: Ralph Mason +User-Agent: Thunderbird 1.4 (Windows/20050908) +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Index Usage using IN +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, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200602/23 +X-Sequence-Number: 17009 + +Hi, + +I have 2 tables both have an index on ID (both ID columns are an oid). + +I want to find only only rows in one and not the other. + +Select ID from TableA where ID not IN ( Select ID from Table B) + +This always generates sequential scans. + +Table A has about 250,000 rows. Table B has about 250,000 Rows. + +We should get a Scan on Table B and a Index Lookup on Table A. + +Is there any way to force this? enable_seqscan off doesn't help at all. + +The Plan is + +Seq Scan on tablea(cost=100000000.00..23883423070450.96 rows=119414 width=4) + Filter: (NOT (subplan))" + SubPlan -> + Seq Scan on tableb (cost=100000000.00..100004611.17 rows=242617 +width=4) + + +Thanks +Ralph + + + + +From pgsql-performance-owner@postgresql.org Wed Feb 1 16:14:47 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 55BF39DCBD2 + for ; + Wed, 1 Feb 2006 16:14:47 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 24952-04 + for ; + Wed, 1 Feb 2006 16:14:47 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id C0C439DCB4B + for ; + Wed, 1 Feb 2006 16:14:44 -0400 (AST) +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 k11KEjkY004219; + Wed, 1 Feb 2006 15:14:45 -0500 (EST) +To: "Kevin Grittner" +cc: pgsql-performance@postgresql.org +Subject: Re: Planner reluctant to start from subquery +In-reply-to: <43E0BEDD.EE98.0025.0@wicourts.gov> +References: + <43E0AA7E.EE98.0025.0@wicourts.gov><43E0AA7E.EE98.0025.0@wicourts.gov> + <3759.1138822464@sss.pgh.pa.us> <43E0BEDD.EE98.0025.0@wicourts.gov> +Comments: In-reply-to "Kevin Grittner" + message dated "Wed, 01 Feb 2006 13:59:57 -0600" +Date: Wed, 01 Feb 2006 15:14:45 -0500 +Message-ID: <4218.1138824885@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.103 required=5 tests=[AWL=0.103] +X-Spam-Score: 0.103 +X-Spam-Level: +X-Archive-Number: 200602/22 +X-Sequence-Number: 17008 + +"Kevin Grittner" writes: +> Tom Lane wrote: +>> ... expected an equivalent IN clause to work better. In fact, I'm not +>> clear why the planner isn't finding the cheapest plan (which it does +>> estimate as cheapest) from the IN version you posted. + +> All I know is that trying various permutations, I saw it pick a good +> plan for the IN format when I eliminated the last outer join in the FROM +> clause. I know it isn't conclusive, but it was a correlation which +> suggested a possible causality to me. + +But there is still an outer join in your third example (the one with the +best plan), so that doesn't seem to hold water. In any case, the way +that IN planning works these days it really should have considered the +plan equivalent to your JOIN-against-GROUP-BY variant. + +I'm interested to poke at this ... are you in a position to provide a +test case? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Feb 1 16:22:55 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id ED0A09DC85F + for ; + Wed, 1 Feb 2006 16:22:54 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25298-08 + for ; + Wed, 1 Feb 2006 16:22:54 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from gghcwest.com (adsl-71-128-90-172.dsl.pltn13.pacbell.net + [71.128.90.172]) + by postgresql.org (Postfix) with ESMTP id D79B79DCDDE + for ; + Wed, 1 Feb 2006 16:22:51 -0400 (AST) +Received: from toonses.gghcwest.com (toonses.gghcwest.com [192.168.168.115]) + by gghcwest.com (8.12.10/8.12.9) with ESMTP id k11KMomd019604 + for ; Wed, 1 Feb 2006 12:22:50 -0800 +Received: from jwb by toonses.gghcwest.com with local (Exim 4.52) + id 1F4OV9-0002EG-HF + for pgsql-performance@postgresql.org; Wed, 01 Feb 2006 12:22:51 -0800 +Subject: Re: Index Usage using IN +From: "Jeffrey W. Baker" +To: pgsql-performance@postgresql.org +In-Reply-To: <43E1164B.7020104@telogis.com> +References: <43E1164B.7020104@telogis.com> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Date: Wed, 01 Feb 2006 12:22:50 -0800 +Message-Id: <1138825370.8376.5.camel@toonses.gghcwest.com> +Mime-Version: 1.0 +X-Mailer: Evolution 2.4.1 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.09 required=5 tests=[AWL=0.090] +X-Spam-Score: 0.09 +X-Spam-Level: +X-Archive-Number: 200602/24 +X-Sequence-Number: 17010 + +On Thu, 2006-02-02 at 09:12 +1300, Ralph Mason wrote: +> Hi, +> +> I have 2 tables both have an index on ID (both ID columns are an oid). +> +> I want to find only only rows in one and not the other. +> +> Select ID from TableA where ID not IN ( Select ID from Table B) + +Have you considered this: + +SELECT ID from TableA EXCEPT Select ID from Table B + +? + +-jwb + + +From pgsql-performance-owner@postgresql.org Wed Feb 1 16:24:59 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id A726D9DCBD2 + for ; + Wed, 1 Feb 2006 16:24:58 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25203-08 + for ; + Wed, 1 Feb 2006 16:24:59 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from gwmta.wicourts.gov (gwmta.wicourts.gov [165.219.244.99]) + by postgresql.org (Postfix) with ESMTP id F00279DCB4B + for ; + Wed, 1 Feb 2006 16:24:55 -0400 (AST) +Received: from Courts-MTA by gwmta.wicourts.gov + with Novell_GroupWise; Wed, 01 Feb 2006 14:24:57 -0600 +Message-Id: <43E0C4A7.EE98.0025.0@wicourts.gov> +X-Mailer: Novell GroupWise Internet Agent 7.0 +Date: Wed, 01 Feb 2006 14:24:39 -0600 +From: "Kevin Grittner" +To: "Tom Lane" +Cc: +Subject: Re: Planner reluctant to start from subquery +References: <43E0AA7E.EE98.0025.0@wicourts.gov> + <43E0AA7E.EE98.0025.0@wicourts.gov> <3759.1138822464@sss.pgh.pa.us> + <43E0BEDD.EE98.0025.0@wicourts.gov><43E0BEDD.EE98.0025.0@wicourts.gov> + <4218.1138824885@sss.pgh.pa.us> +In-Reply-To: <4218.1138824885@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.028 required=5 tests=[AWL=0.028] +X-Spam-Score: 0.028 +X-Spam-Level: +X-Archive-Number: 200602/25 +X-Sequence-Number: 17011 + +>>> On Wed, Feb 1, 2006 at 2:14 pm, in message +<4218.1138824885@sss.pgh.pa.us>, +Tom Lane wrote: +> "Kevin Grittner" writes: +>> Tom Lane wrote: +>>> ... expected an equivalent IN clause to work better. In fact, I'm +not +>>> clear why the planner isn't finding the cheapest plan (which it +does +>>> estimate as cheapest) from the IN version you posted. +> +>> All I know is that trying various permutations, I saw it pick a +good +>> plan for the IN format when I eliminated the last outer join in the +FROM +>> clause. I know it isn't conclusive, but it was a correlation which +>> suggested a possible causality to me. +> +> But there is still an outer join in your third example (the one with +the +> best plan), so that doesn't seem to hold water. + +Right, if I moved the DocImageMetaData from a subquery in the WHERE +clause up to the FROM clause, or I eliminated all OUTER JOINs, it chose +a good plan. Of course, this was just playing with a few dozen +permutations, so it proves nothing -- I'm just sayin'.... + +> In any case, the way +> that IN planning works these days it really should have considered +the +> plan equivalent to your JOIN- against- GROUP- BY variant. +> +> I'm interested to poke at this ... are you in a position to provide +a +> test case? + +I can't supply the original data, since many of the tables have +millions of rows, with some of the data (related to juvenile, paternity, +sealed, and expunged cases) protected by law. I could try to put +together a self-contained example, but I'm not sure the best way to do +that, since the table sizes and value distributions may be significant +here. Any thoughts on that? + +-Kevin + + + +From pgsql-performance-owner@postgresql.org Wed Feb 1 16:28:22 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 530189DCAA7 + for ; + Wed, 1 Feb 2006 16:28:22 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25300-08 + for ; + Wed, 1 Feb 2006 16:28:22 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from gghcwest.com (adsl-71-128-90-172.dsl.pltn13.pacbell.net + [71.128.90.172]) + by postgresql.org (Postfix) with ESMTP id 0FB909DC85F + for ; + Wed, 1 Feb 2006 16:28:18 -0400 (AST) +Received: from toonses.gghcwest.com (toonses.gghcwest.com [192.168.168.115]) + by gghcwest.com (8.12.10/8.12.9) with ESMTP id k11KSImd020153 + for ; Wed, 1 Feb 2006 12:28:18 -0800 +Received: from jwb by toonses.gghcwest.com with local (Exim 4.52) + id 1F4OaR-0002Eb-JN + for pgsql-performance@postgresql.org; Wed, 01 Feb 2006 12:28:19 -0800 +Subject: Re: Index Usage using IN +From: "Jeffrey W. Baker" +To: pgsql-performance@postgresql.org +In-Reply-To: <1138825370.8376.5.camel@toonses.gghcwest.com> +References: <43E1164B.7020104@telogis.com> + <1138825370.8376.5.camel@toonses.gghcwest.com> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Date: Wed, 01 Feb 2006 12:28:19 -0800 +Message-Id: <1138825699.8376.8.camel@toonses.gghcwest.com> +Mime-Version: 1.0 +X-Mailer: Evolution 2.4.1 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.093 required=5 tests=[AWL=0.093, UPPERCASE_25_50=0] +X-Spam-Score: 0.093 +X-Spam-Level: +X-Archive-Number: 200602/26 +X-Sequence-Number: 17012 + +On Wed, 2006-02-01 at 12:22 -0800, Jeffrey W. Baker wrote: +> On Thu, 2006-02-02 at 09:12 +1300, Ralph Mason wrote: +> > Hi, +> > +> > I have 2 tables both have an index on ID (both ID columns are an oid). +> > +> > I want to find only only rows in one and not the other. +> > +> > Select ID from TableA where ID not IN ( Select ID from Table B) +> +> Have you considered this: +> +> SELECT ID from TableA EXCEPT Select ID from Table B + +Alternately: + + SELECT a.ID + FROM TableA AS a +LEFT JOIN TableB AS b + ON a.ID = b.ID + WHERE b.ID IS NULL + +-jwb + +From pgsql-performance-owner@postgresql.org Wed Feb 1 16:36:16 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 1D0C69DCB4B + for ; + Wed, 1 Feb 2006 16:36:16 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 26373-07 + for ; + Wed, 1 Feb 2006 16:36:16 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id E7C009DCAA7 + for ; + Wed, 1 Feb 2006 16:36:13 -0400 (AST) +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 k11KaF8a004360; + Wed, 1 Feb 2006 15:36:15 -0500 (EST) +To: "Kevin Grittner" +cc: pgsql-performance@postgresql.org +Subject: Re: Planner reluctant to start from subquery +In-reply-to: <43E0C4A7.EE98.0025.0@wicourts.gov> +References: <43E0AA7E.EE98.0025.0@wicourts.gov> + <43E0AA7E.EE98.0025.0@wicourts.gov> <3759.1138822464@sss.pgh.pa.us> + <43E0BEDD.EE98.0025.0@wicourts.gov><43E0BEDD.EE98.0025.0@wicourts.gov> + <4218.1138824885@sss.pgh.pa.us> <43E0C4A7.EE98.0025.0@wicourts.gov> +Comments: In-reply-to "Kevin Grittner" + message dated "Wed, 01 Feb 2006 14:24:39 -0600" +Date: Wed, 01 Feb 2006 15:36:15 -0500 +Message-ID: <4359.1138826175@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.103 required=5 tests=[AWL=0.103] +X-Spam-Score: 0.103 +X-Spam-Level: +X-Archive-Number: 200602/27 +X-Sequence-Number: 17013 + +"Kevin Grittner" writes: +> Tom Lane wrote: +>> I'm interested to poke at this ... are you in a position to provide a +>> test case? + +> I can't supply the original data, since many of the tables have +> millions of rows, with some of the data (related to juvenile, paternity, +> sealed, and expunged cases) protected by law. I could try to put +> together a self-contained example, but I'm not sure the best way to do +> that, since the table sizes and value distributions may be significant +> here. Any thoughts on that? + +I think that the only aspect of the data that really matters here is the +number of distinct values, which would affect decisions about whether +HashAggregate is appropriate or not. And you could probably get the +same thing to happen with at most a few tens of thousands of rows. + +Also, all we need to worry about is the columns used in the WHERE/JOIN +conditions, which looks to be mostly case numbers, dates, and county +identification ... how much confidential info is there in that? At +worst you could translate the case numbers to some randomly generated +identifiers. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Feb 1 16:41:11 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 7A02F9DCDE7 + for ; + Wed, 1 Feb 2006 16:41:10 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 27990-08 + for ; + Wed, 1 Feb 2006 16:41:11 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 124D79DCC07 + for ; + Wed, 1 Feb 2006 16:41:07 -0400 (AST) +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 k11Kf9uM004388; + Wed, 1 Feb 2006 15:41:09 -0500 (EST) +To: Ralph Mason +cc: pgsql-performance@postgresql.org +Subject: Re: Index Usage using IN +In-reply-to: <1138825370.8376.5.camel@toonses.gghcwest.com> +References: <43E1164B.7020104@telogis.com> + <1138825370.8376.5.camel@toonses.gghcwest.com> +Comments: In-reply-to "Jeffrey W. Baker" + message dated "Wed, 01 Feb 2006 12:22:50 -0800" +Date: Wed, 01 Feb 2006 15:41:09 -0500 +Message-ID: <4387.1138826469@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.103 required=5 tests=[AWL=0.103] +X-Spam-Score: 0.103 +X-Spam-Level: +X-Archive-Number: 200602/28 +X-Sequence-Number: 17014 + +"Jeffrey W. Baker" writes: +> On Thu, 2006-02-02 at 09:12 +1300, Ralph Mason wrote: +>> Select ID from TableA where ID not IN ( Select ID from Table B) + +> Have you considered this: + +> SELECT ID from TableA EXCEPT Select ID from Table B + +Also, increasing work_mem might persuade the planner to try a hashed +subplan, which'd be a lot better than what you have. Note that it's +quite unlikely that indexes are going to help for this. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Feb 1 16:43:14 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id EDA5B9DCC07 + for ; + Wed, 1 Feb 2006 16:43:13 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28879-06 + for ; + Wed, 1 Feb 2006 16:43:14 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from gwmta.wicourts.gov (gwmta.wicourts.gov [165.219.244.99]) + by postgresql.org (Postfix) with ESMTP id BCCC69DCC3F + for ; + Wed, 1 Feb 2006 16:43:11 -0400 (AST) +Received: from Courts-MTA by gwmta.wicourts.gov + with Novell_GroupWise; Wed, 01 Feb 2006 14:43:13 -0600 +Message-Id: <43E0C8F5.EE98.0025.0@wicourts.gov> +X-Mailer: Novell GroupWise Internet Agent 7.0 +Date: Wed, 01 Feb 2006 14:43:01 -0600 +From: "Kevin Grittner" +To: "Tom Lane" +Cc: +Subject: Re: Planner reluctant to start from subquery +References: <43E0AA7E.EE98.0025.0@wicourts.gov> + <43E0AA7E.EE98.0025.0@wicourts.gov> <3759.1138822464@sss.pgh.pa.us> + <43E0BEDD.EE98.0025.0@wicourts.gov> + <43E0BEDD.EE98.0025.0@wicourts.gov> <4218.1138824885@sss.pgh.pa.us> + <43E0C4A7.EE98.0025.0@wicourts.gov><43E0C4A7.EE98.0025.0@wicourts.gov> + <4359.1138826175@sss.pgh.pa.us> +In-Reply-To: <4359.1138826175@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.038 required=5 tests=[AWL=0.038] +X-Spam-Score: 0.038 +X-Spam-Level: +X-Archive-Number: 200602/29 +X-Sequence-Number: 17015 + +>>> On Wed, Feb 1, 2006 at 2:36 pm, in message +<4359.1138826175@sss.pgh.pa.us>, +Tom Lane wrote: +> "Kevin Grittner" writes: +>> Tom Lane wrote: +>>> I'm interested to poke at this ... are you in a position to provide +a +>>> test case? +> +>> I can't supply the original data, since many of the tables have +>> millions of rows, with some of the data (related to juvenile, +paternity, +>> sealed, and expunged cases) protected by law. I could try to put +>> together a self- contained example, but I'm not sure the best way to +do +>> that, since the table sizes and value distributions may be +significant +>> here. Any thoughts on that? +> +> I think that the only aspect of the data that really matters here is +the +> number of distinct values, which would affect decisions about +whether +> HashAggregate is appropriate or not. And you could probably get the +> same thing to happen with at most a few tens of thousands of rows. +> +> Also, all we need to worry about is the columns used in the +WHERE/JOIN +> conditions, which looks to be mostly case numbers, dates, and county +> identification ... how much confidential info is there in that? At +> worst you could translate the case numbers to some randomly +generated +> identifiers. + +OK, I could probably obliterate name, addresses, etc. in a copy of the +data (those aren't significant to the query anyway) and provide a test +case. However, I just found another clue. + +Since you were so confident it couldn't be the outer join, I went +looking for what else I changed at the same time. I eliminated the code +referencing that table, which contained an OR. I've seen ORs cause +nasty problems with optimizers in the past. I took out the OR in the +where clause, without eliminating that last outer join, and it optimized +fine. + +I'll hold off a bit to see if you still need the test case. ;-) + +-Kevin + + +From pgsql-performance-owner@postgresql.org Wed Feb 1 16:51:11 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id DEDE09DC85F + for ; + Wed, 1 Feb 2006 16:51:10 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 31937-02 + for ; + Wed, 1 Feb 2006 16:51:11 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from gwmta.wicourts.gov (gwmta.wicourts.gov [165.219.244.99]) + by postgresql.org (Postfix) with ESMTP id 7B4E79DC89F + for ; + Wed, 1 Feb 2006 16:51:07 -0400 (AST) +Received: from Courts-MTA by gwmta.wicourts.gov + with Novell_GroupWise; Wed, 01 Feb 2006 14:51:09 -0600 +Message-Id: <43E0CACA.EE98.0025.0@wicourts.gov> +X-Mailer: Novell GroupWise Internet Agent 7.0 +Date: Wed, 01 Feb 2006 14:50:51 -0600 +From: "Kevin Grittner" +To: "Tom Lane" , + "Kevin Grittner" +Cc: +Subject: Re: Planner reluctant to start from subquery +References: <43E0AA7E.EE98.0025.0@wicourts.gov> + <43E0AA7E.EE98.0025.0@wicourts.gov> <3759.1138822464@sss.pgh.pa.us> + <43E0BEDD.EE98.0025.0@wicourts.gov> + <43E0BEDD.EE98.0025.0@wicourts.gov> <4218.1138824885@sss.pgh.pa.us> + <43E0C4A7.EE98.0025.0@wicourts.gov> + <43E0C4A7.EE98.0025.0@wicourts.gov> <4359.1138826175@sss.pgh.pa.us> + <43E0C8F5.EE98.0025.0@wicourts.gov> +In-Reply-To: <43E0C8F5.EE98.0025.0@wicourts.gov> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.046 required=5 tests=[AWL=0.046] +X-Spam-Score: 0.046 +X-Spam-Level: +X-Archive-Number: 200602/30 +X-Sequence-Number: 17016 + +>>> On Wed, Feb 1, 2006 at 2:43 pm, in message +<43E0C8F5.EE98.0025.0@wicourts.gov>, "Kevin Grittner" + wrote: +> +> I took out the OR in the +> where clause, without eliminating that last outer join, and it +optimized +> fine. + +FYI, with both sides of the OR separated: + +explain analyze +SELECT "C".*, "P"."partyNo" + FROM "Case" "C" + JOIN "Party" "P" ON ("C"."caseNo" = "P"."caseNo" AND "C"."countyNo" = +"P"."countyNo") + LEFT OUTER JOIN "WccaPermCaseType" "WPCT" + ON ( "C"."caseType" = "WPCT"."caseType" + AND "C"."countyNo" = "WPCT"."countyNo" + AND "WPCT"."profileName" = 'PUBLIC' + ) + WHERE "WPCT"."profileName" IS NOT NULL + AND "C"."countyNo" = 66 + AND "C"."caseNo" IN + ( + SELECT "D"."caseNo" + FROM "DocImageMetaData" "D" + WHERE "D"."isEFiling" = true + AND "D"."insertedDate" BETWEEN '2006-01-01' AND '2006-01-07' + AND "D"."countyNo" = 66 + ) + ORDER BY + "caseNo" +; + + QUERY PLAN + +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Sort (cost=2321.48..2321.48 rows=1 width=210) (actual +time=5.908..6.001 rows=51 loops=1) + Sort Key: "C"."caseNo" + -> Nested Loop (cost=2309.94..2321.47 rows=1 width=210) (actual +time=3.407..5.605 rows=51 loops=1) + -> Nested Loop (cost=2309.94..2316.98 rows=1 width=226) +(actual time=3.353..4.659 rows=22 loops=1) + -> Nested Loop (cost=2309.94..2313.50 rows=1 +width=226) (actual time=3.301..4.023 rows=22 loops=1) + -> HashAggregate (cost=2309.94..2309.95 rows=1 +width=18) (actual time=3.251..3.300 rows=22 loops=1) + -> Index Scan using +"DocImageMetaData_CountyNoInsertedDate" on "DocImageMetaData" "D" +(cost=0.00..2309.93 rows=6 width=18) (actual time=0.681..3.141 rows=29 +loops=1) + Index Cond: ((("countyNo")::smallint = +66) AND (("insertedDate")::date >= '2006-01-01'::date) AND +(("insertedDate")::date <= '2006-01-07'::date)) + Filter: "isEFiling" + -> Index Scan using "Case_pkey" on "Case" "C" +(cost=0.00..3.53 rows=1 width=208) (actual time=0.018..0.020 rows=1 +loops=22) + Index Cond: ((("C"."countyNo")::smallint = +66) AND (("C"."caseNo")::bpchar = ("outer"."caseNo")::bpchar)) + -> Index Scan using "WccaPermCaseType_ProfileName" on +"WccaPermCaseType" "WPCT" (cost=0.00..3.47 rows=1 width=8) (actual +time=0.015..0.017 rows=1 loops=22) + Index Cond: ((("WPCT"."profileName")::text = +'PUBLIC'::text) AND (("outer"."caseType")::bpchar = +("WPCT"."caseType")::bpchar) AND (66 = ("WPCT"."countyNo")::smallint)) + Filter: ("profileName" IS NOT NULL) + -> Index Scan using "Party_pkey" on "Party" "P" +(cost=0.00..4.46 rows=2 width=22) (actual time=0.017..0.025 rows=2 +loops=22) + Index Cond: ((66 = ("P"."countyNo")::smallint) AND +(("outer"."caseNo")::bpchar = ("P"."caseNo")::bpchar)) + Total runtime: 6.511 ms +(17 rows) + +explain analyze +SELECT "C".*, "P"."partyNo" + FROM "Case" "C" + JOIN "Party" "P" ON ("C"."caseNo" = "P"."caseNo" AND "C"."countyNo" = +"P"."countyNo") + LEFT OUTER JOIN "WccaPermCaseType" "WPCT" + ON ( "C"."caseType" = "WPCT"."caseType" + AND "C"."countyNo" = "WPCT"."countyNo" + AND "WPCT"."profileName" = 'PUBLIC' + ) + WHERE "C"."caseType" = 'PA' AND "C"."isConfidential" = false + AND "C"."countyNo" = 66 + AND "C"."caseNo" IN + ( + SELECT "D"."caseNo" + FROM "DocImageMetaData" "D" + WHERE "D"."isEFiling" = true + AND "D"."insertedDate" BETWEEN '2006-01-01' AND '2006-01-07' + AND "D"."countyNo" = 66 + ) + ORDER BY + "caseNo" +; + + QUERY PLAN + +---------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Sort (cost=11527.21..11527.21 rows=1 width=210) (actual +time=107.449..107.449 rows=0 loops=1) + Sort Key: "C"."caseNo" + -> Nested Loop IN Join (cost=3.47..11527.20 rows=1 width=210) +(actual time=107.432..107.432 rows=0 loops=1) + -> Hash Left Join (cost=3.47..9637.44 rows=255 width=228) +(actual time=107.425..107.425 rows=0 loops=1) + Hash Cond: ((("outer"."caseType")::bpchar = +("inner"."caseType")::bpchar) AND (("outer"."countyNo")::smallint = +("inner"."countyNo")::smallint)) + -> Nested Loop (cost=0.00..9631.40 rows=255 width=228) +(actual time=107.418..107.418 rows=0 loops=1) + -> Index Scan using "Case_CaseTypeStatus" on +"Case" "C" (cost=0.00..4536.25 rows=1136 width=208) (actual +time=107.412..107.412 rows=0 loops=1) + Index Cond: ((("caseType")::bpchar = +'PA'::bpchar) AND (("countyNo")::smallint = 66)) + Filter: (NOT "isConfidential") + -> Index Scan using "Party_pkey" on "Party" "P" +(cost=0.00..4.46 rows=2 width=22) (never executed) + Index Cond: ((66 = +("P"."countyNo")::smallint) AND (("outer"."caseNo")::bpchar = +("P"."caseNo")::bpchar)) + -> Hash (cost=3.47..3.47 rows=1 width=8) (never +executed) + -> Index Scan using +"WccaPermCaseType_ProfileName" on "WccaPermCaseType" "WPCT" +(cost=0.00..3.47 rows=1 width=8) (never executed) + Index Cond: ((("profileName")::text = +'PUBLIC'::text) AND (("caseType")::bpchar = 'PA'::bpchar) AND +(("countyNo")::smallint = 66)) + -> Index Scan using "DocImageMetaData_pkey" on +"DocImageMetaData" "D" (cost=0.00..7.40 rows=1 width=18) (never +executed) + Index Cond: ((("D"."countyNo")::smallint = 66) AND +(("outer"."caseNo")::bpchar = ("D"."caseNo")::bpchar)) + Filter: ("isEFiling" AND (("insertedDate")::date >= +'2006-01-01'::date) AND (("insertedDate")::date <= '2006-01-07'::date)) + Total runtime: 107.860 ms +(18 rows) + + +From pgsql-performance-owner@postgresql.org Wed Feb 1 16:53:09 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id AC6E09DC85F + for ; + Wed, 1 Feb 2006 16:53:08 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 30643-08 + for ; + Wed, 1 Feb 2006 16:53:09 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 7111C9DC871 + for ; + Wed, 1 Feb 2006 16:53:06 -0400 (AST) +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 k11Kr8k8004612; + Wed, 1 Feb 2006 15:53:08 -0500 (EST) +To: "Kevin Grittner" +cc: pgsql-performance@postgresql.org +Subject: Re: Planner reluctant to start from subquery +In-reply-to: <43E0C8F5.EE98.0025.0@wicourts.gov> +References: <43E0AA7E.EE98.0025.0@wicourts.gov> + <43E0AA7E.EE98.0025.0@wicourts.gov> <3759.1138822464@sss.pgh.pa.us> + <43E0BEDD.EE98.0025.0@wicourts.gov> + <43E0BEDD.EE98.0025.0@wicourts.gov> <4218.1138824885@sss.pgh.pa.us> + <43E0C4A7.EE98.0025.0@wicourts.gov><43E0C4A7.EE98.0025.0@wicourts.gov> + <4359.1138826175@sss.pgh.pa.us> <43E0C8F5.EE98.0025.0@wicourts.gov> +Comments: In-reply-to "Kevin Grittner" + message dated "Wed, 01 Feb 2006 14:43:01 -0600" +Date: Wed, 01 Feb 2006 15:53:08 -0500 +Message-ID: <4611.1138827188@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.103 required=5 tests=[AWL=0.103] +X-Spam-Score: 0.103 +X-Spam-Level: +X-Archive-Number: 200602/31 +X-Sequence-Number: 17017 + +"Kevin Grittner" writes: +> Since you were so confident it couldn't be the outer join, I went +> looking for what else I changed at the same time. I eliminated the code +> referencing that table, which contained an OR. I've seen ORs cause +> nasty problems with optimizers in the past. I took out the OR in the +> where clause, without eliminating that last outer join, and it optimized +> fine. + +I don't think that OR is relevant either, since again it's present in +both the well-optimized and badly-optimized variants that you posted. + + regards, tom lane + +From pgsql-admin-owner@postgresql.org Wed Feb 1 17:16:50 2006 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 9B0E49DCDF7; + Wed, 1 Feb 2006 17:16:49 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 32989-10; Wed, 1 Feb 2006 17:16:50 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id D8EBE9DCDF3; + Wed, 1 Feb 2006 17:16:46 -0400 (AST) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 0624C39841; Wed, 1 Feb 2006 15:16:33 -0600 (CST) +Date: Wed, 1 Feb 2006 15:16:33 -0600 +From: "Jim C. Nasby" +To: pgsql-admin@postgresql.org, pgsql-performance@postgresql.org +Subject: Default autovacuum settings too conservative +Message-ID: <20060201211633.GM95850@pervasive.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +X-Operating-System: FreeBSD 6.0-RELEASE amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.104 required=5 tests=[AWL=0.104] +X-Spam-Score: 0.104 +X-Spam-Level: +X-Archive-Number: 200602/8 +X-Sequence-Number: 20429 + +As I recall, the idea behind vacuum_threshold was to prevent +too-frequent vacuuming of small tables. I'm beginning to question this +reasoning: + +Small tables vacuum very, very quickly, so 'extra' vacuuming is very +unlikely to hurt system performance. + +Small tables are most likely to have either very few updates (ie: a +'lookup table') or very frequent updates (ie: a table implementing a +queue). In the former, even with vacuum_threshold = 0 vacuum will be a +very rare occurance. In the later case, a high threshold is likely to +cause a large amount of un-nececcasry bloat. + +Also, vacuum_scale_factor of 0.4 seems unreasonably large. It means +tables will be 40% dead space, which seems excessively wasteful. +Something between 0.1 and 0.2 seems much better. + +Has anyone looked at how effective these two settings are? +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Wed Feb 1 17:15:16 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 53B899DCDF2 + for ; + Wed, 1 Feb 2006 17:15:15 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 33761-09 + for ; + Wed, 1 Feb 2006 17:15:15 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from wolff.to (wolff.to [66.93.197.194]) + by postgresql.org (Postfix) with SMTP id 52FF39DCDE3 + for ; + Wed, 1 Feb 2006 17:15:12 -0400 (AST) +Received: (qmail 2867 invoked by uid 500); 1 Feb 2006 21:23:03 -0000 +Date: Wed, 1 Feb 2006 15:23:03 -0600 +From: Bruno Wolff III +To: Ralph Mason +Cc: pgsql-performance@postgresql.org +Subject: Re: Index Usage using IN +Message-ID: <20060201212303.GA1212@wolff.to> +Mail-Followup-To: Bruno Wolff III , + Ralph Mason , + pgsql-performance@postgresql.org +References: <43E1164B.7020104@telogis.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <43E1164B.7020104@telogis.com> +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.09 required=5 tests=[AWL=0.090] +X-Spam-Score: 0.09 +X-Spam-Level: +X-Archive-Number: 200602/32 +X-Sequence-Number: 17018 + +On Thu, Feb 02, 2006 at 09:12:59 +1300, + Ralph Mason wrote: +> Hi, +> +> I have 2 tables both have an index on ID (both ID columns are an oid). +> +> I want to find only only rows in one and not the other. +> +> Select ID from TableA where ID not IN ( Select ID from Table B) +> +> This always generates sequential scans. +> +> Table A has about 250,000 rows. Table B has about 250,000 Rows. +> +> We should get a Scan on Table B and a Index Lookup on Table A. + +I don't think that is going to work if there are NULLs in table B. +I don't know whether or not Postgres has code to special case NULL testing +(either for constraints ruling them out, or doing probes for them in addition +to the key it is trying to match) for doing NOT IN. Just doing a simple +index probe into table A isn't going to tell you all you need to know if +you don't find a match. + +From pgsql-admin-owner@postgresql.org Wed Feb 1 17:37:11 2006 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 944DD9DC871; + Wed, 1 Feb 2006 17:37:10 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 40596-01; Wed, 1 Feb 2006 17:37:11 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from outbound.mailhop.org (outbound.mailhop.org [63.208.196.171]) + by postgresql.org (Postfix) with ESMTP id 418289DC85F; + Wed, 1 Feb 2006 17:37:06 -0400 (AST) +Received: from ool-4350c7ad.dyn.optonline.net ([67.80.199.173] + helo=[192.168.0.91]) by outbound.mailhop.org with esmtpa (Exim 4.51) + id 1F4Pf2-000McF-8Z; Wed, 01 Feb 2006 16:37:08 -0500 +X-Mail-Handler: MailHop Outbound by DynDNS +X-Originating-IP: 67.80.199.173 +X-Report-Abuse-To: abuse@dyndns.com (see + http://www.mailhop.org/outbound/abuse.html for abuse reporting + information) +X-MHO-User: zeut +Message-ID: <43E12A03.6070906@zeut.net> +Date: Wed, 01 Feb 2006 16:37:07 -0500 +From: "Matthew T. O'Connor" +User-Agent: Thunderbird 1.4 (Windows/20050908) +MIME-Version: 1.0 +To: "Jim C. Nasby" +CC: pgsql-admin@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Default autovacuum settings too conservative +References: <20060201211633.GM95850@pervasive.com> +In-Reply-To: <20060201211633.GM95850@pervasive.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, score=0.112 required=5 tests=[AWL=0.112] +X-Spam-Score: 0.112 +X-Spam-Level: +X-Archive-Number: 200602/10 +X-Sequence-Number: 20431 + +Jim C. Nasby wrote: +> Small tables are most likely to have either very few updates (ie: a +> 'lookup table') or very frequent updates (ie: a table implementing a +> queue). In the former, even with vacuum_threshold = 0 vacuum will be a +> very rare occurance. In the later case, a high threshold is likely to +> cause a large amount of un-nececcasry bloat. + +Well a threshold of 0 won't work because then a 0 tuple table will get +vacuumed every time. Or at least autovacuum needs to special case this. + +> Also, vacuum_scale_factor of 0.4 seems unreasonably large. It means +> tables will be 40% dead space, which seems excessively wasteful. +> Something between 0.1 and 0.2 seems much better. + +Depends on the app and the usage patterns as to what too much slack +space is. + +> Has anyone looked at how effective these two settings are? + +As far I as I know, we are still looking for real world feedback. 8.1 +is the first release to have the integrated autovacuum. The thresholds +in 8.1 are a good bit less conservative than the thresholds in the +contrib version. The contrib thresholds were universally considered WAY +to conservative, but that was somewhat necessary since you couldn't set +them on a per table basis as you can in 8.1. If we continue to hear +from people that the current 8.1 default thresholds are still to +conservative we can look into lowering them. + +I think the default settings should be designed to minimize the impact +autovacuum has on the system while preventing the system from ever +getting wildly bloated (also protect xid wraparound, but that doesn't +have anything to do with the thresholds). + +Matt + +From pgsql-performance-owner@postgresql.org Wed Feb 1 18:13:01 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 700E99DC89F + for ; + Wed, 1 Feb 2006 18:13:01 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 43723-07 + for ; + Wed, 1 Feb 2006 18:13:00 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.206]) + by postgresql.org (Postfix) with ESMTP id F3B699DC871 + for ; + Wed, 1 Feb 2006 18:12:56 -0400 (AST) +Received: by zproxy.gmail.com with SMTP id 16so249888nzp + for ; + Wed, 01 Feb 2006 14:12:59 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding; + b=S8YyTTmzHdYM2Fre0FM2o/H5SOpgq6sZwC1cuM29NmHsJoMyatNn3Kk/GuhaP6HLID+oCinxHQr4mtTjachjEuyiOrd1YGdFT8EpslY7uOva2OUTXPUUXgdGyWySM0NCFlHLSi1KwWyBnRcN3PoKC7GGsNeexOHz7516zPqabWk= +Received: by 10.64.10.17 with SMTP id 17mr24963qbj; + Wed, 01 Feb 2006 14:12:59 -0800 (PST) +Received: from ?64.161.133.227? ( [64.161.133.227]) + by mx.gmail.com with ESMTP id f17sm581319qba.2006.02.01.14.12.58; + Wed, 01 Feb 2006 14:12:58 -0800 (PST) +Message-ID: <43E13266.2090101@gmail.com> +Date: Wed, 01 Feb 2006 14:12:54 -0800 +From: Hari Warrier +User-Agent: Thunderbird 1.5 (Windows/20051201) +MIME-Version: 1.0 +To: Ralph Mason +CC: pgsql-performance@postgresql.org +Subject: Re: Index Usage using IN +References: <43E1164B.7020104@telogis.com> +In-Reply-To: <43E1164B.7020104@telogis.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, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200602/35 +X-Sequence-Number: 17021 + + +Select ID from TableA where not exists ( Select ID from Table B where ID += TableA.ID) +might give you index scan. Of course, that is only useful is TableA is +very small table. +Not appropriate for 250k rows + +on 2/1/2006 12:12 PM Ralph Mason said the following: +> Hi, +> +> I have 2 tables both have an index on ID (both ID columns are an oid). +> +> I want to find only only rows in one and not the other. +> +> Select ID from TableA where ID not IN ( Select ID from Table B) +> +> This always generates sequential scans. +> +> Table A has about 250,000 rows. Table B has about 250,000 Rows. +> +> We should get a Scan on Table B and a Index Lookup on Table A. +> +> Is there any way to force this? enable_seqscan off doesn't help at all. +> +> The Plan is +> +> Seq Scan on tablea(cost=100000000.00..23883423070450.96 rows=119414 +> width=4) +> Filter: (NOT (subplan))" +> SubPlan -> Seq Scan on tableb (cost=100000000.00..100004611.17 +> rows=242617 width=4) +> +> +> Thanks +> Ralph +> +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 6: explain analyze is your friend +> + + +From pgsql-performance-owner@postgresql.org Thu Feb 2 00:47:26 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 1746D9DC9E7 + for ; + Thu, 2 Feb 2006 00:47:25 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 26446-01 + for ; + Thu, 2 Feb 2006 00:47:21 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.Mi8.com (d01gw01.mi8.com [63.240.6.47]) + by postgresql.org (Postfix) with ESMTP id 9FFD39DC807 + for ; + Thu, 2 Feb 2006 00:47:20 -0400 (AST) +Received: from 172.16.1.148 by mail.Mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D1)); Wed, 01 Feb 2006 23:47:12 -0500 +X-Server-Uuid: 241911D6-425B-44B9-A073-E3FE0F8FC774 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.175]) by + D01HOST02.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Wed, 1 Feb + 2006 23:47:11 -0500 +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.105]) with Microsoft Exchange Server HTTP-DAV ; Thu, 2 Feb + 2006 04:47:11 +0000 +User-Agent: Microsoft-Entourage/11.2.1.051004 +Date: Wed, 01 Feb 2006 20:47:09 -0800 +Subject: Re: Huge Data sets, simple queries +From: "Luke Lonergan" +To: "Jeffrey W. Baker" , + "Lance Lierheimer" +cc: pgsql-performance@postgresql.org +Message-ID: +Thread-Topic: [PERFORM] Huge Data sets, simple queries +Thread-Index: AcYnCQ7Mv1XVKnpYSsuSoYyFtgu+SwAqqqcy +In-Reply-To: <1138782313.14732.1.camel@noodles> +MIME-Version: 1.0 +X-OriginalArrivalTime: 02 Feb 2006 04:47:11.0712 (UTC) + FILETIME=[BB07D600:01C627B3] +X-WSS-ID: 6FFF515A32K2829519-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, score=1.35 required=5 tests=[AWL=0.097, + RCVD_NUMERIC_HELO=1.253] +X-Spam-Score: 1.35 +X-Spam-Level: * +X-Archive-Number: 200602/36 +X-Sequence-Number: 17022 + +Jeffrey, + +On 2/1/06 12:25 AM, "Jeffrey W. Baker" wrote: + +> Ah, but someday Pg will be able to concurrently read from two +> datastreams to complete a single query. And that day will be glorious +> and fine, and you'll want as much disk concurrency as you can get your +> hands on. + +Well - so happens that we have one of those multi-processing postgres' +handy, so we'll test this theory out in the next couple of days. We've a +customer who ordered 3 machines with 6 drives each (Dell 2850s) on two U320 +SCSI busses, and we're going to try configuring them all in a single RAID10 +and run two Bizgres MPP segments on that (along with two mirrors). + +We'll try the RAID10 config and if we get full parallelism, we'll use it (if +the customer like it). Otherwise, we'll use two 3 disk RAID5 sets. + +I'll post the results here. + +Thanks Jeffrey, + +- Luke + + + +From pgsql-performance-owner@postgresql.org Thu Feb 2 03:10:03 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id E306E9DC817 + for ; + Thu, 2 Feb 2006 03:10:02 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 56060-05 + for ; + Thu, 2 Feb 2006 03:10:02 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.196]) + by postgresql.org (Postfix) with ESMTP id 4CDC49DC81D + for ; + Thu, 2 Feb 2006 03:09:58 -0400 (AST) +Received: by xproxy.gmail.com with SMTP id i30so240179wxd + for ; + Wed, 01 Feb 2006 23:09:59 -0800 (PST) +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=L3xi7v4OZLBBbyVngOiU6IlQpbVv5/MyQWxnCSPLbA5UIfA42gyPj+oG/iMSzbbQm+d+SSWoM+rDUVnPEfD7LuRkoBApIPkb88Z0nVZTuYNbQizs94KMBinJLWksUVwHq9Jskdwy1prd1JAoVgSzoeovRpBSHLw3cNz7Y3TxGGs= +Received: by 10.70.74.19 with SMTP id w19mr556959wxa; + Wed, 01 Feb 2006 23:09:59 -0800 (PST) +Received: by 10.70.62.5 with HTTP; Wed, 1 Feb 2006 23:09:59 -0800 (PST) +Message-ID: <580055310602012309o40b9b0d4g@mail.gmail.com> +Date: Thu, 2 Feb 2006 12:39:59 +0530 +From: Pradeep Parmar +To: pgsql-performance@postgresql.org +Subject: pgbench output +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_845_26377674.1138864199026" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=1.066 required=5 tests=[AWL=0.120, HTML_10_20=0.945, + HTML_MESSAGE=0.001] +X-Spam-Score: 1.066 +X-Spam-Level: * +X-Archive-Number: 200602/37 +X-Sequence-Number: 17023 + +------=_Part_845_26377674.1138864199026 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Hi, + +I'm fairly new to PostgreSQL. I was trying pgbench , but could not +understand the output . Can anyone help me out to understand the output of +pgbench + + +----Pradeep + +------=_Part_845_26377674.1138864199026 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Hi,

I'm fairly new to PostgreSQL. I was trying pgbench , but could n= +ot understand the output . Can anyone help me out to understand the output = +of pgbench


----Pradeep
+ +------=_Part_845_26377674.1138864199026-- + +From pgsql-performance-owner@postgresql.org Thu Feb 2 08:14:56 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 649249DC81E + for ; + Thu, 2 Feb 2006 08:14:55 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 22155-04 + for ; + Thu, 2 Feb 2006 08:14:56 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.logix-tt.com (serval.logix-tt.com [213.239.221.42]) + by postgresql.org (Postfix) with ESMTP id 0565D9DCC89 + for ; + Thu, 2 Feb 2006 08:14:50 -0400 (AST) +Received: from kingfisher.intern.logix-tt.com (Md470.m.pppool.de + [89.49.212.112]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logix-tt.com (Postfix) with ESMTP id 17AB824400F; + Thu, 2 Feb 2006 13:14:55 +0100 (CET) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id 468A5181C209A; + Thu, 2 Feb 2006 13:14:55 +0100 (CET) +Message-ID: <43E1F7BF.2050100@logix-tt.com> +Date: Thu, 02 Feb 2006 13:14:55 +0100 +From: Markus Schaber +Organization: Logical Tracking and Tracing International AG, Switzerland +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Michael Stone +Cc: pgsql-performance@postgresql.org +Subject: Re: Where is my bottleneck? +References: <43D67496.2020203@androme.es> <20060130110047.GB9976@mathom.us> +In-Reply-To: <20060130110047.GB9976@mathom.us> +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.128 required=5 tests=[AWL=0.128] +X-Spam-Score: 0.128 +X-Spam-Level: +X-Archive-Number: 200602/38 +X-Sequence-Number: 17024 + +Hi, Michael, + +Michael Stone wrote: + +>> I have a performance problem and I don't know where is my bottleneck. +> +> [snip] +> +>> Most of the time the idle value is even higher than 60%. +> +> It's generally a fairly safe bet that if you are running slow and your +> cpu is idle, your i/o isn't fast enough. + +Or the query is misoptimized (low work_mem, missing indices) and cause +much more I/O than necessary. + +HTH, +Markus + +-- +Markus Schaber | Logical Tracking&Tracing International AG +Dipl. Inf. | Software Development GIS + +Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org + +From pgsql-performance-owner@postgresql.org Thu Feb 2 08:44:22 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id B668B9DC810 + for ; + Thu, 2 Feb 2006 08:44:21 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 33291-07 + for ; + Thu, 2 Feb 2006 08:44:23 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.logix-tt.com (serval.logix-tt.com [213.239.221.42]) + by postgresql.org (Postfix) with ESMTP id 27C569DCDE4 + for ; + Thu, 2 Feb 2006 08:44:18 -0400 (AST) +Received: from kingfisher.intern.logix-tt.com (Md470.m.pppool.de + [89.49.212.112]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logix-tt.com (Postfix) with ESMTP id 977FD24400F; + Thu, 2 Feb 2006 13:44:23 +0100 (CET) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id 1AD89181C209A; + Thu, 2 Feb 2006 13:44:24 +0100 (CET) +Message-ID: <43E1FEA7.8060509@logix-tt.com> +Date: Thu, 02 Feb 2006 13:44:23 +0100 +From: Markus Schaber +Organization: Logical Tracking and Tracing International AG, Switzerland +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Marc Morin +Cc: pgsql-performance@postgresql.org +Subject: Re: partitioning and locking problems +References: <2BCEB9A37A4D354AA276774EE13FB8C263B3DE@mailserver.sandvine.com> +In-Reply-To: <2BCEB9A37A4D354AA276774EE13FB8C263B3DE@mailserver.sandvine.com> +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.127 required=5 tests=[AWL=0.127] +X-Spam-Score: 0.127 +X-Spam-Level: +X-Archive-Number: 200602/39 +X-Sequence-Number: 17025 + +Hi, Marc, + +Marc Morin wrote: + +> 1- long running report is running on view +> 2- continuous inserters into view into a table via a rule +> 3- truncate or rule change occurs, taking an exclusive lock. +> Must wait for #1 to finish. +> 4- new reports and inserters must now wait for #3. +> 5- now everyone is waiting for a single query in #1. Results +> in loss of insert data granularity (important for our application). + +Apart from having two separate views (one for report, one for insert) as +Richard suggested: + +If you have fixed times for #3, don't start any #1 that won't finish +before it's time for #3. + +You could also use the LOCK command on an empty lock table at the +beginning of each #1 or #3 transaction to prevent #3 from getting the +view lock before #1 is finished. + + +HTH, +Markus + +-- +Markus Schaber | Logical Tracking&Tracing International AG +Dipl. Inf. | Software Development GIS + +Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org + +From pgsql-performance-owner@postgresql.org Sat Feb 4 16:48:53 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 8D9BF9DC99F + for ; + Thu, 2 Feb 2006 10:03:06 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 58400-03 + for ; + Thu, 2 Feb 2006 10:03:09 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id 8284F9DCAD4 + for ; + Thu, 2 Feb 2006 10:03:03 -0400 (AST) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 145C1308E1; Thu, 2 Feb 2006 15:03:07 +0100 (MET) +From: "tschak" +X-Newsgroups: pgsql.performance +Subject: Index occupancy +Date: 2 Feb 2006 06:03:01 -0800 +Organization: http://groups.google.com +Lines: 21 +Message-ID: <1138888981.186497.321210@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/4.0 (compatible; MSIE 6.0; X11; Linux x86_64; + en) Opera 8.51,gzip(gfe),gzip(gfe) +Complaints-To: groups-abuse@google.com +Injection-Info: z14g2000cwz.googlegroups.com; posting-host=134.100.209.153; + posting-account=_HdIfA0AAACyPG_D8pd3_LIIXfSFJrWL +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.091 required=5 tests=[AWL=0.091] +X-Spam-Score: 0.091 +X-Spam-Level: +X-Archive-Number: 200602/44 +X-Sequence-Number: 17030 + +Hi everyone, + +I have a question concerning the size of an index... +What I acually did was bulid a btree index on an smallint attribute +within a table with 10^8 rows. The table itself is app. 10GB large and +what I would like to have the smallest possible indeces. Unfortunately +the current size is about 2GB per indexed column (8 columns are indexed +in total) which is too large if the planner is supposed to choose a +bitmap scan between all of the indices. + +So what I would like to know is the following: +Is there an easy way to tell postgres to occupy the index pages up to +100 %? +I am working in a decision support system so inserts/deletes etc. do +normally not happen at all? + + +Thanks, + +Tschak + + +From pgsql-performance-owner@postgresql.org Thu Feb 2 12:29:11 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 147479DCAE0 + for ; + Thu, 2 Feb 2006 12:29:10 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 01051-03 + for ; + Thu, 2 Feb 2006 12:29:07 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mailserver.sandvine.com (sandvine.com [199.243.201.138]) + by postgresql.org (Postfix) with ESMTP id AADBE9DCA1C + for ; + Thu, 2 Feb 2006 12:29:06 -0400 (AST) +X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: quoted-printable +Subject: Re: partitioning and locking problems +Date: Thu, 2 Feb 2006 11:27:38 -0500 +Message-ID: <2BCEB9A37A4D354AA276774EE13FB8C2BCC2A6@mailserver.sandvine.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] partitioning and locking problems +Thread-Index: AcYn9jI+Hg9aRe0DS42sG9SqksFpBAAH3Avw +From: "Marc Morin" +To: "Markus Schaber" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200602/40 +X-Sequence-Number: 17026 + +Using a separate lock table is what we've decided to do in this +particular case to serialize #1 and #3. Inserters don't take this lock +and as such will not be stalled.=20 + +> -----Original Message----- +> From: Markus Schaber [mailto:schabi@logix-tt.com]=20 +> Sent: Thursday, February 02, 2006 7:44 AM +> To: Marc Morin +> Cc: pgsql-performance@postgresql.org +> Subject: Re: [PERFORM] partitioning and locking problems +>=20 +> Hi, Marc, +>=20 +> Marc Morin wrote: +>=20 +> > 1- long running report is running on view +> > 2- continuous inserters into view into a table via a rule +> > 3- truncate or rule change occurs, taking an exclusive lock. +> > Must wait for #1 to finish. +> > 4- new reports and inserters must now wait for #3. +> > 5- now everyone is waiting for a single query in #1. Results +> > in loss of insert data granularity (important for our application). +>=20 +> Apart from having two separate views (one for report, one for=20 +> insert) as Richard suggested: +>=20 +> If you have fixed times for #3, don't start any #1 that won't=20 +> finish before it's time for #3. +>=20 +> You could also use the LOCK command on an empty lock table at=20 +> the beginning of each #1 or #3 transaction to prevent #3 from=20 +> getting the view lock before #1 is finished. +>=20 +>=20 +> HTH, +> Markus +>=20 +> -- +> Markus Schaber | Logical Tracking&Tracing International AG +> Dipl. Inf. | Software Development GIS +>=20 +> Fight against software patents in EU! www.ffii.org=20 +> www.nosoftwarepatents.org +>=20 +>=20 + +From pgsql-performance-owner@postgresql.org Thu Feb 2 12:58:30 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 27CEB9DC81E + for ; + Thu, 2 Feb 2006 12:58:30 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 08122-03 + for ; + Thu, 2 Feb 2006 12:58:25 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id A221B9DC817 + for ; + Thu, 2 Feb 2006 12:58:24 -0400 (AST) +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 k12GwOVC016718; + Thu, 2 Feb 2006 11:58:24 -0500 (EST) +To: "Kevin Grittner" +cc: pgsql-performance@postgreSQL.org +Subject: Re: Planner reluctant to start from subquery +In-reply-to: <43E1D4A6.EE98.0025.0@wicourts.gov> +References: <43E0AA7E.EE98.0025.0@wicourts.gov> + <43E0AA7E.EE98.0025.0@wicourts.gov> <3759.1138822464@sss.pgh.pa.us> + <43E0BEDD.EE98.0025.0@wicourts.gov> + <43E0BEDD.EE98.0025.0@wicourts.gov> <4218.1138824885@sss.pgh.pa.us> + <43E0C4A7.EE98.0025.0@wicourts.gov><43E0C4A7.EE98.0025.0@wicourts.gov> + <4359.1138826175@sss.pgh.pa.us> <43E1D4A6.EE98.0025.0@wicourts.gov> +Comments: In-reply-to "Kevin Grittner" + message dated "Thu, 02 Feb 2006 09:45:10 -0600" +Date: Thu, 02 Feb 2006 11:58:24 -0500 +Message-ID: <16717.1138899504@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.103 required=5 tests=[AWL=0.103] +X-Spam-Score: 0.103 +X-Spam-Level: +X-Archive-Number: 200602/41 +X-Sequence-Number: 17027 + +"Kevin Grittner" writes [offlist]: +> Attached is a pg_dump -c file with only the required rows (none of +> which contain confidential data), and 0.1% of the rows from the larger +> tables. It does show the same pattern of costing and plan choice. + +Thanks for the test case. The first thing I found out was that HEAD +does generate the fast plan from the IN case, while 8.1 does not, and +after a bit of digging the reason became clear. The initial state +that the planner starts from is essentially + + SELECT ... FROM ((C JOIN P) LEFT JOIN WPCT) IN-JOIN D + +(IN-JOIN being a notation for the way the planner thinks about IN, which +is that it's a join with some special runtime behavior). The problem +with this is that outer joins don't always commute with other joins, +and up through 8.1 we didn't have any code to analyze whether or not +re-ordering outer joins is safe. So we never did it at all. HEAD does +have such code, and so it is able to re-order the joins enough to +generate the fast plan, which is essentially + + SELECT ... FROM ((C IN-JOIN D) JOIN P) LEFT JOIN WPCT + +This is why eliminating the OUTER JOIN improved things for you. Your +manual rearrangement into a JOIN-with-GROUP-BY inside the OUTER JOIN +essentially duplicates the IN-JOIN rearrangement that HEAD is able to +do for itself. + +BTW, the reason why getting rid of the OR improved matters is that: +(a) with the "WPCT"."profileName" IS NOT NULL part as a top-level WHERE +clause, the planner could prove that it could reduce the OUTER JOIN to +a JOIN (because no null-extended row would pass that qual), whereupon +it had join order flexibility again. +(b) with the "C"."caseType" = 'PA' AND "C"."isConfidential" = false +part as a top-level WHERE clause, there still wasn't any join order +flexibility, but this added restriction on C reduced the number of C +rows enough that there wasn't a performance problem anyway. + +So it's all fairly clear now what is happening. The good news is we +have this fixed for 8.2, the bad news is that that patch is much too +large to consider back-patching. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Feb 2 15:41:33 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id AAA0F9DCA80 + for ; + Thu, 2 Feb 2006 15:41:32 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 85500-10 + for ; + Thu, 2 Feb 2006 15:41:30 -0400 (AST) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id B33C69DCA6D + for ; + Thu, 2 Feb 2006 15:41:28 -0400 (AST) +Received: from unicorn.rentec.com (unicorn.rentec.com [216.223.240.9]) + by svr4.postgresql.org (Postfix) with ESMTP id 14C6C5AF1FA + for ; + Thu, 2 Feb 2006 19:41:29 +0000 (GMT) +Received: from ram.rentec.com (mailhost [192.5.35.66]) + by unicorn.rentec.com (8.13.1/8.12.1) with ESMTP id k12JfJhf024755 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); + Thu, 2 Feb 2006 14:41:21 -0500 (EST) +X-Source: non-mednet +Received: from [172.26.132.145] (hoopoe.rentec.com [172.26.132.145]) + by ram.rentec.com (8.13.1/8.12.1) with ESMTP id k12JfJ0v027014; + Thu, 2 Feb 2006 14:41:19 -0500 (EST) +Message-ID: <43E2605F.5050705@rentec.com> +Date: Thu, 02 Feb 2006 14:41:19 -0500 +From: Alan Stange +Reply-To: stange@rentec.com +Organization: Renaissance Technologies Corp. +User-Agent: Thunderbird 1.6a1 (X11/20060106) +MIME-Version: 1.0 +To: "Jeffrey W. Baker" +Cc: pgsql-performance@postgresql.org +Subject: Re: Huge Data sets, simple queries +References: + <1138737838.5648.4.camel@toonses.gghcwest.com> +In-Reply-To: <1138737838.5648.4.camel@toonses.gghcwest.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Logged: Logged by unicorn.rentec.com as k12JfJhf024755 at Thu Feb 2 14:41:21 + 2006 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.037 required=5 tests=[AWL=0.037] +X-Spam-Score: 0.037 +X-Spam-Level: +X-Archive-Number: 200602/42 +X-Sequence-Number: 17028 + +Jeffrey W. Baker wrote: +> On Tue, 2006-01-31 at 09:00 -0800, Luke Lonergan wrote: +> +>> Jim, +>> +>> On 1/30/06 12:25 PM, "Jim C. Nasby" wrote: +>> +>> +>>> Why divide by 2? A good raid controller should be able to send read +>>> requests to both drives out of the mirrored set to fully utilize the +>>> bandwidth. Of course, that probably won't come into play unless the OS +>>> decides that it's going to read-ahead fairly large chunks of the table +>>> at a time... +>>> +>> I've not seen one that does, nor would it work in the general case IMO. In +>> RAID1 writes are duplicated and reads come from one of the copies. You +>> could alternate read service requests to minimize rotational latency, but +>> you can't improve bandwidth. +>> +> +> Then you've not seen Linux. Linux does balanced reads on software +> mirrors. I'm not sure why you think this can't improve bandwidth. It +> does improve streaming bandwidth as long as the platter STR is more than +> the bus STR. +> +FYI: so does the Solaris Volume Manager (by default) on Solaris. One +can choose alternate access methods like "First" (if the other mirrors +are slower than the first) or "Geometric". It's been doing this for a +good 10 years now (back when it was called DiskSuite), so it's nothing new. + +-- Alan + + + + + + + +From pgsql-performance-owner@postgresql.org Sat Feb 4 20:49:07 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id E81589DC986 + for ; + Sat, 4 Feb 2006 20:49:05 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 77654-07 + for ; + Sat, 4 Feb 2006 20:49:08 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 99ABD9DC8A8 + for ; + Sat, 4 Feb 2006 20:49:03 -0400 (AST) +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 k150n5vF005057; + Sat, 4 Feb 2006 19:49:05 -0500 (EST) +To: "tschak" +cc: pgsql-performance@postgresql.org +Subject: Re: Index occupancy +In-reply-to: <1138888981.186497.321210@z14g2000cwz.googlegroups.com> +References: <1138888981.186497.321210@z14g2000cwz.googlegroups.com> +Comments: In-reply-to "tschak" + message dated "02 Feb 2006 06:03:01 -0800" +Date: Sat, 04 Feb 2006 19:49:05 -0500 +Message-ID: <5056.1139100545@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.104 required=5 tests=[AWL=0.104] +X-Spam-Score: 0.104 +X-Spam-Level: +X-Archive-Number: 200602/45 +X-Sequence-Number: 17031 + +"tschak" writes: +> I have a question concerning the size of an index... +> What I acually did was bulid a btree index on an smallint attribute +> within a table with 10^8 rows. The table itself is app. 10GB large and +> what I would like to have the smallest possible indeces. Unfortunately +> the current size is about 2GB per indexed column (8 columns are indexed +> in total) which is too large if the planner is supposed to choose a +> bitmap scan between all of the indices. + +> So what I would like to know is the following: +> Is there an easy way to tell postgres to occupy the index pages up to +> 100 %? + +No, but even if there were it wouldn't make much of a difference. The +minimum possible size of a PG index is about 16 bytes per entry, which +would still put you at 1.6Gb for that many rows. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Feb 6 04:37:13 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 8D62D9DCB32 + for ; + Mon, 6 Feb 2006 04:37:12 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 07766-07 + for ; + Mon, 6 Feb 2006 04:37:13 -0400 (AST) +X-Greylist: delayed 00:06:37.769896 by SQLgrey- +Received: from correo6.acens.net (correo6.acens.net [217.116.0.39]) + by postgresql.org (Postfix) with ESMTP id EC6DA9DCB65 + for ; + Mon, 6 Feb 2006 04:37:09 -0400 (AST) +Received: (qmail 13478 invoked from network); 6 Feb 2006 08:28:07 -0000 +Received: from unknown (HELO albert.sedifa.com) ([83.175.220.10]) + (envelope-sender ) + by correo6.acens.net (qmail-ldap-1.03) with SMTP + for ; 6 Feb 2006 08:28:07 -0000 +From: Albert Cervera Areny +Organization: Sedifa, S.L. +To: pgsql-performance@postgresql.org +Subject: Re: Storing Digital Video +Date: Mon, 6 Feb 2006 09:30:30 +0100 +User-Agent: KMail/1.7.2 +References: <3cf983d0601311632t4a2f068au1f958746c2b092a7@mail.gmail.com> +In-Reply-To: <3cf983d0601311632t4a2f068au1f958746c2b092a7@mail.gmail.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200602060930.31144.albert@sedifa.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200602/46 +X-Sequence-Number: 17032 + +A Dimecres 01 Febrer 2006 01:32, Rodrigo Madera va escriure: +> I am concerned with performance issues involving the storage of DV on +> a database. +> +> I though of some options, which would be the most advised for speed? +> +> 1) Pack N frames inside a "container" and store the container to the db. +> 2) Store each frame in a separate record in the table "frames". +> 3) (type something here) +> +> Thanks for the help, + + +What if you store meta data in the database and use some PL/Python/Java/Perl +functions to store and retrieve video files from the server. The function +would store files to the files system, not a table. This avoids the need for +a file server for your application while making your relational queries fast. + +Any experiences/thoughts on this solution? + +> +> Rodrigo +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 9: In versions below 8.0, the planner will ignore your desire to +> choose an index scan if your joining column's datatypes do not +> match + + + +From pgsql-performance-owner@postgresql.org Mon Feb 6 16:00:34 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 79FA09DCBC0 + for ; + Mon, 6 Feb 2006 16:00:19 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 36176-04-2 + for ; + Mon, 6 Feb 2006 16:00:19 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from yertle.kcilink.com (yertle.kcilink.com [65.205.34.180]) + by postgresql.org (Postfix) with ESMTP id B0FE89DCBA3 + for ; + Mon, 6 Feb 2006 16:00:13 -0400 (AST) +Received: from [192.168.7.103] (host-103.int.kcilink.com [192.168.7.103]) + by yertle.kcilink.com (Postfix) with ESMTP id 417DCB80D + for ; + Mon, 6 Feb 2006 15:00:13 -0500 (EST) +Mime-Version: 1.0 (Apple Message framework v746.2) +In-Reply-To: <43E12A03.6070906@zeut.net> +References: <20060201211633.GM95850@pervasive.com> <43E12A03.6070906@zeut.net> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <116B6671-FAAA-453C-A52A-26B077373BB4@khera.org> +Content-Transfer-Encoding: 7bit +From: Vivek Khera +Subject: Re: Default autovacuum settings too conservative +Date: Mon, 6 Feb 2006 15:00:12 -0500 +To: Postgresql Performance +X-Mailer: Apple Mail (2.746.2) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.068 required=5 tests=[AWL=0.068] +X-Spam-Score: 0.068 +X-Spam-Level: +X-Archive-Number: 200602/47 +X-Sequence-Number: 17033 + + +On Feb 1, 2006, at 4:37 PM, Matthew T. O'Connor wrote: + +> As far I as I know, we are still looking for real world feedback. +> 8.1 is the first release to have the integrated autovacuum. The +> thresholds in 8.1 are a good bit less conservative than the +> thresholds in the contrib version. The contrib thresholds were +> universally considered WAY to conservative, but that was somewhat +> necessary since you couldn't set them on a per table basis as you +> can in 8.1. If we continue to hear from people that the current +> 8.1 default thresholds are still to conservative we can look into +> lowering them. + +I spent the weekend researching and pondering this topic as well. + +For me the per-table tuning is vital, since I have some tables that +are very small and implement a queue (ie, update very often several +million times per day and have at most 10 or so rows), some that are +fairly stable with O(10k) rows which update occasionally, and a +couple of tables that are quite large: 20 million rows which updates +a few million times per day and inserts a few thousand, and another +table with ~275 million rows in which we insert and update roughly 3 +million per day. + +The 40% overhead would kill these large tables both in terms of +performance and disk usage. I'm pondering a global 10% and having the +big tables at or below 1% based on the rate of change. + +Is there a way to make the autovacuum process log more verbosely +while leaving the rest of the logging minimal? This would help tune it. + + +From pgsql-performance-owner@postgresql.org Mon Feb 6 16:21:53 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id E63049DCCAA + for ; + Mon, 6 Feb 2006 16:21:51 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 38258-06-2 + for ; + Mon, 6 Feb 2006 16:21:51 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from pillette.com (adsl-67-119-5-202.dsl.snfc21.pacbell.net + [67.119.5.202]) by postgresql.org (Postfix) with ESMTP id 5BAB99DCCA6 + for ; + Mon, 6 Feb 2006 16:21:47 -0400 (AST) +Received: from [192.168.1.234] ([192.168.1.234]) + by pillette.com (8.11.6/8.11.6) with ESMTP id k16KLTK03372; + Mon, 6 Feb 2006 12:21:29 -0800 +Message-ID: <43E7B33F.4030509@pillette.com> +Date: Mon, 06 Feb 2006 12:36:15 -0800 +From: Andrew Lazarus +Reply-To: andrew@pillette.com +Organization: Pillette Investment Management +User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "FERREIRA, William (VALTECH)" +CC: Tom Lane , pgsql-performance@postgresql.org +Subject: Re: execution plan : Oracle vs PostgreSQL +References: + <414D259CE29DE54DAD534037C83CE4B726961E@FR0-MAILMB20.res.airbus.corp> +In-Reply-To: + <414D259CE29DE54DAD534037C83CE4B726961E@FR0-MAILMB20.res.airbus.corp> +Content-Type: multipart/mixed; boundary="------------000005050406040802050202" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200602/48 +X-Sequence-Number: 17034 + +This is a multi-part message in MIME format. +--------------000005050406040802050202 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Indeed there is: you can use an ARRAY constructor with SELECT. Here's +some PGPLSQL code I have (simplified and with the variable names shrouded). + + SELECT INTO m + ARRAY(SELECT d FROM hp + WHERE hp.ss=$1 + ORDER BY 1); + + +FERREIRA, William (VALTECH) wrote: + +> maybe there is an other way to query children directly into an array and having query plan caching ? + + +--------------000005050406040802050202 +Content-Type: text/x-vcard; charset=utf-8; + name="andrew.vcf" +Content-Transfer-Encoding: 7bit +Content-Disposition: attachment; + filename="andrew.vcf" + +begin:vcard +fn:Andrew Lazarus +n:Lazarus;Andrew +org:Pillette Investment Management;Research and Development +adr;dom:;;3028 Fillmore;San Francisco;CA;94123 +email;internet:andrew@pillette.com +title:Director +tel;work:800-366-0688 +tel;fax:415-440-4093 +url:http://www.pillette.com +version:2.1 +end:vcard + + +--------------000005050406040802050202-- + +From pgsql-performance-owner@postgresql.org Mon Feb 6 19:04:07 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 915799DCA88 + for ; + Mon, 6 Feb 2006 19:04:05 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 68934-03 + for ; + Mon, 6 Feb 2006 19:04:07 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id 4D6E89DCA5F + for ; + Mon, 6 Feb 2006 19:04:02 -0400 (AST) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 8DF1430941; Tue, 7 Feb 2006 00:04:03 +0100 (MET) +From: Chris Browne +X-Newsgroups: pgsql.performance +Subject: Re: Default autovacuum settings too conservative +Date: Mon, 06 Feb 2006 17:15:16 -0500 +Organization: cbbrowne Computing Inc +Lines: 17 +Message-ID: <60mzh4i16z.fsf@dba2.int.libertyrms.com> +References: <20060201211633.GM95850@pervasive.com> <43E12A03.6070906@zeut.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@news.hub.org +User-Agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4.18 (linux) +Cancel-Lock: sha1:3jcA2GgJFQDN/FndsiU/OKZGg5A= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.242 required=5 tests=[AWL=0.242] +X-Spam-Score: 0.242 +X-Spam-Level: +X-Archive-Number: 200602/49 +X-Sequence-Number: 17035 + +matthew@zeut.net ("Matthew T. O'Connor") writes: +> I think the default settings should be designed to minimize the +> impact autovacuum has on the system while preventing the system from +> ever getting wildly bloated (also protect xid wraparound, but that +> doesn't have anything to do with the thresholds). + +That would suggest setting the "base threshold" +autovacuum_vacuum_threshold relatively low, and the "scale factor" +autovacuum_vacuum_scale_factor fairly high. +-- +let name="cbbrowne" and tld="ntlug.org" in name ^ "@" ^ tld;; +http://cbbrowne.com/info/nonrdbms.html +I think it may be possible to simplify and condense the content of +this thread somewhat: + "GX is an ex-API. It is no longer supported" - The Rest of Us + "No it isn't. It's just pining for the fjords!" - Lawson +-- Michael Paquette + +From pgsql-performance-owner@postgresql.org Tue Feb 7 00:11:25 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 119149DCA49 + for ; + Tue, 7 Feb 2006 00:11:24 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37117-07 + for ; + Tue, 7 Feb 2006 00:11:21 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 32AAC9DC8E0 + for ; + Tue, 7 Feb 2006 00:11:21 -0400 (AST) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 6473939841; Tue, 7 Feb 2006 04:11:05 +0000 (UTC) +Date: Mon, 6 Feb 2006 22:11:05 -0600 +From: "Jim C. Nasby" +To: Tom Lane +Cc: Marc Morin , pgsql-performance@postgresql.org +Subject: Re: partitioning and locking problems +Message-ID: <20060207041105.GY1240@pervasive.com> +References: <2BCEB9A37A4D354AA276774EE13FB8C263B3E5@mailserver.sandvine.com> + <307.1138807221@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <307.1138807221@sss.pgh.pa.us> +X-Operating-System: FreeBSD 6.0-RELEASE amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.104 required=5 tests=[AWL=0.104] +X-Spam-Score: 0.104 +X-Spam-Level: +X-Archive-Number: 200602/50 +X-Sequence-Number: 17036 + +On Wed, Feb 01, 2006 at 10:20:21AM -0500, Tom Lane wrote: +> "Marc Morin" writes: +> > Do you mean it would be impossible to change the code so that existing +> > selects continue to use the pre-truncated table until they commit? +> +> Yes, because that table won't exist any more (as in the file's been +> unlinked) once the TRUNCATE commits. + +Is there a reason the truncate must happen in 'real time'? If TRUNCATE +marked a table as "truncated as of tid, cid" and created a new set of +empty objects to be used by all transactions after that, then it should +be possible to truncate without waiting on existing selects. +Unfortunately, I can't think of any way to avoid blocking new inserters, +but in the partitioning case that shouldn't matter. + +> > The update/insert rule change appears to be more more doable? No? +> +> You've still got race conditions there: do onlooker transactions see the +> old set of rules, or the new set, or some unholy mixture? Removing the +> lock as you suggest would make it possible for the rule rewriter to pick +> up non-self-consistent data from the system catalogs, leading to +> arbitrarily bad behavior ... if you're lucky, it'll just crash, if +> you're not lucky the incorrect rule will do a fandango on your data. + +Where can one read about why the catalogs can't/don't use MVCC (I'm +assuming that's why this won't work...) +-- +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-admin-owner@postgresql.org Tue Feb 7 01:05:49 2006 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id B89009DC803; + Tue, 7 Feb 2006 01:05:48 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 49770-03; Tue, 7 Feb 2006 01:05:47 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 292D69DC84B; + Tue, 7 Feb 2006 01:05:46 -0400 (AST) +Received: by noel.decibel.org (Postfix, from userid 1001) + id D373C39820; Tue, 7 Feb 2006 05:05:45 +0000 (UTC) +Date: Mon, 6 Feb 2006 23:05:45 -0600 +From: "Jim C. Nasby" +To: "Matthew T. O'Connor" +Cc: pgsql-admin@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Default autovacuum settings too conservative +Message-ID: <20060207050545.GZ1240@pervasive.com> +References: <20060201211633.GM95850@pervasive.com> <43E12A03.6070906@zeut.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <43E12A03.6070906@zeut.net> +X-Operating-System: FreeBSD 6.0-RELEASE amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.104 required=5 tests=[AWL=0.104] +X-Spam-Score: 0.104 +X-Spam-Level: +X-Archive-Number: 200602/64 +X-Sequence-Number: 20485 + +On Wed, Feb 01, 2006 at 04:37:07PM -0500, Matthew T. O'Connor wrote: +> I think the default settings should be designed to minimize the impact +> autovacuum has on the system while preventing the system from ever +> getting wildly bloated (also protect xid wraparound, but that doesn't +> have anything to do with the thresholds). + +I don't really see the logic behind that. Problems caused by inadequate +vacuuming seem to be much more prevalent than problems caused by vacuum +impacting the system. If vacuum impact is a concern I think it more +reasonable to make the default vacuum_cost_delay non-zero instead. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue Feb 7 01:06:30 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id ED7339DCBF6 + for ; + Tue, 7 Feb 2006 01:06:28 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 46017-07 + for ; + Tue, 7 Feb 2006 01:06:27 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id B68C19DCBF4 + for ; + Tue, 7 Feb 2006 01:06:26 -0400 (AST) +Received: by noel.decibel.org (Postfix, from userid 1001) + id ABE2739830; Tue, 7 Feb 2006 05:06:26 +0000 (UTC) +Date: Mon, 6 Feb 2006 23:06:26 -0600 +From: "Jim C. Nasby" +To: Pradeep Parmar +Cc: pgsql-performance@postgresql.org +Subject: Re: pgbench output +Message-ID: <20060207050626.GA1240@pervasive.com> +References: <580055310602012309o40b9b0d4g@mail.gmail.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <580055310602012309o40b9b0d4g@mail.gmail.com> +X-Operating-System: FreeBSD 6.0-RELEASE amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.104 required=5 tests=[AWL=0.104] +X-Spam-Score: 0.104 +X-Spam-Level: +X-Archive-Number: 200602/52 +X-Sequence-Number: 17038 + +Well, it tells you how many transactions per second it was able to do. +Do you have specific questions? + +On Thu, Feb 02, 2006 at 12:39:59PM +0530, Pradeep Parmar wrote: +> Hi, +> +> I'm fairly new to PostgreSQL. I was trying pgbench , but could not +> understand the output . Can anyone help me out to understand the output of +> pgbench +> +> +> ----Pradeep + +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue Feb 7 02:38:25 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id B3E849DC83C + for ; + Tue, 7 Feb 2006 02:38:23 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 65652-05 + for ; + Tue, 7 Feb 2006 02:38:23 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id 08E939DC803 + for ; + Tue, 7 Feb 2006 02:38:20 -0400 (AST) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 39D3A30945; Tue, 7 Feb 2006 07:38:21 +0100 (MET) +From: Christopher Browne +X-Newsgroups: pgsql.performance +Subject: Re: Default autovacuum settings too conservative +Date: Mon, 06 Feb 2006 22:14:53 -0800 +Organization: cbbrowne Computing Inc +Lines: 22 +Message-ID: +References: <20060201211633.GM95850@pervasive.com> <43E12A03.6070906@zeut.net> + <20060207050545.GZ1240@pervasive.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@news.hub.org +X-message-flag: Outlook is rather hackable, isn't it? +X-Home-Page: http://www.cbbrowne.com/info/ +X-Affero: http://svcs.affero.net/rm.php?r=cbbrowne +User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Jumbo Shrimp, + berkeley-unix) +Cancel-Lock: sha1:p+NBh3GhmgqTPYl5/L8RYdKzwGY= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.65 required=5 tests=[AWL=-0.163, INFO_TLD=0.813] +X-Spam-Score: 0.65 +X-Spam-Level: +X-Archive-Number: 200602/53 +X-Sequence-Number: 17039 + +> On Wed, Feb 01, 2006 at 04:37:07PM -0500, Matthew T. O'Connor wrote: +>> I think the default settings should be designed to minimize the impact +>> autovacuum has on the system while preventing the system from ever +>> getting wildly bloated (also protect xid wraparound, but that doesn't +>> have anything to do with the thresholds). +> +> I don't really see the logic behind that. Problems caused by inadequate +> vacuuming seem to be much more prevalent than problems caused by vacuum +> impacting the system. If vacuum impact is a concern I think it more +> reasonable to make the default vacuum_cost_delay non-zero instead. + +That's a good point. + +I would not be keen, on the other hand, on having the delays terribly +high. + +Big tables, if delayed significantly, will take plenty longer to +vacuum, and I always get paranoid about long running transactions :-). +-- +let name="cbbrowne" and tld="gmail.com" in name ^ "@" ^ tld;; +http://linuxdatabases.info/info/postgresql.html +This login session: $13.99 + +From pgsql-performance-owner@postgresql.org Tue Feb 7 03:26:43 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id A8AB89DC83C + for ; + Tue, 7 Feb 2006 03:26:42 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 70082-10 + for ; + Tue, 7 Feb 2006 03:26:41 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 816F29DC807 + for ; + Tue, 7 Feb 2006 03:26:35 -0400 (AST) +Received: by noel.decibel.org (Postfix, from userid 1001) + id DB8083982E; Tue, 7 Feb 2006 07:26:21 +0000 (UTC) +Date: Tue, 7 Feb 2006 01:26:21 -0600 +From: "Jim C. Nasby" +To: Christopher Browne +Cc: pgsql-performance@postgresql.org +Subject: Re: Default autovacuum settings too conservative +Message-ID: <20060207072621.GI13592@pervasive.com> +References: <20060201211633.GM95850@pervasive.com> <43E12A03.6070906@zeut.net> + <20060207050545.GZ1240@pervasive.com> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +X-Operating-System: FreeBSD 6.0-RELEASE amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.104 required=5 tests=[AWL=0.104] +X-Spam-Score: 0.104 +X-Spam-Level: +X-Archive-Number: 200602/54 +X-Sequence-Number: 17040 + +On Mon, Feb 06, 2006 at 10:14:53PM -0800, Christopher Browne wrote: +> > On Wed, Feb 01, 2006 at 04:37:07PM -0500, Matthew T. O'Connor wrote: +> >> I think the default settings should be designed to minimize the impact +> >> autovacuum has on the system while preventing the system from ever +> >> getting wildly bloated (also protect xid wraparound, but that doesn't +> >> have anything to do with the thresholds). +> > +> > I don't really see the logic behind that. Problems caused by inadequate +> > vacuuming seem to be much more prevalent than problems caused by vacuum +> > impacting the system. If vacuum impact is a concern I think it more +> > reasonable to make the default vacuum_cost_delay non-zero instead. +> +> That's a good point. +> +> I would not be keen, on the other hand, on having the delays terribly +> high. +> +> Big tables, if delayed significantly, will take plenty longer to +> vacuum, and I always get paranoid about long running transactions :-). + +Very true, but I'd hope anyone running a table large enough for this to +make a difference would have done some tuning of their own... + +What we really need is a replacement for vacuum_delay that takes +PostgreSQL generated IO activity into account... +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue Feb 7 08:39:32 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id B749D9DC987 + for ; + Tue, 7 Feb 2006 08:39:31 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 31355-01 + for ; + Tue, 7 Feb 2006 08:39:34 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.logix-tt.com (serval.logix-tt.com [213.239.221.42]) + by postgresql.org (Postfix) with ESMTP id ECC469DC9DA + for ; + Tue, 7 Feb 2006 08:39:28 -0400 (AST) +Received: from kingfisher.intern.logix-tt.com (Mc0c4.m.pppool.de + [89.49.192.196]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logix-tt.com (Postfix) with ESMTP id 2209124400F; + Tue, 7 Feb 2006 13:39:34 +0100 (CET) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id AAA9218151EB5; + Tue, 7 Feb 2006 13:39:34 +0100 (CET) +Message-ID: <43E89506.40903@logix-tt.com> +Date: Tue, 07 Feb 2006 13:39:34 +0100 +From: Markus Schaber +Organization: Logical Tracking and Tracing International AG, Switzerland +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Default autovacuum settings too conservative +References: <20060201211633.GM95850@pervasive.com> <43E12A03.6070906@zeut.net> + <20060207050545.GZ1240@pervasive.com> + + <20060207072621.GI13592@pervasive.com> +In-Reply-To: <20060207072621.GI13592@pervasive.com> +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.125 required=5 tests=[AWL=0.125] +X-Spam-Score: 0.125 +X-Spam-Level: +X-Archive-Number: 200602/55 +X-Sequence-Number: 17041 + +Hi, Jim, + +Jim C. Nasby wrote: + +> What we really need is a replacement for vacuum_delay that takes +> PostgreSQL generated IO activity into account... + +There are also other ideas which can make vacuum less painfull: + +- Use a "delete"-map (like the free space map) so vacuum can quickly +find the pages to look at. + +- Have vacuum end its transaction after a certain amount of work, and +restart at the same page later. + +- Have vacuum full search good candidates with non-stopping lock (and +usage of delete-map and fsm), then doing {lock, recheck, move, unlock} +in small amounts of data with delay between. + +- Introducing some load measurement, and a pressure measurement (number +of deleted rows, TID wraparound etc.). Then start vacuum when load is +low or pressure is very high. Tune other parameters (like "certain +amount of work" depending on those measures. + +All of them are a lot of code to hack, but although I'm not a postgresql +core developer, I am keen enough to invite you to send patches. :-) + +Markus +-- +Markus Schaber | Logical Tracking&Tracing International AG +Dipl. Inf. | Software Development GIS + +Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org + +From pgsql-performance-owner@postgresql.org Tue Feb 7 10:20:15 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id AE0EE9DC9DA + for ; + Tue, 7 Feb 2006 10:20:14 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 64250-01 + for ; + Tue, 7 Feb 2006 10:20:15 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from vms044pub.verizon.net (vms044pub.verizon.net [206.46.252.44]) + by postgresql.org (Postfix) with ESMTP id 7526D9DC9D2 + for ; + Tue, 7 Feb 2006 10:20:08 -0400 (AST) +Received: from osgiliath.mathom.us ([151.200.26.117]) + by vms044.mailsrvcs.net (Sun Java System Messaging Server 6.2-4.02 + (built Sep + 9 2005)) with ESMTPA id <0IUB001E9MHMIOC4@vms044.mailsrvcs.net> for + pgsql-performance@postgresql.org; Tue, 07 Feb 2006 08:20:11 -0600 (CST) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id 27B3F6E5E6 for + ; + Tue, 07 Feb 2006 09:20:09 -0500 (EST) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath.home.mathom.us [127.0.0.1]) (amavisd-new, + port 10024) + with LMTP id 01865-01-7 for ; Tue, + 07 Feb 2006 09:20:08 -0500 (EST) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id 765076E6CF; Tue, 07 Feb 2006 09:20:08 -0500 (EST) +Date: Tue, 07 Feb 2006 09:20:08 -0500 +From: Michael Stone +Subject: Re: Default autovacuum settings too conservative +In-reply-to: <20060207050545.GZ1240@pervasive.com> +To: pgsql-performance@postgresql.org +Mail-followup-to: pgsql-performance@postgresql.org +Message-id: <20060207142006.GM1293@mathom.us> +MIME-version: 1.0 +Content-type: text/plain; charset=us-ascii; format=flowed +Content-disposition: inline +X-Pgp-Fingerprint: 53 FF 38 00 E7 DD 0A 9C 84 52 84 C5 EE DF 7C 88 +X-Virus-Scanned: Debian amavisd-new at mathom.us +References: <20060201211633.GM95850@pervasive.com> <43E12A03.6070906@zeut.net> + <20060207050545.GZ1240@pervasive.com> +User-Agent: Mutt/1.5.11 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200602/56 +X-Sequence-Number: 17042 + +On Mon, Feb 06, 2006 at 11:05:45PM -0600, Jim C. Nasby wrote: +>I don't really see the logic behind that. Problems caused by inadequate +>vacuuming seem to be much more prevalent than problems caused by vacuum +>impacting the system. + +Agreed. If your tables are large enough that a vacuum matters, you +probably shouldn't be blindly running autovacuum anyway. + +Mike Stone + +From pgsql-performance-owner@postgresql.org Tue Feb 7 18:09:11 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 018B99DC85F + for ; + Tue, 7 Feb 2006 18:09:10 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 59542-09 + for ; + Tue, 7 Feb 2006 18:09:12 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smtp.nildram.co.uk (smtp.nildram.co.uk [195.112.4.54]) + by postgresql.org (Postfix) with ESMTP id E70659DC80F + for ; + Tue, 7 Feb 2006 18:09:08 -0400 (AST) +Received: from [192.168.0.5] (unknown [84.12.81.110]) + by smtp.nildram.co.uk (Postfix) with ESMTP + id 561F2255B1C; Tue, 7 Feb 2006 22:08:59 +0000 (GMT) +Subject: Re: partitioning and locking problems +From: Simon Riggs +To: Marc Morin +Cc: Markus Schaber , + pgsql-performance@postgresql.org +In-Reply-To: <2BCEB9A37A4D354AA276774EE13FB8C2BCC2A6@mailserver.sandvine.com> +References: <2BCEB9A37A4D354AA276774EE13FB8C2BCC2A6@mailserver.sandvine.com> +Content-Type: text/plain +Date: Tue, 07 Feb 2006 22:09:02 +0000 +Message-Id: <1139350142.1258.174.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.3 (2.2.3-2.fc4) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.075 required=5 tests=[AWL=0.075] +X-Spam-Score: 0.075 +X-Spam-Level: +X-Archive-Number: 200602/57 +X-Sequence-Number: 17043 + +On Thu, 2006-02-02 at 11:27 -0500, Marc Morin wrote: + +> > > 1- long running report is running on view +> > > 2- continuous inserters into view into a table via a rule +> > > 3- truncate or rule change occurs, taking an exclusive lock. +> > > Must wait for #1 to finish. +> > > 4- new reports and inserters must now wait for #3. +> > > 5- now everyone is waiting for a single query in #1. Results +> > > in loss of insert data granularity (important for our application). + +> Using a separate lock table is what we've decided to do in this +> particular case to serialize #1 and #3. Inserters don't take this lock +> and as such will not be stalled. + +Would it not be simpler to have the Inserters change from one table to +another either upon command, on a fixed timing cycle or even better +based upon one of the inserted values (Logdate?) (or all 3?). (Requires +changes in the application layer: 3GL or db functions). + +The truncates can wait until the data has stopped being used. + +I'd be disinclined to using the locking system as a scheduling tool. + +Best Regards, Simon Riggs + + + +From pgsql-performance-owner@postgresql.org Tue Feb 7 18:21:02 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id E46A99DC80F + for ; + Tue, 7 Feb 2006 18:21:01 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 63535-06 + for ; + Tue, 7 Feb 2006 18:21:02 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smtpauth07.mail.atl.earthlink.net + (smtpauth07.mail.atl.earthlink.net [209.86.89.67]) + by postgresql.org (Postfix) with ESMTP id 258829DC82A + for ; + Tue, 7 Feb 2006 18:20:59 -0400 (AST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=bW6hdPK86s79si7hAaO6Sf44HzhbPxbFF9XnC3lJq+YcRuiI/aIc8wLU3/jV6Zm+; + 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 [71.243.30.247] (helo=ron-6d52adff2a6.earthlink.net) + by smtpauth07.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1F6bCl-0001Cw-Bv; Tue, 07 Feb 2006 17:21:00 -0500 +Message-Id: <7.0.1.0.2.20060207171933.037eee98@earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 7.0.1.0 +Date: Tue, 07 Feb 2006 17:22:22 -0500 +To: Simon Riggs ,pgsql-performance@postgresql.org +From: Ron +Subject: Re: partitioning and locking problems +In-Reply-To: <1139350142.1258.174.camel@localhost.localdomain> +References: <2BCEB9A37A4D354AA276774EE13FB8C2BCC2A6@mailserver.sandvine.com> + <1139350142.1258.174.camel@localhost.localdomain> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bcaed4711ccea23c093c94ea04d64c1214350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 71.243.30.247 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.479 required=5 tests=[DNS_FROM_RFC_ABUSE=0.479] +X-Spam-Score: 0.479 +X-Spam-Level: +X-Archive-Number: 200602/58 +X-Sequence-Number: 17044 + +At 05:09 PM 2/7/2006, Simon Riggs wrote: + +>I'd be disinclined to using the locking system as a scheduling tool. +I Agree with Simon. Using the locking system for scheduling feels +like a form of Programming by Side Effect. + +Ron + + + +From pgsql-performance-owner@postgresql.org Tue Feb 7 18:58:35 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 169049DCA83 + for ; + Tue, 7 Feb 2006 18:58:34 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 68631-09 + for ; + Tue, 7 Feb 2006 18:58:36 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mailserver.sandvine.com (sandvine.com [199.243.201.138]) + by postgresql.org (Postfix) with ESMTP id E05DF9DC83C + for ; + Tue, 7 Feb 2006 18:58:31 -0400 (AST) +X-MimeOLE: Produced By Microsoft Exchange V6.5 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: partitioning and locking problems +Date: Tue, 7 Feb 2006 17:57:03 -0500 +Message-ID: <2BCEB9A37A4D354AA276774EE13FB8C2BCC2F4@mailserver.sandvine.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] partitioning and locking problems +Thread-Index: AcYsMu7hyeeAf+K0S/+g7J0iFrCDmwABwmKA +From: "Marc Morin" +To: "Simon Riggs" +Cc: "Markus Schaber" , +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200602/59 +X-Sequence-Number: 17045 + +All good ideas, unfortunately, we can't change the inserting applicatin +code easily.=20 + +> -----Original Message----- +> From: Simon Riggs [mailto:simon@2ndquadrant.com]=20 +> Sent: Tuesday, February 07, 2006 5:09 PM +> To: Marc Morin +> Cc: Markus Schaber; pgsql-performance@postgresql.org +> Subject: Re: [PERFORM] partitioning and locking problems +>=20 +> On Thu, 2006-02-02 at 11:27 -0500, Marc Morin wrote: +>=20 +> > > > 1- long running report is running on view +> > > > 2- continuous inserters into view into a table=20 +> via a rule +> > > > 3- truncate or rule change occurs, taking an=20 +> exclusive lock. +> > > > Must wait for #1 to finish. +> > > > 4- new reports and inserters must now wait for #3. +> > > > 5- now everyone is waiting for a single query=20 +> in #1. Results +> > > > in loss of insert data granularity (important for our=20 +> application). +>=20 +> > Using a separate lock table is what we've decided to do in this=20 +> > particular case to serialize #1 and #3. Inserters don't take this=20 +> > lock and as such will not be stalled. +>=20 +> Would it not be simpler to have the Inserters change from one=20 +> table to another either upon command, on a fixed timing cycle=20 +> or even better based upon one of the inserted values=20 +> (Logdate?) (or all 3?). (Requires changes in the application=20 +> layer: 3GL or db functions). +>=20 +> The truncates can wait until the data has stopped being used. +>=20 +> I'd be disinclined to using the locking system as a scheduling tool. +>=20 +> Best Regards, Simon Riggs +>=20 +>=20 +>=20 + +From pgsql-performance-owner@postgresql.org Tue Feb 7 20:59:13 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 1D1D79DCC0B + for ; + Tue, 7 Feb 2006 20:59:13 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 92963-02 + for ; + Tue, 7 Feb 2006 20:59:16 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id A9EB89DCC09 + for ; + Tue, 7 Feb 2006 20:59:10 -0400 (AST) +Received: by noel.decibel.org (Postfix, from userid 1001) + id C27CD39849; Wed, 8 Feb 2006 00:59:12 +0000 (UTC) +Date: Tue, 7 Feb 2006 18:59:12 -0600 +From: "Jim C. Nasby" +To: Simon Riggs +Cc: Marc Morin , Markus Schaber , + pgsql-performance@postgresql.org +Subject: Re: partitioning and locking problems +Message-ID: <20060208005912.GS38134@pervasive.com> +References: <2BCEB9A37A4D354AA276774EE13FB8C2BCC2A6@mailserver.sandvine.com> + <1139350142.1258.174.camel@localhost.localdomain> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1139350142.1258.174.camel@localhost.localdomain> +X-Operating-System: FreeBSD 6.0-RELEASE amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.104 required=5 tests=[AWL=0.104] +X-Spam-Score: 0.104 +X-Spam-Level: +X-Archive-Number: 200602/60 +X-Sequence-Number: 17046 + +On Tue, Feb 07, 2006 at 10:09:02PM +0000, Simon Riggs wrote: +> On Thu, 2006-02-02 at 11:27 -0500, Marc Morin wrote: +> +> > > > 1- long running report is running on view +> > > > 2- continuous inserters into view into a table via a rule +> > > > 3- truncate or rule change occurs, taking an exclusive lock. +> > > > Must wait for #1 to finish. +> > > > 4- new reports and inserters must now wait for #3. +> > > > 5- now everyone is waiting for a single query in #1. Results +> > > > in loss of insert data granularity (important for our application). +> +> > Using a separate lock table is what we've decided to do in this +> > particular case to serialize #1 and #3. Inserters don't take this lock +> > and as such will not be stalled. +> +> Would it not be simpler to have the Inserters change from one table to +> another either upon command, on a fixed timing cycle or even better +> based upon one of the inserted values (Logdate?) (or all 3?). (Requires +> changes in the application layer: 3GL or db functions). + +Unfortunately, AFAIK rule changes would suffer from the exact same +problem, which will be a serious issue for table partitioning. If you +try and add a new partition while a long report is running you'll end up +blocking everything. + +ALso, IIRC the OP was trying *not* to have the locking system impose +scheduling. I believe the intention is that either 1 not block 3 or 3 +not block 4. + +I'm honestly somewhat surprised someone hasn't run into this problem +with partitioning yet; or maybe everyone who needs to do long +transactions just shoves those off to slony slaves... +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue Feb 7 21:03:38 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 0C9539DC999 + for ; + Tue, 7 Feb 2006 21:03:38 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 87836-09 + for ; + Tue, 7 Feb 2006 21:03:41 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id D1A719DC80F + for ; + Tue, 7 Feb 2006 21:03:35 -0400 (AST) +Received: by noel.decibel.org (Postfix, from userid 1001) + id AAC9439842; Wed, 8 Feb 2006 01:03:39 +0000 (UTC) +Date: Tue, 7 Feb 2006 19:03:39 -0600 +From: "Jim C. Nasby" +To: Markus Schaber +Cc: pgsql-performance@postgresql.org +Subject: Re: Default autovacuum settings too conservative +Message-ID: <20060208010339.GT38134@pervasive.com> +References: <20060201211633.GM95850@pervasive.com> <43E12A03.6070906@zeut.net> + <20060207050545.GZ1240@pervasive.com> + + <20060207072621.GI13592@pervasive.com> + <43E89506.40903@logix-tt.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <43E89506.40903@logix-tt.com> +X-Operating-System: FreeBSD 6.0-RELEASE amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.104 required=5 tests=[AWL=0.104] +X-Spam-Score: 0.104 +X-Spam-Level: +X-Archive-Number: 200602/61 +X-Sequence-Number: 17047 + +On Tue, Feb 07, 2006 at 01:39:34PM +0100, Markus Schaber wrote: +> Hi, Jim, +> +> Jim C. Nasby wrote: +> +> > What we really need is a replacement for vacuum_delay that takes +> > PostgreSQL generated IO activity into account... +> +> There are also other ideas which can make vacuum less painfull: +> +> - Use a "delete"-map (like the free space map) so vacuum can quickly +> find the pages to look at. + +Already on TODO. + +> - Have vacuum end its transaction after a certain amount of work, and +> restart at the same page later. + +AFAIK this isn't possible with the current way vacuum works. + +> - Have vacuum full search good candidates with non-stopping lock (and +> usage of delete-map and fsm), then doing {lock, recheck, move, unlock} +> in small amounts of data with delay between. + +This isn't an issue of locks, it's an issue of long-running +transactions. It *might* be possible for vacuum to break work into +smaller transactions, but I'm pretty sure that would be a non-trivial +amount of hacking. + +> - Introducing some load measurement, and a pressure measurement (number +> of deleted rows, TID wraparound etc.). Then start vacuum when load is +> low or pressure is very high. Tune other parameters (like "certain +> amount of work" depending on those measures. + +Which is essentially what I was suggesting... + +> All of them are a lot of code to hack, but although I'm not a postgresql +> core developer, I am keen enough to invite you to send patches. :-) + +Well, if you know C then you're already 1 step closer to being able to +change these kinds of things than I am. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue Feb 7 21:56:26 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 1F01D9DC999 + for ; + Tue, 7 Feb 2006 21:56:26 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 03521-07 + for ; + Tue, 7 Feb 2006 21:56:29 -0400 (AST) +X-Greylist: delayed 00:06:45.282756 by SQLgrey- +Received: from mail.pws.com.au (mail.pws.com.au [202.130.194.163]) + by postgresql.org (Postfix) with SMTP id DB0949DC80F + for ; + Tue, 7 Feb 2006 21:56:22 -0400 (AST) +Received: (qmail 28739 invoked from network); 8 Feb 2006 01:49:39 -0000 +Received: from unknown (HELO ?172.17.72.5?) (russell@pws.com.au@203.45.0.138) + by mail.pws.com.au with SMTP; 8 Feb 2006 01:49:39 -0000 +Message-ID: <43E94E42.3080605@pws.com.au> +Date: Wed, 08 Feb 2006 12:49:54 +1100 +From: Russell Smith +User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051013) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "Jim C. Nasby" +CC: Markus Schaber , + pgsql-performance@postgresql.org +Subject: Re: Default autovacuum settings too conservative +References: <20060201211633.GM95850@pervasive.com> <43E12A03.6070906@zeut.net> + <20060207050545.GZ1240@pervasive.com> + + <20060207072621.GI13592@pervasive.com> + <43E89506.40903@logix-tt.com> + <20060208010339.GT38134@pervasive.com> +In-Reply-To: <20060208010339.GT38134@pervasive.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, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200602/62 +X-Sequence-Number: 17048 + +Jim C. Nasby wrote: +> On Tue, Feb 07, 2006 at 01:39:34PM +0100, Markus Schaber wrote: +> +>>Hi, Jim, +>> +>>Jim C. Nasby wrote: +>> +>> +>>>What we really need is a replacement for vacuum_delay that takes +>>>PostgreSQL generated IO activity into account... +>> +>>There are also other ideas which can make vacuum less painfull: +>> +>>- Use a "delete"-map (like the free space map) so vacuum can quickly +>>find the pages to look at. +> +> +> Already on TODO. +> +> +>>- Have vacuum end its transaction after a certain amount of work, and +>>restart at the same page later. +> +> +> AFAIK this isn't possible with the current way vacuum works. + +There was a patch posted for this in the 8.0 cycle, but it was said to +be not useful. I think it's possibly useful for large tables and with +autovac only. + +> +> +>>- Have vacuum full search good candidates with non-stopping lock (and +>>usage of delete-map and fsm), then doing {lock, recheck, move, unlock} +>>in small amounts of data with delay between. +> +> +> This isn't an issue of locks, it's an issue of long-running +> transactions. It *might* be possible for vacuum to break work into +> smaller transactions, but I'm pretty sure that would be a non-trivial +> amount of hacking. + +When tables are tracked individually for wraparound, the longest +transaction required for vacuuming will be one to vacuum one table. +With delete-map and other functions, the time for that transaction may +be reduced. Partial vacuum of large tables is an option, but again +requires some real smarts in the autovac code to track wraparound issues. + +> +> +>>- Introducing some load measurement, and a pressure measurement (number +>>of deleted rows, TID wraparound etc.). Then start vacuum when load is +>>low or pressure is very high. Tune other parameters (like "certain +>>amount of work" depending on those measures. +> +> +> Which is essentially what I was suggesting... +> +> +>>All of them are a lot of code to hack, but although I'm not a postgresql +>>core developer, I am keen enough to invite you to send patches. :-) +> +> +> Well, if you know C then you're already 1 step closer to being able to +> change these kinds of things than I am. + +Regards + +Russell Smith + +From pgsql-performance-owner@postgresql.org Wed Feb 8 00:39:15 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id BD5789DCC19 + for ; + Wed, 8 Feb 2006 00:39:14 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 36876-01 + for ; + Wed, 8 Feb 2006 00:39:13 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id 61FB29DCC08 + for ; + Wed, 8 Feb 2006 00:39:12 -0400 (AST) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id D91C530945; Wed, 8 Feb 2006 05:39:11 +0100 (MET) +From: Christopher Browne +X-Newsgroups: pgsql.performance +Subject: Re: Default autovacuum settings too conservative +Date: Tue, 07 Feb 2006 20:12:10 -0800 +Organization: cbbrowne Computing Inc +Lines: 65 +Message-ID: +References: <20060201211633.GM95850@pervasive.com> <43E12A03.6070906@zeut.net> + <20060207050545.GZ1240@pervasive.com> + + <20060207072621.GI13592@pervasive.com> + <43E89506.40903@logix-tt.com> + <20060208010339.GT38134@pervasive.com> + <43E94E42.3080605@pws.com.au> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@news.hub.org +X-message-flag: Outlook is rather hackable, isn't it? +X-Home-Page: http://www.cbbrowne.com/info/ +X-Affero: http://svcs.affero.net/rm.php?r=cbbrowne +User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Jumbo Shrimp, + berkeley-unix) +Cancel-Lock: sha1:TAkH8egoaOP+Xk7JfDm0NMTL2V8= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.664 required=5 tests=[AWL=-0.149, INFO_TLD=0.813] +X-Spam-Score: 0.664 +X-Spam-Level: +X-Archive-Number: 200602/63 +X-Sequence-Number: 17049 + +> Jim C. Nasby wrote: +>> On Tue, Feb 07, 2006 at 01:39:34PM +0100, Markus Schaber wrote: +>> +>>>Hi, Jim, +>>> +>>>Jim C. Nasby wrote: +>>> +>>> +>>>>What we really need is a replacement for vacuum_delay that takes +>>>>PostgreSQL generated IO activity into account... +>>> +>>>There are also other ideas which can make vacuum less painfull: +>>> +>>>- Use a "delete"-map (like the free space map) so vacuum can quickly +>>>find the pages to look at. +>> Already on TODO. +>> +>>>- Have vacuum end its transaction after a certain amount of work, and +>>>restart at the same page later. +>> AFAIK this isn't possible with the current way vacuum works. +> +> There was a patch posted for this in the 8.0 cycle, but it was said to +> be not useful. I think it's possibly useful for large tables and with +> autovac only. + +I could see it being useful in an autovac perspective. Work on a +table for a while, giving up after some period of time, but without +giving up on having done some work. + +>>>- Have vacuum full search good candidates with non-stopping lock (and +>>>usage of delete-map and fsm), then doing {lock, recheck, move, unlock} +>>>in small amounts of data with delay between. +>> This isn't an issue of locks, it's an issue of long-running +>> transactions. It *might* be possible for vacuum to break work into +>> smaller transactions, but I'm pretty sure that would be a non-trivial +>> amount of hacking. + +Right. And part of the trouble is that you lose certainty that you +have covered off transaction wraparound. + +> When tables are tracked individually for wraparound, the longest +> transaction required for vacuuming will be one to vacuum one +> table. With delete-map and other functions, the time for that +> transaction may be reduced. Partial vacuum of large tables is an +> option, but again requires some real smarts in the autovac code to +> track wraparound issues. + +Unfortunately, "delete-map" *doesn't* help you with the wraparound +problem. The point of the "delete map" or "vacuum space map" is to +allow the VACUUM to only touch the pages known to need vacuuming. + +At some point, you still need to walk through the whole table (touched +parts and untouched) in order to make sure that the old tuples are +frozen. + +Tracking tables individually does indeed help by making the longest +transaction be the one needed for the largest table. Unfortunately, +that one can't lean on the "delete map"/"vacuum space map" to ignore +parts of the table :-(. +-- +(reverse (concatenate 'string "gro.gultn" "@" "enworbbc")) +http://linuxdatabases.info/info/slony.html +"Access to a COFF symbol table via ldtbread is even less abstract, + really sucks in general, and should be banned from earth." + -- SCSH 0.5.1 unix.c + +From pgsql-performance-owner@postgresql.org Wed Feb 8 04:30:43 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 60E8F9DC850 + for ; + Wed, 8 Feb 2006 04:30:43 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 80977-02 + for ; + Wed, 8 Feb 2006 04:30:41 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smtp.nildram.co.uk (smtp.nildram.co.uk [195.112.4.54]) + by postgresql.org (Postfix) with ESMTP id 1D4B49DC833 + for ; + Wed, 8 Feb 2006 04:30:38 -0400 (AST) +Received: from [192.168.0.5] (unknown [84.12.26.47]) + by smtp.nildram.co.uk (Postfix) with ESMTP + id 7C774252BA9; Wed, 8 Feb 2006 08:30:24 +0000 (GMT) +Subject: Re: partitioning and locking problems +From: Simon Riggs +To: "Jim C. Nasby" +Cc: Marc Morin , Markus Schaber , + pgsql-performance@postgresql.org +In-Reply-To: <20060208005912.GS38134@pervasive.com> +References: <2BCEB9A37A4D354AA276774EE13FB8C2BCC2A6@mailserver.sandvine.com> + <1139350142.1258.174.camel@localhost.localdomain> + <20060208005912.GS38134@pervasive.com> +Content-Type: text/plain +Date: Wed, 08 Feb 2006 08:30:29 +0000 +Message-Id: <1139387429.1258.248.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.3 (2.2.3-2.fc4) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.077 required=5 tests=[AWL=0.077] +X-Spam-Score: 0.077 +X-Spam-Level: +X-Archive-Number: 200602/64 +X-Sequence-Number: 17050 + +On Tue, 2006-02-07 at 18:59 -0600, Jim C. Nasby wrote: + +> I'm honestly somewhat surprised someone hasn't run into this problem +> with partitioning yet; or maybe everyone who needs to do long +> transactions just shoves those off to slony slaves... + +All DDL takes locks, on all DBMS. + +Best Regards, Simon Riggs + + +From pgsql-performance-owner@postgresql.org Wed Feb 8 07:05:08 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 702159DC881 + for ; + Wed, 8 Feb 2006 07:05:07 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 19914-04 + for ; + Wed, 8 Feb 2006 07:05:09 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.logix-tt.com (serval.logix-tt.com [213.239.221.42]) + by postgresql.org (Postfix) with ESMTP id 74A479DC82D + for ; + Wed, 8 Feb 2006 07:05:04 -0400 (AST) +Received: from kingfisher.intern.logix-tt.com (Mcbf1.m.pppool.de + [89.49.203.241]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logix-tt.com (Postfix) with ESMTP id EBD8124400F; + Wed, 8 Feb 2006 12:05:09 +0100 (CET) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id 3FF0918151EB5; + Wed, 8 Feb 2006 12:05:10 +0100 (CET) +Message-ID: <43E9D066.40101@logix-tt.com> +Date: Wed, 08 Feb 2006 12:05:10 +0100 +From: Markus Schaber +Organization: Logical Tracking and Tracing International AG, Switzerland +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Christopher Browne +Cc: pgsql-performance@postgresql.org +Subject: Re: Default autovacuum settings too conservative +References: <20060201211633.GM95850@pervasive.com> <43E12A03.6070906@zeut.net> + <20060207050545.GZ1240@pervasive.com> + + <20060207072621.GI13592@pervasive.com> + <43E89506.40903@logix-tt.com> + <20060208010339.GT38134@pervasive.com> + <43E94E42.3080605@pws.com.au> + +In-Reply-To: +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.122 required=5 tests=[AWL=0.122] +X-Spam-Score: 0.122 +X-Spam-Level: +X-Archive-Number: 200602/65 +X-Sequence-Number: 17051 + +Hi, Christopher, + +Christopher Browne wrote: + +> Right. And part of the trouble is that you lose certainty that you +> have covered off transaction wraparound. + +Yes. Vacuum (full) serve at least four purposes: + +- TID wraparound prevention +- obsolete row removal +- table compaction +- giving space back to the OS by truncating files + +While the first one needs full table sweeps, the others don't. And from +my personal experience, at least the obsolete row removal is needed much +more frequently than TID wraparound prevention. + +>>When tables are tracked individually for wraparound, the longest +>>transaction required for vacuuming will be one to vacuum one +>>table. With delete-map and other functions, the time for that +>>transaction may be reduced. Partial vacuum of large tables is an +>>option, but again requires some real smarts in the autovac code to +>>track wraparound issues. +> +> Unfortunately, "delete-map" *doesn't* help you with the wraparound +> problem. The point of the "delete map" or "vacuum space map" is to +> allow the VACUUM to only touch the pages known to need vacuuming. +> +> At some point, you still need to walk through the whole table (touched +> parts and untouched) in order to make sure that the old tuples are +> frozen. + +Preventing transaction ID wraparound needs a guaranteed full table sweep +during a vacuum run, but not necessarily in a single transaction. It +should be possible to divide this full table sweep into smaller chunks, +each of them in its own transaction. + +It will certainly be necessary to block e. G. simultaneous VACUUMs, +CLUSTERs or other maintainance commands for the whole VACUUM run, but +normal SELECT, INSERT and UPDATE statement should be able to interleave +with the VACUUM transaction. + +Markus +-- +Markus Schaber | Logical Tracking&Tracing International AG +Dipl. Inf. | Software Development GIS + +Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org + +From pgsql-performance-owner@postgresql.org Wed Feb 8 13:46:22 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 0C0359DCBC3 + for ; + Wed, 8 Feb 2006 13:46:21 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 00312-03 + for ; + Wed, 8 Feb 2006 13:46:17 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.logix-tt.com (serval.logix-tt.com [213.239.221.42]) + by postgresql.org (Postfix) with ESMTP id ED0149DCBE4 + for ; + Wed, 8 Feb 2006 13:46:15 -0400 (AST) +Received: from kingfisher.intern.logix-tt.com (Mcbf1.m.pppool.de + [89.49.203.241]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logix-tt.com (Postfix) with ESMTP id 32B1924400F; + Wed, 8 Feb 2006 18:46:18 +0100 (CET) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id 334C0181520ED; + Wed, 8 Feb 2006 14:38:08 +0100 (CET) +Message-ID: <43E9F440.1080001@logix-tt.com> +Date: Wed, 08 Feb 2006 14:38:08 +0100 +From: Markus Schaber +Organization: Logical Tracking and Tracing International AG, Switzerland +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Mahesh Shinde , + pgsql-performance@postgresql.org +Subject: Re: Default autovacuum settings too conservative +References: <20060201211633.GM95850@pervasive.com> <43E12A03.6070906@zeut.net> + <20060207050545.GZ1240@pervasive.com> + + <20060207072621.GI13592@pervasive.com> + <43E89506.40903@logix-tt.com> + <20060208010339.GT38134@pervasive.com> + <43E94E42.3080605@pws.com.au> + + <43E9D066.40101@logix-tt.com> + <002c01c62ca4$3159b860$dd0aa8c0@codecindia.com> +In-Reply-To: <002c01c62ca4$3159b860$dd0aa8c0@codecindia.com> +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.121 required=5 tests=[AWL=0.121] +X-Spam-Score: 0.121 +X-Spam-Level: +X-Archive-Number: 200602/71 +X-Sequence-Number: 17057 + +Hi, Mahesh, + +Mahesh Shinde wrote: + +> Does vacuum improves the performance of the database search.. As if now I +> have a table who is having a records 70 lac and daily appx 10-15 thousand +> rows get added. so please let me know which type of vacuum I should prefer. +> I am accessing a data using java application which is hosted on the same +> database server. + +I don't know what "70 lac" means. + +But if you only add to the table, and never update or delete, vacuum +brings nothing for performance. (Although it is necessary for TID +wraparound prevention.) + +However, if your often do range queries on an index that does not +correspond to the insertion order, you may benefit from CLUSTERing on +that index from time to time. + + + +Hth, +Markus + +-- +Markus Schaber | Logical Tracking&Tracing International AG +Dipl. Inf. | Software Development GIS + +Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org + +From pgsql-performance-owner@postgresql.org Wed Feb 8 09:54:57 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 14F449DCA0D + for ; + Wed, 8 Feb 2006 09:54:56 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 52123-01 + for ; + Wed, 8 Feb 2006 09:54:59 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.suntradingllc.com (mail.suntradingllc.com [66.227.78.98]) + by postgresql.org (Postfix) with ESMTP id 5809D9DCA6E + for ; + Wed, 8 Feb 2006 09:54:52 -0400 (AST) +Received: (qmail 28612 invoked by uid 89); 8 Feb 2006 13:54:54 -0000 +Received: by simscan 1.1.0 ppid: 28604, pid: 28607, t: 0.9201s + scanners: attach: 1.1.0 clamav: 0.85.1/m:34/d:1166 spam: 3.0.4 +Received: from unknown (HELO ?172.20.34.18?) + (jake@suntradingllc.com@172.20.34.18) + by 0 with SMTP; 8 Feb 2006 13:54:53 -0000 +Subject: optimizing away join when querying view +From: Jacob Costello +To: pgsql-performance@postgresql.org +Content-Type: text/plain +Organization: Sun Trading, LLC +Date: Wed, 08 Feb 2006 07:54:51 -0600 +Message-Id: <1139406891.11389.60.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.3 (2.2.3-2.fc4) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200602/66 +X-Sequence-Number: 17052 + +Postgres doesn't seem to optimize away unnecessary joins in a view +definition when the view is queried in such a way that the join need not +be executed. In the example below, I define two tables, foo and bar, +with a foreign key on bar referencing foo, and a view on the natural +join of the tables. The tables are defined so that the relationship +from bar to foo is allowed to be many to one, with the column of bar +referencing foo (column a) set NOT NULL, so that there must be exactly +one foo record for every bar record. I then EXPLAIN selecting the "b" +column from bar, through the view and from bar directly. The tables +have been ANALYZEd but have no data. EXPLAIN shows the join actually +occurring when selecting b from the view quux. If I understand +correctly (maybe I don't), this is guaranteed to be exactly the same as +the selecting b directly from the bar table. The practical import of +this comes into play when views are provided to simplify queries for end +users, and those views use joins to include related data. If the user +enters a query that is equivalent to a query on a base table, why should +the query pay a performance penalty ? + +table foo: + +Column | Type | Modifiers +--------+---------+----------- +a | integer | not null +Indexes: + "foo_pkey" PRIMARY KEY, btree (a) + + +table bar: + +Column | Type | Modifiers +--------+---------+----------- +a | integer | not null +b | integer | +Foreign-key constraints: + "bar_a_fkey" FOREIGN KEY (a) REFERENCES foo(a) + + +view quux: + +Column | Type | Modifiers +--------+---------+----------- +a | integer | +b | integer | +View definition: +SELECT bar.a, bar.b + FROM bar +NATURAL JOIN foo + + +EXPLAINed Queries: + +explain select b from bar; + + QUERY PLAN +--------------------------------------------------- +Seq Scan on bar (cost=0.00..1.00 rows=1 width=4) +(1 row) + +explain select b from quux; + + QUERY PLAN +-------------------------------------------------------------------------- +Nested Loop (cost=0.00..5.84 rows=1 width=4) + -> Seq Scan on bar (cost=0.00..1.00 rows=1 width=8) + -> Index Scan using foo_pkey on foo (cost=0.00..4.82 rows=1 +width=4) + Index Cond: ("outer".a = foo.a) +(4 rows) + +-- +Jacob Costello +Sun Trading, LLC + + + +From pgsql-performance-owner@postgresql.org Wed Feb 8 10:09:29 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 2E7779DC93F + for ; + Wed, 8 Feb 2006 10:09:29 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 50359-10 + for ; + Wed, 8 Feb 2006 10:09:32 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smtpauth07.mail.atl.earthlink.net + (smtpauth07.mail.atl.earthlink.net [209.86.89.67]) + by postgresql.org (Postfix) with ESMTP id CD7B19DC821 + for ; + Wed, 8 Feb 2006 10:09:26 -0400 (AST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=mP5kuwt4Xr7+badqK3Q3xAuMw8HZdXy/Z8ubD5J2Rtd6W2xhkNIvl9dxyl821cXY; + h=Received:Message-Id:X-Mailer:Date:To:From:Subject:Mime-Version:Content-Type:X-ELNK-Trace:X-Originating-IP; +Received: from [71.243.30.247] (helo=ron-6d52adff2a6.earthlink.net) + by smtpauth07.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1F6q0g-0001TC-Tu; Wed, 08 Feb 2006 09:09:31 -0500 +Message-Id: <7.0.1.0.2.20060208090456.035842d0@earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 7.0.1.0 +Date: Wed, 08 Feb 2006 09:11:11 -0500 +To: pgsql-performance@postgresql.org +From: Ron +Subject: Size and performance hit from using UTF8 vs. ASCII? +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bc1e79237d68aec2a23af248512d9d2416350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 71.243.30.247 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.479 required=5 tests=[DNS_FROM_RFC_ABUSE=0.479] +X-Spam-Score: 0.479 +X-Spam-Level: +X-Archive-Number: 200602/67 +X-Sequence-Number: 17053 + +I'm specifically interested in the default C Locale; but if there's a +difference in the answer for other locales, I'd like to hear about +that as well. + +Thanks in Advance, +Ron + + + +From pgsql-performance-owner@postgresql.org Wed Feb 8 11:37:36 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id C41549DC815 + for ; + Wed, 8 Feb 2006 11:37:35 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 70746-04 + for ; + Wed, 8 Feb 2006 11:37:39 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 128869DC82D + for ; + Wed, 8 Feb 2006 11:37:32 -0400 (AST) +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 k18Fbb9J007894; + Wed, 8 Feb 2006 10:37:38 -0500 (EST) +To: Jacob Costello +cc: pgsql-performance@postgresql.org +Subject: Re: optimizing away join when querying view +In-reply-to: <1139406891.11389.60.camel@localhost.localdomain> +References: <1139406891.11389.60.camel@localhost.localdomain> +Comments: In-reply-to Jacob Costello + message dated "Wed, 08 Feb 2006 07:54:51 -0600" +Date: Wed, 08 Feb 2006 10:37:37 -0500 +Message-ID: <7893.1139413057@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.108 required=5 tests=[AWL=0.108] +X-Spam-Score: 0.108 +X-Spam-Level: +X-Archive-Number: 200602/68 +X-Sequence-Number: 17054 + +Jacob Costello writes: +> Postgres doesn't seem to optimize away unnecessary joins + +There is no such thing as an unnecessary join, unless you are willing to +stake the correctness of the query on constraints that could be dropped +after the query is planned. Until we have some infrastructure to deal +with that situation, nothing like this is going to happen. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Feb 8 11:46:45 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 4861F9DCA84 + for ; + Wed, 8 Feb 2006 11:46:44 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 77836-06 + for ; + Wed, 8 Feb 2006 11:46:48 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by postgresql.org (Postfix) with ESMTP id 05E3A9DCA41 + for ; + Wed, 8 Feb 2006 11:46:41 -0400 (AST) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id D307E3AF48; Wed, 8 Feb 2006 07:46:39 -0800 (PST) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id D11783AF2F; Wed, 8 Feb 2006 07:46:39 -0800 (PST) +Date: Wed, 8 Feb 2006 07:46:39 -0800 (PST) +From: Stephan Szabo +To: Jacob Costello +Cc: pgsql-performance@postgresql.org +Subject: Re: optimizing away join when querying view +In-Reply-To: <1139406891.11389.60.camel@localhost.localdomain> +Message-ID: <20060208073955.S43207@megazone.bigpanda.com> +References: <1139406891.11389.60.camel@localhost.localdomain> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.139 required=5 tests=[AWL=0.139] +X-Spam-Score: 0.139 +X-Spam-Level: +X-Archive-Number: 200602/69 +X-Sequence-Number: 17055 + +On Wed, 8 Feb 2006, Jacob Costello wrote: + +> Postgres doesn't seem to optimize away unnecessary joins in a view +> definition when the view is queried in such a way that the join need not +> be executed. In the example below, I define two tables, foo and bar, +> with a foreign key on bar referencing foo, and a view on the natural +> join of the tables. The tables are defined so that the relationship +> from bar to foo is allowed to be many to one, with the column of bar +> referencing foo (column a) set NOT NULL, so that there must be exactly +> one foo record for every bar record. I then EXPLAIN selecting the "b" +> column from bar, through the view and from bar directly. The tables +> have been ANALYZEd but have no data. EXPLAIN shows the join actually +> occurring when selecting b from the view quux. If I understand +> correctly (maybe I don't), this is guaranteed to be exactly the same as +> the selecting b directly from the bar table. + +AFAIK there are periods in which a foreign key does not guarantee that +there's one foo record for every bar record between an action and the +constraint check for that action at statement end so you'd probably have +to be careful in any case. + +From pgsql-performance-owner@postgresql.org Wed Feb 8 11:54:04 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 0F9179DCA84 + for ; + Wed, 8 Feb 2006 11:54:04 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 80742-01 + for ; + Wed, 8 Feb 2006 11:54:08 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from gghcwest.com (adsl-71-128-90-172.dsl.pltn13.pacbell.net + [71.128.90.172]) + by postgresql.org (Postfix) with ESMTP id AC53C9DCA6E + for ; + Wed, 8 Feb 2006 11:54:01 -0400 (AST) +Received: from [192.246.145.82] (pismo.gghcwest.com [192.246.145.82]) + by gghcwest.com (8.12.10/8.12.9) with ESMTP id k18Fs2md021394; + Wed, 8 Feb 2006 07:54:03 -0800 +Subject: Re: Size and performance hit from using UTF8 vs. ASCII? +From: "Jeffrey W. Baker" +To: Ron +Cc: pgsql-performance@postgresql.org +In-Reply-To: <7.0.1.0.2.20060208090456.035842d0@earthlink.net> +References: <7.0.1.0.2.20060208090456.035842d0@earthlink.net> +Content-Type: text/plain +Date: Wed, 08 Feb 2006 07:54:01 -0800 +Message-Id: <1139414042.8707.7.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.5.90 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200602/70 +X-Sequence-Number: 17056 + +On Wed, 2006-02-08 at 09:11 -0500, Ron wrote: +> I'm specifically interested in the default C Locale; but if there's a +> difference in the answer for other locales, I'd like to hear about +> that as well. + +The size hit will be effectively zero if your data is mainly of the +ASCII variety, since ASCII printable characters to UTF-8 is an identity +transform. However anything involving string comparisons, including +equality, similarity (LIKE, regular expressions), or any other kind of +comparison (ORDER BY, GROUP BY) will be slower. In my experience the +performance hit varies from zero to 100% in CPU time. UTF-8 is never +faster that ASCII, as far as I know. + +However, if you need UTF-8 then you need it, and there's no point in +worrying about the performance hit. + +You may as well just do two benchmark runs with your database +initialized in either character set to see for yourself. + +-jwb + + + +From pgsql-performance-owner@postgresql.org Wed Feb 8 18:03:25 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 0C1BE9DC850 + for ; + Wed, 8 Feb 2006 18:03:24 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 64839-01 + for ; + Wed, 8 Feb 2006 18:03:25 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smtpauth01.mail.atl.earthlink.net + (smtpauth01.mail.atl.earthlink.net [209.86.89.61]) + by postgresql.org (Postfix) with ESMTP id 15A3C9DC815 + for ; + Wed, 8 Feb 2006 18:03:20 -0400 (AST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=dEU+cnKHXTRghuliLlgJkXnJlZigBnbomSVVrP7Mtt750K6vJ6dpa1N29BktGfOP; + h=Received:Message-Id:X-Mailer:Date:To:From:Subject:Mime-Version:Content-Type:X-ELNK-Trace:X-Originating-IP; +Received: from [71.243.43.186] (helo=ron-6d52adff2a6.earthlink.net) + by smtpauth01.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1F6xPH-0003KZ-0K; Wed, 08 Feb 2006 17:03:23 -0500 +Message-Id: <7.0.1.0.2.20060208164655.0382eb40@earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 7.0.1.0 +Date: Wed, 08 Feb 2006 17:05:02 -0500 +To: pgsql-performance@postgresql.org +From: Ron +Subject: Sane configuration options for a WinXP laptop 8.1 install? +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bc20c8ec4962e77a85ac70a3d572967740350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 71.243.43.186 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.479 required=5 tests=[DNS_FROM_RFC_ABUSE=0.479] +X-Spam-Score: 0.479 +X-Spam-Level: +X-Archive-Number: 200602/72 +X-Sequence-Number: 17058 + +In an attempt to save myself some time, I thought I ask The Community +if anyone has guidance here. + +HW: Intel PM (very likely to be upgraded to an AMD Turion when the +proper HW becomes available) w/ 2GB of RAM (shortly to be 4GB) and a +5400rpm 100GB HD (will be dual 7200rpm 160GB HD's as soon as they +become available) + +OS: The laptop in question is running the latest WinXP service pack +and patches. When the CPU and HD upgrades mentioned above happen, I +will probably start running dual boot FC5 + 64b Windows. + +Possible optional HW: external "box of HDs" for doing and/or +modelling stuff that can't be using only the internal ones. + +I want to get as much performance as I can out of the HW + OS. + +Anyone want to take a stab at what the config files and options +should be for best performance under most circumstances? + +This is intended to be a portable development platform, so opinions +as to which contrib modules are worth/not worth installing is also appreciated. + +TiA, +Ron + + + +From pgsql-performance-owner@postgresql.org Wed Feb 8 19:31:16 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 7B4389DCC6A + for ; + Wed, 8 Feb 2006 19:31:15 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 79387-06 + for ; + Wed, 8 Feb 2006 19:31:17 -0400 (AST) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 4BBA49DCBF0 + for ; + Wed, 8 Feb 2006 19:31:13 -0400 (AST) +Received: from gw.proximity.com.au (147-68-185-210.rev.techex.net.au + [210.185.68.147]) + by svr4.postgresql.org (Postfix) with ESMTP id A5B465AF05C + for ; + Wed, 8 Feb 2006 23:31:16 +0000 (GMT) +Received: from localhost (localhost [127.0.0.1]) + by gw.proximity.com.au (Postfix) with ESMTP id BE7531EFCF5; + Thu, 9 Feb 2006 10:31:10 +1100 (EST) +Received: from gw.proximity.com.au ([127.0.0.1]) + by localhost (gw [127.0.0.1]) (amavisd-new, port 10024) with ESMTP + id 27959-08; Thu, 9 Feb 2006 10:31:09 +1100 (EST) +Received: from [192.168.128.103] (bee.proximity.com.au [192.168.128.103]) + by gw.proximity.com.au (Postfix) with ESMTP id AF9A61EFCF3; + Thu, 9 Feb 2006 10:31:09 +1100 (EST) +Message-ID: <43EA7F3D.7050306@proximity.com.au> +Date: Thu, 09 Feb 2006 10:31:09 +1100 +From: Tim Allen +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Markus Schaber +Cc: Mahesh Shinde , + pgsql-performance@postgresql.org +Subject: Re: Default autovacuum settings too conservative +References: <20060201211633.GM95850@pervasive.com> <43E12A03.6070906@zeut.net> + <20060207050545.GZ1240@pervasive.com> + + <20060207072621.GI13592@pervasive.com> + <43E89506.40903@logix-tt.com> + <20060208010339.GT38134@pervasive.com> + <43E94E42.3080605@pws.com.au> + + <43E9D066.40101@logix-tt.com> + <002c01c62ca4$3159b860$dd0aa8c0@codecindia.com> + <43E9F440.1080001@logix-tt.com> +In-Reply-To: <43E9F440.1080001@logix-tt.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at proximity.com.au +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200602/73 +X-Sequence-Number: 17059 + +Markus Schaber wrote: +>>Does vacuum improves the performance of the database search.. As if now I +>>have a table who is having a records 70 lac and daily appx 10-15 thousand +>>rows get added. so please let me know which type of vacuum I should prefer. +>>I am accessing a data using java application which is hosted on the same +>>database server. +> +> I don't know what "70 lac" means. + +One lac (also spelt "lakh") is one hundred thousand. And one crore is +ten million. Indians count differently from the rest of the world :-). + +Tim + +-- +----------------------------------------------- +Tim Allen tim@proximity.com.au +Proximity Pty Ltd http://www.proximity.com.au/ + +From pgsql-performance-owner@postgresql.org Wed Feb 8 20:21:03 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 1ADCA9DCC79 + for ; + Wed, 8 Feb 2006 20:21:03 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91141-02 + for ; + Wed, 8 Feb 2006 20:21:05 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from moutng.kundenserver.de (moutng.kundenserver.de + [212.227.126.187]) + by postgresql.org (Postfix) with ESMTP id 8B4519DCC78 + for ; + Wed, 8 Feb 2006 20:21:00 -0400 (AST) +Received: from [84.157.3.179] (helo=lunix.schabi.de) + by mrelayeu.kundenserver.de (node=mrelayeu3) with ESMTP (Nemesis), + id 0MKxQS-1F6zYV09Ro-00007I; Thu, 09 Feb 2006 01:21:03 +0100 +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by lunix.schabi.de (Postfix) with ESMTP id 4E8B0557A8; + Thu, 9 Feb 2006 01:21:02 +0100 (CET) +Message-ID: <43EA8AED.9020706@logix-tt.com> +Date: Thu, 09 Feb 2006 01:21:01 +0100 +From: Markus Schaber +User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: de-DE, de, en-us, en +MIME-Version: 1.0 +To: Mahesh Shinde +CC: pgsql-performance@postgresql.org +Subject: Re: Default autovacuum settings too conservative +References: <20060201211633.GM95850@pervasive.com> <43E12A03.6070906@zeut.net> + <20060207050545.GZ1240@pervasive.com> + + <20060207072621.GI13592@pervasive.com> + <43E89506.40903@logix-tt.com> + <20060208010339.GT38134@pervasive.com> + <43E94E42.3080605@pws.com.au> + + <43E9D066.40101@logix-tt.com> + <002c01c62ca4$3159b860$dd0aa8c0@codecindia.com> + <43E9F440.1080001@logix-tt.com> <43EA7F3D.7050306@proximity.com.au> +In-Reply-To: <43EA7F3D.7050306@proximity.com.au> +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Provags-ID: kundenserver.de abuse@kundenserver.de + login:a9554655f07a4e401310f2acfb43f5bf +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200602/74 +X-Sequence-Number: 17060 + +Hi, Tim, + +Tim Allen schrieb: +>> I don't know what "70 lac" means. +> One lac (also spelt "lakh") is one hundred thousand. And one crore is +> ten million. Indians count differently from the rest of the world :-). + +Okay, so he talks about 7 million rows. + +Thank you. + +Markus + +From pgsql-performance-owner@postgresql.org Thu Feb 9 02:32:55 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 1FD7F9DC823 + for ; + Thu, 9 Feb 2006 02:32:55 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 59375-03 + for ; + Thu, 9 Feb 2006 02:32:54 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id D15DE9DC80C + for ; + Thu, 9 Feb 2006 02:32:52 -0400 (AST) +Received: by noel.decibel.org (Postfix, from userid 1001) + id C334E39842; Thu, 9 Feb 2006 06:32:35 +0000 (UTC) +Received: (hashcash-sendmail, from uid 1001); + Thu, 9 Feb 2006 00:32:35 -0600 +Date: Thu, 9 Feb 2006 00:32:35 -0600 +From: "Jim C. Nasby" +To: Ron +Cc: pgsql-performance@postgresql.org +Subject: Re: Sane configuration options for a WinXP laptop 8.1 install? +Message-ID: <20060209063235.GZ57845@pervasive.com> +References: <7.0.1.0.2.20060208164655.0382eb40@earthlink.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <7.0.1.0.2.20060208164655.0382eb40@earthlink.net> +X-Operating-System: FreeBSD 6.0-RELEASE amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060209:rjpeace@earthlink.net::/1QTaSY7XftK0lC/:0000000000000000 + 0000000000000000000000002k4W +X-Hashcash: + 1:20:060209:pgsql-performance@postgresql.org::Fk8lidNgOJrMLxut:00000 + 0000000000000000000000003jo4 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.104 required=5 tests=[AWL=0.104] +X-Spam-Score: 0.104 +X-Spam-Level: +X-Archive-Number: 200602/75 +X-Sequence-Number: 17061 + +On Wed, Feb 08, 2006 at 05:05:02PM -0500, Ron wrote: +> In an attempt to save myself some time, I thought I ask The Community +> if anyone has guidance here. +> +> HW: Intel PM (very likely to be upgraded to an AMD Turion when the +> proper HW becomes available) w/ 2GB of RAM (shortly to be 4GB) and a +> 5400rpm 100GB HD (will be dual 7200rpm 160GB HD's as soon as they +> become available) +> +> OS: The laptop in question is running the latest WinXP service pack +> and patches. When the CPU and HD upgrades mentioned above happen, I +> will probably start running dual boot FC5 + 64b Windows. +> +> Possible optional HW: external "box of HDs" for doing and/or +> modelling stuff that can't be using only the internal ones. +> +> I want to get as much performance as I can out of the HW + OS. +> +> Anyone want to take a stab at what the config files and options +> should be for best performance under most circumstances? +> +> This is intended to be a portable development platform, so opinions +> as to which contrib modules are worth/not worth installing is also +> appreciated. + +Off the top of my head... + +shared_buffers=30000 +drop max_connections to what you'll actually be using +maintenance_work_mem=100000 +work_mem=2000000/max_connections (maybe * 0.9 for some added margin) +autovacuum=on +autovacuum_vacuum_cost_delay=20 +autovacuum_vacuum_scale_factor=0.2 +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Thu Feb 9 10:02:01 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 2E0499DC81F + for ; + Thu, 9 Feb 2006 10:02:00 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 45356-04 + for ; + Thu, 9 Feb 2006 10:02:03 -0400 (AST) +X-Greylist: delayed 00:16:57.786819 by SQLgrey- +Received: from mta4.adelphia.net (mta4.adelphia.net [68.168.78.184]) + by postgresql.org (Postfix) with ESMTP id 1F75E9DC81C + for ; + Thu, 9 Feb 2006 10:01:56 -0400 (AST) +Received: from nemo.qabal.org ([67.23.174.57]) by mta13.adelphia.net + (InterMail vM.6.01.05.02 201-2131-123-102-20050715) with ESMTP + id <20060209134502.USFE25152.mta13.adelphia.net@nemo.qabal.org> + for ; + Thu, 9 Feb 2006 08:45:02 -0500 +Received: from [127.0.0.1] (nemo.qabal.org [192.168.1.9]) + by nemo.qabal.org (8.13.4/8.12.11) with ESMTP id k19Dj15d006924 + for ; Thu, 9 Feb 2006 08:45:01 -0500 +Message-ID: <43EB475C.3040708@qabal.org> +Date: Thu, 09 Feb 2006 08:45:00 -0500 +From: Nate Byrnes +User-Agent: Thunderbird 1.5 (Windows/20051201) +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Storing Digital Video +References: <3cf983d0601311632t4a2f068au1f958746c2b092a7@mail.gmail.com> + <200602060930.31144.albert@sedifa.com> +In-Reply-To: <200602060930.31144.albert@sedifa.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, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200602/76 +X-Sequence-Number: 17062 + +I must claim some ignorance, I come from the application world... but, +from a data integrity perspective, it makes a whole lot of sense to +store video, images, documents, whatever in the database rather than on +the file system external to it. Personally, I would use LOB's, but I do +not know the internals well enough to say LOBs or large columns. +Regardless, there are a lot of compelling reasons ranging from software +maintenance, disk management, data access control, single security layer +implementation, and so on which justify storing data like this in the +DB. Am I too much of an Oracle guy? I think that Postgres is more than +capable enough for this type of implementation. Is this confidence +unfounded? + + Aside from disk utilization, what are the performance issues with +LOB and / or large columns? Does the data on disk get too fragmented to +allow for efficient querying? Are the performance issues significant +enough to push parts of the data integrity responsibility to the +application layer? + +Thanks, + Nate + +Albert Cervera Areny wrote: +> A Dimecres 01 Febrer 2006 01:32, Rodrigo Madera va escriure: +> +>> I am concerned with performance issues involving the storage of DV on +>> a database. +>> +>> I though of some options, which would be the most advised for speed? +>> +>> 1) Pack N frames inside a "container" and store the container to the db. +>> 2) Store each frame in a separate record in the table "frames". +>> 3) (type something here) +>> +>> Thanks for the help, +>> +> +> +> What if you store meta data in the database and use some PL/Python/Java/Perl +> functions to store and retrieve video files from the server. The function +> would store files to the files system, not a table. This avoids the need for +> a file server for your application while making your relational queries fast. +> +> Any experiences/thoughts on this solution? +> +> +>> Rodrigo +>> +>> ---------------------------(end of broadcast)--------------------------- +>> TIP 9: In versions below 8.0, the planner will ignore your desire to +>> choose an index scan if your joining column's datatypes do not +>> match +>> +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: Don't 'kill -9' the postmaster +> +> !DSPAM:43e70ada303236796316472! +> +> + +From pgsql-performance-owner@postgresql.org Thu Feb 9 11:10:37 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 151C39DC851 + for ; + Thu, 9 Feb 2006 11:10:35 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 60468-01 + for ; + Thu, 9 Feb 2006 11:10:38 -0400 (AST) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 6A0569DC987 + for ; + Thu, 9 Feb 2006 11:10:30 -0400 (AST) +Received: from pat.uio.no (pat.uio.no [129.240.130.16]) + by svr4.postgresql.org (Postfix) with ESMTP id A39F75AF085 + for ; + Thu, 9 Feb 2006 15:10:35 +0000 (GMT) +Received: from mail-mx4.uio.no ([129.240.10.45]) + by pat.uio.no with esmtp (Exim 4.43) id 1F7DRH-0005Cc-KA + for pgsql-performance@postgresql.org; Thu, 09 Feb 2006 16:10:31 +0100 +Received: from bbking.uio.no ([129.240.201.179]) + by mail-mx4.uio.no with esmtps (TLSv1:AES256-SHA:256) (Exim 4.43) + id 1F7DRD-00008I-SD + for pgsql-performance@postgresql.org; Thu, 09 Feb 2006 16:10:27 +0100 +Subject: Help with optimizing a sql statement +From: Rafael Martinez Guerrero +To: pgsql-performance@postgresql.org +Content-Type: text/plain +Organization: University of Oslo +Message-Id: <1139497827.25608.1014.camel@bbking.uio.no> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 (1.4.5-17) +Date: Thu, 09 Feb 2006 16:10:27 +0100 +Content-Transfer-Encoding: 7bit +X-UiO-Spam-info: not spam, SpamAssassin (score=-5.43, required 12, + autolearn=disabled, AWL -0.43, UIO_MAIL_IS_INTERNAL -5.00) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200602/77 +X-Sequence-Number: 17063 + +Hello + +We are running an application via web that use a lot of time to perform +some operations. We are trying to find out if some of the sql statements +used are the reason of the slow speed. + +We have identified a sql that takes like 4-5000ms more than the second +slowest sql in out test server. I hope that we will get some help to try +to optimize it. + +Thanks in advance for any help. + +Some information: +******************************************************************************** +rttest=# EXPLAIN ANALYZE SELECT DISTINCT main.* + +FROM Users main , + Principals Principals_1, + ACL ACL_2, + Groups Groups_3, + CachedGroupMembers CachedGroupMembers_4 + +WHERE ((ACL_2.RightName = 'OwnTicket')) +AND ((CachedGroupMembers_4.MemberId = Principals_1.id)) +AND ((Groups_3.id = CachedGroupMembers_4.GroupId)) +AND ((Principals_1.Disabled = '0') or (Principals_1.Disabled = '0')) +AND ((Principals_1.id != '1')) +AND ((main.id = Principals_1.id)) +AND ( ( ACL_2.PrincipalId = Groups_3.id AND ACL_2.PrincipalType = +'Group' AND ( Groups_3.Domain = 'SystemInternal' OR Groups_3.Domain = +'UserDefined' OR Groups_3.Domain = 'ACLEquivalence')) OR ( ( +(Groups_3.Domain = 'RT::Queue-Role' ) ) AND Groups_3.Type +=ACL_2.PrincipalType) ) +AND (ACL_2.ObjectType = 'RT::System' OR (ACL_2.ObjectType = 'RT::Queue') +) + +ORDER BY main.Name ASC + +QUERY PLAN +----------------------------------------------------------------- + Unique (cost=28394.99..28395.16 rows=2 width=706) (actual +time=15574.272..15787.681 rows=254 loops=1) + -> Sort (cost=28394.99..28394.99 rows=2 width=706) (actual +time=15574.267..15607.310 rows=22739 loops=1) + Sort Key: main.name, main.id, main."password", main.comments, +main.signature, main.emailaddress, main.freeformcontactinfo, +main.organization, main.realname, main.nickname, main.lang, +main.emailencoding, main.webencoding, main.externalcontactinfoid, +main.contactinfosystem, main.externalauthid, main.authsystem, +main.gecos, main.homephone, main.workphone, main.mobilephone, +main.pagerphone, main.address1, main.address2, main.city, main.state, +main.zip, main.country, main.timezone, main.pgpkey, main.creator, +main.created, main.lastupdatedby, main.lastupdated + -> Nested Loop (cost=20825.91..28394.98 rows=2 width=706) +(actual time=1882.608..14589.596 rows=22739 loops=1) + Join Filter: (((("inner"."domain")::text = +'RT::Queue-Role'::text) OR ("outer".principalid = "inner".id)) AND +((("inner"."type")::text = ("outer".principaltype)::text) OR +("outer".principalid = "inner".id)) AND ((("inner"."domain")::text = +'RT::Queue-Role'::text) OR (("outer".principaltype)::text = +'Group'::text)) AND ((("inner"."type")::text = +("outer".principaltype)::text) OR (("outer".principaltype)::text = +'Group'::text)) AND ((("inner"."type")::text = +("outer".principaltype)::text) OR (("inner"."domain")::text = +'SystemInternal'::text) OR (("inner"."domain")::text = +'UserDefined'::text) OR (("inner"."domain")::text = +'ACLEquivalence'::text))) + -> Seq Scan on acl acl_2 (cost=0.00..40.57 rows=45 +width=13) (actual time=0.020..1.730 rows=51 loops=1) + Filter: (((rightname)::text = 'OwnTicket'::text) +AND (((objecttype)::text = 'RT::System'::text) OR ((objecttype)::text = +'RT::Queue'::text))) + -> Materialize (cost=20825.91..20859.37 rows=3346 +width=738) (actual time=36.925..166.374 rows=66823 loops=51) + -> Merge Join (cost=15259.56..20825.91 rows=3346 +width=738) (actual time=1882.539..3538.258 rows=66823 loops=1) + Merge Cond: ("outer".id = "inner".memberid) + -> Merge Join (cost=0.00..5320.37 +rows=13182 width=710) (actual time=0.116..874.960 rows=13167 loops=1) + Merge Cond: ("outer".id = "inner".id) + -> Index Scan using users_pkey on +users main (cost=0.00..1063.60 rows=13181 width=706) (actual +time=0.032..52.355 rows=13181 loops=1) + -> Index Scan using principals_pkey on +principals principals_1 (cost=0.00..3737.49 rows=141801 width=4) +(actual time=0.020..463.043 rows=141778 loops=1) + Filter: ((disabled = 0::smallint) +AND (id <> 1)) + -> Sort (cost=15259.56..15349.54 rows=35994 +width=36) (actual time=1882.343..1988.353 rows=80357 loops=1) + Sort Key: cachedgroupmembers_4.memberid + -> Hash Join (cost=3568.51..12535.63 +rows=35994 width=36) (actual time=96.151..1401.537 rows=80357 loops=1) + Hash Cond: ("outer".groupid = +"inner".id) + -> Seq Scan on +cachedgroupmembers cachedgroupmembers_4 (cost=0.00..5961.53 rows=352753 +width=8) (actual time=0.011..500.508 rows=352753 loops=1) + -> Hash (cost=3535.70..3535.70 +rows=13124 width=32) (actual time=95.966..95.966 rows=0 loops=1) + -> Index Scan using +groups1, groups1, groups1, groups1 on groups groups_3 +(cost=0.00..3535.70 rows=13124 width=32) (actual time=0.045..76.506 +rows=13440 loops=1) + Index Cond: +((("domain")::text = 'RT::Queue-Role'::text) OR (("domain")::text = +'SystemInternal'::text) OR (("domain")::text = 'UserDefined'::text) OR +(("domain")::text = 'ACLEquivalence'::text)) + + Total runtime: 15825.022 ms + +******************************************************************************** +rttest=# \d users + Table "public.users" + Column | Type | +Modifiers +-----------------------+-----------------------------+------------------------------------------------ + id | integer | not null default +nextval('users_id_seq'::text) + name | character varying(200) | not null + password | character varying(40) | + comments | text | + signature | text | + emailaddress | character varying(120) | + freeformcontactinfo | text | + organization | character varying(200) | + realname | character varying(120) | + nickname | character varying(16) | + lang | character varying(16) | + emailencoding | character varying(16) | + webencoding | character varying(16) | + externalcontactinfoid | character varying(100) | + contactinfosystem | character varying(30) | + externalauthid | character varying(100) | + authsystem | character varying(30) | + gecos | character varying(16) | + homephone | character varying(30) | + workphone | character varying(30) | + mobilephone | character varying(30) | + pagerphone | character varying(30) | + address1 | character varying(200) | + address2 | character varying(200) | + city | character varying(100) | + state | character varying(100) | + zip | character varying(16) | + country | character varying(50) | + timezone | character varying(50) | + pgpkey | text | + creator | integer | not null default +0 + created | timestamp without time zone | + lastupdatedby | integer | not null default +0 + lastupdated | timestamp without time zone | +Indexes: + "users_pkey" primary key, btree (id) + "users1" unique, btree (name) + "users2" btree (name) + "users3" btree (id, emailaddress) + "users4" btree (emailaddress) +******************************************************************************** +rttest=# \d principals + + Table "public.principals" + Column | Type | +Modifiers +---------------+-----------------------+---------------------------------------- + id | integer | not null default +nextval('principals_id_seq'::text) + principaltype | character varying(16) | not null + objectid | integer | + disabled | smallint | not null default 0 +Indexes: + "principals_pkey" primary key, btree (id) + "principals2" btree (objectid) + +******************************************************************************** +rttest=# \d acl + + Table "public.acl" + Column | Type | +Modifiers +---------------+-----------------------+---------------------------------------------- + id | integer | not null default +nextval('acl_id_seq'::text) + principaltype | character varying(25) | not null + principalid | integer | not null + rightname | character varying(25) | not null + objecttype | character varying(25) | not null + objectid | integer | not null default 0 + delegatedby | integer | not null default 0 + delegatedfrom | integer | not null default 0 +Indexes: + "acl_pkey" primary key, btree (id) + "acl1" btree (rightname, objecttype, objectid, principaltype, +principalid) + + +******************************************************************************** +rttest=# \d groups + + Table "public.groups" + Column | Type | +Modifiers +-------------+------------------------+------------------------------------------------- + id | integer | not null default +nextval('groups_id_seq'::text) + name | character varying(200) | + description | character varying(255) | + domain | character varying(64) | + type | character varying(64) | + instance | integer | +Indexes: + "groups_pkey" primary key, btree (id) + "groups1" unique, btree ("domain", instance, "type", id, name) + "groups2" btree ("type", instance, "domain") + + +******************************************************************************** + rttest=# \d cachedgroupmembers" + + Table "public.cachedgroupmembers" + Column | Type | +Modifiers +-------------------+----------+------------------------------------------------------------- + id | integer | not null default +nextval('cachedgroupmembers_id_seq'::text) + groupid | integer | + memberid | integer | + via | integer | + immediateparentid | integer | + disabled | smallint | not null default 0 +Indexes: + "cachedgroupmembers_pkey" primary key, btree (id) + "cachedgroupmembers2" btree (memberid) + "cachedgroupmembers3" btree (groupid) + "disgroumem" btree (groupid, memberid, disabled) + + +******************************************************************************** + +-- +Rafael Martinez, +Center for Information Technology Services +University of Oslo, Norway + +PGP Public Key: http://folk.uio.no/rafael/ + + +From pgsql-performance-owner@postgresql.org Thu Feb 9 11:23:46 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id D51139DC851 + for ; + Thu, 9 Feb 2006 11:23:45 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 61619-04 + for ; + Thu, 9 Feb 2006 11:23:50 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from moonunit2.moonview.localnet (wsip-68-15-5-150.sd.sd.cox.net + [68.15.5.150]) by postgresql.org (Postfix) with ESMTP id 5196F9DC81C + for ; + Thu, 9 Feb 2006 11:23:43 -0400 (AST) +Received: from [192.168.0.3] (moonunit3.moonview.localnet [192.168.0.3]) + by moonunit2.moonview.localnet (8.13.1/8.13.1) with ESMTP id + k19EQu0r001820; Thu, 9 Feb 2006 06:26:56 -0800 +Message-ID: <43EB5D59.1030207@modgraph-usa.com> +Date: Thu, 09 Feb 2006 07:18:49 -0800 +From: "Craig A. James" +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Nate Byrnes +CC: pgsql-performance@postgresql.org +Subject: Re: Storing Digital Video +References: <3cf983d0601311632t4a2f068au1f958746c2b092a7@mail.gmail.com> + <200602060930.31144.albert@sedifa.com> <43EB475C.3040708@qabal.org> +In-Reply-To: <43EB475C.3040708@qabal.org> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.093 required=5 tests=[AWL=0.093] +X-Spam-Score: 0.093 +X-Spam-Level: +X-Archive-Number: 200602/78 +X-Sequence-Number: 17064 + +Nate Byrnes wrote: +> I must claim some ignorance, I come from the application world... but, +> from a data integrity perspective, it makes a whole lot of sense to +> store video, images, documents, whatever in the database rather than on +> the file system external to it. Personally, I would use LOB's, but I do +> not know the internals well enough to say LOBs or large columns. +> Regardless, there are a lot of compelling reasons ranging from software +> maintenance, disk management, data access control, single security layer +> implementation, and so on which justify storing data like this in the +> DB. Am I too much of an Oracle guy? + +Yes, you are too much of an Oracle guy ;-). Oracle got this notion that they could conquer the world, that EVERYTHING should be in an Oracle database. I think they even built a SAMBA file system on top of Oracle. It's like a hammer manufacturer telling you the hammer is also good for screws and for gluing. It just ain't so. + +You can store videos in a database, but there will be a price. You're asking the database to do something that the file system is already exceptionally good at: store big files. + +You make one good point about security: A database can provide a single point of access control. Storing the videos externally requires a second mechanism. That's not necessarily bad -- you probably have a middleware layer, which can ensure that it won't deliver the goods unless the user has successfully connected to the database. + +Craig + +From pgsql-performance-owner@postgresql.org Thu Feb 9 11:58:26 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 6E1609DC945 + for ; + Thu, 9 Feb 2006 11:58:25 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 68187-04 + for ; + Thu, 9 Feb 2006 11:58:30 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mta10.adelphia.net (mta10.adelphia.net [68.168.78.202]) + by postgresql.org (Postfix) with ESMTP id 187C79DC8A5 + for ; + Thu, 9 Feb 2006 11:58:22 -0400 (AST) +Received: from nemo.qabal.org ([67.23.174.57]) by mta10.adelphia.net + (InterMail vM.6.01.05.02 201-2131-123-102-20050715) with ESMTP + id <20060209155827.UHXZ18877.mta10.adelphia.net@nemo.qabal.org>; + Thu, 9 Feb 2006 10:58:27 -0500 +Received: from [127.0.0.1] (nemo.qabal.org [192.168.1.9]) + by nemo.qabal.org (8.13.4/8.12.11) with ESMTP id k19FwQnV007106; + Thu, 9 Feb 2006 10:58:26 -0500 +Message-ID: <43EB66A1.10302@qabal.org> +Date: Thu, 09 Feb 2006 10:58:25 -0500 +From: Nate Byrnes +User-Agent: Thunderbird 1.5 (Windows/20051201) +MIME-Version: 1.0 +To: "Craig A. James" +CC: pgsql-performance@postgresql.org +Subject: Re: Storing Digital Video +References: <3cf983d0601311632t4a2f068au1f958746c2b092a7@mail.gmail.com> + <200602060930.31144.albert@sedifa.com> <43EB475C.3040708@qabal.org> + <43EB5D59.1030207@modgraph-usa.com> +In-Reply-To: <43EB5D59.1030207@modgraph-usa.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, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200602/79 +X-Sequence-Number: 17065 + + Thanks, until Postgres can pay my bills (hopefully soon...) I will +have to be an Oracle guy. Aside from the filesystem being better at +managing large files (which I do agree) are there performance +implications for the storage in the DB? + Where I work, the question is not can you add the security code to +the middleware, but how many middlewares and applications will need to +be updated. + Regards, + Nate + +Craig A. James wrote: +> Nate Byrnes wrote: +>> I must claim some ignorance, I come from the application world... +>> but, from a data integrity perspective, it makes a whole lot of sense +>> to store video, images, documents, whatever in the database rather +>> than on the file system external to it. Personally, I would use +>> LOB's, but I do not know the internals well enough to say LOBs or +>> large columns. Regardless, there are a lot of compelling reasons +>> ranging from software maintenance, disk management, data access +>> control, single security layer implementation, and so on which +>> justify storing data like this in the DB. Am I too much of an +>> Oracle guy? +> +> Yes, you are too much of an Oracle guy ;-). Oracle got this notion +> that they could conquer the world, that EVERYTHING should be in an +> Oracle database. I think they even built a SAMBA file system on top +> of Oracle. It's like a hammer manufacturer telling you the hammer is +> also good for screws and for gluing. It just ain't so. +> +> You can store videos in a database, but there will be a price. You're +> asking the database to do something that the file system is already +> exceptionally good at: store big files. +> +> You make one good point about security: A database can provide a +> single point of access control. Storing the videos externally +> requires a second mechanism. That's not necessarily bad -- you +> probably have a middleware layer, which can ensure that it won't +> deliver the goods unless the user has successfully connected to the +> database. +> +> Craig +> +> !DSPAM:43eb5e8970644042098162! +> + +From pgsql-performance-owner@postgresql.org Thu Feb 9 15:07:00 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 469E29DC9E4 + for ; + Thu, 9 Feb 2006 15:07:00 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 12663-05 + for ; + Thu, 9 Feb 2006 15:07:00 -0400 (AST) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id DB7EA9DC9A6 + for ; + Thu, 9 Feb 2006 15:06:57 -0400 (AST) +Received: from pi.infinitydrive.net (ip-64-70-39-107.hosts.zerolag.com + [64.70.39.107]) + by svr4.postgresql.org (Postfix) with ESMTP id 00F6A5AF182 + for ; + Thu, 9 Feb 2006 19:06:58 +0000 (GMT) +Received: by pi.infinitydrive.net (Postfix, from userid 99) + id 3774FA758E; Thu, 9 Feb 2006 11:06:57 -0800 (PST) +Received: from [192.168.1.95] (dsl092-045-084.lax1.dsl.speakeasy.net + [66.92.45.84]) + by pi.infinitydrive.net (Postfix) with ESMTP id C25A1A758D + for ; + Thu, 9 Feb 2006 11:06:55 -0800 (PST) +Message-ID: <43EB92DA.2080607@orangekids.org> +Date: Thu, 09 Feb 2006 11:07:06 -0800 +From: Orion Henry +User-Agent: Mozilla Thunderbird 1.0.7 (Macintosh/20050923) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Large Database Design Help +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, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200602/80 +X-Sequence-Number: 17066 + + +Hello All, + +I've inherited a postgresql database that I would like to refactor. It +was origionally designed for Postgres 7.0 on a PIII 500Mhz and some +design decisions were made that don't make sense any more. Here's the +problem: + +1) The database is very large, the largest table has 40 million tuples. + +2) The database needs to import 10's of thousands of tuples each night +quickly. The current method is VERY slow. + +3) I can't import new records with a COPY or drop my indexes b/c some of +them are new records (INSERTS) and some are altered records (UPDATES) +and the only way I can think of to identify these records is to perform +a select for each record. + +Here is how the database is currently laid out and you'll see why I have +a problem with it + +1) The data is easily partitionable by client ID. In an attempt to keep +the indexes small and the inserts fast one table was made per client +ID. Thus the primary table in the database (the one with 40 million +tuples) is really 133 tables each ending with a three digit suffix. +The largest of these client tables has 8 million of the 40 million +tuples. The system started with around a half dozen clients and is now +a huge pain to manage with so many tables. I was hoping new hardware +and new postgres features would allow for this data to be merged safely +into a single table. + +2) The imports are not done inside of transactions. I'm assuming the +system designers excluded this for a reason. Will I run into problems +performing tens of thousands of inserts and updates inside a single +transaction? + +3) The current code that bulk loads data into the database is a loop +that looks like this: + + $result = exe("INSERT INTO $table ($name_str) SELECT +$val_str WHERE NOT EXISTS (SELECT 1 FROM $table WHERE $keys)"); + if ($result == 0) + { + $result = exe("UPDATE $table SET $non_keys WHERE +$keys"); + } + +Is there a faster way to bulk load data when it's not known ahead of +time if it's a new record or an updated record? + +What I would LIKE to do but am afraid I will hit a serious performance +wall (or am missing an obvious / better way to do it) + +1) Merge all 133 client tables into a single new table, add a client_id +column, do the data partitioning on the indexes not the tables as seen here: + + CREATE INDEX actioninfo_order_number_XXX_idx ON actioninfo ( +order_number ) WHERE client_id = XXX; + CREATE INDEX actioninfo_trans_date_XXX_idx ON actioninfo ( +transaction_date ) WHERE client_id = XXX; + + (Aside question: if I were to find a way to use COPY and I were +loading data on a single client_id, would dropping just the indexes for +that client_id accelerate the load?) + +2) Find some way to make the bulk loads faster or more efficent (help!) + +3) Wrap each load into a transaction ( tens of thousands of records per +load ) + +Is this a good plan? Is there a better way? Am I walking into a trap? +Should I leave well enough alone and not try and fix something that's +not broken? + +FWIW here's the hardware and the profile of the current uber table: + + Column | Type | Modifiers +-------------------+---------+----------- + order_number | integer | not null + order_line_number | integer | not null + action_number | integer | not null + transaction_date | date | + code | text | + trans_group_code | text | + quantity | integer | + extension | money | + sales_tax | money | + shipping | money | + discount | money | + +Dual Opteron 246, 4 disk SCSI RAID5, 4GB of RAM + +# du -sh /var/lib/postgres/data/ +16G /var/lib/postgres/data/ + +( the current database is PG 7.4 - I intend to upgrade it to 8.1 if and +when I do this refactoring ) +( the current OS is Debian Unstable but I intend to be running RHEL 4.0 +if and when I do this refactoring ) + + +From pgsql-performance-owner@postgresql.org Thu Feb 9 15:26:42 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id C6C229DCBD3 + for ; + Thu, 9 Feb 2006 15:26:41 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 17883-01 + for ; + Thu, 9 Feb 2006 15:26:38 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 26FE59DCBE3 + for ; + Thu, 9 Feb 2006 15:26:36 -0400 (AST) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 2D47739850; Thu, 9 Feb 2006 19:26:22 +0000 (UTC) +Received: (hashcash-sendmail, from uid 1001); + Thu, 9 Feb 2006 13:26:21 -0600 +Date: Thu, 9 Feb 2006 13:26:21 -0600 +From: "Jim C. Nasby" +To: "Craig A. James" +Cc: Nate Byrnes , pgsql-performance@postgresql.org +Subject: Re: Storing Digital Video +Message-ID: <20060209192621.GU57845@pervasive.com> +References: <3cf983d0601311632t4a2f068au1f958746c2b092a7@mail.gmail.com> + <200602060930.31144.albert@sedifa.com> <43EB475C.3040708@qabal.org> + <43EB5D59.1030207@modgraph-usa.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <43EB5D59.1030207@modgraph-usa.com> +X-Operating-System: FreeBSD 6.0-RELEASE amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060209:cjames@modgraph-usa.com::5l7zNcQKyoKr6Lwd:00000000000000 + 0000000000000000000000002AUS +X-Hashcash: 1:20:060209:nate@qabal.org::GnB1BFH93v0d+h2d:000045a +X-Hashcash: + 1:20:060209:pgsql-performance@postgresql.org::xnn9aQ39yrl2aZ7N:00000 + 0000000000000000000000001xwA +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.104 required=5 tests=[AWL=0.104] +X-Spam-Score: 0.104 +X-Spam-Level: +X-Archive-Number: 200602/81 +X-Sequence-Number: 17067 + +On Thu, Feb 09, 2006 at 07:18:49AM -0800, Craig A. James wrote: +> Nate Byrnes wrote: +> >I must claim some ignorance, I come from the application world... but, +> >from a data integrity perspective, it makes a whole lot of sense to +> >store video, images, documents, whatever in the database rather than on +> >the file system external to it. Personally, I would use LOB's, but I do +> >not know the internals well enough to say LOBs or large columns. +> >Regardless, there are a lot of compelling reasons ranging from software +> >maintenance, disk management, data access control, single security layer +> >implementation, and so on which justify storing data like this in the +> >DB. Am I too much of an Oracle guy? +> +> Yes, you are too much of an Oracle guy ;-). Oracle got this notion that +> they could conquer the world, that EVERYTHING should be in an Oracle +> database. I think they even built a SAMBA file system on top of Oracle. +> It's like a hammer manufacturer telling you the hammer is also good for +> screws and for gluing. It just ain't so. +> +> You can store videos in a database, but there will be a price. You're +> asking the database to do something that the file system is already +> exceptionally good at: store big files. +> +> You make one good point about security: A database can provide a single +> point of access control. Storing the videos externally requires a second +> mechanism. That's not necessarily bad -- you probably have a middleware +> layer, which can ensure that it won't deliver the goods unless the user has +> successfully connected to the database. + +You're forgetting about cleanup and transactions. If you store outside +the database you either have to write some kind of garbage collector, or +you add a trigger to delete the file on disk when the row in the +database pointing at it is deleted and hope that the transaction doesn't +rollback. + +Of course, someone could probably write some stand-alone code that would +handle all of this in a generic way... :) +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Thu Feb 9 15:33:51 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id AA6519DC9F7 + for ; + Thu, 9 Feb 2006 15:33:50 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 17604-06 + for ; + Thu, 9 Feb 2006 15:33:47 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 135F69DC948 + for ; + Thu, 9 Feb 2006 15:33:45 -0400 (AST) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 397733984E; Thu, 9 Feb 2006 19:33:46 +0000 (UTC) +Received: (hashcash-sendmail, from uid 1001); + Thu, 9 Feb 2006 13:33:45 -0600 +Date: Thu, 9 Feb 2006 13:33:45 -0600 +From: "Jim C. Nasby" +To: Rafael Martinez Guerrero +Cc: pgsql-performance@postgresql.org +Subject: Re: Help with optimizing a sql statement +Message-ID: <20060209193345.GV57845@pervasive.com> +References: <1139497827.25608.1014.camel@bbking.uio.no> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1139497827.25608.1014.camel@bbking.uio.no> +X-Operating-System: FreeBSD 6.0-RELEASE amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060209:r.m.guerrero@usit.uio.no::YBFZ3hVfjRvLfIJs:0000000000000 + 0000000000000000000000000AEG +X-Hashcash: + 1:20:060209:pgsql-performance@postgresql.org::/yEbu3N6n/4LI2Ae:00000 + 0000000000000000000000006gy5 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.104 required=5 tests=[AWL=0.104] +X-Spam-Score: 0.104 +X-Spam-Level: +X-Archive-Number: 200602/82 +X-Sequence-Number: 17068 + +At least part of the problem is that it's way off on some of the row +estimates. I'd suggest upping the statisticss target on at least all of +the join columns to at least 100. (Note that it's doing a nested loop +thinking it will have only 2 rows but it actually has 22000 rows). + +On Thu, Feb 09, 2006 at 04:10:27PM +0100, Rafael Martinez Guerrero wrote: +> Hello +> +> We are running an application via web that use a lot of time to perform +> some operations. We are trying to find out if some of the sql statements +> used are the reason of the slow speed. +> +> We have identified a sql that takes like 4-5000ms more than the second +> slowest sql in out test server. I hope that we will get some help to try +> to optimize it. +> +> Thanks in advance for any help. +> +> Some information: +> ******************************************************************************** +> rttest=# EXPLAIN ANALYZE SELECT DISTINCT main.* +> +> FROM Users main , +> Principals Principals_1, +> ACL ACL_2, +> Groups Groups_3, +> CachedGroupMembers CachedGroupMembers_4 +> +> WHERE ((ACL_2.RightName = 'OwnTicket')) +> AND ((CachedGroupMembers_4.MemberId = Principals_1.id)) +> AND ((Groups_3.id = CachedGroupMembers_4.GroupId)) +> AND ((Principals_1.Disabled = '0') or (Principals_1.Disabled = '0')) +> AND ((Principals_1.id != '1')) +> AND ((main.id = Principals_1.id)) +> AND ( ( ACL_2.PrincipalId = Groups_3.id AND ACL_2.PrincipalType = +> 'Group' AND ( Groups_3.Domain = 'SystemInternal' OR Groups_3.Domain = +> 'UserDefined' OR Groups_3.Domain = 'ACLEquivalence')) OR ( ( +> (Groups_3.Domain = 'RT::Queue-Role' ) ) AND Groups_3.Type +> =ACL_2.PrincipalType) ) +> AND (ACL_2.ObjectType = 'RT::System' OR (ACL_2.ObjectType = 'RT::Queue') +> ) +> +> ORDER BY main.Name ASC +> +> QUERY PLAN +> ----------------------------------------------------------------- +> Unique (cost=28394.99..28395.16 rows=2 width=706) (actual +> time=15574.272..15787.681 rows=254 loops=1) +> -> Sort (cost=28394.99..28394.99 rows=2 width=706) (actual +> time=15574.267..15607.310 rows=22739 loops=1) +> Sort Key: main.name, main.id, main."password", main.comments, +> main.signature, main.emailaddress, main.freeformcontactinfo, +> main.organization, main.realname, main.nickname, main.lang, +> main.emailencoding, main.webencoding, main.externalcontactinfoid, +> main.contactinfosystem, main.externalauthid, main.authsystem, +> main.gecos, main.homephone, main.workphone, main.mobilephone, +> main.pagerphone, main.address1, main.address2, main.city, main.state, +> main.zip, main.country, main.timezone, main.pgpkey, main.creator, +> main.created, main.lastupdatedby, main.lastupdated +> -> Nested Loop (cost=20825.91..28394.98 rows=2 width=706) +> (actual time=1882.608..14589.596 rows=22739 loops=1) +> Join Filter: (((("inner"."domain")::text = +> 'RT::Queue-Role'::text) OR ("outer".principalid = "inner".id)) AND +> ((("inner"."type")::text = ("outer".principaltype)::text) OR +> ("outer".principalid = "inner".id)) AND ((("inner"."domain")::text = +> 'RT::Queue-Role'::text) OR (("outer".principaltype)::text = +> 'Group'::text)) AND ((("inner"."type")::text = +> ("outer".principaltype)::text) OR (("outer".principaltype)::text = +> 'Group'::text)) AND ((("inner"."type")::text = +> ("outer".principaltype)::text) OR (("inner"."domain")::text = +> 'SystemInternal'::text) OR (("inner"."domain")::text = +> 'UserDefined'::text) OR (("inner"."domain")::text = +> 'ACLEquivalence'::text))) +> -> Seq Scan on acl acl_2 (cost=0.00..40.57 rows=45 +> width=13) (actual time=0.020..1.730 rows=51 loops=1) +> Filter: (((rightname)::text = 'OwnTicket'::text) +> AND (((objecttype)::text = 'RT::System'::text) OR ((objecttype)::text = +> 'RT::Queue'::text))) +> -> Materialize (cost=20825.91..20859.37 rows=3346 +> width=738) (actual time=36.925..166.374 rows=66823 loops=51) +> -> Merge Join (cost=15259.56..20825.91 rows=3346 +> width=738) (actual time=1882.539..3538.258 rows=66823 loops=1) +> Merge Cond: ("outer".id = "inner".memberid) +> -> Merge Join (cost=0.00..5320.37 +> rows=13182 width=710) (actual time=0.116..874.960 rows=13167 loops=1) +> Merge Cond: ("outer".id = "inner".id) +> -> Index Scan using users_pkey on +> users main (cost=0.00..1063.60 rows=13181 width=706) (actual +> time=0.032..52.355 rows=13181 loops=1) +> -> Index Scan using principals_pkey on +> principals principals_1 (cost=0.00..3737.49 rows=141801 width=4) +> (actual time=0.020..463.043 rows=141778 loops=1) +> Filter: ((disabled = 0::smallint) +> AND (id <> 1)) +> -> Sort (cost=15259.56..15349.54 rows=35994 +> width=36) (actual time=1882.343..1988.353 rows=80357 loops=1) +> Sort Key: cachedgroupmembers_4.memberid +> -> Hash Join (cost=3568.51..12535.63 +> rows=35994 width=36) (actual time=96.151..1401.537 rows=80357 loops=1) +> Hash Cond: ("outer".groupid = +> "inner".id) +> -> Seq Scan on +> cachedgroupmembers cachedgroupmembers_4 (cost=0.00..5961.53 rows=352753 +> width=8) (actual time=0.011..500.508 rows=352753 loops=1) +> -> Hash (cost=3535.70..3535.70 +> rows=13124 width=32) (actual time=95.966..95.966 rows=0 loops=1) +> -> Index Scan using +> groups1, groups1, groups1, groups1 on groups groups_3 +> (cost=0.00..3535.70 rows=13124 width=32) (actual time=0.045..76.506 +> rows=13440 loops=1) +> Index Cond: +> ((("domain")::text = 'RT::Queue-Role'::text) OR (("domain")::text = +> 'SystemInternal'::text) OR (("domain")::text = 'UserDefined'::text) OR +> (("domain")::text = 'ACLEquivalence'::text)) +> +> Total runtime: 15825.022 ms +> +> ******************************************************************************** +> rttest=# \d users +> Table "public.users" +> Column | Type | +> Modifiers +> -----------------------+-----------------------------+------------------------------------------------ +> id | integer | not null default +> nextval('users_id_seq'::text) +> name | character varying(200) | not null +> password | character varying(40) | +> comments | text | +> signature | text | +> emailaddress | character varying(120) | +> freeformcontactinfo | text | +> organization | character varying(200) | +> realname | character varying(120) | +> nickname | character varying(16) | +> lang | character varying(16) | +> emailencoding | character varying(16) | +> webencoding | character varying(16) | +> externalcontactinfoid | character varying(100) | +> contactinfosystem | character varying(30) | +> externalauthid | character varying(100) | +> authsystem | character varying(30) | +> gecos | character varying(16) | +> homephone | character varying(30) | +> workphone | character varying(30) | +> mobilephone | character varying(30) | +> pagerphone | character varying(30) | +> address1 | character varying(200) | +> address2 | character varying(200) | +> city | character varying(100) | +> state | character varying(100) | +> zip | character varying(16) | +> country | character varying(50) | +> timezone | character varying(50) | +> pgpkey | text | +> creator | integer | not null default +> 0 +> created | timestamp without time zone | +> lastupdatedby | integer | not null default +> 0 +> lastupdated | timestamp without time zone | +> Indexes: +> "users_pkey" primary key, btree (id) +> "users1" unique, btree (name) +> "users2" btree (name) +> "users3" btree (id, emailaddress) +> "users4" btree (emailaddress) +> ******************************************************************************** +> rttest=# \d principals +> +> Table "public.principals" +> Column | Type | +> Modifiers +> ---------------+-----------------------+---------------------------------------- +> id | integer | not null default +> nextval('principals_id_seq'::text) +> principaltype | character varying(16) | not null +> objectid | integer | +> disabled | smallint | not null default 0 +> Indexes: +> "principals_pkey" primary key, btree (id) +> "principals2" btree (objectid) +> +> ******************************************************************************** +> rttest=# \d acl +> +> Table "public.acl" +> Column | Type | +> Modifiers +> ---------------+-----------------------+---------------------------------------------- +> id | integer | not null default +> nextval('acl_id_seq'::text) +> principaltype | character varying(25) | not null +> principalid | integer | not null +> rightname | character varying(25) | not null +> objecttype | character varying(25) | not null +> objectid | integer | not null default 0 +> delegatedby | integer | not null default 0 +> delegatedfrom | integer | not null default 0 +> Indexes: +> "acl_pkey" primary key, btree (id) +> "acl1" btree (rightname, objecttype, objectid, principaltype, +> principalid) +> +> +> ******************************************************************************** +> rttest=# \d groups +> +> Table "public.groups" +> Column | Type | +> Modifiers +> -------------+------------------------+------------------------------------------------- +> id | integer | not null default +> nextval('groups_id_seq'::text) +> name | character varying(200) | +> description | character varying(255) | +> domain | character varying(64) | +> type | character varying(64) | +> instance | integer | +> Indexes: +> "groups_pkey" primary key, btree (id) +> "groups1" unique, btree ("domain", instance, "type", id, name) +> "groups2" btree ("type", instance, "domain") +> +> +> ******************************************************************************** +> rttest=# \d cachedgroupmembers" +> +> Table "public.cachedgroupmembers" +> Column | Type | +> Modifiers +> -------------------+----------+------------------------------------------------------------- +> id | integer | not null default +> nextval('cachedgroupmembers_id_seq'::text) +> groupid | integer | +> memberid | integer | +> via | integer | +> immediateparentid | integer | +> disabled | smallint | not null default 0 +> Indexes: +> "cachedgroupmembers_pkey" primary key, btree (id) +> "cachedgroupmembers2" btree (memberid) +> "cachedgroupmembers3" btree (groupid) +> "disgroumem" btree (groupid, memberid, disabled) +> +> +> ******************************************************************************** +> +> -- +> Rafael Martinez, +> Center for Information Technology Services +> University of Oslo, Norway +> +> PGP Public Key: http://folk.uio.no/rafael/ +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 9: In versions below 8.0, the planner will ignore your desire to +> choose an index scan if your joining column's datatypes do not +> match +> + +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Thu Feb 9 15:44:29 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id C1D519DCC09 + for ; + Thu, 9 Feb 2006 15:44:28 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 19755-09 + for ; + Thu, 9 Feb 2006 15:44:28 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from globalrelay.com (mail1.globalrelay.com [216.18.71.77]) + by postgresql.org (Postfix) with ESMTP id 51B549DCBE3 + for ; + Thu, 9 Feb 2006 15:44:23 -0400 (AST) +X-Virus-Scanned: Scanned by GRC-AntiVirus Gateway +X-GR-Acctd: YES +Received: from [63.226.156.118] (HELO DaveEMachine) + by globalrelay.com (CommuniGate Pro SMTP 4.2.3) + with ESMTP id 83342339; Thu, 09 Feb 2006 11:44:23 -0800 +From: "Dave Dutcher" +To: "'Rafael Martinez Guerrero'" +Cc: +Subject: Re: Help with optimizing a sql statement +Date: Thu, 9 Feb 2006 13:44:22 -0600 +Message-ID: <001f01c62db1$3a380910$8300a8c0@tridecap.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.2627 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +In-Reply-To: <20060209193345.GV57845@pervasive.com> +Importance: Normal +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.06 required=5 tests=[AWL=0.060] +X-Spam-Score: 0.06 +X-Spam-Level: +X-Archive-Number: 200602/83 +X-Sequence-Number: 17069 + +First I'm wondering if the tables have been recently analyzed. If an +analyze has been run recently, then it is probably a good idea to look +at the statistics target. + + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Jim C. +Nasby +Sent: Thursday, February 09, 2006 1:34 PM +To: Rafael Martinez Guerrero +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Help with optimizing a sql statement + +At least part of the problem is that it's way off on some of the row +estimates. I'd suggest upping the statisticss target on at least all of +the join columns to at least 100. (Note that it's doing a nested loop +thinking it will have only 2 rows but it actually has 22000 rows). + +On Thu, Feb 09, 2006 at 04:10:27PM +0100, Rafael Martinez Guerrero +wrote: +> Hello +> +> We are running an application via web that use a lot of time to +perform +> some operations. We are trying to find out if some of the sql +statements +> used are the reason of the slow speed. +> +> We have identified a sql that takes like 4-5000ms more than the second +> slowest sql in out test server. I hope that we will get some help to +try +> to optimize it. +> +> Thanks in advance for any help. +> +[Snip] + + +From pgsql-performance-owner@postgresql.org Thu Feb 9 15:45:17 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 331C69DC9A6 + for ; + Thu, 9 Feb 2006 15:45:16 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 19509-08 + for ; + Thu, 9 Feb 2006 15:45:15 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) + by postgresql.org (Postfix) with ESMTP id 61F999DC99B + for ; + Thu, 9 Feb 2006 15:45:12 -0400 (AST) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1F7Hiw-00065S-00; Thu, 09 Feb 2006 14:45:02 -0500 +To: Orion Henry +Cc: pgsql-performance@postgresql.org +Subject: Re: Large Database Design Help +References: <43EB92DA.2080607@orangekids.org> +In-Reply-To: <43EB92DA.2080607@orangekids.org> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 09 Feb 2006 14:45:02 -0500 +Message-ID: <87ek2c71vl.fsf@stark.xeocode.com> +Lines: 61 +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, score=0.131 required=5 tests=[AWL=0.131] +X-Spam-Score: 0.131 +X-Spam-Level: +X-Archive-Number: 200602/85 +X-Sequence-Number: 17071 + + +Orion Henry writes: + +> What I would LIKE to do but am afraid I will hit a serious performance wall +> (or am missing an obvious / better way to do it) +> +> 1) Merge all 133 client tables into a single new table, add a client_id column, +> do the data partitioning on the indexes not the tables as seen here: +> +> CREATE INDEX actioninfo_order_number_XXX_idx ON actioninfo ( order_number ) +> WHERE client_id = XXX; +> CREATE INDEX actioninfo_trans_date_XXX_idx ON actioninfo ( transaction_date ) +> WHERE client_id = XXX; + +The advantages to the partitioned scheme are a) you can drop a client quickly +in a single operation b) the indexes are only half as wide since they don't +include client_id and c) you can do a sequential scan of an entire client +without using the index at all. + +Unless any of these are overwhelming I would say to go ahead and merge them. +If you frequently scan all the records of a single client or frequently drop +entire clients then the current scheme may be helpful. + +> (Aside question: if I were to find a way to use COPY and I were loading +> data on a single client_id, would dropping just the indexes for that client_id +> accelerate the load?) + +Dropping indexes would accelerate the load but unless you're loading a large +number of records relative the current size I'm not sure it would be a win +since you would then have to rebuild the index for the entire segment. + +> 2) Find some way to make the bulk loads faster or more efficent (help!) + +If your existing data isn't changing while you're doing the load (and if it is +then your existing load process has a race condition btw) then you could do it +in a couple big queries: + +COPY ${table}_new FROM '...'; +CREATE TABLE ${table}_exists as SELECT * FROM ${table}_new WHERE EXISTS (select 1 from $table where ${table}_new.key = $table.key); +CREATE TABLE ${table}_insert as SELECT * FROM ${table}_new WHERE NOT EXISTS (select 1 from $table where ${table}_new.key = $table.key); + +UPDATE $table set ... FROM ${table}_exists WHERE ${table}_exists.key = ${table}.key +INSERT INTO $table (select * from ${table}_insert) + +actually you could skip the whole ${table_insert} step there and just do the +insert I guess. There are also other approaches you could use like adding a +new column to ${table}_new instead of creating new tables, etc. + +> 3) Wrap each load into a transaction ( tens of thousands of records per load ) + +Yes, Postgres is faster if you do more operations in a single transaction. +Every COMMIT means waiting for an fsync. The only disadvantage to batching +them into a large transaction is if it lasts a *long* time then it could +create problems with your vacuum strategy. Any vacuum that runs while the +transaction is still running won't be able to vacuum anything. + +You might consider running VACUUM FULL or CLUSTER on the table when you're +done with the loading process. It will lock the table while it runs though. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Thu Feb 9 15:45:15 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 2DBE29DC980 + for ; + Thu, 9 Feb 2006 15:45:15 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18780-08 + for ; + Thu, 9 Feb 2006 15:45:14 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 18B019DC948 + for ; + Thu, 9 Feb 2006 15:45:06 -0400 (AST) +Received: by noel.decibel.org (Postfix, from userid 1001) + id E992939858; Thu, 9 Feb 2006 19:45:07 +0000 (UTC) +Received: (hashcash-sendmail, from uid 1001); + Thu, 9 Feb 2006 13:45:07 -0600 +Date: Thu, 9 Feb 2006 13:45:07 -0600 +From: "Jim C. Nasby" +To: Orion Henry +Cc: pgsql-performance@postgresql.org +Subject: Re: Large Database Design Help +Message-ID: <20060209194507.GW57845@pervasive.com> +References: <43EB92DA.2080607@orangekids.org> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <43EB92DA.2080607@orangekids.org> +X-Operating-System: FreeBSD 6.0-RELEASE amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060209:lab@orangekids.org::IMcL4yf1wpU4YfKW:0000000000000000000 + 0000000000000000000000001Upv +X-Hashcash: + 1:20:060209:pgsql-performance@postgresql.org::m9IyvrLnEBdck6aF:00000 + 0000000000000000000000001jMD +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.104 required=5 tests=[AWL=0.104] +X-Spam-Score: 0.104 +X-Spam-Level: +X-Archive-Number: 200602/84 +X-Sequence-Number: 17070 + +On Thu, Feb 09, 2006 at 11:07:06AM -0800, Orion Henry wrote: +> +> Hello All, +> +> I've inherited a postgresql database that I would like to refactor. It +> was origionally designed for Postgres 7.0 on a PIII 500Mhz and some +> design decisions were made that don't make sense any more. Here's the +> problem: +> +> 1) The database is very large, the largest table has 40 million tuples. +> +> 2) The database needs to import 10's of thousands of tuples each night +> quickly. The current method is VERY slow. +> +> 3) I can't import new records with a COPY or drop my indexes b/c some of +> them are new records (INSERTS) and some are altered records (UPDATES) +> and the only way I can think of to identify these records is to perform +> a select for each record. +> +> Here is how the database is currently laid out and you'll see why I have +> a problem with it +> +> 1) The data is easily partitionable by client ID. In an attempt to keep +> the indexes small and the inserts fast one table was made per client +> ID. Thus the primary table in the database (the one with 40 million +> tuples) is really 133 tables each ending with a three digit suffix. +> The largest of these client tables has 8 million of the 40 million +> tuples. The system started with around a half dozen clients and is now +> a huge pain to manage with so many tables. I was hoping new hardware +> and new postgres features would allow for this data to be merged safely +> into a single table. + +If all the clients are equally active then partitioning by client +probably makes little sense. If some clients are much more active than +others then leaving this as-is could be a pretty big win. If the +partitioning is done with either a view and rules or inherited tables +and rules it shouldn't be too hard to manage. + +> 2) The imports are not done inside of transactions. I'm assuming the +> system designers excluded this for a reason. Will I run into problems +> performing tens of thousands of inserts and updates inside a single +> transaction? + +Never attribute to thoughtful design that which can be fully explained +by ignorance. :) I'd bet they just didn't know any better. + +> 3) The current code that bulk loads data into the database is a loop +> that looks like this: +> +> $result = exe("INSERT INTO $table ($name_str) SELECT +> $val_str WHERE NOT EXISTS (SELECT 1 FROM $table WHERE $keys)"); +> if ($result == 0) +> { +> $result = exe("UPDATE $table SET $non_keys WHERE +> $keys"); +> } +> +> Is there a faster way to bulk load data when it's not known ahead of +> time if it's a new record or an updated record? + +Uuuugly. :) Instead, load everything into a temp table using COPY and +then UPDATE real_table ... FROM temp_table t WHERE real_table.key = +t.key and INSERT SELECT ... WHERE NOT EXISTS. But take note that this is +a race condition so you can only do it if you know nothing else will be +inserting into the real table at the same time. + +You might want to look at the stats-proc code at +http://cvs.distributed.net; it does exactly this type of thing. + +> What I would LIKE to do but am afraid I will hit a serious performance +> wall (or am missing an obvious / better way to do it) +> +> 1) Merge all 133 client tables into a single new table, add a client_id +> column, do the data partitioning on the indexes not the tables as seen here: +> +> CREATE INDEX actioninfo_order_number_XXX_idx ON actioninfo ( +> order_number ) WHERE client_id = XXX; +> CREATE INDEX actioninfo_trans_date_XXX_idx ON actioninfo ( +> transaction_date ) WHERE client_id = XXX; +> +> (Aside question: if I were to find a way to use COPY and I were +> loading data on a single client_id, would dropping just the indexes for +> that client_id accelerate the load?) + +Hrm, I believe it would... + +> 2) Find some way to make the bulk loads faster or more efficent (help!) +Don't do things row-by-row. If you can't ensure that there will be only +one process inserting to eliminate the race condition I mentioned above +then reply back and I'll point you at code that should still be much +faster than what you're doing now. + +> 3) Wrap each load into a transaction ( tens of thousands of records per +> load ) + +Getting rid of row-by-row will be your biggest win. If you do have to do +row-by-row, at least wrap it in a transaction. As long as the +transaction doesn't take *too* long it won't be an issue. + +> Is this a good plan? Is there a better way? Am I walking into a trap? +> Should I leave well enough alone and not try and fix something that's +> not broken? +> +> FWIW here's the hardware and the profile of the current uber table: +> +> Column | Type | Modifiers +> -------------------+---------+----------- +> order_number | integer | not null +> order_line_number | integer | not null +> action_number | integer | not null +> transaction_date | date | +> code | text | +> trans_group_code | text | +> quantity | integer | +> extension | money | +> sales_tax | money | +> shipping | money | +> discount | money | +> +> Dual Opteron 246, 4 disk SCSI RAID5, 4GB of RAM + +Remember that the write performance of raid5 normally stinks. + +> # du -sh /var/lib/postgres/data/ +> 16G /var/lib/postgres/data/ +> +> ( the current database is PG 7.4 - I intend to upgrade it to 8.1 if and +> when I do this refactoring ) + +Going to 8.1 would help in a large number of ways even if you don't +refactor. The stats-proc code I mentioned runs 2x faster under 8.1 than +it does under 7.4. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Thu Feb 9 15:46:07 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 092E99DCBE3 + for ; + Thu, 9 Feb 2006 15:46:07 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 20913-06 + for ; + Thu, 9 Feb 2006 15:46:06 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 747F99DCBDA + for ; + Thu, 9 Feb 2006 15:46:04 -0400 (AST) +Received: by noel.decibel.org (Postfix, from userid 1001) + id B13C839834; Thu, 9 Feb 2006 19:46:05 +0000 (UTC) +Received: (hashcash-sendmail, from uid 1001); + Thu, 9 Feb 2006 13:46:03 -0600 +Date: Thu, 9 Feb 2006 13:46:03 -0600 +From: "Jim C. Nasby" +To: Dave Dutcher +Cc: 'Rafael Martinez Guerrero' , + pgsql-performance@postgresql.org +Subject: Re: Help with optimizing a sql statement +Message-ID: <20060209194603.GX57845@pervasive.com> +References: <20060209193345.GV57845@pervasive.com> + <001f01c62db1$3a380910$8300a8c0@tridecap.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <001f01c62db1$3a380910$8300a8c0@tridecap.com> +X-Operating-System: FreeBSD 6.0-RELEASE amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060209:dave@tridecap.com::G5+En4JrsmsqugtM:00000000000000000000 + 00000000000000000000000026KF +X-Hashcash: + 1:20:060209:r.m.guerrero@usit.uio.no::RCIxqUNYmltyk9S1:0000000000000 + 000000000000000000000000BDqG +X-Hashcash: + 1:20:060209:pgsql-performance@postgresql.org::Pbk5hlB0IAZyuADj:00000 + 0000000000000000000000005nqf +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.104 required=5 tests=[AWL=0.104] +X-Spam-Score: 0.104 +X-Spam-Level: +X-Archive-Number: 200602/86 +X-Sequence-Number: 17072 + +I looked at the estimates for the table access methods and they all +looked ok, so I think the statistics are pretty up-to-date; there just +aren't enough of them for the planner to do a good job. + +On Thu, Feb 09, 2006 at 01:44:22PM -0600, Dave Dutcher wrote: +> First I'm wondering if the tables have been recently analyzed. If an +> analyze has been run recently, then it is probably a good idea to look +> at the statistics target. +> +> +> -----Original Message----- +> From: pgsql-performance-owner@postgresql.org +> [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Jim C. +> Nasby +> Sent: Thursday, February 09, 2006 1:34 PM +> To: Rafael Martinez Guerrero +> Cc: pgsql-performance@postgresql.org +> Subject: Re: [PERFORM] Help with optimizing a sql statement +> +> At least part of the problem is that it's way off on some of the row +> estimates. I'd suggest upping the statisticss target on at least all of +> the join columns to at least 100. (Note that it's doing a nested loop +> thinking it will have only 2 rows but it actually has 22000 rows). +> +> On Thu, Feb 09, 2006 at 04:10:27PM +0100, Rafael Martinez Guerrero +> wrote: +> > Hello +> > +> > We are running an application via web that use a lot of time to +> perform +> > some operations. We are trying to find out if some of the sql +> statements +> > used are the reason of the slow speed. +> > +> > We have identified a sql that takes like 4-5000ms more than the second +> > slowest sql in out test server. I hope that we will get some help to +> try +> > to optimize it. +> > +> > Thanks in advance for any help. +> > +> [Snip] +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 1: if posting/reading through Usenet, please send an appropriate +> subscribe-nomail command to majordomo@postgresql.org so that your +> message can get through to the mailing list cleanly +> + +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Thu Feb 9 17:50:27 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 25E199DCD4E + for ; + Thu, 9 Feb 2006 17:50:26 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 43913-02 + for ; + Thu, 9 Feb 2006 17:50:27 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.194]) + by postgresql.org (Postfix) with ESMTP id 5E1109DCD2F + for ; + Thu, 9 Feb 2006 17:50:23 -0400 (AST) +Received: by xproxy.gmail.com with SMTP id i30so194044wxd + for ; + Thu, 09 Feb 2006 13:50:25 -0800 (PST) +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=uZ3n7QtcioRD60jIvoln9472H+Wtvi8EGiBMPP4Btlx9bjCn87g5fSpdY08/dQA0AwEh9EKphOaPHOoBdWecQLFhQng2+P/PX/Wz4RhA4FCaCmwKbfKMJYhncKLnvnTAsFM1UbVKT7l9Piann7QymQGfMB6waAXkQ9uQlp4lY/w= +Received: by 10.70.104.19 with SMTP id b19mr2673029wxc; + Thu, 09 Feb 2006 13:49:57 -0800 (PST) +Received: by 10.70.125.13 with HTTP; Thu, 9 Feb 2006 13:49:56 -0800 (PST) +Message-ID: +Date: Thu, 9 Feb 2006 15:49:56 -0600 +From: Matthew Nuzum +Reply-To: newz@bearfruit.org +To: Orion Henry +Subject: Re: Large Database Design Help +Cc: pgsql-performance@postgresql.org +In-Reply-To: <43EB92DA.2080607@orangekids.org> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <43EB92DA.2080607@orangekids.org> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200602/87 +X-Sequence-Number: 17073 + +On 2/9/06, Orion Henry wrote: +> +> Hello All, +> +> I've inherited a postgresql database that I would like to refactor. It +> was origionally designed for Postgres 7.0 on a PIII 500Mhz and some +> design decisions were made that don't make sense any more. Here's the +> problem: +> +> 1) The database is very large, the largest table has 40 million tuples. +> +> 2) The database needs to import 10's of thousands of tuples each night +> quickly. The current method is VERY slow. +> +> 3) I can't import new records with a COPY or drop my indexes b/c some of +> them are new records (INSERTS) and some are altered records (UPDATES) +> and the only way I can think of to identify these records is to perform +> a select for each record. + + [snip] +> +> 3) The current code that bulk loads data into the database is a loop +> that looks like this: +> +> $result =3D exe("INSERT INTO $table ($name_str) SELECT +> $val_str WHERE NOT EXISTS (SELECT 1 FROM $table WHERE $keys)"); +> if ($result =3D=3D 0) +> { +> $result =3D exe("UPDATE $table SET $non_keys WHER= +E +> $keys"); +> } +> +> Is there a faster way to bulk load data when it's not known ahead of +> time if it's a new record or an updated record? + +I experimented with something like this and I was able to successively +decrease the amount of time needed with an import. The final solution +that took my import down from aproximately 24 hours to about 30 min +was to use a C#/Java hashtable or a python dictionary. For example, +the unique data in one particular table was "User_Agent" so I made it +the key in my hashtable. I actually added a method to the hashtable so +that when I added a new record to the hashtable it would do the insert +into the db. + +The downside to this is that it used *GOBS* of RAM. + +Using Python, I was able to dramatically decrease the ram usage by +switching to a GDB based dictionary instead of the standard +dictionary. It only increased the time by about 50% so the total +processing time was about 45 min vs the previous 30 min. + +I only had about 35 million records and my technique was getting to +the point where it was unweldy, so with your 40 million and counting +records you would probably want to start with the GDB technique unless +you have a ton of available ram. + +You might interpret this as being a knock against PostgreSQL since I +pulled the data out of the db, but it's not; You'd be hard pressed to +find anything as fast as the in-memory hashtable or the on disk GDB; +however it's usefullness is very limited and for anything more complex +than just key=3D>value lookups moving to PostgreSQL is likely a big win. + +-- +Matthew Nuzum +www.bearfruit.org + +From pgsql-performance-owner@postgresql.org Thu Feb 9 18:43:31 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 2BB649DC87F + for ; + Thu, 9 Feb 2006 18:43:31 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 50947-07 + for ; + Thu, 9 Feb 2006 18:43:32 -0400 (AST) +X-Greylist: delayed 07:32:52.349909 by SQLgrey- +Received: from pat.uio.no (pat.uio.no [129.240.130.16]) + by postgresql.org (Postfix) with ESMTP id 690749DC84A + for ; + Thu, 9 Feb 2006 18:43:22 -0400 (AST) +Received: from mail-mx2.uio.no ([129.240.10.30]) + by pat.uio.no with esmtp (Exim 4.43) + id 1F7KVT-00014m-IC; Thu, 09 Feb 2006 23:43:19 +0100 +Received: from ti200710a080-12451.bb.online.no ([85.164.176.163] + helo=[10.1.1.101]) + by mail-mx2.uio.no with esmtpsa (SSLv3:RC4-MD5:128) (Exim 4.43) + id 1F7KVO-00020F-Uw; Thu, 09 Feb 2006 23:43:15 +0100 +Subject: Re: Help with optimizing a sql statement +From: Rafael Martinez +To: "Jim C. Nasby" +Cc: Dave Dutcher , pgsql-performance@postgresql.org +In-Reply-To: <20060209194603.GX57845@pervasive.com> +References: <20060209193345.GV57845@pervasive.com> + <001f01c62db1$3a380910$8300a8c0@tridecap.com> + <20060209194603.GX57845@pervasive.com> +Content-Type: text/plain +Organization: University of Oslo +Date: Thu, 09 Feb 2006 23:44:42 +0100 +Message-Id: <1139525082.19758.6.camel@linux.site> +Mime-Version: 1.0 +X-Mailer: Evolution 2.4.0 +Content-Transfer-Encoding: 7bit +X-UiO-Spam-info: not spam, SpamAssassin (score=-3.844, required 12, + autolearn=disabled, AWL 1.16, UIO_MAIL_IS_INTERNAL -5.00) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200602/88 +X-Sequence-Number: 17074 + +On Thu, 2006-02-09 at 13:46 -0600, Jim C. Nasby wrote: +> I looked at the estimates for the table access methods and they all +> looked ok, so I think the statistics are pretty up-to-date; there just +> aren't enough of them for the planner to do a good job. +> + +VACUUM ANALYZE runs 4 times every hour, so yes, statistics are +up-to-date. I will increase default_statistics_target tomorrow at work +and see what happens. + +Thanks for your help. + +-- +Rafael Martinez, +Center for Information Technology Services +University of Oslo, Norway + +PGP Public Key: http://folk.uio.no/rafael/ + + +From pgsql-performance-owner@postgresql.org Thu Feb 9 19:14:56 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 833019DC87F + for ; + Thu, 9 Feb 2006 19:14:55 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 58053-03 + for ; + Thu, 9 Feb 2006 19:14:57 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.198]) + by postgresql.org (Postfix) with ESMTP id 477A09DCCBB + for ; + Thu, 9 Feb 2006 19:14:53 -0400 (AST) +Received: by xproxy.gmail.com with SMTP id i30so204685wxd + for ; + Thu, 09 Feb 2006 15:14:56 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=CndRNFNxaf+y24SOMpTifFOWMfW3oNSlx9QydiQ8ww0wnfQVBSvaVoIVoTr1x1pfu8Zy+9zTnSDsSp4Bd67GmuwPUomS3d/HW2x3y+a6QGl70RllmPoSCfIgnbCivD/GTurLWXNN0jyQlELXQ6UyFhOPpb7SBCElTgI528OQ9Uw= +Received: by 10.70.109.20 with SMTP id h20mr2415079wxc; + Thu, 09 Feb 2006 15:14:10 -0800 (PST) +Received: by 10.70.116.7 with HTTP; Thu, 9 Feb 2006 15:14:09 -0800 (PST) +Message-ID: <72e966b00602091514p21332e7fw60fdec07c2ab56ef@mail.gmail.com> +Date: Thu, 9 Feb 2006 16:14:09 -0700 +From: Jan Peterson +To: "Jim C. Nasby" +Subject: Re: Storing Digital Video +Cc: "Craig A. James" , Nate Byrnes , + pgsql-performance@postgresql.org +In-Reply-To: <20060209192621.GU57845@pervasive.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <3cf983d0601311632t4a2f068au1f958746c2b092a7@mail.gmail.com> + <200602060930.31144.albert@sedifa.com> <43EB475C.3040708@qabal.org> + <43EB5D59.1030207@modgraph-usa.com> + <20060209192621.GU57845@pervasive.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200602/89 +X-Sequence-Number: 17075 + +In my experience, you don't want to store this stuff in the database.=20 +In general, it will work fine, until you have to VACUUM the +pg_largeobject table. Unless you have a very powerful I/O subsystem, +this VACUUM will kill your performance. + +> You're forgetting about cleanup and transactions. If you store outside +> the database you either have to write some kind of garbage collector, or +> you add a trigger to delete the file on disk when the row in the +> database pointing at it is deleted and hope that the transaction doesn't +> rollback. + +Our solution to this problem was to have a separate table of "external +files to delete". When you want to delete a file, you just stuff an +entry into this table. If your transaction rolls back, so does your +insert into this table. You have a separate thread that periodically +walks this table and zaps the files from the filesystem. + +We found that using a procedural language (such as pl/Perl) was fine +for proof of concept. We did find limitations in how data is returned +from Perl functions as a string, combined with the need for binary +data in the files, that prevented us from using it in production. We +had to rewrite the functions in C. + + -jan- +-- +Jan L. Peterson + + +From pgsql-performance-owner@postgresql.org Thu Feb 9 19:22:00 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id CB9A69DC87F + for ; + Thu, 9 Feb 2006 19:21:59 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 57926-05 + for ; + Thu, 9 Feb 2006 19:22:02 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 78A369DC84A + for ; + Thu, 9 Feb 2006 19:21:57 -0400 (AST) +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 k19NM0Ys005732; + Thu, 9 Feb 2006 18:22:00 -0500 (EST) +To: Rafael Martinez Guerrero +cc: pgsql-performance@postgresql.org +Subject: Re: Help with optimizing a sql statement +In-reply-to: <1139497827.25608.1014.camel@bbking.uio.no> +References: <1139497827.25608.1014.camel@bbking.uio.no> +Comments: In-reply-to Rafael Martinez Guerrero + message dated "Thu, 09 Feb 2006 16:10:27 +0100" +Date: Thu, 09 Feb 2006 18:22:00 -0500 +Message-ID: <5731.1139527320@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.108 required=5 tests=[AWL=0.108] +X-Spam-Score: 0.108 +X-Spam-Level: +X-Archive-Number: 200602/90 +X-Sequence-Number: 17076 + +Rafael Martinez Guerrero writes: +> WHERE ((ACL_2.RightName = 'OwnTicket')) +> AND ((CachedGroupMembers_4.MemberId = Principals_1.id)) +> AND ((Groups_3.id = CachedGroupMembers_4.GroupId)) +> AND ((Principals_1.Disabled = '0') or (Principals_1.Disabled = '0')) +> AND ((Principals_1.id != '1')) +> AND ((main.id = Principals_1.id)) +> AND ( ( ACL_2.PrincipalId = Groups_3.id AND ACL_2.PrincipalType = +> 'Group' AND ( Groups_3.Domain = 'SystemInternal' OR Groups_3.Domain = +> 'UserDefined' OR Groups_3.Domain = 'ACLEquivalence')) OR ( ( +> (Groups_3.Domain = 'RT::Queue-Role' ) ) AND Groups_3.Type +> =ACL_2.PrincipalType) ) +> AND (ACL_2.ObjectType = 'RT::System' OR (ACL_2.ObjectType = 'RT::Queue') +> ) + +Are you sure this WHERE clause really expresses your intent? It seems +awfully oddly constructed. Removing the redundant parens and clarifying +the layout, I get + +WHERE ACL_2.RightName = 'OwnTicket' +AND CachedGroupMembers_4.MemberId = Principals_1.id +AND Groups_3.id = CachedGroupMembers_4.GroupId +AND (Principals_1.Disabled = '0' or Principals_1.Disabled = '0') +AND Principals_1.id != '1' +AND main.id = Principals_1.id +AND ( ( ACL_2.PrincipalId = Groups_3.id AND ACL_2.PrincipalType = 'Group' AND + (Groups_3.Domain = 'SystemInternal' OR Groups_3.Domain = 'UserDefined' OR Groups_3.Domain = 'ACLEquivalence') ) + OR + ( Groups_3.Domain = 'RT::Queue-Role' AND Groups_3.Type = ACL_2.PrincipalType ) + ) +AND (ACL_2.ObjectType = 'RT::System' OR ACL_2.ObjectType = 'RT::Queue') + +That next-to-last major AND clause seems a rather unholy mix of join and +restriction clauses; I wonder if it's not buggy in itself. If it is +correct, I think most of the performance problem comes from the fact +that the planner can't break it down into independent clauses. You +might try getting rid of the central OR in favor of doing a UNION of +two queries that comprise all the other terms. More repetitious, but +would likely perform better. + +BTW, what PG version is this? It looks to me like it's doing some +manipulations of the WHERE clause that we got rid of a couple years ago. +If this is 7.4 or older then you really ought to be thinking about an +update. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Feb 9 19:35:07 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id BE0789DCA2C + for ; + Thu, 9 Feb 2006 19:35:06 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 60422-07 + for ; + Thu, 9 Feb 2006 19:35:08 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from pat.uio.no (pat.uio.no [129.240.130.16]) + by postgresql.org (Postfix) with ESMTP id 271739DC951 + for ; + Thu, 9 Feb 2006 19:35:04 -0400 (AST) +Received: from mail-mx5.uio.no ([129.240.10.46]) + by pat.uio.no with esmtp (Exim 4.43) + id 1F7LJa-0006M0-Ez; Fri, 10 Feb 2006 00:35:06 +0100 +Received: from ti200710a080-12451.bb.online.no ([85.164.176.163] + helo=[10.1.1.101]) + by mail-mx5.uio.no with esmtpsa (SSLv3:RC4-MD5:128) (Exim 4.43) + id 1F7LJX-00065c-Qt; Fri, 10 Feb 2006 00:35:03 +0100 +Subject: Re: Help with optimizing a sql statement +From: Rafael Martinez +To: Tom Lane +Cc: pgsql-performance@postgresql.org +In-Reply-To: <5731.1139527320@sss.pgh.pa.us> +References: <1139497827.25608.1014.camel@bbking.uio.no> + <5731.1139527320@sss.pgh.pa.us> +Content-Type: text/plain +Organization: University of Oslo +Date: Fri, 10 Feb 2006 00:36:34 +0100 +Message-Id: <1139528194.19758.18.camel@linux.site> +Mime-Version: 1.0 +X-Mailer: Evolution 2.4.0 +Content-Transfer-Encoding: 7bit +X-UiO-Spam-info: not spam, SpamAssassin (score=-4.274, required 12, + autolearn=disabled, AWL 0.73, UIO_MAIL_IS_INTERNAL -5.00) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200602/91 +X-Sequence-Number: 17077 + +On Thu, 2006-02-09 at 18:22 -0500, Tom Lane wrote: +> Rafael Martinez Guerrero writes: +> > WHERE ((ACL_2.RightName = 'OwnTicket')) +> > AND ((CachedGroupMembers_4.MemberId = Principals_1.id)) +> > AND ((Groups_3.id = CachedGroupMembers_4.GroupId)) +> > AND ((Principals_1.Disabled = '0') or (Principals_1.Disabled = '0')) +> > AND ((Principals_1.id != '1')) +> > AND ((main.id = Principals_1.id)) +> > AND ( ( ACL_2.PrincipalId = Groups_3.id AND ACL_2.PrincipalType = +> > 'Group' AND ( Groups_3.Domain = 'SystemInternal' OR Groups_3.Domain = +> > 'UserDefined' OR Groups_3.Domain = 'ACLEquivalence')) OR ( ( +> > (Groups_3.Domain = 'RT::Queue-Role' ) ) AND Groups_3.Type +> > =ACL_2.PrincipalType) ) +> > AND (ACL_2.ObjectType = 'RT::System' OR (ACL_2.ObjectType = 'RT::Queue') +> > ) +> +> Are you sure this WHERE clause really expresses your intent? It seems +> awfully oddly constructed. Removing the redundant parens and clarifying +> the layout, I get +> +[............] + +This is an application that we have not programmed, so I am not sure +what they are trying to do here. I will contact the developers. Tomorrow +I will try to test some of your suggestions. + +> BTW, what PG version is this? It looks to me like it's doing some +> manipulations of the WHERE clause that we got rid of a couple years ago. +> If this is 7.4 or older then you really ought to be thinking about an +> update. +> + +We are running 7.4.8 in this server and will upgrade to 8.0.6 in a few +weeks. + +Thanks. +-- +Rafael Martinez, +Center for Information Technology Services +University of Oslo, Norway + +PGP Public Key: http://folk.uio.no/rafael/ + + +From pgsql-performance-owner@postgresql.org Thu Feb 9 22:28:50 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id CFB579DCC6A + for ; + Thu, 9 Feb 2006 22:28:49 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 92334-09 + for ; + Thu, 9 Feb 2006 22:28:53 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from yertle.kcilink.com (yertle.kcilink.com [65.205.34.180]) + by postgresql.org (Postfix) with ESMTP id CC50E9DCC59 + for ; + Thu, 9 Feb 2006 22:28:47 -0400 (AST) +Received: from [192.168.1.3] (unknown [192.168.1.3]) + by yertle.kcilink.com (Postfix) with ESMTP id 389ABB864 + for ; + Thu, 9 Feb 2006 21:28:51 -0500 (EST) +Mime-Version: 1.0 (Apple Message framework v746.2) +In-Reply-To: <1139528194.19758.18.camel@linux.site> +References: <1139497827.25608.1014.camel@bbking.uio.no> + <5731.1139527320@sss.pgh.pa.us> + <1139528194.19758.18.camel@linux.site> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: +Content-Transfer-Encoding: 7bit +From: Vivek Khera +Subject: Re: Help with optimizing a sql statement +Date: Thu, 9 Feb 2006 21:28:53 -0500 +To: Postgresql Performance +X-Mailer: Apple Mail (2.746.2) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.063 required=5 tests=[AWL=0.063] +X-Spam-Score: 0.063 +X-Spam-Level: +X-Archive-Number: 200602/92 +X-Sequence-Number: 17078 + + +On Feb 9, 2006, at 6:36 PM, Rafael Martinez wrote: + +> This is an application that we have not programmed, so I am not sure +> what they are trying to do here. I will contact the developers. +> Tomorrow +> I will try to test some of your suggestions. + +well, obviously you're running RT... what you want to do is update +all your software to the latest versions. in particular update RT to +3.4.5 and all the dependent modules to their latest. We run with Pg +8.0 which is plenty fast. one of these days I'll update to 8.1 but +need to test it out first. i'm not sure how much RT has been tested +against 8.1 + + +From pgsql-performance-owner@postgresql.org Fri Feb 10 02:05:53 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 88E6C9DCBFB + for ; + Fri, 10 Feb 2006 02:05:52 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 33782-08 + for ; + Fri, 10 Feb 2006 02:05:51 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) + by postgresql.org (Postfix) with ESMTP id 8C5129DCBCA + for ; + Fri, 10 Feb 2006 02:05:50 -0400 (AST) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1F7RPa-0001TK-00; Fri, 10 Feb 2006 01:05:42 -0500 +To: Tom Lane +Cc: Rafael Martinez Guerrero , + pgsql-performance@postgresql.org +Subject: Re: Help with optimizing a sql statement +References: <1139497827.25608.1014.camel@bbking.uio.no> + <5731.1139527320@sss.pgh.pa.us> +In-Reply-To: <5731.1139527320@sss.pgh.pa.us> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 10 Feb 2006 01:05:42 -0500 +Message-ID: <87zmkz6955.fsf@stark.xeocode.com> +Lines: 19 +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, score=0.131 required=5 tests=[AWL=0.131] +X-Spam-Score: 0.131 +X-Spam-Level: +X-Archive-Number: 200602/93 +X-Sequence-Number: 17079 + +Tom Lane writes: + +> Are you sure this WHERE clause really expresses your intent? It seems +> awfully oddly constructed. Removing the redundant parens and clarifying +> the layout, I get +... +> That next-to-last major AND clause seems a rather unholy mix of join and +> restriction clauses; I wonder if it's not buggy in itself. + +FYI RT uses a perl module called SearchBuilder which constructs these queries +dynamically. So he's probably not really free to fiddle with the query all he +wants. + +At the very least I would suggest checking the changelog for SearchBuilder for +more recent versions. There have been a lot of tweaks for working with +Postgres. In the past it really only worked properly with MySQL. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Fri Feb 10 04:16:53 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 2B5D99DCCD2 + for ; + Fri, 10 Feb 2006 04:16:53 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 27005-02 + for ; + Fri, 10 Feb 2006 04:16:51 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from uproxy.gmail.com (uproxy.gmail.com [66.249.92.206]) + by postgresql.org (Postfix) with ESMTP id 9CB2A9DCAB8 + for ; + Fri, 10 Feb 2006 04:16:48 -0400 (AST) +Received: by uproxy.gmail.com with SMTP id j3so199578ugf + for ; + Fri, 10 Feb 2006 00:16:49 -0800 (PST) +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=NoT9zP65uBUOfKpiTFXiqp/hSA/H6jLALWlf6ZbMKCXPS5EEgai1yQ8lDSwJSW0GcrdFmrnaYuhmqXckJQuVUBNgY6q8WqIZa7zP+7k+AjahAaGslOv51qq5UrBMbbLuOm1bbcOtIzRnMhRMWplmg7UO6yHS5SifOEvS91JFBz0= +Received: by 10.66.255.13 with SMTP id c13mr4766639ugi; + Fri, 10 Feb 2006 00:16:49 -0800 (PST) +Received: by 10.66.238.1 with HTTP; Fri, 10 Feb 2006 00:16:49 -0800 (PST) +Message-ID: <1ca1c1410602100016p2b5fdcc4wbf45612d7efc5fdf@mail.gmail.com> +Date: Fri, 10 Feb 2006 00:16:49 -0800 +From: Aaron Turner +To: pgsql-performance@postgresql.org +Subject: 10+hrs vs 15min because of just one index +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, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200602/94 +X-Sequence-Number: 17080 + +So I'm trying to figure out how to optimize my PG install (8.0.3) to +get better performance without dropping one of my indexes. + +Basically, I have a table of 5M records with 3 columns: + +pri_key (SERIAL) +data char(48) +groupid integer + +there is an additional unique index on the data column. + +The problem is that when I update the groupid column for all the +records, the query takes over 10hrs (after that I just canceled the +update). Looking at iostat, top, vmstat shows I'm horribly disk IO +bound (for data not WAL, CPU 85-90% iowait) and not swapping. + +Dropping the unique index on data (which isn't used in the query), +running the update and recreating the index runs in under 15 min.=20 +Hence it's pretty clear to me that the index is the problem and +there's really nothing worth optimizing in my query. + +As I understand from #postgresql, doing an UPDATE on one column causes +all indexes for the effected row to have to be updated due to the way +PG replaces the old row with a new one for updates. This seems to +explain why dropping the unique index on data solves the performance +problem. + +interesting settings: +shared_buffers =3D 32768 +maintenance_work_mem =3D 262144 +fsync =3D true +wal_sync_method =3D open_sync +wal_buffers =3D 512 +checkpoint_segments =3D 30 +effective_cache_size =3D 10000 +work_mem =3D (1024 i think?) + +box: +Linux 2.6.9-11EL (CentOS 4.1) +2x Xeon 3.4 HT +2GB of RAM (but Apache and other services are running) +4 disk raid 10 (74G Raptor) for data +4 disk raid 10 (7200rpm) for WAL + +other then throwing more spindles at the problem, any suggestions? + +Thanks, +Aaron + +-- +Aaron Turner +http://synfin.net/ + +From pgsql-performance-owner@postgresql.org Fri Feb 10 04:22:47 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 2E97E9DC9A2 + for ; + Fri, 10 Feb 2006 04:22:47 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25076-07 + for ; + Fri, 10 Feb 2006 04:22:47 -0400 (AST) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id A416D9DC8A9 + for ; + Fri, 10 Feb 2006 04:22:44 -0400 (AST) +Received: from ctb-mesg3.saix.net (ctb-mesg3.saix.net [196.25.240.73]) + by svr4.postgresql.org (Postfix) with ESMTP id 067705AF1F4 + for ; + Fri, 10 Feb 2006 08:22:45 +0000 (GMT) +Received: from mygus (dsl-146-121-181.telkomadsl.co.za [165.146.121.181]) + by ctb-mesg3.saix.net (Postfix) with ESMTP id 4CF9D443F; + Fri, 10 Feb 2006 10:22:36 +0200 (SAST) +From: "James Dey" +To: +Subject: Basic Database Performance +Date: Fri, 10 Feb 2006 10:22:35 +0200 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0033_01C62E2B.EACBBD10" +X-Mailer: Microsoft Office Outlook, Build 11.0.6353 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +Thread-Index: AcYuGyUzYb4rrFf9T36Oe9u6HTFB+w== +Message-Id: <20060210082236.4CF9D443F@ctb-mesg3.saix.net> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.001 required=5 tests=[HTML_MESSAGE=0.001] +X-Spam-Score: 0.001 +X-Spam-Level: +X-Archive-Number: 200602/95 +X-Sequence-Number: 17081 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0033_01C62E2B.EACBBD10 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit + +Hi Guys, + + + +Apologies if this is a novice queston, but I think it is a performance one +nevertheless. We are running a prototype of a system running on +PHP/Postgresql on an Intel Xeon 2ghz server, 1GB RAM, 40GB hard drive, as a +test bench. The system will be used for tens of thousands of users, and at +the moment we are testing on a base of around 400 users concurrently during +the day. + + + +During the day, the system is incredibly slow to a point where it is +unusable. The reason we are testing on such as small server is to test +performance under pressure, and my estimation is that spec should handle +thousands of users. + + + +The server spikes from 5% usage to 95% up and down. The system is a very +simple e-learning and management system and has not given us any issues to +date, only since we've been testing with more users has it done so. The fact +that 400 users doing inserts and queries every few minutes is very +concerning, I would like to know if I could be tweaking some config +settings. + + +We are running PG 7.4 on a Debian Sarge server, and will be upgrading to +pg8.0 on a new server, but have some migration issues (that's for another +list!) + + +Any help would be greatly appreciated! + + +All the very best, + + + +James Dey + + + +tel +27 11 704-1945 + +cell +27 82 785-5102 + +fax +27 11 388-8907 + +mail james@mygus.com + + + +myGUS / SLT retains all its intellectual property rights in any information +contained in e-mail messages (or any attachments thereto) which relates to +the official business of myGUS / SLT or of any of its associates. Such +information may be legally privileged, is to be treated as confidential and +myGUS / SLT will take legal steps against any unauthorised use. myGUS / SLT +does not take any responsibility for, or endorses any information which does +not relate to its official business, including personal mail and/or opinions +by senders who may or may not be employed by myGUS / SLT. In the event that +you receive a message not intended for you, we request that you notify the +sender immediately, do not read, disclose or use the content in any way +whatsoever and destroy/delete the message immediately. While myGUS / SLT +will take reasonable precautions, it cannot ensure that this e-mail will be +free of errors, viruses, interception or interference therewith. myGUS / SLT +does not, therefore, issue any guarantees or warranties in this regard and +cannot be held liable for any loss or damages incurred by the recipient +which have been caused by any of the above-mentioned factors. + + + + +------=_NextPart_000_0033_01C62E2B.EACBBD10 +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + +
+ +

Hi Guys,

+ +

 

+ +

Apologies if this is a novice queston, but I think it = +is a +performance one nevertheless. We are running a prototype of a system = +running on +PHP/Postgresql on an Intel Xeon 2ghz server, 1GB RAM, 40GB hard drive, = +as a +test bench. The system will be used for tens of thousands of users, and = +at the +moment we are testing on a base of around 400 users concurrently during = +the +day.

+ +

 

+ +

During the day, the system is incredibly slow to a = +point +where it is unusable. The reason we are testing on such as small server = +is to +test performance under pressure, and my estimation is that spec should = +handle +thousands of users.

+ +

 

+ +

The server spikes from 5% usage to 95% up and down. = +The system +is a very simple e-learning and management system and has not given us = +any +issues to date, only since we’ve been testing with more users has = +it done +so. The fact that 400 users doing inserts and queries every few minutes = +is very +concerning, I would like to know if I could be tweaking some config = +settings.

+ +


+We are running PG 7.4 on a Debian Sarge server, and will be upgrading to = +pg8.0 +on a new server, but have some migration issues (that’s for = +another +list!)

+ +


+Any help would be greatly appreciated!

+ +


+All the very best,

+ +

 

+ +

James = +Dey

+ +

 = +

+ +

t= +el           = ++27 11 = +704-1945

+ +

c= +ell       &= +nbsp;  +27 +82 785-5102

+ +

f= +ax       &= +nbsp;   +27 +11 388-8907

+ +

m= +ail        james@mygus.com<= +/font>

+ +

 <= +/span>

+ +

myGUS / SLT retains all its = +intellectual +property rights in any information contained in e-mail messages (or any +attachments thereto) which relates to the official business of myGUS / = +SLT or +of any of its associates. Such information may be legally privileged, is = +to be +treated as confidential and myGUS / SLT will take legal steps against = +any +unauthorised use. myGUS / SLT does not take any responsibility for, or = +endorses +any information which does not relate to its official business, = +including +personal mail and/or opinions by senders who may or may not be employed = +by +myGUS / SLT. In the event that you receive a message not intended for = +you, we +request that you notify the sender immediately, do not read, disclose or = +use +the content in any way whatsoever and destroy/delete the message = +immediately. +While myGUS / SLT will take reasonable precautions, it cannot ensure = +that this +e-mail will be free of errors, viruses, interception or interference = +therewith. +myGUS / SLT does not, therefore, issue any guarantees or warranties in = +this +regard and cannot be held liable for any loss or damages incurred by the +recipient which have been caused by any of the above-mentioned = +factors.

+ +

 

+ +
+ + + + + +------=_NextPart_000_0033_01C62E2B.EACBBD10-- + + +From pgsql-performance-owner@postgresql.org Fri Feb 10 05:00:35 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 9BF329DCBAF + for ; + Fri, 10 Feb 2006 05:00:34 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 32099-07 + for ; + Fri, 10 Feb 2006 05:00:35 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.196]) + by postgresql.org (Postfix) with ESMTP id 93F409DC9F8 + for ; + Fri, 10 Feb 2006 05:00:32 -0400 (AST) +Received: by wproxy.gmail.com with SMTP id i21so310138wra + for ; + Fri, 10 Feb 2006 01:00:34 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=AjgsIYwmMU9lKDMijfIo1mJQxvFrWjHBDIkg4q6E0bDE7KnAU6Q45AJqAVto+18hBanmJA7ojeVLEV14zCoqC0ma1hoHzG5R3C1L7gz5AdkObGsECAy/sI62TFSMJ4CNRZYDaLNVWHzcOAbjVKVu8fl1r/S2EnJv//gw4xVbxfg= +Received: by 10.64.232.20 with SMTP id e20mr392761qbh; + Fri, 10 Feb 2006 01:00:34 -0800 (PST) +Received: by 10.65.254.12 with HTTP; Fri, 10 Feb 2006 01:00:34 -0800 (PST) +Message-ID: <9e4684ce0602100100x3d75554apb9decc3d08af52bd@mail.gmail.com> +Date: Fri, 10 Feb 2006 10:00:34 +0100 +From: hubert depesz lubaczewski +To: Aaron Turner +Subject: Re: 10+hrs vs 15min because of just one index +Cc: pgsql-performance@postgresql.org +In-Reply-To: <1ca1c1410602100016p2b5fdcc4wbf45612d7efc5fdf@mail.gmail.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <1ca1c1410602100016p2b5fdcc4wbf45612d7efc5fdf@mail.gmail.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.188 required=5 tests=[AWL=0.188] +X-Spam-Score: 0.188 +X-Spam-Level: +X-Archive-Number: 200602/96 +X-Sequence-Number: 17082 + +On 2/10/06, Aaron Turner wrote: +> So I'm trying to figure out how to optimize my PG install (8.0.3) to +> get better performance without dropping one of my indexes. +> Basically, I have a table of 5M records with 3 columns: +> pri_key (SERIAL) +> data char(48) +> groupid integer +> there is an additional unique index on the data column. +> The problem is that when I update the groupid column for all the +> records, the query takes over 10hrs (after that I just canceled the +> update). Looking at iostat, top, vmstat shows I'm horribly disk IO +> bound (for data not WAL, CPU 85-90% iowait) and not swapping. +> Dropping the unique index on data (which isn't used in the query), + +for such a large update i would suggest to go with different scenario: +split update into packets (10000, or 50000 rows at the time) +and do: +update packet +vacuum table +for all packets. and then reindex the table. should work much nicer. + +depesz + +From pgsql-performance-owner@postgresql.org Fri Feb 10 05:36:59 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id A0A2A9DCCD2 + for ; + Fri, 10 Feb 2006 05:36:58 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 41834-01 + for ; + Fri, 10 Feb 2006 05:36:59 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) + by postgresql.org (Postfix) with ESMTP id 578369DCBAF + for ; + Fri, 10 Feb 2006 05:36:56 -0400 (AST) +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 1B8A5407DEA; Fri, 10 Feb 2006 09:36:36 +0000 (GMT) +Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP id E5C7B15EA4; + Fri, 10 Feb 2006 09:36:35 +0000 (GMT) +Message-ID: <43EC5EA3.5070001@archonet.com> +Date: Fri, 10 Feb 2006 09:36:35 +0000 +From: Richard Huxton +User-Agent: Thunderbird 1.5 (X11/20051201) +MIME-Version: 1.0 +To: James Dey +Cc: pgsql-performance@postgresql.org +Subject: Re: Basic Database Performance +References: <20060210082236.4CF9D443F@ctb-mesg3.saix.net> +In-Reply-To: <20060210082236.4CF9D443F@ctb-mesg3.saix.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, score=0.116 required=5 tests=[AWL=0.116] +X-Spam-Score: 0.116 +X-Spam-Level: +X-Archive-Number: 200602/97 +X-Sequence-Number: 17083 + +James Dey wrote: +> +> Apologies if this is a novice queston, but I think it is a performance one +> nevertheless. We are running a prototype of a system running on +> PHP/Postgresql on an Intel Xeon 2ghz server, 1GB RAM, 40GB hard drive, as a +> test bench. The system will be used for tens of thousands of users, and at +> the moment we are testing on a base of around 400 users concurrently during +> the day. + +OK, that's 400 web-users, so presumably a fraction of that for +concurrent database connections. + +> During the day, the system is incredibly slow to a point where it is +> unusable. The reason we are testing on such as small server is to test +> performance under pressure, and my estimation is that spec should handle +> thousands of users. + +It'll depend on what the users are doing +It'll depend on what your code is doing +It'll depend on how you've configured PostgreSQL. + +> The server spikes from 5% usage to 95% up and down. + +Usage? Do you mean CPU? + + > The system is a very +> simple e-learning and management system and has not given us any issues to +> date, only since we've been testing with more users has it done so. The fact +> that 400 users doing inserts and queries every few minutes is very +> concerning, I would like to know if I could be tweaking some config +> settings. + +You haven't said what config settings you're working with. + +OK - the main questions have to be: +1. Are you limited by CPU, memory or disk i/o? +2. Are you happy your config settings are good? + How do you know? +3. Are there particular queries that are causing the problem, or lock +contention? + +> We are running PG 7.4 on a Debian Sarge server, and will be upgrading to +> pg8.0 on a new server, but have some migration issues (that's for another +> list!) + +Go straight to 8.1 - no point in upgrading half-way. If you don't like +compiling from source it's in backports.org + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Fri Feb 10 05:50:24 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id A8C109DC818 + for ; + Fri, 10 Feb 2006 05:50:23 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 42498-04 + for ; + Fri, 10 Feb 2006 05:50:23 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) + by postgresql.org (Postfix) with ESMTP id 4E7959DC897 + for ; + Fri, 10 Feb 2006 05:50:19 -0400 (AST) +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 F2333407300; Fri, 10 Feb 2006 09:50:21 +0000 (GMT) +Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP id B630315EA8; + Fri, 10 Feb 2006 09:50:21 +0000 (GMT) +Message-ID: <43EC61DD.8010106@archonet.com> +Date: Fri, 10 Feb 2006 09:50:21 +0000 +From: Richard Huxton +User-Agent: Thunderbird 1.5 (X11/20051201) +MIME-Version: 1.0 +To: James Dey +Cc: 'Postgresql Performance' +Subject: Re: Basic Database Performance +References: <20060210094413.7690943ED@ctb-mesg4.saix.net> +In-Reply-To: <20060210094413.7690943ED@ctb-mesg4.saix.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, score=0.117 required=5 tests=[AWL=0.117] +X-Spam-Score: 0.117 +X-Spam-Level: +X-Archive-Number: 200602/98 +X-Sequence-Number: 17084 + + +Don't forget to cc: the list. + +James Dey wrote: +> Hi Richard, +> +> Firstly, thanks a million for the reply. +> +> To answer your questions: +> 1. Are you limited by CPU, memory or disk i/o? +> I am not limited, but would like to get the most out of the config I have in +> order to be able to know what I'll get, when I scale up. + +But you said: "During the day, the system is incredibly slow to a point +where it is unusable". So presumably one or more of cpu,memory or disk +i/o is the problem. + +> 2. Are you happy your config settings are good? How do you know? +> I'm not, and would appreciate any help with these. + +If you have a look here, there is an introduction for 7.4 + http://www.varlena.com/varlena/GeneralBits/Tidbits/index.php +For 8.x you might find the following more useful. + http://www.powerpostgresql.com/PerfList + +> 3. Are there particular queries that are causing the problem, or lock +> contention? +> Not that I can see + +What is the balance between activity on Apache/PHP/PostgreSQL? + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Fri Feb 10 05:55:55 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 7497C9DC818 + for ; + Fri, 10 Feb 2006 05:55:54 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 42687-05 + for ; + Fri, 10 Feb 2006 05:55:55 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from ctb-mesg4.saix.net (ctb-mesg4.saix.net [196.25.240.74]) + by postgresql.org (Postfix) with ESMTP id 2DD599DC888 + for ; + Fri, 10 Feb 2006 05:55:51 -0400 (AST) +Received: from mygus (dsl-146-121-181.telkomadsl.co.za [165.146.121.181]) + by ctb-mesg4.saix.net (Postfix) with ESMTP id 8D1C03B9D; + Fri, 10 Feb 2006 11:55:51 +0200 (SAST) +From: "James Dey" +To: "'Richard Huxton'" +Cc: "'Postgresql Performance'" +Subject: Re: Basic Database Performance +Date: Fri, 10 Feb 2006 11:55:49 +0200 +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: <43EC61DD.8010106@archonet.com> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +Thread-Index: AcYuJ2nIqlz6tMfMRBud9EgOgA5QdwAALvzA +Message-Id: <20060210095551.8D1C03B9D@ctb-mesg4.saix.net> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200602/99 +X-Sequence-Number: 17085 + +Sorry about that + +James Dey + +tel +27 11 704-1945 +cell +27 82 785-5102 +fax +27 11 388-8907 +mail james@mygus.com + + +-----Original Message----- +From: Richard Huxton [mailto:dev@archonet.com] +Sent: 10 February 2006 11:50 AM +To: James Dey +Cc: 'Postgresql Performance' +Subject: Re: [PERFORM] Basic Database Performance + + +Don't forget to cc: the list. + +James Dey wrote: +> Hi Richard, +> +> Firstly, thanks a million for the reply. +> +> To answer your questions: +> 1. Are you limited by CPU, memory or disk i/o? +> I am not limited, but would like to get the most out of the config I have +in +> order to be able to know what I'll get, when I scale up. + +But you said: "During the day, the system is incredibly slow to a point +where it is unusable". So presumably one or more of cpu,memory or disk +i/o is the problem. + +> 2. Are you happy your config settings are good? How do you know? +> I'm not, and would appreciate any help with these. + +If you have a look here, there is an introduction for 7.4 + http://www.varlena.com/varlena/GeneralBits/Tidbits/index.php +For 8.x you might find the following more useful. + http://www.powerpostgresql.com/PerfList + +> 3. Are there particular queries that are causing the problem, or lock +> contention? +> Not that I can see + +What is the balance between activity on Apache/PHP/PostgreSQL? + +-- + Richard Huxton + Archonet Ltd + + +From pgsql-performance-owner@postgresql.org Fri Feb 10 06:04:31 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 945979DC888 + for ; + Fri, 10 Feb 2006 06:04:30 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 43638-08 + for ; + Fri, 10 Feb 2006 06:04:31 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.logix-tt.com (serval.logix-tt.com [213.239.221.42]) + by postgresql.org (Postfix) with ESMTP id 227CB9DC894 + for ; + Fri, 10 Feb 2006 06:04:27 -0400 (AST) +Received: from kingfisher.intern.logix-tt.com (Mc547.m.pppool.de + [89.49.197.71]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logix-tt.com (Postfix) with ESMTP id 68A9024400F; + Fri, 10 Feb 2006 11:04:32 +0100 (CET) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id 664A518189FA9; + Fri, 10 Feb 2006 11:04:33 +0100 (CET) +Message-ID: <43EC6531.60202@logix-tt.com> +Date: Fri, 10 Feb 2006 11:04:33 +0100 +From: Markus Schaber +Organization: Logical Tracking and Tracing International AG, Switzerland +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Greg Stark +Cc: Orion Henry , + pgsql-performance@postgresql.org +Subject: Re: Large Database Design Help +References: <43EB92DA.2080607@orangekids.org> + <87ek2c71vl.fsf@stark.xeocode.com> +In-Reply-To: <87ek2c71vl.fsf@stark.xeocode.com> +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.121 required=5 tests=[AWL=0.121] +X-Spam-Score: 0.121 +X-Spam-Level: +X-Archive-Number: 200602/100 +X-Sequence-Number: 17086 + +Hi, Greg, + +Greg Stark wrote: + +>> (Aside question: if I were to find a way to use COPY and I were loading +>>data on a single client_id, would dropping just the indexes for that client_id +>>accelerate the load?) +> Dropping indexes would accelerate the load but unless you're loading a large +> number of records relative the current size I'm not sure it would be a win +> since you would then have to rebuild the index for the entire segment. + +And, additionally, rebuilding a partial index with "WHERE client_id=42" +needs a full table scan, which is very slow, so temporarily dropping the +indices will not be useful if you merge the tables. + +Btw, I don't know whether PostgreSQL can make use of partial indices +when building other partial indices. If yes, you could temporarily drop +all but one of the partial indices for a specific client. + + +HTH, +Markus + +-- +Markus Schaber | Logical Tracking&Tracing International AG +Dipl. Inf. | Software Development GIS + +Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org + +From pgsql-performance-owner@postgresql.org Fri Feb 10 06:24:39 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 9720F9DCCEA + for ; + Fri, 10 Feb 2006 06:24:38 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 46061-09 + for ; + Fri, 10 Feb 2006 06:24:39 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.logix-tt.com (serval.logix-tt.com [213.239.221.42]) + by postgresql.org (Postfix) with ESMTP id B2BF29DCCA7 + for ; + Fri, 10 Feb 2006 06:24:35 -0400 (AST) +Received: from kingfisher.intern.logix-tt.com (Mc547.m.pppool.de + [89.49.197.71]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logix-tt.com (Postfix) with ESMTP id 5B7B624400F; + Fri, 10 Feb 2006 11:24:41 +0100 (CET) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id BF0AF18189FA9; + Fri, 10 Feb 2006 11:24:42 +0100 (CET) +Message-ID: <43EC69EA.3010709@logix-tt.com> +Date: Fri, 10 Feb 2006 11:24:42 +0100 +From: Markus Schaber +Organization: Logical Tracking and Tracing International AG, Switzerland +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Orion Henry +Cc: pgsql-performance@postgresql.org +Subject: Re: Large Database Design Help +References: <43EB92DA.2080607@orangekids.org> +In-Reply-To: <43EB92DA.2080607@orangekids.org> +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.121 required=5 tests=[AWL=0.121] +X-Spam-Score: 0.121 +X-Spam-Level: +X-Archive-Number: 200602/101 +X-Sequence-Number: 17087 + +Hi, Henry, + +Orion Henry wrote: + +> 1) The database is very large, the largest table has 40 million tuples. + +I'm afraid this doesn't qualify as '_very_ large' yet, but it +definitively is large enough to have some deep thoughts about it. :-) + +> 1) The data is easily partitionable by client ID. In an attempt to keep +> the indexes small and the inserts fast one table was made per client +> ID. Thus the primary table in the database (the one with 40 million +> tuples) is really 133 tables each ending with a three digit suffix. +> The largest of these client tables has 8 million of the 40 million +> tuples. The system started with around a half dozen clients and is now +> a huge pain to manage with so many tables. I was hoping new hardware +> and new postgres features would allow for this data to be merged safely +> into a single table. + +It possibly is a good idea to merge them. + +If you decide to keep them separated for whatever reason, you might want +to use schemas instead of three digit suffixes. Together with +appropriate named users or 'set search_path', this may help you to +simplify your software. + +In case you want to keep separate tables, but need some reports touching +all tables from time to time, table inheritance may help you. Just +create a base table, and then inherit all user specific tables from that +base table. Of course, this can be combined with the schema approach by +having the child tables in their appropriate schemas. + +> 2) The imports are not done inside of transactions. I'm assuming the +> system designers excluded this for a reason. Will I run into problems +> performing tens of thousands of inserts and updates inside a single +> transaction? + +Yes, it should give you a huge boost. Every commit has to flush the WAL +out to disk, which takes at least one disk spin. So on a simple 7200 RPM +disk, you cannot have more than 120 transactions/second. + +It may make sense to split such a bulk load into transactions of some +tens of thousands of rows, but that depends on how easy it is for your +application to resume in the middle of the bulk if the connection +aborts, and how much concurrent access you have on the backend. + +> 3) The current code that bulk loads data into the database is a loop +> that looks like this: +> +> $result = exe("INSERT INTO $table ($name_str) SELECT +> $val_str WHERE NOT EXISTS (SELECT 1 FROM $table WHERE $keys)"); +> if ($result == 0) +> { +> $result = exe("UPDATE $table SET $non_keys WHERE +> $keys"); +> } +> Is there a faster way to bulk load data when it's not known ahead of +> time if it's a new record or an updated record? + +Perhaps the easiest way might be to issue the update first. Update +returns a row count of the updated rows. If it is 0, you have to insert +the row. + +This can even be encapsulated into a "before insert" trigger on the +table, which tries the update and ignores the insert if the update +succeeded. This way, you can even use COPY on the client side. + +We're using this approach for one of our databases, where a client side +crash can result in occasional duplicates being COPYed to the table. + +> Dual Opteron 246, 4 disk SCSI RAID5, 4GB of RAM + +For lots non-read-only database workloads, RAID5 is a performance +killer. Raid 1/0 might be better, or having two mirrors of two disks +each, the first mirror holding system, swap, and the PostgreSQL WAL +files, the second one holding the data. Don't forget to tune the +postgresql settings appropriately. :-) + +> # du -sh /var/lib/postgres/data/ +> 16G /var/lib/postgres/data/ + +Your database seems to be small enough to fit on a single disk, so the +two mirrors approach I described above will be the best IMHO. + +> ( the current database is PG 7.4 - I intend to upgrade it to 8.1 if and +> when I do this refactoring ) + +This is a very good idea, 8.1 is miles ahead of 7.4 in many aspects. + +> ( the current OS is Debian Unstable but I intend to be running RHEL 4.0 +> if and when I do this refactoring ) + +This should not make too much difference. + +HTH, +Markus +-- +Markus Schaber | Logical Tracking&Tracing International AG +Dipl. Inf. | Software Development GIS + +Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org + +From pgsql-performance-owner@postgresql.org Fri Feb 10 06:37:04 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 829A89DC9A2 + for ; + Fri, 10 Feb 2006 06:37:04 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 50179-05 + for ; + Fri, 10 Feb 2006 06:37:06 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.logix-tt.com (serval.logix-tt.com [213.239.221.42]) + by postgresql.org (Postfix) with ESMTP id D3AD89DC888 + for ; + Fri, 10 Feb 2006 06:37:00 -0400 (AST) +Received: from kingfisher.intern.logix-tt.com (Mc547.m.pppool.de + [89.49.197.71]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logix-tt.com (Postfix) with ESMTP id 8994A24400F; + Fri, 10 Feb 2006 11:37:06 +0100 (CET) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id B53A618189FA9; + Fri, 10 Feb 2006 11:37:07 +0100 (CET) +Message-ID: <43EC6CD3.1020308@logix-tt.com> +Date: Fri, 10 Feb 2006 11:37:07 +0100 +From: Markus Schaber +Organization: Logical Tracking and Tracing International AG, Switzerland +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: James Dey +Cc: pgsql-performance@postgresql.org +Subject: Re: Basic Database Performance +References: <20060210082236.4CF9D443F@ctb-mesg3.saix.net> +In-Reply-To: <20060210082236.4CF9D443F@ctb-mesg3.saix.net> +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=windows-1252 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.121 required=5 tests=[AWL=0.121] +X-Spam-Score: 0.121 +X-Spam-Level: +X-Archive-Number: 200602/102 +X-Sequence-Number: 17088 + +Hi, James, + +James Dey wrote: + +> Apologies if this is a novice queston, but I think it is a performance +> one nevertheless. We are running a prototype of a system running on +> PHP/Postgresql on an Intel Xeon 2ghz server, 1GB RAM, 40GB hard drive, +> as a test bench. The system will be used for tens of thousands of users, +> and at the moment we are testing on a base of around 400 users +> concurrently during the day. + +The first thing that comes into my mind here is "connection pooling / +recycling". + +Try to make shure that connections are reused between http requests. +Reopening the connection on every http request will break your system, +as the backend startup time is rather high. + +> During the day, the system is incredibly slow to a point where it is +> unusable. The reason we are testing on such as small server is to test +> performance under pressure, and my estimation is that spec should handle +> thousands of users. + +Note that amount of data, concurrent users, hardware and speed don't +always scale linearly. + +> The server spikes from 5% usage to 95% up and down. The system is a very +> simple e-learning and management system and has not given us any issues +> to date, only since we�ve been testing with more users has it done so. +> The fact that 400 users doing inserts and queries every few minutes is +> very concerning, I would like to know if I could be tweaking some config +> settings. + +You should make shure that you run vacuum / analyze regularly (either +autovacuum, or vacuum full at night when you have no users on the system). + +Use statement logging or other profiling means to isolate the slow +queries, and EXPLAIN ANALYZE them to see what goes wrong. Create the +needed indices, and drop unneded one. (insert usual performance tuning +tips here...) + +> We are running PG 7.4 on a Debian Sarge server, and will be upgrading to +> pg8.0 on a new server, but have some migration issues (that�s for +> another list!) + +Ignore 8.0 and go to 8.1 directly. + + +HTH, +Markus + +-- +Markus Schaber | Logical Tracking&Tracing International AG +Dipl. Inf. | Software Development GIS + +Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org + +From pgsql-performance-owner@postgresql.org Fri Feb 10 11:40:59 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 5302A9DC9A9 + for ; + Fri, 10 Feb 2006 11:40:58 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 02302-09 + for ; + Fri, 10 Feb 2006 11:41:02 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.199]) + by postgresql.org (Postfix) with ESMTP id AEFFE9DC997 + for ; + Fri, 10 Feb 2006 11:40:55 -0400 (AST) +Received: by zproxy.gmail.com with SMTP id i28so460821nzi + for ; + Fri, 10 Feb 2006 07:41:00 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; + b=j9r4T39VsNUR7hKwcAB/0o0vXmIhwcDB2JBl6f3LMHnHcEUFztXgVYfpKAsq96sZApGCyhopuxImTt//abCrigUBjtNt6J1fTJG70NPi8qRlgwcBMpkYDwNVC0/iqojRK7+dDSCIdt/GHlw4dnaKWV2V/pfEnfzxtZoUhh/0ycM= +Received: by 10.37.20.33 with SMTP id x33mr3660228nzi; + Fri, 10 Feb 2006 07:41:00 -0800 (PST) +Received: by 10.36.71.10 with HTTP; Fri, 10 Feb 2006 07:41:00 -0800 (PST) +Message-ID: <674d1f8a0602100741y454ccd77ld445888d1cfa420e@mail.gmail.com> +Date: Fri, 10 Feb 2006 21:11:00 +0530 +From: Gourish Singbal +To: "Jim C. Nasby" +Subject: Re: pgbench output +Cc: Pradeep Parmar , pgsql-performance@postgresql.org +In-Reply-To: <20060207050626.GA1240@pervasive.com> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_25084_13384017.1139586060015" +References: <580055310602012309o40b9b0d4g@mail.gmail.com> + <20060207050626.GA1240@pervasive.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.134 required=5 tests=[AWL=0.133, + HTML_MESSAGE=0.001] +X-Spam-Score: 0.134 +X-Spam-Level: +X-Archive-Number: 200602/103 +X-Sequence-Number: 17089 + +------=_Part_25084_13384017.1139586060015 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Hi All, + +Here are some of the results i got after performing pgbench marking between +postgresql 7.4.5 and postgresql 8.1.2. having parameters with same values i= +n +the postgresql.conf file. + +postgres@machine:/newdisk/postgres/data> /usr/local/pgsql7.4.5/bin/pgbench +-c 10 -t 10000 regression +starting vacuum...end. +transaction type: TPC-B (sort of) +scaling factor: 10 +number of clients: 10 +number of transactions per client: 10000 +number of transactions actually processed: 100000/100000 +tps =3D 80.642615 (including connections establishing) +tps =3D 80.650638 (excluding connections establishing) + +postgres@machine:/newdisk/postgres/data> /usr/local/pgsql/bin/pgbench -c 10 +-t 10000 regression +starting vacuum...end. +transaction type: TPC-B (sort of) +scaling factor: 10 +number of clients: 10 +number of transactions per client: 10000 +number of transactions actually processed: 100000/100000 +tps =3D 124.134926 (including connections establishing) +tps =3D 124.148749 (excluding connections establishing) + +Conclusion : So please correct me if i am wrong ... this result set shows +that the postgresql version 8.1.2 has perform better than 7.4.5 in the +bench marking process since 8.1.2 was able to complete more transcations pe= +r +second successfully . + + +On 2/7/06, Jim C. Nasby wrote: + +> Well, it tells you how many transactions per second it was able to do. +> Do you have specific questions? +> +> On Thu, Feb 02, 2006 at 12:39:59PM +0530, Pradeep Parmar wrote: +> > Hi, +> > +> > I'm fairly new to PostgreSQL. I was trying pgbench , but could not +> > understand the output . Can anyone help me out to understand the output +> of +> > pgbench +> > +> > +> > ----Pradeep +> +> -- +> Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +> Pervasive Software http://pervasive.com work: 512-231-6117 +> vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: Don't 'kill -9' the postmaster +> + + + +-- +Best, +Gourish Singbal + +------=_Part_25084_13384017.1139586060015 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +
 
+
Hi All,
+
 
+
Here are some of the results i got after performing pgbench marking be= +tween postgresql 7.4.5 and postgresql 8.1.2. having parameters with same va= +lues in the postgresql.conf file.
+
 
+
postgres@ma= +chine:/newdisk/postgres/data> /usr/local/pgsql7.4.5/bin/pgbench -c 1= +0 -t 10000 regression
starting vacuum...end.
transaction type: TPC-B = +(sort of) +
scaling factor: 10
number of clients: 10
number of transactions p= +er client: 10000
number of transactions actually processed: 100000/10000= +0
tps =3D 80.642615 (including connections establishing)
tps =3D 80.6= +50638 + (excluding connections establishing)
+
+

postgres@mach= +ine:/newdisk/postgres/data> /usr/local/pgsql/bin/pgbench -c 10 -t 10= +000 regression
starting vacuum...end.
transaction type: TPC-B (sort o= +f) +
scaling factor: 10
number of clients: 10
number of transactions p= +er client: 10000
number of transactions actually processed: 100000/10000= +0
tps =3D 124.134926 (including connections establishing)
tps =3D 124= +.148749 + (excluding connections establishing)

+

Conclusion : So please correct me if i am wrong ... this result set show= +s that the postgresql version  8.1.2 has perform better than 7.4.5&nbs= +p;in the bench marking process since 8.1.2 was able to complete more transc= +ations per second successfully .=20 +

+


On 2/7/06, Jim C. Nasby <jnasby@pervas= +ive.com> wrote:

+
+
Well, it tells you how many tran= +sactions per second it was able to do.
Do you have specific questions? +
On Thu, Feb 02, 2006 at 12:39:59PM +0530, Pradeep Parmar wrote:
>= + Hi,
>
> I'm fairly new to PostgreSQL. I was trying pgbench , b= +ut could not
> understand the output . Can anyone help me out to unde= +rstand the output of +
> pgbench
>
>
> ----Pradeep

--
Jim C. Na= +sby, Sr. Engineering Consultant      jnasby@pervasive.com
Pervasive Soft= +ware       +http://pervasive.com    work: 512-231-6117
vcard= +: http://jim.nasby.net/perva= +sive.vcf       cell: 512-569-9461

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



--
Best,
Gourish Singbal=20 + +------=_Part_25084_13384017.1139586060015-- + +From pgsql-performance-owner@postgresql.org Fri Feb 10 12:53:50 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 483E49DC9B1 + for ; + Fri, 10 Feb 2006 12:53:49 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 17488-09 + for ; + Fri, 10 Feb 2006 12:53:47 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from uproxy.gmail.com (uproxy.gmail.com [66.249.92.206]) + by postgresql.org (Postfix) with ESMTP id DC1DA9DC89F + for ; + Fri, 10 Feb 2006 12:53:46 -0400 (AST) +Received: by uproxy.gmail.com with SMTP id u2so10894uge + for ; + Fri, 10 Feb 2006 08:53:45 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=OF1hxMYyYg5z9E36XqIs6Az7rWMfGlzGylgLBKQ362x8Wl3abhDq2yxKxozOfj+qTblgHOzVbkN8JjHRHp9Y7Tmwsriqlns0O//d+pgYXzi8bYwVVTOc8mfW6gjltVVKkGkbmVm7cxTa0skl9Oe5Vaek45caB6rGs5B7pgckMRE= +Received: by 10.66.255.4 with SMTP id c4mr2336662ugi; + Fri, 10 Feb 2006 08:35:50 -0800 (PST) +Received: by 10.66.221.12 with HTTP; Fri, 10 Feb 2006 08:35:49 -0800 (PST) +Message-ID: <1ca1c1410602100835w3a1f85a3tc6373ee7f4d13943@mail.gmail.com> +Date: Fri, 10 Feb 2006 08:35:49 -0800 +From: Aaron Turner +To: hubert depesz lubaczewski +Subject: Re: 10+hrs vs 15min because of just one index +Cc: pgsql-performance@postgresql.org +In-Reply-To: <9e4684ce0602100100x3d75554apb9decc3d08af52bd@mail.gmail.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <1ca1c1410602100016p2b5fdcc4wbf45612d7efc5fdf@mail.gmail.com> + <9e4684ce0602100100x3d75554apb9decc3d08af52bd@mail.gmail.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200602/104 +X-Sequence-Number: 17090 + +On 2/10/06, hubert depesz lubaczewski wrote: +> On 2/10/06, Aaron Turner wrote: +> > So I'm trying to figure out how to optimize my PG install (8.0.3) to +> > get better performance without dropping one of my indexes. +> > Basically, I have a table of 5M records with 3 columns: +> > pri_key (SERIAL) +> > data char(48) +> > groupid integer +> > there is an additional unique index on the data column. +> > The problem is that when I update the groupid column for all the +> > records, the query takes over 10hrs (after that I just canceled the +> > update). Looking at iostat, top, vmstat shows I'm horribly disk IO +> > bound (for data not WAL, CPU 85-90% iowait) and not swapping. +> > Dropping the unique index on data (which isn't used in the query), +> +> for such a large update i would suggest to go with different scenario: +> split update into packets (10000, or 50000 rows at the time) +> and do: +> update packet +> vacuum table +> for all packets. and then reindex the table. should work much nicer. + +The problem is that all 5M records are being updated by a single +UPDATE statement, not 5M individual statements. Also, vacuum can't +run inside of a transaction. + +On a side note, is there any performance information on updating +indexes (via insert/update) over the size of the column? Obviously, +char(48) is larger then most for indexing purposes, but I wonder if +performance drops linerally or exponentially as the column width +increases. Right now my column is hexidecimal... if I stored it as a +binary representation it would be smaller. + +Thanks, +Aaron + +From pgsql-performance-owner@postgresql.org Fri Feb 10 13:13:38 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 49BDD9DC829 + for ; + Fri, 10 Feb 2006 13:13:38 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 22151-04 + for ; + Fri, 10 Feb 2006 13:13:36 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from outbound.mailhop.org (outbound.mailhop.org [63.208.196.171]) + by postgresql.org (Postfix) with ESMTP id A23DC9DCD3D + for ; + Fri, 10 Feb 2006 13:13:35 -0400 (AST) +Received: from ool-4350c7ad.dyn.optonline.net ([67.80.199.173] + helo=[192.168.0.91]) by outbound.mailhop.org with esmtpa (Exim 4.51) + id 1F7bpu-0007Qb-Su; Fri, 10 Feb 2006 12:13:34 -0500 +X-Mail-Handler: MailHop Outbound by DynDNS +X-Originating-IP: 67.80.199.173 +X-Report-Abuse-To: abuse@dyndns.com (see + http://www.mailhop.org/outbound/abuse.html for abuse reporting + information) +X-MHO-User: zeut +Message-ID: <43ECC9BF.2030107@zeut.net> +Date: Fri, 10 Feb 2006 12:13:35 -0500 +From: "Matthew T. O'Connor" +User-Agent: Thunderbird 1.4 (Windows/20050908) +MIME-Version: 1.0 +To: Aaron Turner +CC: pgsql-performance@postgresql.org +Subject: Re: 10+hrs vs 15min because of just one index +References: <1ca1c1410602100016p2b5fdcc4wbf45612d7efc5fdf@mail.gmail.com> +In-Reply-To: <1ca1c1410602100016p2b5fdcc4wbf45612d7efc5fdf@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, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200602/105 +X-Sequence-Number: 17091 + +Aaron Turner wrote: +> So I'm trying to figure out how to optimize my PG install (8.0.3) to +> get better performance without dropping one of my indexes. + +What about something like this: + +begin; +drop slow_index_name; +update; +create index slow_index_name; +commit; +vacuum; + +Matt + +From pgsql-performance-owner@postgresql.org Fri Feb 10 13:24:46 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id D2ADE9DC818 + for ; + Fri, 10 Feb 2006 13:24:45 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 22863-09 + for ; + Fri, 10 Feb 2006 13:24:41 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from uproxy.gmail.com (uproxy.gmail.com [66.249.92.203]) + by postgresql.org (Postfix) with ESMTP id B37099DC829 + for ; + Fri, 10 Feb 2006 13:24:40 -0400 (AST) +Received: by uproxy.gmail.com with SMTP id m2so6231ugc + for ; + Fri, 10 Feb 2006 09:24:39 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=RRl+vM68HNwuX3T4FyuqV+Iz9Uyg7c2ktY/T44Qz9ub3yE9hCigwpOTD1vhYPiRObVtzjJ8V0myegJ6Trkkt9/9+XbcxMIAiKf8HTgdDnVf6LpDIbQghtBt4Z3AlBUnqkBpEr7DKhpY40DAu6k/thpaD504aDdslCu0XyqitWso= +Received: by 10.66.221.11 with SMTP id t11mr4920669ugg; + Fri, 10 Feb 2006 09:24:39 -0800 (PST) +Received: by 10.66.221.12 with HTTP; Fri, 10 Feb 2006 09:24:39 -0800 (PST) +Message-ID: <1ca1c1410602100924s191e7cddo4bda80d8f8d7cb6d@mail.gmail.com> +Date: Fri, 10 Feb 2006 09:24:39 -0800 +From: Aaron Turner +To: "Matthew T. O'Connor" +Subject: Re: 10+hrs vs 15min because of just one index +Cc: pgsql-performance@postgresql.org +In-Reply-To: <43ECC9BF.2030107@zeut.net> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <1ca1c1410602100016p2b5fdcc4wbf45612d7efc5fdf@mail.gmail.com> + <43ECC9BF.2030107@zeut.net> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200602/106 +X-Sequence-Number: 17092 + +On 2/10/06, Matthew T. O'Connor wrote: +> Aaron Turner wrote: +> > So I'm trying to figure out how to optimize my PG install (8.0.3) to +> > get better performance without dropping one of my indexes. +> +> What about something like this: +> +> begin; +> drop slow_index_name; +> update; +> create index slow_index_name; +> commit; +> vacuum; + +Right. That's exactly what I'm doing to get the update to occur in 15 +minutes. Unfortunately though, I'm basically at the point of every +time I insert/update into that table I have to drop the index which is +making my life very painful (having to de-dupe records in RAM in my +application is a lot faster but also more complicated/error prone). + +Basically, I need some way to optimize PG so that I don't have to drop +that index every time. + +Suggestions? + +-- +Aaron Turner +http://synfin.net/ + +From pgsql-hackers-owner@postgresql.org Fri Feb 10 15:20:55 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 6E84A9DCD23; + Fri, 10 Feb 2006 15:20:54 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 65484-06; Fri, 10 Feb 2006 15:20:54 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smtpauth01.mail.atl.earthlink.net + (smtpauth01.mail.atl.earthlink.net [209.86.89.61]) + by postgresql.org (Postfix) with ESMTP id B75B19DCD1F; + Fri, 10 Feb 2006 15:20:51 -0400 (AST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=JpjbTKTtQY2XeKgKobMo8BdWVA0smF8QWXxR38Hk/mLQej6YVYsxEUzrtJHvZBh+; + h=Received:Message-Id:X-Mailer:Date:To:From:Subject:Mime-Version:Content-Type:X-ELNK-Trace:X-Originating-IP; +Received: from [24.34.169.163] (helo=ron-6d52adff2a6.earthlink.net) + by smtpauth01.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1F7dp6-0000vX-Eq; Fri, 10 Feb 2006 14:20:52 -0500 +Message-Id: <7.0.1.0.2.20060210141522.035d4940@earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 7.0.1.0 +Date: Fri, 10 Feb 2006 14:22:31 -0500 +To: pgsql-performance@postgresql.org,pgsql-hackers@postgresql.org +From: Ron +Subject: What do the Windows pg hackers out there like for dev tools? +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bc1dea45d25da41afed5dd0ebf646fc314350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 24.34.169.163 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.479 required=5 tests=[DNS_FROM_RFC_ABUSE=0.479] +X-Spam-Score: 0.479 +X-Spam-Level: +X-Archive-Number: 200602/417 +X-Sequence-Number: 79555 + +Subject line says it all. I'm going to be testing changes under both +Linux and WinXP, so I'm hoping those of you that do M$ hacking will +pass along your list of suggestions and/or favorite (and hated so I +know what to avoid) tools. + +TiA, +Ron + + + +From pgsql-performance-owner@postgresql.org Fri Feb 10 16:18:06 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 082399DCE1E + for ; + Fri, 10 Feb 2006 16:18:01 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 99091-06-3 + for ; + Fri, 10 Feb 2006 16:18:01 -0400 (AST) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 122299DCDC1 + for ; + Fri, 10 Feb 2006 16:17:52 -0400 (AST) +Received: from peufeu.com (unknown [82.67.9.10]) + by svr4.postgresql.org (Postfix) with ESMTP id DEE925AF8E8 + for ; + Fri, 10 Feb 2006 19:56:00 +0000 (GMT) +Received: (qmail 30555 invoked from network); 10 Feb 2006 20:48:54 +0100 +Received: from unknown (HELO apollo13) (82.67.9.10) + by boutiquenumerique.com with SMTP; 10 Feb 2006 20:48:54 +0100 +To: "Orion Henry" , + pgsql-performance@postgresql.org +Subject: Re: Large Database Design Help +References: <43EB92DA.2080607@orangekids.org> +Message-ID: +Date: Fri, 10 Feb 2006 20:48:53 +0100 +From: PFC +Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +In-Reply-To: <43EB92DA.2080607@orangekids.org> +User-Agent: Opera M2/8.51 (Linux, build 1462) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.086 required=5 tests=[AWL=0.086] +X-Spam-Score: 0.086 +X-Spam-Level: +X-Archive-Number: 200602/109 +X-Sequence-Number: 17095 + + +> was origionally designed for Postgres 7.0 on a PIII 500Mhz and some + + Argh. + +> 1) The database is very large, the largest table has 40 million tuples. + + Is this simple types (like a few ints, text...) ? + How much space does it use on disk ? can it fit in RAM ? + +> 2) The database needs to import 10's of thousands of tuples each night +> quickly. The current method is VERY slow. + + You bet, COMMIT'ing after each insert or update is about the worst that +can be done. It works fine on MySQL/MyISAM (which doesn't know about +commit...) so I'd guess the system designer had a previous experience with +MySQL. + + My advice woule be : + + - get a decent machine with some RAM (I guess you already knew this)... + + Now, the update. + + I would tend to do this : + +- Generate a text file with your update data, using whatever tool you like +best (perl, php, python, java...) +- CREATE TEMPORARY TABLE blah ... +- COPY blah FROM your update file. + + COPY is super fast. I think temporary tables don't write to the xlog, so +they are also very fast. This should not take more than a few seconds for +a few 10 K's of simple rows on modern hardware. It actually takes a +fraction of a second on my PC for about 9K rows with 5 INTEGERs on them. + + You can also add constraints on your temporary table, to sanitize your +data, in order to be reasonably sure that the following updates will work. + + The data you feed to copy should be correct, or it will rollback. This is +your script's job to escape everything. + + Now you got your data in the database. You have several options : + + - You are confident that the UPDATE will work without being rolled back +by some constraint violation. Therefore, you issue a big joined UPDATE to +update all the rows in your main table which are also in your temp table. +Then you issue an INSERT INTO ... SELECT ... to insert the ones which were +not already in the big table. + + Joined updates can be slow if your RAM is too small and it has to thrash +the disk looking for every tuple around. + You can cheat and CLUSTER your main table (say, once a week), so it is +all in index order. Then you arrange your update data so it is in the same +order (for instance, you SELECT INTO another temp table, with an ORDER BY +corresponding to the CLUSTER on the main table). Having both in the same +order will help reducing random disk accesses. + + - If you don't like this method, then you might want to use the same +strategy as before (ie. a zillion queries), but write it in PSQL instead. +PSQL is a lot faster, because everything is already parsed and planned +beforehand. So you could do the following : + +- for each row in the temporary update table : + - UPDATE the corresponding row in the main table + - IF FOUND, then cool, it was updated, nothing more to do. + You don't need to SELECT in order to know if the row is there. + UPDATE does it for you, without the race condition. + - IF NOT FOUND, then insert. + This has a race condition. + You know your application, so you'll know if it matters or not. + + What do you think ? + +> 3) I can't import new records with a COPY or drop my indexes b/c some of +> them are new records (INSERTS) and some are altered records (UPDATES) +> and the only way I can think of to identify these records is to perform +> a select for each record. + + Yes and no ; if you must do this, then use PSQL, it's a lot faster. And +skip the SELECT. + Also, use the latest version. It really rocks. + Like many said on the list, put pg_xlog on its own physical disk, with +ext2fs. + +> 3) Wrap each load into a transaction ( tens of thousands of records per +> load ) + + That's the idea. The first strategy here (big update) uses one +transaction anyway. For the other one, your choice. You can either do it +all in 1 transaction, or in bunches of 1000 rows... but 1 row at a time +would be horrendously slow. + + Regards, + + P.F.C + +From pgsql-performance-owner@postgresql.org Fri Feb 10 16:13:35 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id B3D7C9DCD1F + for ; + Fri, 10 Feb 2006 16:13:33 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 99267-01 + for ; + Fri, 10 Feb 2006 16:13:34 -0400 (AST) +X-Greylist: delayed 00:25:08.841647 by SQLgrey- +Received: from peufeu.com (unknown [82.67.9.10]) + by postgresql.org (Postfix) with ESMTP id E64879DCB7A + for ; + Fri, 10 Feb 2006 16:13:30 -0400 (AST) +Received: (qmail 30962 invoked from network); 10 Feb 2006 21:14:07 +0100 +Received: from unknown (HELO apollo13) (82.67.9.10) + by boutiquenumerique.com with SMTP; 10 Feb 2006 21:14:07 +0100 +To: "James Dey" , pgsql-performance@postgresql.org +Subject: Re: Basic Database Performance +References: <20060210082236.4CF9D443F@ctb-mesg3.saix.net> +Message-ID: +Date: Fri, 10 Feb 2006 21:14:06 +0100 +From: PFC +Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +In-Reply-To: <20060210082236.4CF9D443F@ctb-mesg3.saix.net> +User-Agent: Opera M2/8.51 (Linux, build 1462) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.08 required=5 tests=[AWL=0.080] +X-Spam-Score: 0.08 +X-Spam-Level: +X-Archive-Number: 200602/108 +X-Sequence-Number: 17094 + +> We are running a prototype of a system running on +> PHP/Postgresql on an Intel Xeon 2ghz server, 1GB RAM, 40GB hard drive, + + I think this is a decent server... + + Now, I guess you are using Apache and PHP like everyone. + + Know these facts : + + - A client connection means an apache process (think HTTP 1.1 +Keep-Alives...) + - The PHP interpreter in mod_php will be active during all the time it +takes to receive the request, parse it, generate the dynamic page, and +send it to the client to the last byte (because it is sent streaming). So, +a php page that might take 10 ms to generate will actually hog an +interpreter for between 200 ms and 1 second, depending on client ping time +and other network latency figures. + - This is actually on-topic for this list, because it will also hog a +postgres connection and server process during all that time. Thus, it will +most probably be slow and unscalable. + + The solutions I use are simple : + + First, use lighttpd instead of apache. Not only is it simpler to use and +configure, it uses a lot less RAM and resources, is faster, lighter, etc. +It uses an asynchronous model. It's there on my server, a crap Celeron, +pushing about 100 hits/s, and it sits at 4% CPU and 18 megabytes of RAM in +the top. It's impossible to overload this thing unless you benchmark it on +gigabit lan, with 100 bytes files. + + Then, plug php in, using the fast-cgi protocol. Basically php spawns a +process pool, and you chose the size of this pool. Say you spawn 20 PHP +interpreters for instance. + + When a PHP page is requested, lighttpd asks the process pool to generate +it. Then, a PHP interpreter from the pool does the job, and hands the page +over to lighttpd. This is very fast. lighttpd handles the slow +transmission of the data to the client, while the PHP interpreter goes +back to the pool to service another request. + + This gives you database connection pooling for free, actually. The +connections are limited to the number of processes in the pool, so you +won't get hundreds of them all over the place. You can use php's +persistent connections without worries. You don't need to configure a +connection pool. It just works (TM). + + Also you might want to use eaccelerator on your PHP. It precompiles your +PHP pages, so you don't lose time on parsing. Page time on my site went + from 50-200 ms to 5-20 ms just by installing this. It's free. + + Try this and you might realize that after all, postgres was fast enough ! + + + + +From pgsql-performance-owner@postgresql.org Fri Feb 10 16:20:36 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id C24CD9DCD23 + for ; + Fri, 10 Feb 2006 16:20:35 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 99124-07 + for ; + Fri, 10 Feb 2006 16:20:36 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.204]) + by postgresql.org (Postfix) with ESMTP id 761159DCD1F + for ; + Fri, 10 Feb 2006 16:20:33 -0400 (AST) +Received: by zproxy.gmail.com with SMTP id r28so518310nza + for ; + Fri, 10 Feb 2006 12:20:35 -0800 (PST) +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=FghhjHsDEAHS8tXw8rDKNqnJDINdWC6QXQf7wzJruNh59xYaIBjBQKpyV4RNt9b+ey24tW+eJ4dzbiE8tvgcCSN87pVVcp7UPqLG9DKON60vE7XIir9e4pvMZPRr/bLSuoF7ccsoRvozkJQzsmQZ9cziz4TPHz+TFxFSOxX3fnA= +Received: by 10.64.10.9 with SMTP id 9mr2535732qbj; + Fri, 10 Feb 2006 12:20:34 -0800 (PST) +Received: by 10.65.188.20 with HTTP; Fri, 10 Feb 2006 12:20:34 -0800 (PST) +Message-ID: <9c89e2490602101220i796e6913pdfa05f40bb894b97@mail.gmail.com> +Date: Fri, 10 Feb 2006 12:20:34 -0800 +From: david drummard +To: pgsql-performance@postgresql.org +Subject: help required in design of database +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_719_3617172.1139602834650" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.643 required=5 tests=[HTML_00_10=0.642, + HTML_MESSAGE=0.001] +X-Spam-Score: 0.643 +X-Spam-Level: +X-Archive-Number: 200602/110 +X-Sequence-Number: 17096 + +------=_Part_719_3617172.1139602834650 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Hi, + +I have an unique requirement. I have a feed of 2.5 - 3 million rows of data +which arrives every 1/2 an hour. Each row has 2 small string values (about +50 chars each) and 10 int values. I need searcheability and running +arbitrary queries on any of these values. This means i have to create an +index on every column. The feed comes in as a text file comma separated. +Here is what i am planning to do + +1) create a new table every time a new feed file comes in. Create table wit= +h +indexes. Use the copy command to dump the data into the table. +2) rename the current table to some old table name and rename the new table +to current table name so that applications can access them directly. + +Note that these are read only tables and it is fine if the step 2 takes a +small amount of time (it is not a mission critical table hence, a small +downtime of some secs is fine). + +My question is what is the best way to do step (1) so that after the copy i= +s +done, the table is fully indexed and properly balanced and optimized for +query. +Should i create indexes before or after import ? I need to do this in +shortest period of time so that the data is always uptodate. Note that +incremental updates are not possible since almost every row will be changed +in the new file. + +my table creation script looks like this + +create table datatablenew(fe varchar(40), va varchar(60), a int, b int, c +int, d int, e int, f int, g int, h int, i int, j int, k int, l int, m int, = +n +int, o int, p int, q real); +create index fe_idx on datatablenew using hash (fe); +create index va_idx on datatablenew using hash(va); +create index a_idx on datatablenew (a); +...... +create index q_idx on datatablenew(q); + + +please advice. + +thanks +vijay + +------=_Part_719_3617172.1139602834650 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Hi,
+
+I have an unique requirement. I have a feed of 2.5 - 3 million rows of +data which arrives every 1/2 an hour. Each row has 2 small string +values  (about 50 chars each) and 10 int values. I need +searcheability and running arbitrary queries on any of these values. +This means i have to create an index on every column. The feed comes in +as a text file comma separated. Here is what i am planning to do
+
+1) create a new table every time a new feed file comes in. Create table +with indexes. Use the copy command to dump the data into the table.
+2) rename the current table to some old table name and rename the new +table to current table name so that applications can access them +directly.
+
+Note that these are read only tables and it is fine if the step 2 takes +a small amount of time (it is not a mission critical table hence, a +small downtime of some secs is fine).
+
+My question is what is the best way to do step (1) so that after the +copy is done, the table is fully indexed  and properly balanced +and optimized for query.
+Should i create indexes before or after import ? I need to do this in +shortest period of time so that the data is always uptodate. Note that +incremental updates are not possible since almost every row will be +changed in the new file.
+
+my table creation script looks like this
+
+create table datatablenew(fe varchar(40), va varchar(60), a int, b int, +c int, d int, e int, f int, g int, h int, i int, j int, k int, l int, m +int, n int, o int, p int, q real);
+create index fe_idx on datatablenew using hash (fe);
+create index va_idx on datatablenew using hash(va);
+create index a_idx on datatablenew (a);
+......
+create index q_idx on datatablenew(q);
+
+
+please advice.
+
+thanks
+vijay
+ +------=_Part_719_3617172.1139602834650-- + +From pgsql-performance-owner@postgresql.org Fri Feb 10 17:03:19 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id CDC329DC9E3 + for ; + Fri, 10 Feb 2006 17:03:18 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 07143-10 + for ; + Fri, 10 Feb 2006 17:03:19 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from cassarossa.samfundet.no (cassarossa.samfundet.no + [129.241.93.19]) + by postgresql.org (Postfix) with ESMTP id B51709DC86D + for ; + Fri, 10 Feb 2006 17:03:15 -0400 (AST) +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 1F7fQB-0004JX-D0 + for pgsql-performance@postgresql.org; Fri, 10 Feb 2006 22:03:15 +0100 +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1F7fQF-0004nQ-00 + for ; Fri, 10 Feb 2006 22:03:19 +0100 +Date: Fri, 10 Feb 2006 22:03:19 +0100 +From: "Steinar H. Gunderson" +To: pgsql-performance@postgresql.org +Subject: Re: help required in design of database +Message-ID: <20060210210319.GA18407@uio.no> +Mail-Followup-To: pgsql-performance@postgresql.org +References: <9c89e2490602101220i796e6913pdfa05f40bb894b97@mail.gmail.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Disposition: inline +In-Reply-To: <9c89e2490602101220i796e6913pdfa05f40bb894b97@mail.gmail.com> +X-Operating-System: Linux 2.6.14.3 on a x86_64 +X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ +User-Agent: Mutt/1.5.11 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.075 required=5 tests=[AWL=0.075] +X-Spam-Score: 0.075 +X-Spam-Level: +X-Archive-Number: 200602/111 +X-Sequence-Number: 17097 + +On Fri, Feb 10, 2006 at 12:20:34PM -0800, david drummard wrote: +> 1) create a new table every time a new feed file comes in. Create table with +> indexes. Use the copy command to dump the data into the table. +> 2) rename the current table to some old table name and rename the new table +> to current table name so that applications can access them directly. + +That sounds like a working plan. + +> Should i create indexes before or after import ? I need to do this in +> shortest period of time so that the data is always uptodate. Note that +> incremental updates are not possible since almost every row will be changed +> in the new file. + +You should create indexes after the import. Remember to pump up your memory +settings (maintenance_work_mem) if you want this to be quick. + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-performance-owner@postgresql.org Fri Feb 10 18:06:42 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 4FB7A9DC800 + for ; + Fri, 10 Feb 2006 18:06:41 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 20038-05 + for ; + Fri, 10 Feb 2006 18:06:42 -0400 (AST) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id E17A19DC855 + for ; + Fri, 10 Feb 2006 18:06:38 -0400 (AST) +Received: from mail.optiosoftware.com (mail.optio.com [192.216.93.10]) + by svr4.postgresql.org (Postfix) with ESMTP id 68CF75AF864 + for ; + Fri, 10 Feb 2006 22:06:41 +0000 (GMT) +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_01C62E8E.437A3F6A" +Subject: joining two tables slow due to sequential scan +Date: Fri, 10 Feb 2006 17:06:35 -0500 +Message-ID: <47668A1334CDBF46927C1A0DFEB223D3131302@mail.optiosoftware.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: joining two tables slow due to sequential scan +Thread-Index: AcYujkHN1/mQ5kzZQ2ib5koRLF6qWA== +From: "Tim Jones" +To: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.081 required=5 tests=[AWL=0.080, + HTML_MESSAGE=0.001] +X-Spam-Score: 0.081 +X-Spam-Level: +X-Archive-Number: 200602/112 +X-Sequence-Number: 17098 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C62E8E.437A3F6A +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + +=20 +I am trying to join two tables and keep getting a sequential scan in the +plan even though there is an index on the columns I am joining on. +Basically this the deal ... I have two tables with docid in them which +is what I am using for the join. =20 +=20 +ClinicalDocs ... (no primary key) though it does not help if I make +docid primary key +docid integer (index) +patientid integer (index) +visitid integer (index) + ... +=20 +Documentversions +docid integer (index) +docversionnumber (index) +docversionidentifier (primary key) +=20 +It seems to do an index scan if I put the primary key as docid. This is +what occurs when I link on the patid from ClinicalDocs to patient table. +However I can not make the docid primary key because it gets repeated +depending on how may versions of a document I have. I have tried using +a foreign key on documentversions with no sucess.=20 +=20 +In addition this query +=20 +select * from documentversions join clinicaldocuments on +documentversions.documentidentifier +=3D clinicaldocuments.dssdocumentidentifier where +documentversions.documentstatus =3D 'AC';=20 +=20 +does index scan=20 +but if I change the order e.g +=20 +select * from clinicaldocuments join documentversions on +clinicaldocuments.dssdocumentidentifier +=3D documentversions .documentidentifier where +clinicaldocuments.patientidentifier=3D 123; +=20 +does sequential scan what I need is bottom query +it is extremely slow ... Any ideas ? +=20 +Tim Jones +Healthcare Project Manager +Optio Software, Inc. +(770) 576-3555 +=20 + +------_=_NextPart_001_01C62E8E.437A3F6A +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + + + +
 
+
I am = +trying to join=20 +two tables and keep getting a sequential scan in the plan even though = +there is=20 +an index on the columns I am joining on.  Basically this the = +deal  ...=20 +I have two tables with docid in them which is what I am using for the=20 +join. 
+
 
+
ClinicalDocs ... (no=20 +primary key) though it does not help if I make docid primary=20 +key
+
docid = +integer=20 +(index)
+
patientid integer=20 +(index)
+
visitid integer=20 +(index)
+
 ...
+
 
+
Documentversions
+
docid = +integer=20 +(index)
+
docversionnumber=20 +(index)
+
docversionidentifier=20 +(primary key)
+
 
+
It = +seems to do an=20 +index scan if I put the primary key as docid.  This is what occurs = +when I=20 +link on the patid from ClinicalDocs to patient table.  However I = +can not=20 +make the docid primary key because it gets repeated depending on how may = + +versions of a document I have.  I have tried using a foreign key on = + +documentversions with no sucess.
+
 
+
In = +addition this=20 +query
+
 
+
select = +* from=20 +documentversions join clinicaldocuments on=20 +documentversions.documentidentifier
=3D = +clinicaldocuments.dssdocumentidentifier=20 +where documentversions.documentstatus =3D 'AC';
+
 
+
does = +index scan=20 +
+
but if = +I change the=20 +order e.g
+
 
+
select * from = +clinicaldocuments=20 +join documentversions on clinicaldocuments.dssdocumentidentifier
=3D=20 +documentversions .documentidentifier where = +clinicaldocuments.patientidentifier=3D=20 +123;
+
 
+
does sequential scan what I need is = +bottom=20 +query
+
it is extremely slow ... Any ideas=20 +?
+
 
+
Tim Jones
+
Healthcare Project = +Manager
+
Optio Software,=20 +Inc.
+
(770) = +576-3555
+
 
+ +------_=_NextPart_001_01C62E8E.437A3F6A-- + +From pgsql-performance-owner@postgresql.org Fri Feb 10 18:14:48 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id DBA299DC95C + for ; + Fri, 10 Feb 2006 18:14:47 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 23461-01 + for ; + Fri, 10 Feb 2006 18:14:49 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from globalrelay.com (mail1.globalrelay.com [216.18.71.77]) + by postgresql.org (Postfix) with ESMTP id 942A69DC855 + for ; + Fri, 10 Feb 2006 18:14:42 -0400 (AST) +X-Virus-Scanned: Scanned by GRC-AntiVirus Gateway +X-GR-Acctd: YES +Received: from [63.226.156.118] (HELO DaveEMachine) + by globalrelay.com (CommuniGate Pro SMTP 4.2.3) + with ESMTP id 83442275; Fri, 10 Feb 2006 14:14:40 -0800 +From: "Dave Dutcher" +To: "'Tim Jones'" , + +Subject: Re: joining two tables slow due to sequential scan +Date: Fri, 10 Feb 2006 16:14:30 -0600 +Message-ID: <001f01c62e8f$63551840$8300a8c0@tridecap.com> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0020_01C62E5D.18BAA840" +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 +In-Reply-To: <47668A1334CDBF46927C1A0DFEB223D3131302@mail.optiosoftware.com> +Importance: Normal +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.081 required=5 tests=[AWL=0.080, + HTML_MESSAGE=0.001] +X-Spam-Score: 0.081 +X-Spam-Level: +X-Archive-Number: 200602/113 +X-Sequence-Number: 17099 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0020_01C62E5D.18BAA840 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit + +What version of postgres are you using? Can you post the output from +EXPLAIN ANALYZE? + + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Tim Jones +Sent: Friday, February 10, 2006 4:07 PM +To: pgsql-performance@postgresql.org +Subject: [PERFORM] joining two tables slow due to sequential scan + + +I am trying to join two tables and keep getting a sequential scan in the +plan even though there is an index on the columns I am joining on. +Basically this the deal ... I have two tables with docid in them which +is what I am using for the join. + +ClinicalDocs ... (no primary key) though it does not help if I make +docid primary key +docid integer (index) +patientid integer (index) +visitid integer (index) + ... + +Documentversions +docid integer (index) +docversionnumber (index) +docversionidentifier (primary key) + +It seems to do an index scan if I put the primary key as docid. This is +what occurs when I link on the patid from ClinicalDocs to patient table. +However I can not make the docid primary key because it gets repeated +depending on how may versions of a document I have. I have tried using +a foreign key on documentversions with no sucess. + +In addition this query + +select * from documentversions join clinicaldocuments on +documentversions.documentidentifier += clinicaldocuments.dssdocumentidentifier where +documentversions.documentstatus = 'AC'; + +does index scan +but if I change the order e.g + +select * from clinicaldocuments join documentversions on +clinicaldocuments.dssdocumentidentifier += documentversions .documentidentifier where +clinicaldocuments.patientidentifier= 123; + +does sequential scan what I need is bottom query +it is extremely slow ... Any ideas ? + +Tim Jones +Healthcare Project Manager +Optio Software, Inc. +(770) 576-3555 + + +------=_NextPart_000_0020_01C62E5D.18BAA840 +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + + + + + + + + +
+ +

What version of postgres +are you using?  Can you = +post the +output from EXPLAIN ANALYZE?

+ +

 

+ +

 

+ +

-----Original = +Message-----
+From: +pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Tim Jones
+Sent: Friday, February = +10, 2006 +4:07 PM
+To: +pgsql-performance@postgresql.org
+Subject: [PERFORM] = +joining two +tables slow due to sequential scan

+ +

 

+ +
+ +

 

+ +
+ +
+ +

I am trying to join two = +tables and +keep getting a sequential scan in the plan even though there is an index = +on the +columns I am joining on.  Basically this the deal  ... I have = +two +tables with docid in them which is what I am using for the join.  = +

+ +
+ +
+ +

 

+ +
+ +
+ +

ClinicalDocs ... (no = +primary key) +though it does not help if I make docid primary = +key

+ +
+ +
+ +

docid integer = +(index)

+ +
+ +
+ +

patientid integer = +(index)

+ +
+ +
+ +

visitid integer = +(index)

+ +
+ +
+ +

 ...= +

+ +
+ +
+ +

 

+ +
+ +
+ +

Documentversions

+ +
+ +
+ +

docid integer = +(index)

+ +
+ +
+ +

docversionnumber = +(index)

+ +
+ +
+ +

docversionidentifier = +(primary key)

+ +
+ +
+ +

 

+ +
+ +
+ +

It seems to do an index = +scan if I +put the primary key as docid.  This is what occurs when I link on = +the +patid from ClinicalDocs to patient table.  However I can not make = +the +docid primary key because it gets repeated depending on how may versions = +of a +document I have.  I have tried using a foreign key on = +documentversions +with no sucess.

+ +
+ +
+ +

 

+ +
+ +
+ +

In addition this = +query

+ +
+ +
+ +

 

+ +
+ +
+ +

select * from = +documentversions join +clinicaldocuments on documentversions.documentidentifier
+=3D clinicaldocuments.dssdocumentidentifier where = +documentversions.documentstatus +=3D 'AC';

+ +
+ +
+ +

 

+ +
+ +
+ +

does index scan = +

+ +
+ +
+ +

but if I change the order = +e.g

+ +
+ +
+ +

 

+ +
+ +
+ +

select * from = +clinicaldocuments join +documentversions on clinicaldocuments.dssdocumentidentifier
+=3D documentversions .documentidentifier where +clinicaldocuments.patientidentifier=3D 123;

+ +
+ +
+ +

 

+ +
+ +
+ +

does sequential = +scan what I +need is bottom query

+ +
+ +
+ +

it is extremely slow ... = +Any ideas ?

+ +
+ +
+ +

 

+ +
+ +

Tim = +Jones

+ +

Healthcare Project = +Manager

+ +

Optio Software, = +Inc.

+ +

(770) = +576-3555

+ +
+ +

 

+ +
+ +
+ + + + + +------=_NextPart_000_0020_01C62E5D.18BAA840-- + + +From pgsql-performance-owner@postgresql.org Fri Feb 10 18:22:09 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 2FAA19DC826 + for ; + Fri, 10 Feb 2006 18:22:09 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 21565-08 + for ; + Fri, 10 Feb 2006 18:22:10 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id D237B9DC800 + for ; + Fri, 10 Feb 2006 18:22:06 -0400 (AST) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Fri, 10 Feb 2006 22:22:05 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 10 Feb 2006 16:22:05 -0600 +Subject: Re: joining two tables slow due to sequential scan +From: Scott Marlowe +To: Tim Jones +Cc: pgsql-performance@postgresql.org +In-Reply-To: <47668A1334CDBF46927C1A0DFEB223D3131302@mail.optiosoftware.com> +References: <47668A1334CDBF46927C1A0DFEB223D3131302@mail.optiosoftware.com> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1139610125.22740.145.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Fri, 10 Feb 2006 16:22:05 -0600 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.158 required=5 tests=[AWL=0.157, + UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 0.158 +X-Spam-Level: +X-Archive-Number: 200602/114 +X-Sequence-Number: 17100 + +On Fri, 2006-02-10 at 16:06, Tim Jones wrote: +> +> I am trying to join two tables and keep getting a sequential scan in +> the plan even though there is an index on the columns I am joining +> on. Basically this the deal ... I have two tables with docid in them +> which is what I am using for the join. +> + +SNIP + +> select * from documentversions join clinicaldocuments on +> documentversions.documentidentifier +> = clinicaldocuments.dssdocumentidentifier where +> documentversions.documentstatus = 'AC'; +> +> does index scan +> but if I change the order e.g +> +> select * from clinicaldocuments join documentversions on +> clinicaldocuments.dssdocumentidentifier +> = documentversions .documentidentifier where +> clinicaldocuments.patientidentifier= 123; + +OK. I'm gonna make a couple of guesses here: + +1: clinicaldocuments.patientidentifier is an int8 and you're running +7.4 or before. +2: There are more rows with clinicaldocuments.patientidentifier= 123 +than with documentversions.documentstatus = 'AC'. +3: documentversions.documentidentifier and +clinicaldocuments.dssdocumentidentifier are not the same type. + +Any of those things true? + +From pgsql-performance-owner@postgresql.org Fri Feb 10 18:35:51 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 394019DCAA6 + for ; + Fri, 10 Feb 2006 18:35:51 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25182-04 + for ; + Fri, 10 Feb 2006 18:35:53 -0400 (AST) +X-Greylist: delayed 00:29:11.528226 by SQLgrey- +Received: from mail.optiosoftware.com (mail.optio.com [192.216.93.10]) + by postgresql.org (Postfix) with ESMTP id CB9709DC9E1 + for ; + Fri, 10 Feb 2006 18:35:48 -0400 (AST) +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: joining two tables slow due to sequential scan +Date: Fri, 10 Feb 2006 17:35:50 -0500 +Message-ID: <47668A1334CDBF46927C1A0DFEB223D3131315@mail.optiosoftware.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] joining two tables slow due to sequential scan +Thread-Index: AcYukHEdLtCc4c6BRJuxo6jR64+RfAAAcx3w +From: "Tim Jones" +To: "Scott Marlowe" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.096 required=5 tests=[AWL=0.096] +X-Spam-Score: 0.096 +X-Spam-Level: +X-Archive-Number: 200602/115 +X-Sequence-Number: 17101 + + + +OK. I'm gonna make a couple of guesses here: + +1: clinicaldocuments.patientidentifier is an int8 and you're running +7.4 or before. + +-- nope int4 and 8.1 + +2: There are more rows with clinicaldocuments.patientidentifier=3D 123 +than with documentversions.documentstatus =3D 'AC'. + +-- nope generally speaking all statuses are 'AC' + +3: documentversions.documentidentifier and +clinicaldocuments.dssdocumentidentifier are not the same type. + +-- nope both int4 + +Any of those things true? + +From pgsql-performance-owner@postgresql.org Fri Feb 10 18:36:54 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 197269DC855 + for ; + Fri, 10 Feb 2006 18:36:54 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 24733-08 + for ; + Fri, 10 Feb 2006 18:36:56 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id 7B7439DC826 + for ; + Fri, 10 Feb 2006 18:36:51 -0400 (AST) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Fri, 10 Feb 2006 22:36:52 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 10 Feb 2006 16:36:52 -0600 +Subject: Re: joining two tables slow due to sequential scan +From: Scott Marlowe +To: Tim Jones +Cc: pgsql-performance@postgresql.org +In-Reply-To: <47668A1334CDBF46927C1A0DFEB223D3131315@mail.optiosoftware.com> +References: <47668A1334CDBF46927C1A0DFEB223D3131315@mail.optiosoftware.com> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1139611012.22740.147.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Fri, 10 Feb 2006 16:36:52 -0600 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.158 required=5 tests=[AWL=0.157, + UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 0.158 +X-Spam-Level: +X-Archive-Number: 200602/116 +X-Sequence-Number: 17102 + +On Fri, 2006-02-10 at 16:35, Tim Jones wrote: +> OK. I'm gonna make a couple of guesses here: +> +> 1: clinicaldocuments.patientidentifier is an int8 and you're running +> 7.4 or before. +> +> -- nope int4 and 8.1 +> +> 2: There are more rows with clinicaldocuments.patientidentifier= 123 +> than with documentversions.documentstatus = 'AC'. +> +> -- nope generally speaking all statuses are 'AC' +> +> 3: documentversions.documentidentifier and +> clinicaldocuments.dssdocumentidentifier are not the same type. +> +> -- nope both int4 + +OK then, I guess we'll need to see the explain analyze output of both of +those queries. + +From pgsql-performance-owner@postgresql.org Fri Feb 10 18:37:36 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id C978D9DCD23 + for ; + Fri, 10 Feb 2006 18:37:35 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25580-03 + for ; + Fri, 10 Feb 2006 18:37:37 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.optiosoftware.com (mail.optio.com [192.216.93.10]) + by postgresql.org (Postfix) with ESMTP id 126D79DCAA6 + for ; + Fri, 10 Feb 2006 18:37:30 -0400 (AST) +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: joining two tables slow due to sequential scan +Date: Fri, 10 Feb 2006 17:37:32 -0500 +Message-ID: <47668A1334CDBF46927C1A0DFEB223D3131317@mail.optiosoftware.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] joining two tables slow due to sequential scan +Thread-Index: AcYuj2fJETZfDwzXR6ibeZRXCfv5rQAAMd3g +From: "Tim Jones" +To: "Dave Dutcher" , + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.103 required=5 tests=[AWL=0.103] +X-Spam-Score: 0.103 +X-Spam-Level: +X-Archive-Number: 200602/117 +X-Sequence-Number: 17103 + +for first query + +QUERY PLAN +'Limit (cost=3D4.69..88.47 rows=3D10 width=3D1350) (actual +time=3D32.195..32.338 rows=3D10 loops=3D1)' +' -> Nested Loop (cost=3D4.69..4043.09 rows=3D482 width=3D1350) = +(actual +time=3D32.190..32.316 rows=3D10 loops=3D1)' +' -> Bitmap Heap Scan on documentversions (cost=3D4.69..1139.40 +rows=3D482 width=3D996) (actual time=3D32.161..32.171 rows=3D10 = +loops=3D1)' +' Recheck Cond: (documentstatus =3D ''AC''::bpchar)' +' -> Bitmap Index Scan on ix_docstatus (cost=3D0.00..4.69 +rows=3D482 width=3D0) (actual time=3D31.467..31.467 rows=3D96368 = +loops=3D1)' +' Index Cond: (documentstatus =3D ''AC''::bpchar)' +' -> Index Scan using ix_cdocdid on clinicaldocuments +(cost=3D0.00..6.01 rows=3D1 width=3D354) (actual time=3D0.006..0.007 = +rows=3D1 +loops=3D10)' +' Index Cond: ("outer".documentidentifier =3D +clinicaldocuments.dssdocumentidentifier)' +=20 +=20 + for second query + +QUERY PLAN +'Hash Join (cost=3D899.83..4384.17 rows=3D482 width=3D1350)' +' Hash Cond: ("outer".documentidentifier =3D +"inner".dssdocumentidentifier)' +' -> Seq Scan on documentversions (cost=3D0.00..2997.68 rows=3D96368 +width=3D996)' +' -> Hash (cost=3D898.62..898.62 rows=3D482 width=3D354)' +' -> Bitmap Heap Scan on clinicaldocuments (cost=3D4.69..898.62 +rows=3D482 width=3D354)' +' Recheck Cond: (patientidentifier =3D 123)' +' -> Bitmap Index Scan on ix_cdocpid (cost=3D0.00..4.69 +rows=3D482 width=3D0)' +' Index Cond: (patientidentifier =3D 123)' + + +thnx + +Tim Jones +Healthcare Project Manager +Optio Software, Inc. +(770) 576-3555 +=20 + +________________________________ + +From: Dave Dutcher [mailto:dave@tridecap.com]=20 +Sent: Friday, February 10, 2006 5:15 PM +To: Tim Jones; pgsql-performance@postgresql.org +Subject: RE: [PERFORM] joining two tables slow due to sequential scan + + + +What version of postgres are you using? Can you post the output from +EXPLAIN ANALYZE? + +=20 + +=20 + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Tim Jones +Sent: Friday, February 10, 2006 4:07 PM +To: pgsql-performance@postgresql.org +Subject: [PERFORM] joining two tables slow due to sequential scan + +=20 + +=20 + +I am trying to join two tables and keep getting a sequential scan in the +plan even though there is an index on the columns I am joining on. +Basically this the deal ... I have two tables with docid in them which +is what I am using for the join. =20 + +=20 + +ClinicalDocs ... (no primary key) though it does not help if I make +docid primary key + +docid integer (index) + +patientid integer (index) + +visitid integer (index) + + ... + +=20 + +Documentversions + +docid integer (index) + +docversionnumber (index) + +docversionidentifier (primary key) + +=20 + +It seems to do an index scan if I put the primary key as docid. This is +what occurs when I link on the patid from ClinicalDocs to patient table. +However I can not make the docid primary key because it gets repeated +depending on how may versions of a document I have. I have tried using +a foreign key on documentversions with no sucess.=20 + +=20 + +In addition this query + +=20 + +select * from documentversions join clinicaldocuments on +documentversions.documentidentifier +=3D clinicaldocuments.dssdocumentidentifier where +documentversions.documentstatus =3D 'AC';=20 + +=20 + +does index scan=20 + +but if I change the order e.g + +=20 + +select * from clinicaldocuments join documentversions on +clinicaldocuments.dssdocumentidentifier +=3D documentversions .documentidentifier where +clinicaldocuments.patientidentifier=3D 123; + +=20 + +does sequential scan what I need is bottom query + +it is extremely slow ... Any ideas ? + +=20 + +Tim Jones + +Healthcare Project Manager + +Optio Software, Inc. + +(770) 576-3555 + +=20 + + +From pgsql-performance-owner@postgresql.org Fri Feb 10 18:39:21 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 4E4239DC826 + for ; + Fri, 10 Feb 2006 18:39:21 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25354-06 + for ; + Fri, 10 Feb 2006 18:39:23 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id 78BB49DC800 + for ; + Fri, 10 Feb 2006 18:39:18 -0400 (AST) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Fri, 10 Feb 2006 22:39:19 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 10 Feb 2006 16:39:19 -0600 +Subject: Re: joining two tables slow due to sequential scan +From: Scott Marlowe +To: Tim Jones +Cc: Dave Dutcher , pgsql-performance@postgresql.org +In-Reply-To: <47668A1334CDBF46927C1A0DFEB223D3131317@mail.optiosoftware.com> +References: <47668A1334CDBF46927C1A0DFEB223D3131317@mail.optiosoftware.com> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1139611159.22740.149.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Fri, 10 Feb 2006 16:39:19 -0600 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.157 required=5 tests=[AWL=0.156, + UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 0.157 +X-Spam-Level: +X-Archive-Number: 200602/119 +X-Sequence-Number: 17105 + +On Fri, 2006-02-10 at 16:37, Tim Jones wrote: +> for first query +> +> QUERY PLAN +> 'Limit (cost=4.69..88.47 rows=10 width=1350) (actual +> time=32.195..32.338 rows=10 loops=1)' +> ' -> Nested Loop (cost=4.69..4043.09 rows=482 width=1350) (actual +> time=32.190..32.316 rows=10 loops=1)' +> ' -> Bitmap Heap Scan on documentversions (cost=4.69..1139.40 +> rows=482 width=996) (actual time=32.161..32.171 rows=10 loops=1)' +> ' Recheck Cond: (documentstatus = ''AC''::bpchar)' +> ' -> Bitmap Index Scan on ix_docstatus (cost=0.00..4.69 +> rows=482 width=0) (actual time=31.467..31.467 rows=96368 loops=1)' +> ' Index Cond: (documentstatus = ''AC''::bpchar)' +> ' -> Index Scan using ix_cdocdid on clinicaldocuments +> (cost=0.00..6.01 rows=1 width=354) (actual time=0.006..0.007 rows=1 +> loops=10)' +> ' Index Cond: ("outer".documentidentifier = +> clinicaldocuments.dssdocumentidentifier)' +> +> +> for second query +> +> QUERY PLAN +> 'Hash Join (cost=899.83..4384.17 rows=482 width=1350)' +> ' Hash Cond: ("outer".documentidentifier = +> "inner".dssdocumentidentifier)' +> ' -> Seq Scan on documentversions (cost=0.00..2997.68 rows=96368 +> width=996)' +> ' -> Hash (cost=898.62..898.62 rows=482 width=354)' +> ' -> Bitmap Heap Scan on clinicaldocuments (cost=4.69..898.62 +> rows=482 width=354)' +> ' Recheck Cond: (patientidentifier = 123)' +> ' -> Bitmap Index Scan on ix_cdocpid (cost=0.00..4.69 +> rows=482 width=0)' +> ' Index Cond: (patientidentifier = 123)' + +OK, the first one is explain analyze, but the second one is just plain +explain... + +From pgsql-performance-owner@postgresql.org Fri Feb 10 18:38:40 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 775959DC826 + for ; + Fri, 10 Feb 2006 18:38:39 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 23014-08 + for ; + Fri, 10 Feb 2006 18:38:41 -0400 (AST) +X-Greylist: delayed 00:06:41.766064 by SQLgrey- +Received: from mx1.hive.is (isaserver.ipf.is [85.197.192.10]) + by postgresql.org (Postfix) with SMTP id C6D6B9DC800 + for ; + Fri, 10 Feb 2006 18:38:33 -0400 (AST) +Received: (qmail 16656 invoked by uid 0); 10 Feb 2006 22:31:58 +0000 +Received: from unknown (HELO ?192.168.1.34?) (85.197.216.186) + by postur.hive.is with SMTP; 10 Feb 2006 22:31:58 +0000 +Subject: Re: Large Database Design Help +From: Ragnar +To: pgsql-performance@postgresql.org +In-Reply-To: <43EC69EA.3010709@logix-tt.com> +References: <43EB92DA.2080607@orangekids.org> <43EC69EA.3010709@logix-tt.com> +Content-Type: text/plain +Date: Fri, 10 Feb 2006 22:39:54 +0000 +Message-Id: <1139611194.17929.105.camel@localhost.localdomain> +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, score=0.268 required=5 tests=[AWL=0.268] +X-Spam-Score: 0.268 +X-Spam-Level: +X-Archive-Number: 200602/118 +X-Sequence-Number: 17104 + +On Fri, 2006-02-10 at 11:24 +0100, Markus Schaber wrote: + +> For lots non-read-only database workloads, RAID5 is a performance +> killer. Raid 1/0 might be better, or having two mirrors of two disks +> each, the first mirror holding system, swap, and the PostgreSQL WAL +> files, the second one holding the data. + +I was under the impression that it is preferable to keep the WAL on +its own spindles with no other activity there, to take full advantage +of the sequential nature of the WAL writes. + +That would mean one mirror for the WAL, and one for the rest. +This, of course, may sometimes be too much wasted disk space, as the WAL +typically will not use a whole disk, so you might partition this mirror +into a small ext2 filesystem for WAL, and use the rest for files seldom +accessed, such as backups. + +gnari + + + +From pgsql-performance-owner@postgresql.org Fri Feb 10 18:42:27 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 9529F9DC826 + for ; + Fri, 10 Feb 2006 18:42:26 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 27143-02 + for ; + Fri, 10 Feb 2006 18:42:28 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id 2532E9DC800 + for ; + Fri, 10 Feb 2006 18:42:23 -0400 (AST) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Fri, 10 Feb 2006 22:42:25 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 10 Feb 2006 16:42:25 -0600 +Subject: Re: Large Database Design Help +From: Scott Marlowe +To: Ragnar +Cc: pgsql-performance@postgresql.org +In-Reply-To: <1139611194.17929.105.camel@localhost.localdomain> +References: <43EB92DA.2080607@orangekids.org> <43EC69EA.3010709@logix-tt.com> + <1139611194.17929.105.camel@localhost.localdomain> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1139611345.22740.151.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Fri, 10 Feb 2006 16:42:25 -0600 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.157 required=5 tests=[AWL=0.156, + UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 0.157 +X-Spam-Level: +X-Archive-Number: 200602/120 +X-Sequence-Number: 17106 + +On Fri, 2006-02-10 at 16:39, Ragnar wrote: +> On Fri, 2006-02-10 at 11:24 +0100, Markus Schaber wrote: +> +> > For lots non-read-only database workloads, RAID5 is a performance +> > killer. Raid 1/0 might be better, or having two mirrors of two disks +> > each, the first mirror holding system, swap, and the PostgreSQL WAL +> > files, the second one holding the data. +> +> I was under the impression that it is preferable to keep the WAL on +> its own spindles with no other activity there, to take full advantage +> of the sequential nature of the WAL writes. +> +> That would mean one mirror for the WAL, and one for the rest. +> This, of course, may sometimes be too much wasted disk space, as the WAL +> typically will not use a whole disk, so you might partition this mirror +> into a small ext2 filesystem for WAL, and use the rest for files seldom +> accessed, such as backups. + +Well, on most database servers, the actual access to the OS and swap +drives should drop to about zero over time, so this is a workable +solution if you've only got enough drives / drive slots for two mirrors. + +From pgsql-performance-owner@postgresql.org Fri Feb 10 18:43:59 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 3E4889DC826 + for ; + Fri, 10 Feb 2006 18:43:59 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25449-06 + for ; + Fri, 10 Feb 2006 18:44:01 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.optiosoftware.com (mail.optio.com [192.216.93.10]) + by postgresql.org (Postfix) with ESMTP id D196C9DC800 + for ; + Fri, 10 Feb 2006 18:43:56 -0400 (AST) +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: joining two tables slow due to sequential scan +Date: Fri, 10 Feb 2006 17:43:58 -0500 +Message-ID: <47668A1334CDBF46927C1A0DFEB223D313131D@mail.optiosoftware.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] joining two tables slow due to sequential scan +Thread-Index: AcYuktoSqNJAD8cZSKOqTVIO5IZaoAAAE2Hw +From: "Tim Jones" +To: "Scott Marlowe" +Cc: "Dave Dutcher" , + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.107 required=5 tests=[AWL=0.107] +X-Spam-Score: 0.107 +X-Spam-Level: +X-Archive-Number: 200602/121 +X-Sequence-Number: 17107 + +oops + +QUERY PLAN +'Hash Join (cost=3D899.83..4384.17 rows=3D482 width=3D1350) (actual +time=3D0.203..0.203 rows=3D0 loops=3D1)' +' Hash Cond: ("outer".documentidentifier =3D +"inner".dssdocumentidentifier)' +' -> Seq Scan on documentversions (cost=3D0.00..2997.68 rows=3D96368 +width=3D996) (actual time=3D0.007..0.007 rows=3D1 loops=3D1)' +' -> Hash (cost=3D898.62..898.62 rows=3D482 width=3D354) (actual +time=3D0.161..0.161 rows=3D0 loops=3D1)' +' -> Bitmap Heap Scan on clinicaldocuments (cost=3D4.69..898.62 +rows=3D482 width=3D354) (actual time=3D0.159..0.159 rows=3D0 loops=3D1)' +' Recheck Cond: (patientidentifier =3D 123)' +' -> Bitmap Index Scan on ix_cdocpid (cost=3D0.00..4.69 +rows=3D482 width=3D0) (actual time=3D0.153..0.153 rows=3D0 loops=3D1)' +' Index Cond: (patientidentifier =3D 123)' +'Total runtime: 0.392 ms' + +note I have done these on a smaller db than what I am using but the +plans are the same=20 + + +Tim Jones +Healthcare Project Manager +Optio Software, Inc. +(770) 576-3555 + +-----Original Message----- +From: Scott Marlowe [mailto:smarlowe@g2switchworks.com]=20 +Sent: Friday, February 10, 2006 5:39 PM +To: Tim Jones +Cc: Dave Dutcher; pgsql-performance@postgresql.org +Subject: Re: [PERFORM] joining two tables slow due to sequential scan + +On Fri, 2006-02-10 at 16:37, Tim Jones wrote: +> for first query +>=20 +> QUERY PLAN +> 'Limit (cost=3D4.69..88.47 rows=3D10 width=3D1350) (actual +> time=3D32.195..32.338 rows=3D10 loops=3D1)' +> ' -> Nested Loop (cost=3D4.69..4043.09 rows=3D482 width=3D1350) = +(actual +> time=3D32.190..32.316 rows=3D10 loops=3D1)' +> ' -> Bitmap Heap Scan on documentversions = +(cost=3D4.69..1139.40 +> rows=3D482 width=3D996) (actual time=3D32.161..32.171 rows=3D10 = +loops=3D1)' +> ' Recheck Cond: (documentstatus =3D ''AC''::bpchar)' +> ' -> Bitmap Index Scan on ix_docstatus = +(cost=3D0.00..4.69 +> rows=3D482 width=3D0) (actual time=3D31.467..31.467 rows=3D96368 = +loops=3D1)' +> ' Index Cond: (documentstatus =3D ''AC''::bpchar)' +> ' -> Index Scan using ix_cdocdid on clinicaldocuments +> (cost=3D0.00..6.01 rows=3D1 width=3D354) (actual time=3D0.006..0.007 = +rows=3D1=20 +> loops=3D10)' +> ' Index Cond: ("outer".documentidentifier =3D +> clinicaldocuments.dssdocumentidentifier)' +> =20 +>=20 +> for second query +>=20 +> QUERY PLAN +> 'Hash Join (cost=3D899.83..4384.17 rows=3D482 width=3D1350)' +> ' Hash Cond: ("outer".documentidentifier =3D=20 +> "inner".dssdocumentidentifier)' +> ' -> Seq Scan on documentversions (cost=3D0.00..2997.68 = +rows=3D96368=20 +> width=3D996)' +> ' -> Hash (cost=3D898.62..898.62 rows=3D482 width=3D354)' +> ' -> Bitmap Heap Scan on clinicaldocuments = +(cost=3D4.69..898.62 +> rows=3D482 width=3D354)' +> ' Recheck Cond: (patientidentifier =3D 123)' +> ' -> Bitmap Index Scan on ix_cdocpid (cost=3D0.00..4.69 +> rows=3D482 width=3D0)' +> ' Index Cond: (patientidentifier =3D 123)' + +OK, the first one is explain analyze, but the second one is just plain +explain... + +From pgsql-performance-owner@postgresql.org Fri Feb 10 18:44:11 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 090DD9DC800 + for ; + Fri, 10 Feb 2006 18:44:11 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 24469-10 + for ; + Fri, 10 Feb 2006 18:44:13 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id CB2179DC9E1 + for ; + Fri, 10 Feb 2006 18:44:07 -0400 (AST) +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 k1AMi808002865; + Fri, 10 Feb 2006 17:44:08 -0500 (EST) +To: "Tim Jones" +cc: "Dave Dutcher" , pgsql-performance@postgresql.org +Subject: Re: joining two tables slow due to sequential scan +In-reply-to: <47668A1334CDBF46927C1A0DFEB223D3131317@mail.optiosoftware.com> +References: <47668A1334CDBF46927C1A0DFEB223D3131317@mail.optiosoftware.com> +Comments: In-reply-to "Tim Jones" + message dated "Fri, 10 Feb 2006 17:37:32 -0500" +Date: Fri, 10 Feb 2006 17:44:08 -0500 +Message-ID: <2864.1139611448@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.109 required=5 tests=[AWL=0.109] +X-Spam-Score: 0.109 +X-Spam-Level: +X-Archive-Number: 200602/122 +X-Sequence-Number: 17108 + +"Tim Jones" writes: +> QUERY PLAN +> 'Hash Join (cost=899.83..4384.17 rows=482 width=1350)' +> ' Hash Cond: ("outer".documentidentifier = +> "inner".dssdocumentidentifier)' + +This is not EXPLAIN ANALYZE output. Also, the rowcount estimates +seem far enough off in the other query to make me wonder how long +it's been since you ANALYZEd the tables... + +More generally, though, I don't see anything particularly wrong +with this query plan. You're selecting enough of the table that +an indexscan isn't necessarily a good plan. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Feb 10 18:46:17 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 6E7E49DC800 + for ; + Fri, 10 Feb 2006 18:46:17 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 26187-07 + for ; + Fri, 10 Feb 2006 18:46:19 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id 50F0D9DC9E1 + for ; + Fri, 10 Feb 2006 18:46:13 -0400 (AST) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Fri, 10 Feb 2006 22:46:14 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 10 Feb 2006 16:46:14 -0600 +Subject: Re: joining two tables slow due to sequential scan +From: Scott Marlowe +To: Tim Jones +Cc: Dave Dutcher , pgsql-performance@postgresql.org +In-Reply-To: <47668A1334CDBF46927C1A0DFEB223D313131D@mail.optiosoftware.com> +References: <47668A1334CDBF46927C1A0DFEB223D313131D@mail.optiosoftware.com> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1139611574.22740.154.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Fri, 10 Feb 2006 16:46:14 -0600 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.156 required=5 tests=[AWL=0.155, + UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 0.156 +X-Spam-Level: +X-Archive-Number: 200602/123 +X-Sequence-Number: 17109 + +On Fri, 2006-02-10 at 16:43, Tim Jones wrote: +> oops +> +> QUERY PLAN +> 'Hash Join (cost=899.83..4384.17 rows=482 width=1350) (actual +> time=0.203..0.203 rows=0 loops=1)' +> ' Hash Cond: ("outer".documentidentifier = +> "inner".dssdocumentidentifier)' +> ' -> Seq Scan on documentversions (cost=0.00..2997.68 rows=96368 +> width=996) (actual time=0.007..0.007 rows=1 loops=1)' +> ' -> Hash (cost=898.62..898.62 rows=482 width=354) (actual +> time=0.161..0.161 rows=0 loops=1)' +> ' -> Bitmap Heap Scan on clinicaldocuments (cost=4.69..898.62 +> rows=482 width=354) (actual time=0.159..0.159 rows=0 loops=1)' +> ' Recheck Cond: (patientidentifier = 123)' +> ' -> Bitmap Index Scan on ix_cdocpid (cost=0.00..4.69 +> rows=482 width=0) (actual time=0.153..0.153 rows=0 loops=1)' +> ' Index Cond: (patientidentifier = 123)' +> 'Total runtime: 0.392 ms' +> +> note I have done these on a smaller db than what I am using but the +> plans are the same + + +Hmmmm. We really need to see what's happening on the real database to +see what's going wrong. i.e. if the real database thinks it'll get 30 +rows and it gets back 5,000,000 that's a problem. + +The query planner in pgsql is cost based, so until you have real data +underneath it, and analyze it, you can't really say how it will behave +for you. I.e. small test sets don't work. + +From pgsql-performance-owner@postgresql.org Fri Feb 10 18:51:58 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id B0F6C9DCD86 + for ; + Fri, 10 Feb 2006 18:51:57 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28617-03 + for ; + Fri, 10 Feb 2006 18:51:59 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 8A6549DCB7A + for ; + Fri, 10 Feb 2006 18:51:55 -0400 (AST) +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 k1AMpoE9002938; + Fri, 10 Feb 2006 17:51:50 -0500 (EST) +To: "Tim Jones" +cc: "Scott Marlowe" , + "Dave Dutcher" , pgsql-performance@postgresql.org +Subject: Re: joining two tables slow due to sequential scan +In-reply-to: <47668A1334CDBF46927C1A0DFEB223D313131D@mail.optiosoftware.com> +References: <47668A1334CDBF46927C1A0DFEB223D313131D@mail.optiosoftware.com> +Comments: In-reply-to "Tim Jones" + message dated "Fri, 10 Feb 2006 17:43:58 -0500" +Date: Fri, 10 Feb 2006 17:51:50 -0500 +Message-ID: <2937.1139611910@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.109 required=5 tests=[AWL=0.109] +X-Spam-Score: 0.109 +X-Spam-Level: +X-Archive-Number: 200602/124 +X-Sequence-Number: 17110 + +"Tim Jones" writes: +> QUERY PLAN +> 'Hash Join (cost=899.83..4384.17 rows=482 width=1350) (actual +> time=0.203..0.203 rows=0 loops=1)' +> ... +> 'Total runtime: 0.392 ms' + +Hardly seems like evidence of a performance problem ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Feb 10 18:59:05 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 556929DCD92 + for ; + Fri, 10 Feb 2006 18:59:05 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28617-05 + for ; + Fri, 10 Feb 2006 18:59:07 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.optiosoftware.com (mail.optio.com [192.216.93.10]) + by postgresql.org (Postfix) with ESMTP id E9D369DCD86 + for ; + Fri, 10 Feb 2006 18:59:02 -0400 (AST) +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: joining two tables slow due to sequential scan +Date: Fri, 10 Feb 2006 17:59:03 -0500 +Message-ID: <47668A1334CDBF46927C1A0DFEB223D3131324@mail.optiosoftware.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] joining two tables slow due to sequential scan +Thread-Index: AcYulJakTYfEeSl+RnqOOKcAiwGtCgAABsnw +From: "Tim Jones" +To: "Tom Lane" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.109 required=5 tests=[AWL=0.109] +X-Spam-Score: 0.109 +X-Spam-Level: +X-Archive-Number: 200602/125 +X-Sequence-Number: 17111 + +ok here is real db + +the first query I had seems to make no sense because it is only fast if +I limit the rows since almost all rows have status =3D 'AC' + +second query + tables both have about 10 million rows and it takes a long time as you +can see but this person only has approx 160 total documents + + + QUERY PLAN =20 +------------------------------------------------------------------------ +------------------------------------------------------------------- + Hash Join (cost=3D84813.14..1510711.97 rows=3D48387 width=3D555) = +(actual +time=3D83266.854..91166.315 rows=3D3 loops=3D1) + Hash Cond: ("outer".documentidentifier =3D +"inner".dssdocumentidentifier) + -> Seq Scan on documentversions (cost=3D0.00..269141.98 = +rows=3D9677398 +width=3D415) (actual time=3D0.056..49812.459 rows=3D9677398 loops=3D1) + -> Hash (cost=3D83660.05..83660.05 rows=3D48036 width=3D140) = +(actual +time=3D10.833..10.833 rows=3D3 loops=3D1) + -> Bitmap Heap Scan on clinicaldocuments +(cost=3D301.13..83660.05 rows=3D48036 width=3D140) (actual = +time=3D0.243..0.258 +rows=3D3 loops=3D1) + Recheck Cond: (patientidentifier =3D 690193) + -> Bitmap Index Scan on ix_cdocpid (cost=3D0.00..301.13 +rows=3D48036 width=3D0) (actual time=3D0.201..0.201 rows=3D3 loops=3D1) + Index Cond: (patientidentifier =3D 690193) + Total runtime: 91166.540 ms + + +Tim Jones +Healthcare Project Manager +Optio Software, Inc. +(770) 576-3555 + +-----Original Message----- +From: Tom Lane [mailto:tgl@sss.pgh.pa.us]=20 +Sent: Friday, February 10, 2006 5:52 PM +To: Tim Jones +Cc: Scott Marlowe; Dave Dutcher; pgsql-performance@postgresql.org +Subject: Re: [PERFORM] joining two tables slow due to sequential scan=20 + +"Tim Jones" writes: +> QUERY PLAN +> 'Hash Join (cost=3D899.83..4384.17 rows=3D482 width=3D1350) (actual +> time=3D0.203..0.203 rows=3D0 loops=3D1)' +> ... +> 'Total runtime: 0.392 ms' + +Hardly seems like evidence of a performance problem ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Feb 10 19:25:23 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 706D89DC81A + for ; + Fri, 10 Feb 2006 19:25:22 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 32684-06 + for ; + Fri, 10 Feb 2006 19:25:24 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from globalrelay.com (mail1.globalrelay.com [216.18.71.77]) + by postgresql.org (Postfix) with ESMTP id 407779DC800 + for ; + Fri, 10 Feb 2006 19:25:19 -0400 (AST) +X-Virus-Scanned: Scanned by GRC-AntiVirus Gateway +X-GR-Acctd: YES +Received: from [63.226.156.118] (HELO DaveEMachine) + by globalrelay.com (CommuniGate Pro SMTP 4.2.3) + with ESMTP id 83446776; Fri, 10 Feb 2006 15:25:22 -0800 +From: "Dave Dutcher" +To: "'Tim Jones'" +Cc: +Subject: Re: joining two tables slow due to sequential scan +Date: Fri, 10 Feb 2006 17:25:20 -0600 +Message-ID: <002601c62e99$434299b0$8300a8c0@tridecap.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.2627 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +In-Reply-To: <47668A1334CDBF46927C1A0DFEB223D3131324@mail.optiosoftware.com> +Importance: Normal +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.09 required=5 tests=[AWL=0.090] +X-Spam-Score: 0.09 +X-Spam-Level: +X-Archive-Number: 200602/126 +X-Sequence-Number: 17112 + +OK, if I'm reading this correctly, it looks like the planner is choosing +a sequential scan because it expects 48,000 rows for that +patientidentifier, but its actually only getting 3. The planner has the +number of rows right for the sequential scan, so it seems like the stats +are up to date. I would try increasing the stats for the +patientindentifier column with 'alter table set statistics...' or +increasing the default_statistics_target for the whole DB. Once you +have changed the stats I believe you need to run analyze again. + + + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Tim Jones +Sent: Friday, February 10, 2006 4:59 PM +To: Tom Lane +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] joining two tables slow due to sequential scan + +ok here is real db + +the first query I had seems to make no sense because it is only fast if +I limit the rows since almost all rows have status = 'AC' + +second query + tables both have about 10 million rows and it takes a long time as you +can see but this person only has approx 160 total documents + + + QUERY PLAN +------------------------------------------------------------------------ +------------------------------------------------------------------- + Hash Join (cost=84813.14..1510711.97 rows=48387 width=555) (actual +time=83266.854..91166.315 rows=3 loops=1) + Hash Cond: ("outer".documentidentifier = +"inner".dssdocumentidentifier) + -> Seq Scan on documentversions (cost=0.00..269141.98 rows=9677398 +width=415) (actual time=0.056..49812.459 rows=9677398 loops=1) + -> Hash (cost=83660.05..83660.05 rows=48036 width=140) (actual +time=10.833..10.833 rows=3 loops=1) + -> Bitmap Heap Scan on clinicaldocuments +(cost=301.13..83660.05 rows=48036 width=140) (actual time=0.243..0.258 +rows=3 loops=1) + Recheck Cond: (patientidentifier = 690193) + -> Bitmap Index Scan on ix_cdocpid (cost=0.00..301.13 +rows=48036 width=0) (actual time=0.201..0.201 rows=3 loops=1) + Index Cond: (patientidentifier = 690193) + Total runtime: 91166.540 ms + + +Tim Jones +Healthcare Project Manager +Optio Software, Inc. +(770) 576-3555 + +-----Original Message----- +From: Tom Lane [mailto:tgl@sss.pgh.pa.us] +Sent: Friday, February 10, 2006 5:52 PM +To: Tim Jones +Cc: Scott Marlowe; Dave Dutcher; pgsql-performance@postgresql.org +Subject: Re: [PERFORM] joining two tables slow due to sequential scan + +"Tim Jones" writes: +> QUERY PLAN +> 'Hash Join (cost=899.83..4384.17 rows=482 width=1350) (actual +> time=0.203..0.203 rows=0 loops=1)' +> ... +> 'Total runtime: 0.392 ms' + +Hardly seems like evidence of a performance problem ... + + regards, tom lane + +---------------------------(end of broadcast)--------------------------- +TIP 5: don't forget to increase your free space map settings + + +From pgsql-hackers-owner@postgresql.org Fri Feb 10 20:40:10 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 6FC179DCA5A + for ; + Fri, 10 Feb 2006 20:40:09 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 45612-05 + for ; + Fri, 10 Feb 2006 20:40:12 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.197]) + by postgresql.org (Postfix) with ESMTP id 63E709DC9C0 + for ; + Fri, 10 Feb 2006 20:40:07 -0400 (AST) +Received: by wproxy.gmail.com with SMTP id i11so667028wra + for ; + Fri, 10 Feb 2006 16:40:11 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=SKI1re2pE+8fMno9z5khRBvj8qowrFXtg0LeluSUteFLo7fMwaJ0X5vu+YX8uqHvRHUD0dMYyNKdgrXlL+y12Gc0PqX1H58Jwh6P1Zb7ctn2I+syGaWyK3CQeG9bDuIOIbOv+8momalI7SJuKupOYPLUd2W2NKFaxSKx/LQx81Y= +Received: by 10.65.160.6 with SMTP id m6mr4828qbo; + Fri, 10 Feb 2006 16:40:10 -0800 (PST) +Received: by 10.65.138.11 with HTTP; Fri, 10 Feb 2006 16:40:10 -0800 (PST) +Message-ID: +Date: Fri, 10 Feb 2006 19:40:10 -0500 +From: Merlin Moncure +To: Ron +Subject: Re: What do the Windows pg hackers out there like for dev tools? +Cc: pgsql-hackers@postgresql.org +In-Reply-To: <7.0.1.0.2.20060210141522.035d4940@earthlink.net> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <7.0.1.0.2.20060210141522.035d4940@earthlink.net> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.108 required=5 tests=[AWL=0.108] +X-Spam-Score: 0.108 +X-Spam-Level: +X-Archive-Number: 200602/428 +X-Sequence-Number: 79566 + +On 2/10/06, Ron wrote: +> Subject line says it all. I'm going to be testing changes under both +> Linux and WinXP, so I'm hoping those of you that do M$ hacking will +> pass along your list of suggestions and/or favorite (and hated so I +> know what to avoid) tools. + +If you mean hacking postgresql source code, you pretty much have to +use the built in make/build system...this more or less rules out IDEs +and such. + +I like UltraEdit for a text editor. Another good choice for editor is +source insight. Winmerge is a fantastic tool and you may want to +check out wincvs/tortoisesvn if you want to do checkouts from the gui. + +Of course, to make/build postgresql in windows, you can go with cygwin +or mingw. cygwin is a bit easier to set up and has a more of a unix +flavor but mignw allows you to compile native executables. + +The upcoming windows vista will most likely be able to compile +postgresql without an external build system. + +Merlin + +From pgsql-performance-owner@postgresql.org Fri Feb 10 21:46:18 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 8E9449DCDFD + for ; + Fri, 10 Feb 2006 21:46:14 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 54583-09-5 + for ; + Fri, 10 Feb 2006 21:46:17 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from uproxy.gmail.com (uproxy.gmail.com [66.249.92.206]) + by postgresql.org (Postfix) with ESMTP id 1CA6A9DCDD7 + for ; + Fri, 10 Feb 2006 21:46:10 -0400 (AST) +Received: by uproxy.gmail.com with SMTP id u2so152229uge + for ; + Fri, 10 Feb 2006 17:46:14 -0800 (PST) +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=KMbDxwMSs02SjdoGo7hohuPMULBSW3XlRTTEV1thjDSF2gnFZvk19ekgUpjUG5xoaVewVFboBxr7pGYE+8drd4jv58ZYMe+J0Fr65OtdnRRmi46e5vA9r21VWMyutjKv0kNrYPStxVNX3vxgN8Ty0QcDt/+xtVs5QSA4Pq5jAyc= +Received: by 10.67.19.7 with SMTP id w7mr17655ugi; + Fri, 10 Feb 2006 17:46:14 -0800 (PST) +Received: by 10.66.244.2 with HTTP; Fri, 10 Feb 2006 17:46:14 -0800 (PST) +Message-ID: +Date: Fri, 10 Feb 2006 20:46:14 -0500 +From: uwcssa +To: pgsql-performance@postgresql.org +Subject: postgresql geqo optimization +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_4352_574285.1139622374620" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=1.564 required=5 tests=[AWL=-0.714, HTML_10_20=0.945, + HTML_MESSAGE=0.001, RCVD_IN_BL_SPAMCOP_NET=1.332] +X-Spam-Score: 1.564 +X-Spam-Level: * +X-Archive-Number: 200602/127 +X-Sequence-Number: 17113 + +------=_Part_4352_574285.1139622374620 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +I have a question with regard to GEQO optimizer of Postgresql. + +For complex queries with over 12 tables in a join, (12 is the +default value), the Postgresql optimizer by default will not use the dynami= +c +programming style optimizer. Instead, it uses genetic algorithm to compute = +a +sub-optimal query plan. The reason is that GEQO takes sub-seconds to find = +a +query plan while the DP style optimizer will take minutes or even hours to +optimize a complex query with large join degree. + +I am wondering if anyone here ever had complex queries that the GEQO fails +to work properly, i.e., finds a terrible query plan as compared to one +found by DP optimizer (by forcing Postgresql always uses DP). This is +important to me since I am trying to see what type of queries will be worth +spending a lot of time doing a thorough DP optimization (if it is going to +be executed again and again). + +thanks a lot! + +------=_Part_4352_574285.1139622374620 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +
I have a question with regard to GEQO optimizer of Postgresql.
+
 
+
For complex queries with over 12 tables in a join, (12 is the
+
default value), the Postgresql optimizer by default will not use the d= +ynamic programming style optimizer. Instead, it uses genetic algorithm to c= +ompute a sub-optimal query plan.  The reason is that GEQO takes sub-se= +conds to find a query plan while the DP style optimizer will take minutes o= +r even hours to optimize a complex query with large join degree. +
+
 
+
I am wondering if anyone here ever had complex queries that the GEQO f= +ails to work properly, i.e.,  finds a terrible query plan as compared = +to one found by DP optimizer (by forcing Postgresql always uses DP). &= +nbsp;  This is important to me since I am trying to see what type of q= +ueries will be worth spending a lot of time doing a thorough DP optimizatio= +n (if it is going to be executed again and again). +
+
 
+
thanks a lot!
+ +------=_Part_4352_574285.1139622374620-- + +From pgsql-performance-owner@postgresql.org Fri Feb 10 21:54:07 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 028989DD807 + for ; + Fri, 10 Feb 2006 21:54:01 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 63973-01-5 + for ; + Fri, 10 Feb 2006 21:54:03 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from cassarossa.samfundet.no (cassarossa.samfundet.no + [129.241.93.19]) + by postgresql.org (Postfix) with ESMTP id 58FDE9DD940 + for ; + Fri, 10 Feb 2006 21:51:59 -0400 (AST) +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 1F7jve-0007J4-5F; Sat, 11 Feb 2006 02:52:02 +0100 +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1F7jvi-00057C-00; Sat, 11 Feb 2006 02:52:06 +0100 +Date: Sat, 11 Feb 2006 02:52:06 +0100 +From: "Steinar H. Gunderson" +To: uwcssa +Cc: pgsql-performance@postgresql.org +Subject: Re: postgresql geqo optimization +Message-ID: <20060211015206.GA19612@uio.no> +Mail-Followup-To: uwcssa , 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.14.3 on a x86_64 +X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ +User-Agent: Mutt/1.5.11 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.077 required=5 tests=[AWL=0.077] +X-Spam-Score: 0.077 +X-Spam-Level: +X-Archive-Number: 200602/128 +X-Sequence-Number: 17114 + +On Fri, Feb 10, 2006 at 08:46:14PM -0500, uwcssa wrote: +> I am wondering if anyone here ever had complex queries that the GEQO fails +> to work properly, i.e., finds a terrible query plan as compared to one +> found by DP optimizer (by forcing Postgresql always uses DP). This is +> important to me since I am trying to see what type of queries will be worth +> spending a lot of time doing a thorough DP optimization (if it is going to +> be executed again and again). + +There have been a few problems earlier on this list which might have been the +geqo's fault; search the list archives for "geqo" or "genetic", and you +should be able to find them quite easily. + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-hackers-owner@postgresql.org Fri Feb 10 21:58:07 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id A59089DCE26; + Fri, 10 Feb 2006 21:58:05 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 65426-03; Fri, 10 Feb 2006 21:58:08 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from linda-1.paradise.net.nz (bm-1a.paradise.net.nz + [203.96.152.180]) + by postgresql.org (Postfix) with ESMTP id 855E39DD446; + Fri, 10 Feb 2006 21:57:28 -0400 (AST) +Received: from smtp-3.paradise.net.nz + (tclsnelb1-src-1.paradise.net.nz [203.96.152.172]) by + linda-1.paradise.net.nz (Paradise.net.nz) with ESMTP id + <0IUI009YL2RV9V@linda-1.paradise.net.nz>; Sat, + 11 Feb 2006 14:57:31 +1300 (NZDT) +Received: from [192.168.1.11] + (218-101-29-237.dsl.clear.net.nz [218.101.29.237]) by + smtp-3.paradise.net.nz (Postfix) with ESMTP id EF9B668F587; + Sat, 11 Feb 2006 14:57:30 +1300 (NZDT) +Date: Sat, 11 Feb 2006 14:57:28 +1300 +From: Mark Kirkwood +Subject: Re: What do the Windows pg hackers out there like for dev +In-reply-to: <7.0.1.0.2.20060210141522.035d4940@earthlink.net> +To: Ron +Cc: pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Message-id: <43ED4488.80207@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/20051106) +References: <7.0.1.0.2.20060210141522.035d4940@earthlink.net> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.217 required=5 tests=[AWL=0.217] +X-Spam-Score: 0.217 +X-Spam-Level: +X-Archive-Number: 200602/429 +X-Sequence-Number: 79567 + +Ron wrote: +> Subject line says it all. I'm going to be testing changes under both +> Linux and WinXP, so I'm hoping those of you that do M$ hacking will pass +> along your list of suggestions and/or favorite (and hated so I know what +> to avoid) tools. +> + +Testing only? So you really only need to build and run on Windows... + +I was doing exactly this about a year ago and used Mingw. The only +annoyance was that I could compile everything on Linux in about 3 +minutes (P4 2.8Ghz), but had to wait about 60-90 minutes for the same +thing on Windows 2003 Server! (also a P4 2.8Ghz...). So I used to build +a 'go for coffee' task into the build and test cycle. + +Cheers + +Mark + +From pgsql-hackers-owner@postgresql.org Sat Feb 11 12:09:43 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 23FD29DC839 + for ; + Sat, 11 Feb 2006 12:09:42 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 46581-10 + for ; + Sat, 11 Feb 2006 12:09:39 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id AF34A9DC831 + for ; + Sat, 11 Feb 2006 12:09:38 -0400 (AST) +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 k1BG9Yhr008129; + Sat, 11 Feb 2006 11:09:34 -0500 (EST) +To: Mark Kirkwood +cc: pgsql-hackers@postgresql.org +Subject: Re: [PERFORM] What do the Windows pg hackers out there like for dev +In-reply-to: <43ED4488.80207@paradise.net.nz> +References: <7.0.1.0.2.20060210141522.035d4940@earthlink.net> + <43ED4488.80207@paradise.net.nz> +Comments: In-reply-to Mark Kirkwood + message dated "Sat, 11 Feb 2006 14:57:28 +1300" +Date: Sat, 11 Feb 2006 11:09:34 -0500 +Message-ID: <8128.1139674174@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.109 required=5 tests=[AWL=0.109] +X-Spam-Score: 0.109 +X-Spam-Level: +X-Archive-Number: 200602/438 +X-Sequence-Number: 79576 + +Mark Kirkwood writes: +> I was doing exactly this about a year ago and used Mingw. The only +> annoyance was that I could compile everything on Linux in about 3 +> minutes (P4 2.8Ghz), but had to wait about 60-90 minutes for the same +> thing on Windows 2003 Server! (also a P4 2.8Ghz...). So I used to build +> a 'go for coffee' task into the build and test cycle. + +Youch! That seems unbelievably bad, even for Microsloth. Did you ever +identify what was the bottleneck? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sat Feb 11 16:32:32 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 3DA6E9DC955 + for ; + Sat, 11 Feb 2006 16:32:31 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91162-08 + for ; + Sat, 11 Feb 2006 16:32:30 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id A38469DC941 + for ; + Sat, 11 Feb 2006 16:32:27 -0400 (AST) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 38B0739853; Sat, 11 Feb 2006 20:32:29 +0000 (UTC) +Received: (hashcash-sendmail, from uid 1001); Sat, 11 Feb 2006 14:32:28 -0600 +Date: Sat, 11 Feb 2006 14:32:28 -0600 +From: "Jim C. Nasby" +To: Jan Peterson +Cc: "Craig A. James" , + Nate Byrnes , pgsql-performance@postgresql.org +Subject: Re: Storing Digital Video +Message-ID: <20060211203228.GS57845@pervasive.com> +References: <3cf983d0601311632t4a2f068au1f958746c2b092a7@mail.gmail.com> + <200602060930.31144.albert@sedifa.com> <43EB475C.3040708@qabal.org> + <43EB5D59.1030207@modgraph-usa.com> + <20060209192621.GU57845@pervasive.com> + <72e966b00602091514p21332e7fw60fdec07c2ab56ef@mail.gmail.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <72e966b00602091514p21332e7fw60fdec07c2ab56ef@mail.gmail.com> +X-Operating-System: FreeBSD 6.0-RELEASE amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060211:jan.l.peterson@gmail.com::Qt8VEbM4F0cc0C3o:0000000000000 + 0000000000000000000000001Awx +X-Hashcash: + 1:20:060211:cjames@modgraph-usa.com::HX/RamFjt5aP7EcZ:00000000000000 + 000000000000000000000000194d +X-Hashcash: 1:20:060211:nate@qabal.org::QTcIokvzYxdbYiAo:0001cMD +X-Hashcash: + 1:20:060211:pgsql-performance@postgresql.org::Bm9yD4ABR9fVxCuV:00000 + 0000000000000000000000005t5R +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.104 required=5 tests=[AWL=0.104] +X-Spam-Score: 0.104 +X-Spam-Level: +X-Archive-Number: 200602/130 +X-Sequence-Number: 17116 + +On Thu, Feb 09, 2006 at 04:14:09PM -0700, Jan Peterson wrote: +> In my experience, you don't want to store this stuff in the database. +> In general, it will work fine, until you have to VACUUM the +> pg_largeobject table. Unless you have a very powerful I/O subsystem, +> this VACUUM will kill your performance. + +Good point about the vacuum issue; I haven't had to deal with vacuuming +very large objects. + +> > You're forgetting about cleanup and transactions. If you store outside +> > the database you either have to write some kind of garbage collector, or +> > you add a trigger to delete the file on disk when the row in the +> > database pointing at it is deleted and hope that the transaction doesn't +> > rollback. +> +> Our solution to this problem was to have a separate table of "external +> files to delete". When you want to delete a file, you just stuff an +> entry into this table. If your transaction rolls back, so does your +> insert into this table. You have a separate thread that periodically +> walks this table and zaps the files from the filesystem. + +Sure, there's lots of ways around it. My point was that there *is* a +tradeoff. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Sat Feb 11 17:25:10 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 17ADF9DC941 + for ; + Sat, 11 Feb 2006 17:25:10 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 14946-08 + for ; + Sat, 11 Feb 2006 17:25:10 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 464749DC95A + for ; + Sat, 11 Feb 2006 17:25:07 -0400 (AST) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 1D4D439840; Sat, 11 Feb 2006 21:24:54 +0000 (UTC) +Received: (hashcash-sendmail, from uid 1001); Sat, 11 Feb 2006 15:24:53 -0600 +Date: Sat, 11 Feb 2006 15:24:53 -0600 +From: "Jim C. Nasby" +To: Aaron Turner +Cc: "Matthew T. O'Connor" , pgsql-performance@postgresql.org +Subject: Re: 10+hrs vs 15min because of just one index +Message-ID: <20060211212453.GT57845@pervasive.com> +References: <1ca1c1410602100016p2b5fdcc4wbf45612d7efc5fdf@mail.gmail.com> + <43ECC9BF.2030107@zeut.net> + <1ca1c1410602100924s191e7cddo4bda80d8f8d7cb6d@mail.gmail.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1ca1c1410602100924s191e7cddo4bda80d8f8d7cb6d@mail.gmail.com> +X-Operating-System: FreeBSD 6.0-RELEASE amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060211:synfinatic@gmail.com::UCJOtsbjKwbHjCi8:00000000000000000 + 00000000000000000000000064RB +X-Hashcash: 1:20:060211:matthew@zeut.net::68sdpmRnkM8n0QEj:00tpL +X-Hashcash: + 1:20:060211:pgsql-performance@postgresql.org::BjYLDtovlDTdVEe+:00000 + 0000000000000000000000000N2/ +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.104 required=5 tests=[AWL=0.104] +X-Spam-Score: 0.104 +X-Spam-Level: +X-Archive-Number: 200602/131 +X-Sequence-Number: 17117 + +On Fri, Feb 10, 2006 at 09:24:39AM -0800, Aaron Turner wrote: +> On 2/10/06, Matthew T. O'Connor wrote: +> > Aaron Turner wrote: +> > > So I'm trying to figure out how to optimize my PG install (8.0.3) to +> > > get better performance without dropping one of my indexes. +> > +> > What about something like this: +> > +> > begin; +> > drop slow_index_name; +> > update; +> > create index slow_index_name; +> > commit; +> > vacuum; +> +> Right. That's exactly what I'm doing to get the update to occur in 15 +> minutes. Unfortunately though, I'm basically at the point of every +> time I insert/update into that table I have to drop the index which is +> making my life very painful (having to de-dupe records in RAM in my +> application is a lot faster but also more complicated/error prone). +> +> Basically, I need some way to optimize PG so that I don't have to drop +> that index every time. +> +> Suggestions? + +I think you'll have a tough time making this faster; or I'm just not +understanding the problem well enough. It's probably time to start +thinking about re-architecting some things in the application so that +you don't have to do this. +-- +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 Sun Feb 12 00:08:18 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 2D1879DC9EA + for ; + Sun, 12 Feb 2006 00:08:18 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 01312-04 + for ; + Sun, 12 Feb 2006 00:08:16 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from linda-3.paradise.net.nz (bm-3a.paradise.net.nz + [203.96.152.182]) + by postgresql.org (Postfix) with ESMTP id 111EA9DC9D3 + for ; + Sun, 12 Feb 2006 00:08:15 -0400 (AST) +Received: from smtp-3.paradise.net.nz + (tclsnelb1-src-1.paradise.net.nz [203.96.152.172]) by + linda-3.paradise.net.nz (Paradise.net.nz) with ESMTP id + <0IUK001KP3EQT8@linda-3.paradise.net.nz> for + pgsql-hackers@postgresql.org; Sun, 12 Feb 2006 17:06:26 +1300 (NZDT) +Received: from [192.168.1.11] + (218-101-29-196.dsl.clear.net.nz [218.101.29.196]) by + smtp-3.paradise.net.nz (Postfix) with ESMTP id 42FB5966443; + Sun, 12 Feb 2006 17:06:25 +1300 (NZDT) +Date: Sun, 12 Feb 2006 17:06:22 +1300 +From: Mark Kirkwood +Subject: Re: [PERFORM] What do the Windows pg hackers out there like +In-reply-to: <8128.1139674174@sss.pgh.pa.us> +To: Tom Lane +Cc: pgsql-hackers@postgresql.org +Message-id: <43EEB43E.2090304@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/20051106) +References: <7.0.1.0.2.20060210141522.035d4940@earthlink.net> + <43ED4488.80207@paradise.net.nz> <8128.1139674174@sss.pgh.pa.us> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.215 required=5 tests=[AWL=0.215] +X-Spam-Score: 0.215 +X-Spam-Level: +X-Archive-Number: 200602/475 +X-Sequence-Number: 79613 + +Tom Lane wrote: +> Mark Kirkwood writes: +> +>>I was doing exactly this about a year ago and used Mingw. The only +>>annoyance was that I could compile everything on Linux in about 3 +>>minutes (P4 2.8Ghz), but had to wait about 60-90 minutes for the same +>>thing on Windows 2003 Server! (also a P4 2.8Ghz...). So I used to build +>>a 'go for coffee' task into the build and test cycle. +> +> +> Youch! That seems unbelievably bad, even for Microsloth. Did you ever +> identify what was the bottleneck? +> + +No - I was connecting using an RDB client from a Linux box (over a LAN), +so was never sure how much that was hurting things... but (as noted by +Magnus) the compiler itself is noticeablely slower (easily observed +during the 'configure' step). + +cheers + +Mark + +From pgsql-performance-owner@postgresql.org Sun Feb 12 03:58:52 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 0BBF29DCA8D + for ; + Sun, 12 Feb 2006 03:58:52 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 42724-01 + for ; + Sun, 12 Feb 2006 03:58:50 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from uproxy.gmail.com (uproxy.gmail.com [66.249.92.197]) + by postgresql.org (Postfix) with ESMTP id 46D809DC8E0 + for ; + Sun, 12 Feb 2006 03:58:48 -0400 (AST) +Received: by uproxy.gmail.com with SMTP id y2so338784uge + for ; + Sat, 11 Feb 2006 23:58:48 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=uouoTkWpCx+vFVc0iopcfWfGg5uKByaGIL+GUwsIs4UkZa8Minxn8MFVShQYCuQ+fRqCCwE39Gaj5DPyd84IjucGNVWsN1XEdoaR3HiYPi0ldf25/BWFLSaql13fX+6pdFmJncqxWCOu2nNVCjEekD7gTZKJs6isHDbUC+jfTUg= +Received: by 10.66.186.4 with SMTP id j4mr449875ugf; + Sat, 11 Feb 2006 23:58:48 -0800 (PST) +Received: by 10.66.221.12 with HTTP; Sat, 11 Feb 2006 23:58:48 -0800 (PST) +Message-ID: <1ca1c1410602112358h1e0e9696lff8f172769dc587e@mail.gmail.com> +Date: Sat, 11 Feb 2006 23:58:48 -0800 +From: Aaron Turner +To: "Jim C. Nasby" +Subject: Re: 10+hrs vs 15min because of just one index +Cc: "Matthew T. O'Connor" , pgsql-performance@postgresql.org +In-Reply-To: <20060211212453.GT57845@pervasive.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <1ca1c1410602100016p2b5fdcc4wbf45612d7efc5fdf@mail.gmail.com> + <43ECC9BF.2030107@zeut.net> + <1ca1c1410602100924s191e7cddo4bda80d8f8d7cb6d@mail.gmail.com> + <20060211212453.GT57845@pervasive.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.786 required=5 tests=[AWL=-0.546, + RCVD_IN_BL_SPAMCOP_NET=1.332] +X-Spam-Score: 0.786 +X-Spam-Level: +X-Archive-Number: 200602/132 +X-Sequence-Number: 17118 + +On 2/11/06, Jim C. Nasby wrote: +> On Fri, Feb 10, 2006 at 09:24:39AM -0800, Aaron Turner wrote: +> > On 2/10/06, Matthew T. O'Connor wrote: +> > > Aaron Turner wrote: +> > +> > Basically, I need some way to optimize PG so that I don't have to drop +> > that index every time. +> > +> > Suggestions? +> +> I think you'll have a tough time making this faster; or I'm just not +> understanding the problem well enough. It's probably time to start +> thinking about re-architecting some things in the application so that +> you don't have to do this. + +Well before I go about re-architecting things, it would be good to +have a strong understanding of just what is going on. Obviously, the +unique index on the char(48) is the killer. What I don't know is: + +1) Is this because the column is so long? +2) Is this because PG is not optimized for char(48) (maybe it wants +powers of 2? or doesn't like even numbers... I don't know, just +throwing it out there) +3) Is there some algorithm I can use to estimate relative UPDATE +speed? Ie, if I cut the column length in 1/2 does that make it 50% +faster? +4) Does decoding the data (currently base64) and storing the binary +data improve the distribution of the index, thereby masking it more +efficent? + +Obviously, one solution would be to store the column to be UPDATED in +a seperate joined table. That would cost more disk space, and be more +complex, but it would be more efficient for updates (inserts would of +course be more expensive since now I have to do two). + +-- +Aaron Turner +http://synfin.net/ + +From pgsql-performance-owner@postgresql.org Sun Feb 12 11:54:36 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 9852A9DC886 + for ; + Sun, 12 Feb 2006 11:54:35 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 35123-02 + for ; + Sun, 12 Feb 2006 11:54:40 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 52BD49DC839 + for ; + Sun, 12 Feb 2006 11:54:33 -0400 (AST) +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 k1CFsYli016810; + Sun, 12 Feb 2006 10:54:34 -0500 (EST) +To: Aaron Turner +cc: "Jim C. Nasby" , + "Matthew T. O'Connor" , pgsql-performance@postgresql.org +Subject: Re: 10+hrs vs 15min because of just one index +In-reply-to: <1ca1c1410602112358h1e0e9696lff8f172769dc587e@mail.gmail.com> +References: <1ca1c1410602100016p2b5fdcc4wbf45612d7efc5fdf@mail.gmail.com> + <43ECC9BF.2030107@zeut.net> + <1ca1c1410602100924s191e7cddo4bda80d8f8d7cb6d@mail.gmail.com> + <20060211212453.GT57845@pervasive.com> + <1ca1c1410602112358h1e0e9696lff8f172769dc587e@mail.gmail.com> +Comments: In-reply-to Aaron Turner + message dated "Sat, 11 Feb 2006 23:58:48 -0800" +Date: Sun, 12 Feb 2006 10:54:34 -0500 +Message-ID: <16809.1139759674@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.109 required=5 tests=[AWL=0.109] +X-Spam-Score: 0.109 +X-Spam-Level: +X-Archive-Number: 200602/133 +X-Sequence-Number: 17119 + +Aaron Turner writes: +> Well before I go about re-architecting things, it would be good to +> have a strong understanding of just what is going on. Obviously, the +> unique index on the char(48) is the killer. What I don't know is: + +You have another unique index on the integer primary key, so it's not +the mere fact of a unique index that's hurting you. + +> 1) Is this because the column is so long? + +Possibly. Allowing for 12 bytes index-entry overhead, the char keys +would be 60 bytes vs 16 for the integer column, so this index is +physically almost 4x larger than the other. You might say "but that +should only cause 4x more I/O" but it's not necessarily so. What's +hard to tell is whether you are running out of RAM disk cache space, +resulting in re-reads of pages that could have stayed in memory when +dealing with one-fifth as much index data. You did not show us the +iostat numbers for the two cases, but it'd be interesting to look at +the proportion of writes to reads on the data drive in both cases. + +> 2) Is this because PG is not optimized for char(48) (maybe it wants +> powers of 2? or doesn't like even numbers... I don't know, just +> throwing it out there) + +Are the key values really all 48 chars long? If not, you made a +bad datatype choice: varchar(n) (or even text) would be a lot +smarter. char(n) wastes space on blank-padding. + +Another thing to think about is whether this is C locale or not. +String comparisons in non-C locales can be horrendously expensive +... though I'd expect that to cost CPU not I/O. (Hmm ... is it +possible your libc is hitting locale config files constantly? +Might be worth strace'ing to confirm exactly where the I/O is +going.) + +> 4) Does decoding the data (currently base64) and storing the binary +> data improve the distribution of the index, thereby masking it more +> efficent? + +No, but it'd reduce the size of the index, which you certainly want. +Storing as bytea would also eliminate any questions about wasteful +locale-dependent comparisons. + +The only one of these effects that looks to me like it could result in +worse-than-linear degradation of I/O demand is maxing out the available +RAM for disk cache. So while improving the datatype choice would +probably be worth your while, you should first see if fooling with +shared_buffers helps, and if not it's time to buy RAM not disk. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Feb 12 13:38:52 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id D80199DC836 + for ; + Sun, 12 Feb 2006 13:38:51 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 70376-08 + for ; + Sun, 12 Feb 2006 13:38:48 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mailserver.sandvine.com (sandvine.com [199.243.201.138]) + by postgresql.org (Postfix) with ESMTP id 5A4C89DC835 + for ; + Sun, 12 Feb 2006 13:38:46 -0400 (AST) +X-MimeOLE: Produced By Microsoft Exchange V6.5 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: 10+hrs vs 15min because of just one index +Date: Sun, 12 Feb 2006 12:37:13 -0500 +Message-ID: <2BCEB9A37A4D354AA276774EE13FB8C2BCC338@mailserver.sandvine.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] 10+hrs vs 15min because of just one index +Thread-Index: AcYuGi1h+785T92XQWaXH42+LoIHBAB2V/1w +From: "Marc Morin" +To: "Aaron Turner" , +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200602/134 +X-Sequence-Number: 17120 + +We've done a lot of testing on large DB's with a lot of "inserts" and +have a few comments. + +The updates are "treated" as a large "insert" as we all know from pg's +point of view. + +We've run into 2 classes of problems: excessing WAL checkpoints and +affects of low correlation. + +WAL log write's full 8K block for first modification, then only changes. +This can be the source of "undesireable" behaviour during large batch +inserts like this. =20 + + From your config, a check point will be forced when + +(checkpoint_segments * 16 M) < rows * (8K/N*h + (1-h)*8K) * B + +Where h is the "hitrate" or correlation between the update scan and the +index. Do you have a sense of what this is? In the limits, we have 100% +correlation or 0% correlation. N is the lower cost of putting the +change in the WAL entry, not sure what this is, but small, I am +assuming, say N=3D100. B is the average number of blocks changed per +updated row (assume B=3D1.1 for your case, heap,serial index have very +high correlation) + +In the 0% correlation case, each updated row will cause the index update +to read/modify the block. The modified block will be entirely written to +the WAL log. After (30 * 16M) / (8K) / 1.1 ~ 55k rows, a checkpoint +will be forced and all modified blocks in shared buffers will be written +out. + +Increasing checkpoint_segments to 300 and seeing if that makes a +difference. If so, the excessive WAL checkpoints are your issue. If +performance is exactly the same, then I would assume that you have close +to 0% correlation between the rows in the heap and index. + +Can you increase shared_buffers? With a low correlation index, the only +solution is to hold the working set of blocks in memory. Also, make +sure that the checkpoint segments are big enough for you to modify them +in place, don't want checkpoints occurring.... + +Note that the more updates you do, the larger the tables/index become +and the worse the problem becomes. Vacuuming the table is an "answer" +but unfortunately, it tends to decrease correlation from our +observations. :-( + + From our observations, dropping index and rebuilding them is not always +practical, depends on your application; table will be exclusively locked +during the transaction due to drop index.=20 + +I haven't looked at pg's code for creating an index, but seriously +suspect it's doing an extern sort then insert into the index. Such +operations would have 100% correlation from the index insert point of +view and the "sort" could be in memory or the tape variety (more +efficient i/o pattern). + +Summary, # of indexes, index correlation, pg's multi versioning, +shared_buffers and checkpoint_segments are interconnected in weird and +wonderful ways... Seldom have found "simple" solutions to performance +problems. + +Marc + + +> -----Original Message----- +> From: pgsql-performance-owner@postgresql.org=20 +> [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of=20 +> Aaron Turner +> Sent: Friday, February 10, 2006 3:17 AM +> To: pgsql-performance@postgresql.org +> Subject: [PERFORM] 10+hrs vs 15min because of just one index +>=20 +> So I'm trying to figure out how to optimize my PG install=20 +> (8.0.3) to get better performance without dropping one of my indexes. +>=20 +> Basically, I have a table of 5M records with 3 columns: +>=20 +> pri_key (SERIAL) +> data char(48) +> groupid integer +>=20 +> there is an additional unique index on the data column. +>=20 +> The problem is that when I update the groupid column for all=20 +> the records, the query takes over 10hrs (after that I just=20 +> canceled the update). Looking at iostat, top, vmstat shows=20 +> I'm horribly disk IO bound (for data not WAL, CPU 85-90%=20 +> iowait) and not swapping. +>=20 +> Dropping the unique index on data (which isn't used in the=20 +> query), running the update and recreating the index runs in=20 +> under 15 min.=20 +> Hence it's pretty clear to me that the index is the problem=20 +> and there's really nothing worth optimizing in my query. +>=20 +> As I understand from #postgresql, doing an UPDATE on one=20 +> column causes all indexes for the effected row to have to be=20 +> updated due to the way PG replaces the old row with a new one=20 +> for updates. This seems to explain why dropping the unique=20 +> index on data solves the performance problem. +>=20 +> interesting settings: +> shared_buffers =3D 32768 +> maintenance_work_mem =3D 262144 +> fsync =3D true +> wal_sync_method =3D open_sync +> wal_buffers =3D 512 +> checkpoint_segments =3D 30 +> effective_cache_size =3D 10000 +> work_mem =3D (1024 i think?) +>=20 +> box: +> Linux 2.6.9-11EL (CentOS 4.1) +> 2x Xeon 3.4 HT +> 2GB of RAM (but Apache and other services are running) +> 4 disk raid 10 (74G Raptor) for data +> 4 disk raid 10 (7200rpm) for WAL +>=20 +> other then throwing more spindles at the problem, any suggestions? +>=20 +> Thanks, +> Aaron +>=20 +> -- +> Aaron Turner +> http://synfin.net/ +>=20 +> ---------------------------(end of=20 +> broadcast)--------------------------- +> TIP 5: don't forget to increase your free space map settings +>=20 + +From pgsql-performance-owner@postgresql.org Sun Feb 12 15:04:43 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 195459DC814 + for ; + Sun, 12 Feb 2006 15:04:43 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 87714-07 + for ; + Sun, 12 Feb 2006 15:04:40 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from uproxy.gmail.com (uproxy.gmail.com [66.249.92.204]) + by postgresql.org (Postfix) with ESMTP id 827BC9DC9CD + for ; + Sun, 12 Feb 2006 15:04:37 -0400 (AST) +Received: by uproxy.gmail.com with SMTP id h2so412830ugf + for ; + Sun, 12 Feb 2006 11:04:37 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=TBHvktDQ1xoO9X5UJsUhXelYQiO82nVIWSHvf1iQJY5C0Hxm5KNDwitK3Lkm0WBSfBGfZ1L8jQwosQOh3NpoCSexgIZ3U0lpNbXGgFgGv7ENGCLdklCyT2XcJcJnNahSCF9Bp9v13x0nGsS4BbNNqF0c693iVpX2zgcR95kn4XY= +Received: by 10.66.219.10 with SMTP id r10mr676312ugg; + Sun, 12 Feb 2006 11:04:37 -0800 (PST) +Received: by 10.66.221.12 with HTTP; Sun, 12 Feb 2006 11:04:37 -0800 (PST) +Message-ID: <1ca1c1410602121104p2c231d77u883871d7e2bddbfa@mail.gmail.com> +Date: Sun, 12 Feb 2006 11:04:37 -0800 +From: Aaron Turner +To: Marc Morin +Subject: Re: 10+hrs vs 15min because of just one index +Cc: pgsql-performance@postgresql.org +In-Reply-To: <2BCEB9A37A4D354AA276774EE13FB8C2BCC338@mailserver.sandvine.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <2BCEB9A37A4D354AA276774EE13FB8C2BCC338@mailserver.sandvine.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.286 required=5 tests=[AWL=0.286] +X-Spam-Score: 0.286 +X-Spam-Level: +X-Archive-Number: 200602/135 +X-Sequence-Number: 17121 + +On 2/12/06, Marc Morin wrote: +> From your config, a check point will be forced when +> +> (checkpoint_segments * 16 M) < rows * (8K/N*h + (1-h)*8K) * B +> +> Where h is the "hitrate" or correlation between the update scan and the +> index. Do you have a sense of what this is? + +I know my checkpoints happen > 30 secs apart, since PG isn't +complaining in my log. I have no clue what the correlation is. + +> In the limits, we have 100% +> correlation or 0% correlation. N is the lower cost of putting the +> change in the WAL entry, not sure what this is, but small, I am +> assuming, say N=3D100. B is the average number of blocks changed per +> updated row (assume B=3D1.1 for your case, heap,serial index have very +> high correlation) +> +> In the 0% correlation case, each updated row will cause the index update +> to read/modify the block. The modified block will be entirely written to +> the WAL log. After (30 * 16M) / (8K) / 1.1 ~ 55k rows, a checkpoint +> will be forced and all modified blocks in shared buffers will be written +> out. +> +> Increasing checkpoint_segments to 300 and seeing if that makes a +> difference. If so, the excessive WAL checkpoints are your issue. If +> performance is exactly the same, then I would assume that you have close +> to 0% correlation between the rows in the heap and index. + +Ok, i'll have to give that a try. + +> Can you increase shared_buffers? With a low correlation index, the only +> solution is to hold the working set of blocks in memory. Also, make +> sure that the checkpoint segments are big enough for you to modify them +> in place, don't want checkpoints occurring.... + +I'll have to look at my memory usage on this server... with only 2GB +and a bunch of other processes running around I'm not sure if I can go +up much more without causing swapping. Of course RAM is cheap... + +> Note that the more updates you do, the larger the tables/index become +> and the worse the problem becomes. Vacuuming the table is an "answer" +> but unfortunately, it tends to decrease correlation from our +> observations. :-( + +Good to know. + +> From our observations, dropping index and rebuilding them is not always +> practical, depends on your application; table will be exclusively locked +> during the transaction due to drop index. + +Yep. In my case it's not a huge problem right now, but I know it will +become a serious one sooner or later. + +Thanks a lot Marc. Lots of useful info. + +-- +Aaron Turner +http://synfin.net/ + +From pgsql-performance-owner@postgresql.org Sun Feb 12 15:34:04 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 760A19DC814 + for ; + Sun, 12 Feb 2006 15:34:03 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 97557-09 + for ; + Sun, 12 Feb 2006 15:34:01 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from uproxy.gmail.com (uproxy.gmail.com [66.249.92.196]) + by postgresql.org (Postfix) with ESMTP id E99BE9DC84D + for ; + Sun, 12 Feb 2006 15:33:57 -0400 (AST) +Received: by uproxy.gmail.com with SMTP id u2so412128uge + for ; + Sun, 12 Feb 2006 11:33:58 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=nCfj97yiw9frUugSfNG3sv3gr789araCkD+t3hq+VKdJmXeMR1Dne0VkqEwPgWcW6PuPqkqhqqkvULAvEs5MTPFQmgsYTitK6bG2MR2iW53/7xlFYLa0RgAIdx/Mtj9fh6TQezhj0JLXmiG83b9uaMt54kXamADNXlV3CMV33fU= +Received: by 10.67.30.9 with SMTP id h9mr695963ugj; + Sun, 12 Feb 2006 11:33:57 -0800 (PST) +Received: by 10.66.221.12 with HTTP; Sun, 12 Feb 2006 11:33:57 -0800 (PST) +Message-ID: <1ca1c1410602121133y279ea488nc38f049ac6ebc7f4@mail.gmail.com> +Date: Sun, 12 Feb 2006 11:33:57 -0800 +From: Aaron Turner +To: Tom Lane +Subject: Re: 10+hrs vs 15min because of just one index +Cc: "Jim C. Nasby" , + "Matthew T. O'Connor" , pgsql-performance@postgresql.org +In-Reply-To: <16809.1139759674@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: <1ca1c1410602100016p2b5fdcc4wbf45612d7efc5fdf@mail.gmail.com> + <43ECC9BF.2030107@zeut.net> + <1ca1c1410602100924s191e7cddo4bda80d8f8d7cb6d@mail.gmail.com> + <20060211212453.GT57845@pervasive.com> + <1ca1c1410602112358h1e0e9696lff8f172769dc587e@mail.gmail.com> + <16809.1139759674@sss.pgh.pa.us> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.253 required=5 tests=[AWL=0.253] +X-Spam-Score: 0.253 +X-Spam-Level: +X-Archive-Number: 200602/136 +X-Sequence-Number: 17122 + +On 2/12/06, Tom Lane wrote: +> Aaron Turner writes: +> > Well before I go about re-architecting things, it would be good to +> > have a strong understanding of just what is going on. Obviously, the +> > unique index on the char(48) is the killer. What I don't know is: +> +> You have another unique index on the integer primary key, so it's not +> the mere fact of a unique index that's hurting you. + +Understood. I just wasn't sure if in general unique indexes are some +how more expensive then non-unique indexes. + +> > 1) Is this because the column is so long? +> +> Possibly. Allowing for 12 bytes index-entry overhead, the char keys +> would be 60 bytes vs 16 for the integer column, so this index is +> physically almost 4x larger than the other. You might say "but that +> should only cause 4x more I/O" but it's not necessarily so. What's +> hard to tell is whether you are running out of RAM disk cache space, +> resulting in re-reads of pages that could have stayed in memory when +> dealing with one-fifth as much index data. You did not show us the +> iostat numbers for the two cases, but it'd be interesting to look at +> the proportion of writes to reads on the data drive in both cases. + +Sounds a lot like what Marc mentioned. + +> > 2) Is this because PG is not optimized for char(48) (maybe it wants +> > powers of 2? or doesn't like even numbers... I don't know, just +> > throwing it out there) +> +> Are the key values really all 48 chars long? If not, you made a +> bad datatype choice: varchar(n) (or even text) would be a lot +> smarter. char(n) wastes space on blank-padding. + +Yep, everything exactly 48. Looks like I'll be storing it as a bytea +in the near future though. + +> The only one of these effects that looks to me like it could result in +> worse-than-linear degradation of I/O demand is maxing out the available +> RAM for disk cache. So while improving the datatype choice would +> probably be worth your while, you should first see if fooling with +> shared_buffers helps, and if not it's time to buy RAM not disk. + +Yeah, that's what it's beginning to sound like. Thanks Tom. + +-- +Aaron Turner +http://synfin.net/ + +From pgsql-performance-owner@postgresql.org Sun Feb 12 16:25:59 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 018019DC81D + for ; + Sun, 12 Feb 2006 16:25:57 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 06748-07 + for ; + Sun, 12 Feb 2006 16:25:58 -0400 (AST) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 322819DC814 + for ; + Sun, 12 Feb 2006 16:25:55 -0400 (AST) +Received: from hotmail.com (bay106-dav7.bay106.hotmail.com [65.54.161.79]) + by svr4.postgresql.org (Postfix) with ESMTP id 3586E5AF854 + for ; + Sun, 12 Feb 2006 20:25:56 +0000 (GMT) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Sun, 12 Feb 2006 12:25:54 -0800 +Message-ID: +Received: from 85.105.24.123 by BAY106-DAV7.phx.gbl with DAV; + Sun, 12 Feb 2006 20:25:54 +0000 +X-Originating-IP: [85.105.24.123] +X-Originating-Email: [a_dursun@hotmail.com] +X-Sender: a_dursun@hotmail.com +From: "Adnan DURSUN" +To: +Subject: SQL Function Performance +Date: Sun, 12 Feb 2006 22:25:28 +0200 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0006_01C63023.3A17E170" +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-OriginalArrivalTime: 12 Feb 2006 20:25:54.0368 (UTC) + FILETIME=[86149C00:01C63012] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=3.23 required=5 tests=[AWL=0.593, + DNS_FROM_RFC_ABUSE=0.479, DNS_FROM_RFC_POST=1.44, HTML_MESSAGE=0.001, + HTML_TAG_EXIST_TBODY=0.126, MSGID_FROM_MTA_HEADER=0, + UPPERCASE_50_75=0.591] +X-Spam-Score: 3.23 +X-Spam-Level: *** +X-Archive-Number: 200602/137 +X-Sequence-Number: 17123 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0006_01C63023.3A17E170 +Content-Type: text/plain; + charset="iso-8859-9" +Content-Transfer-Encoding: quoted-printable + + =20 + =20 + Hi all, + + My database has an SQL function. The result comes in = +30-40 seconds when i use the SQL function. On the other hand; The result = +comes + 300-400 milliseconds when i run the SQL statement. Any = +idea ?? My database is Postgresql 8.1.2.. + =20 + Function is below : + + CREATE OR REPLACE FUNCTION fn_online_seferler_satis("varchar", = +date, int4, "varchar", "varchar") + RETURNS SETOF record AS + $BODY$ + SELECT (S.KALKIS_YERI||' '||S.VARIS_YERI||' '||S.SAAT)::varchar = +AS SEFER_BILGI, + sum((i.bilet_ucreti + coalesce(i.police_ucreti,0)) - = +coalesce(i.int_artik_ucret,0)) as top_satis, + count(1)::int4 as top_koltuk + FROM T_KOLTUK_ISLEM I, + T_KOLTUK_SON_DURUM SD, + T_LOKAL_PLAN LP, + W_SEFERLER S + WHERE I.FIRMA_NO =3D SD.FIRMA_NO + AND I.HAT_NO =3D SD.HAT_NO + AND I.SEFER_KOD =3D SD.SEFER_KOD + AND I.PLAN_TARIHI =3D SD.PLAN_TARIHI + AND I.BIN_YER_KOD =3D SD.BIN_YER_KOD + AND I.KOLTUK_NO =3D SD.KOLTUK_NO + AND I.KOD =3D SD.ISLEM_KOD + AND SD.ISLEM =3D 'S' + AND LP.FIRMA_NO =3D I.FIRMA_NO + AND LP.HAT_NO =3D I.HAT_NO + AND LP.SEFER_KOD =3D I.SEFER_KOD + AND LP.PLAN_TARIHI =3D I.PLAN_TARIHI + AND LP.YER_KOD =3D I.BIN_YER_KOD + AND I.FIRMA_NO =3D $1 + AND S.FIRMA_NO =3D LP.FIRMA_NO=20 + AND S.HAT_NO =3D LP.HAT_NO + AND S.KOD =3D LP.SEFER_KOD + AND S.IPTAL =3D 'H' + AND ((I.ISLEM_TARIHI =3D $2 AND $5 =3D 'I') OR = +(LP.KALKIS_TARIHI =3D $2 AND $5 =3D 'K')) + AND (((LP.LOKAL_KOD =3D $3 AND $4 =3D 'K')) OR = +((I.ypt_lcl_kod =3D $3 AND $4 =3D 'I')))=20 + GROUP BY S.KALKIS_YERI,S.VARIS_YERI,S.SAAT; + $BODY$ + LANGUAGE 'sql' VOLATILE; + + Adnan DURSUN + ASRIN Bili=FEim Ltd.=DEti + Turkey + =20 + =20 + =20 + +------=_NextPart_000_0006_01C63023.3A17E170 +Content-Type: text/html; + charset="iso-8859-9" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
+ + + + + + + +
+ + + +
+
 
+
            Hi=20 +all,
+
 
+
            My=20 + database has an SQL function. The result comes in 30-40 = +seconds=20 + when i use the SQL function. On the other hand; The result = +comes
+
        300-400 milliseconds = +when=20 + i run the SQL statement. Any idea ?? My database is = +Postgresql=20 + 8.1.2..
+
       
+
            = +Function is=20 + below :
+
 
+
CREATE OR REPLACE FUNCTION = +fn_online_seferler_satis("varchar", date,=20 + int4, "varchar", "varchar")
  RETURNS SETOF record=20 + AS
$BODY$
SELECT  (S.KALKIS_YERI||' '||S.VARIS_YERI||'=20 + '||S.SAAT)::varchar AS SEFER_BILGI,
 sum((i.bilet_ucreti + = + + coalesce(i.police_ucreti,0)) - coalesce(i.int_artik_ucret,0)) as=20 + top_satis,
 count(1)::int4 as top_koltuk
   = +FROM=20 + T_KOLTUK_ISLEM I,
 T_KOLTUK_SON_DURUM = +SD,
 T_LOKAL_PLAN=20 + LP,
 W_SEFERLER S
  WHERE I.FIRMA_NO =3D=20 + SD.FIRMA_NO
    AND I.HAT_NO =3D=20 + SD.HAT_NO
    AND I.SEFER_KOD =3D=20 + SD.SEFER_KOD
    AND I.PLAN_TARIHI =3D=20 + SD.PLAN_TARIHI
    AND I.BIN_YER_KOD =3D=20 + SD.BIN_YER_KOD
    AND I.KOLTUK_NO =3D=20 + SD.KOLTUK_NO
    AND I.KOD =3D=20 + SD.ISLEM_KOD
    AND SD.ISLEM =3D=20 + 'S'
    AND LP.FIRMA_NO =3D=20 + I.FIRMA_NO
    AND LP.HAT_NO =3D=20 + I.HAT_NO
    AND LP.SEFER_KOD =3D=20 + I.SEFER_KOD
    AND LP.PLAN_TARIHI =3D=20 + I.PLAN_TARIHI
    AND LP.YER_KOD =3D=20 + I.BIN_YER_KOD
    AND I.FIRMA_NO =3D=20 + $1
    AND S.FIRMA_NO =3D LP.FIRMA_NO=20 +
    AND S.HAT_NO =3D = +LP.HAT_NO
    AND=20 + S.KOD =3D LP.SEFER_KOD
    AND S.IPTAL =3D=20 + 'H'
    AND ((I.ISLEM_TARIHI =3D  $2 AND $5 = +=3D 'I') OR=20 + (LP.KALKIS_TARIHI =3D $2 AND $5 =3D 'K'))
    = +AND=20 + (((LP.LOKAL_KOD =3D $3 AND $4 =3D 'K')) OR  ((I.ypt_lcl_kod = +=3D $3 AND $4 =3D=20 + 'I'))) 
GROUP BY S.KALKIS_YERI,S.VARIS_YERI,S.SAAT;
+
$BODY$
  LANGUAGE 'sql' VOLATILE;
+
 
+
Adnan DURSUN
+
ASRIN Bili=FEim Ltd.=DEti
+
Turkey
+
 
+ + + + + +
= + + +------=_NextPart_000_0006_01C63023.3A17E170-- + +From pgsql-performance-owner@postgresql.org Sun Feb 12 22:28:09 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id A60049DCA52 + for ; + Sun, 12 Feb 2006 22:28:08 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 86254-07 + for ; + Sun, 12 Feb 2006 22:28:10 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.logix-tt.com (serval.logix-tt.com [213.239.221.42]) + by postgresql.org (Postfix) with ESMTP id 648F59DC9FC + for ; + Sun, 12 Feb 2006 22:28:04 -0400 (AST) +Received: from kingfisher.intern.logix-tt.com (Mdf2d.m.pppool.de + [89.49.223.45]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logix-tt.com (Postfix) with ESMTP id BF44324407F; + Mon, 13 Feb 2006 03:28:08 +0100 (CET) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id 4800A184B3AD8; + Sun, 12 Feb 2006 22:04:18 +0100 (CET) +Message-ID: <43EFA2D2.1050609@logix-tt.com> +Date: Sun, 12 Feb 2006 22:04:18 +0100 +From: Markus Schaber +Organization: Logical Tracking and Tracing International AG, Switzerland +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Aaron Turner +Cc: "Jim C. Nasby" , + "Matthew T. O'Connor" , pgsql-performance@postgresql.org +Subject: Re: 10+hrs vs 15min because of just one index +References: <1ca1c1410602100016p2b5fdcc4wbf45612d7efc5fdf@mail.gmail.com> + <43ECC9BF.2030107@zeut.net> + <1ca1c1410602100924s191e7cddo4bda80d8f8d7cb6d@mail.gmail.com> + <20060211212453.GT57845@pervasive.com> + <1ca1c1410602112358h1e0e9696lff8f172769dc587e@mail.gmail.com> +In-Reply-To: <1ca1c1410602112358h1e0e9696lff8f172769dc587e@mail.gmail.com> +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.121 required=5 tests=[AWL=0.121] +X-Spam-Score: 0.121 +X-Spam-Level: +X-Archive-Number: 200602/139 +X-Sequence-Number: 17125 + +Hi, Aaron, + +Aaron Turner wrote: + +> 4) Does decoding the data (currently base64) and storing the binary +> data improve the distribution of the index, thereby masking it more +> efficent? + +Yes, but then you should not use varchar, but a bytea. + +If your data is some numer internally, numeric or decimal may be even +better. + +If most of your data is different in the first 8 bytes, it may also make +sense to duplicate them into a bigint, and create the bigint on them. +Then you can use AND in your query to test for the 8 bytes (uses index) +and the bytea. Ugly, but may work. + +HTH, +Markus + +-- +Markus Schaber | Logical Tracking&Tracing International AG +Dipl. Inf. | Software Development GIS + +Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org + +From pgsql-performance-owner@postgresql.org Sun Feb 12 21:30:11 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 8D5EB9DC84D + for ; + Sun, 12 Feb 2006 21:30:10 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 77167-05 + for ; + Sun, 12 Feb 2006 21:30:13 -0400 (AST) +X-Greylist: delayed 00:24:41.268652 by SQLgrey- +Received: from pillette.com (adsl-67-119-5-202.dsl.snfc21.pacbell.net + [67.119.5.202]) by postgresql.org (Postfix) with ESMTP id ED93A9DCA75 + for ; + Sun, 12 Feb 2006 21:30:07 -0400 (AST) +Received: (from andrew@localhost) + by pillette.com (8.11.6/8.11.6) id k1D15R726930; + Sun, 12 Feb 2006 17:05:27 -0800 +Date: Sun, 12 Feb 2006 17:05:27 -0800 +From: andrew@pillette.com +Message-Id: <200602130105.k1D15R726930@pillette.com> +Subject: Re: SQL Function Performance +To: "Adnan DURSUN" +Cc: +X-Originating-IP: 67.124.229.87 +X-Mailer: Webmin 0.940 +MIME-Version: 1.0 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.395 required=5 tests=[AWL=-0.155, + NO_REAL_NAME=0.55] +X-Spam-Score: 0.395 +X-Spam-Level: +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200602/138 +X-Sequence-Number: 17124 + +If you have only recently analyzed the tables in the query, close your psql session (if that's what you were using) and then restart it. I've gotten burned by asking a query using the function, which I believe is when PG creates the plan for the function, and then making significant changes to the tables behind it (new index, bulk insert, etc.). By starting a new session, the function will be re-planned according to up to date statistics or using newly created indices. + +From pgsql-performance-owner@postgresql.org Mon Feb 13 01:46:09 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 927609DC833 + for ; + Mon, 13 Feb 2006 01:46:08 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28624-04 + for ; + Mon, 13 Feb 2006 01:46:07 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) + by postgresql.org (Postfix) with ESMTP id 658449DC805 + for ; + Mon, 13 Feb 2006 01:46:06 -0400 (AST) +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 k1D5k2mY054748 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); + Sun, 12 Feb 2006 22:46:04 -0700 (MST) + (envelope-from mfuhr@winnie.fuhr.org) +Received: from winnie.fuhr.org (localhost [127.0.0.1]) + by winnie.fuhr.org (8.13.4/8.13.4) with ESMTP id k1D5k1h0019216; + Sun, 12 Feb 2006 22:46:01 -0700 (MST) + (envelope-from mfuhr@winnie.fuhr.org) +Received: (from mfuhr@localhost) + by winnie.fuhr.org (8.13.4/8.13.4/Submit) id k1D5k1WT019215; + Sun, 12 Feb 2006 22:46:01 -0700 (MST) (envelope-from mfuhr) +Date: Sun, 12 Feb 2006 22:46:01 -0700 +From: Michael Fuhr +To: Adnan DURSUN +Cc: pgsql-performance@postgresql.org +Subject: Re: SQL Function Performance +Message-ID: <20060213054601.GA19126@winnie.fuhr.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, score=0.121 required=5 tests=[AWL=0.121] +X-Spam-Score: 0.121 +X-Spam-Level: +X-Archive-Number: 200602/140 +X-Sequence-Number: 17126 + +On Sun, Feb 12, 2006 at 10:25:28PM +0200, Adnan DURSUN wrote: +> My database has an SQL function. The result comes in 30-40 seconds +> when i use the SQL function. On the other hand; The result comes +> 300-400 milliseconds when i run the SQL statement. Any idea ?? + +Have you analyzed the tables? If that's not the problem then could +you post the EXPLAIN ANALYZE output for the direct query and for a +prepared query? For the prepared query do this: + +PREPARE stmt (varchar, date, int4, varchar, varchar) AS SELECT ... ; + +where "..." is the same SQL as in the function body, including the +numbered parameters ($1, $2, etc.). To execute the query do this: + +EXPLAIN ANALYZE EXECUTE stmt (...); + +Where "..." is the same parameter list you'd pass to the function +(the same values you used in the direct query). + +If you need to re-prepare the query then run "DEALLOCATE stmt" +before doing so. + +-- +Michael Fuhr + +From pgsql-performance-owner@postgresql.org Mon Feb 13 04:55:19 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 9F7D69DCBC8 + for ; + Mon, 13 Feb 2006 04:55:18 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 67063-04 + for ; + Mon, 13 Feb 2006 04:55:19 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from peufeu.com (unknown [82.67.9.10]) + by postgresql.org (Postfix) with ESMTP id B050D9DCA1A + for ; + Mon, 13 Feb 2006 04:55:15 -0400 (AST) +Received: (qmail 31259 invoked from network); 13 Feb 2006 09:55:21 +0100 +Received: from unknown (HELO apollo13) (82.67.9.10) + by boutiquenumerique.com with SMTP; 13 Feb 2006 09:55:21 +0100 +Date: Mon, 13 Feb 2006 09:55:20 +0100 +To: "Aaron Turner" , "Tom Lane" +Subject: Re: 10+hrs vs 15min because of just one index +Cc: "Jim C. Nasby" , + "Matthew T. O'Connor" , pgsql-performance@postgresql.org +References: <1ca1c1410602100016p2b5fdcc4wbf45612d7efc5fdf@mail.gmail.com> + <43ECC9BF.2030107@zeut.net> + <1ca1c1410602100924s191e7cddo4bda80d8f8d7cb6d@mail.gmail.com> + <20060211212453.GT57845@pervasive.com> + <1ca1c1410602112358h1e0e9696lff8f172769dc587e@mail.gmail.com> + <16809.1139759674@sss.pgh.pa.us> + <1ca1c1410602121133y279ea488nc38f049ac6ebc7f4@mail.gmail.com> +From: PFC +Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-ID: +In-Reply-To: <1ca1c1410602121133y279ea488nc38f049ac6ebc7f4@mail.gmail.com> +User-Agent: Opera M2/8.51 (Linux, build 1462) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.09 required=5 tests=[AWL=0.090] +X-Spam-Score: 0.09 +X-Spam-Level: +X-Archive-Number: 200602/141 +X-Sequence-Number: 17127 + + +>> Are the key values really all 48 chars long? If not, you made a +>> bad datatype choice: varchar(n) (or even text) would be a lot +>> smarter. char(n) wastes space on blank-padding. +> +> Yep, everything exactly 48. Looks like I'll be storing it as a bytea +> in the near future though. + + It's a good idea not to bloat a column by base64 encoding it if you want +to index it. BYTEA should be your friend. + If your values are not random, you might want to exploit the correlation. +But if they are already quite uncorrelated, and you don't need the index +for < >, just for =, you can create an index on the md5 of your column and +use it to search. It will use a lot less data but the data will be more +random. With a functional index, you don't need to modify your application +too much. + +From pgsql-performance-owner@postgresql.org Mon Feb 13 07:49:13 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 26EDE9DC86F + for ; + Mon, 13 Feb 2006 07:49:12 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 94800-10 + for ; + Mon, 13 Feb 2006 07:49:14 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.logix-tt.com (serval.logix-tt.com [213.239.221.42]) + by postgresql.org (Postfix) with ESMTP id B453F9DC817 + for ; + Mon, 13 Feb 2006 07:49:09 -0400 (AST) +Received: from kingfisher.intern.logix-tt.com (Mf755.m.pppool.de + [89.49.247.85]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logix-tt.com (Postfix) with ESMTP id E5B8D24407F; + Mon, 13 Feb 2006 12:49:16 +0100 (CET) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id C3768184B3AD8; + Mon, 13 Feb 2006 12:49:15 +0100 (CET) +Message-ID: <43F0723B.3040505@logix-tt.com> +Date: Mon, 13 Feb 2006 12:49:15 +0100 +From: Markus Schaber +Organization: Logical Tracking and Tracing International AG, Switzerland +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: david drummard +Cc: pgsql-performance@postgresql.org +Subject: Re: help required in design of database +References: <9c89e2490602101220i796e6913pdfa05f40bb894b97@mail.gmail.com> +In-Reply-To: <9c89e2490602101220i796e6913pdfa05f40bb894b97@mail.gmail.com> +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.121 required=5 tests=[AWL=0.121] +X-Spam-Score: 0.121 +X-Spam-Level: +X-Archive-Number: 200602/142 +X-Sequence-Number: 17128 + +Hi, David, + +david drummard wrote: + +> 1) create a new table every time a new feed file comes in. Create table +> with indexes. Use the copy command to dump the data into the table. + +Its faster to obey the following order: + +- Create the table +- COPY the data into the table +- Create the indices +- ANALYZE the table. + +and probably CLUSTER the table on the most-used index, between index +creation and ANALYZE. You also might want to increase the statistics +target on some columns before ANALYZE, depending on your data. + +> 2) rename the current table to some old table name and rename the new +> table to current table name so that applications can access them directly. + +You can also use a view, and then use CREATE OR REPLACE VIEW to switch +between the tables. + +But two table renames inside a transaction should do as well, and +shorten the outage time, as with the transaction encapsulation, no +external app should see the change inside their transaction. + +HTH, +Markus + + +-- +Markus Schaber | Logical Tracking&Tracing International AG +Dipl. Inf. | Software Development GIS + +Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org + +From pgsql-performance-owner@postgresql.org Mon Feb 13 12:22:05 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 3D2A39DCA77 + for ; + Mon, 13 Feb 2006 12:22:05 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 52422-06 + for ; + Mon, 13 Feb 2006 12:22:03 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.optiosoftware.com (mail.optio.com [192.216.93.10]) + by postgresql.org (Postfix) with ESMTP id 7F0FB9DC99F + for ; + Mon, 13 Feb 2006 12:22:01 -0400 (AST) +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: joining two tables slow due to sequential scan +Date: Mon, 13 Feb 2006 11:21:58 -0500 +Message-ID: <47668A1334CDBF46927C1A0DFEB223D3131457@mail.optiosoftware.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] joining two tables slow due to sequential scan +Thread-Index: AcYumUTCGLv3XAabSGacxcKb3ISIkACIB5zw +From: "Tim Jones" +To: "Dave Dutcher" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.111 required=5 tests=[AWL=0.111] +X-Spam-Score: 0.111 +X-Spam-Level: +X-Archive-Number: 200602/143 +X-Sequence-Number: 17129 + +ok I am retarded :) Apparently I thought I had done analyze on these +tables but I actually had not and that was all that was needed. but +thanks for the help. + + +Tim Jones +Healthcare Project Manager +Optio Software, Inc. +(770) 576-3555 + +-----Original Message----- +From: Dave Dutcher [mailto:dave@tridecap.com]=20 +Sent: Friday, February 10, 2006 6:25 PM +To: Tim Jones +Cc: pgsql-performance@postgresql.org +Subject: RE: [PERFORM] joining two tables slow due to sequential scan=20 + +OK, if I'm reading this correctly, it looks like the planner is choosing +a sequential scan because it expects 48,000 rows for that +patientidentifier, but its actually only getting 3. The planner has the +number of rows right for the sequential scan, so it seems like the stats +are up to date. I would try increasing the stats for the +patientindentifier column with 'alter table set statistics...' or +increasing the default_statistics_target for the whole DB. Once you +have changed the stats I believe you need to run analyze again. + + + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Tim Jones +Sent: Friday, February 10, 2006 4:59 PM +To: Tom Lane +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] joining two tables slow due to sequential scan=20 + +ok here is real db + +the first query I had seems to make no sense because it is only fast if +I limit the rows since almost all rows have status =3D 'AC' + +second query + tables both have about 10 million rows and it takes a long time as you +can see but this person only has approx 160 total documents + + + QUERY PLAN =20 +------------------------------------------------------------------------ +------------------------------------------------------------------- + Hash Join (cost=3D84813.14..1510711.97 rows=3D48387 width=3D555) = +(actual +time=3D83266.854..91166.315 rows=3D3 loops=3D1) + Hash Cond: ("outer".documentidentifier =3D +"inner".dssdocumentidentifier) + -> Seq Scan on documentversions (cost=3D0.00..269141.98 = +rows=3D9677398 +width=3D415) (actual time=3D0.056..49812.459 rows=3D9677398 loops=3D1) + -> Hash (cost=3D83660.05..83660.05 rows=3D48036 width=3D140) = +(actual +time=3D10.833..10.833 rows=3D3 loops=3D1) + -> Bitmap Heap Scan on clinicaldocuments +(cost=3D301.13..83660.05 rows=3D48036 width=3D140) (actual = +time=3D0.243..0.258 +rows=3D3 loops=3D1) + Recheck Cond: (patientidentifier =3D 690193) + -> Bitmap Index Scan on ix_cdocpid (cost=3D0.00..301.13 +rows=3D48036 width=3D0) (actual time=3D0.201..0.201 rows=3D3 loops=3D1) + Index Cond: (patientidentifier =3D 690193) Total +runtime: 91166.540 ms + + +Tim Jones +Healthcare Project Manager +Optio Software, Inc. +(770) 576-3555 + +-----Original Message----- +From: Tom Lane [mailto:tgl@sss.pgh.pa.us] +Sent: Friday, February 10, 2006 5:52 PM +To: Tim Jones +Cc: Scott Marlowe; Dave Dutcher; pgsql-performance@postgresql.org +Subject: Re: [PERFORM] joining two tables slow due to sequential scan=20 + +"Tim Jones" writes: +> QUERY PLAN +> 'Hash Join (cost=3D899.83..4384.17 rows=3D482 width=3D1350) (actual +> time=3D0.203..0.203 rows=3D0 loops=3D1)' +> ... +> 'Total runtime: 0.392 ms' + +Hardly seems like evidence of a performance problem ... + + regards, tom lane + +---------------------------(end of broadcast)--------------------------- +TIP 5: don't forget to increase your free space map settings + + +From pgsql-performance-owner@postgresql.org Mon Feb 13 15:44:57 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 125709DC887 + for ; + Mon, 13 Feb 2006 15:44:57 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 95710-07 + for ; + Mon, 13 Feb 2006 15:44:56 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from hotmail.com (bay106-dav18.bay106.hotmail.com [65.54.161.90]) + by postgresql.org (Postfix) with ESMTP id 42E309DC83C + for ; + Mon, 13 Feb 2006 15:44:53 -0400 (AST) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Mon, 13 Feb 2006 11:44:54 -0800 +Message-ID: +Received: from 85.105.24.123 by BAY106-DAV18.phx.gbl with DAV; + Mon, 13 Feb 2006 19:44:54 +0000 +X-Originating-IP: [85.105.24.123] +X-Originating-Email: [a_dursun@hotmail.com] +X-Sender: a_dursun@hotmail.com +From: "Adnan DURSUN" +To: , + +Subject: Re: SQL Function Performance +Date: Mon, 13 Feb 2006 21:44:40 +0200 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0009_01C630E6.B18BAC50" +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-OriginalArrivalTime: 13 Feb 2006 19:44:54.0872 (UTC) + FILETIME=[F6850D80:01C630D5] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=3.223 required=5 tests=[AWL=0.103, + DNS_FROM_RFC_ABUSE=0.479, DNS_FROM_RFC_POST=1.44, HTML_MESSAGE=0.001, + MSGID_FROM_MTA_HEADER=0, WEIRD_QUOTING=1.2] +X-Spam-Score: 3.223 +X-Spam-Level: *** +X-Archive-Number: 200602/144 +X-Sequence-Number: 17130 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0009_01C630E6.B18BAC50 +Content-Type: text/plain; + charset="iso-8859-9" +Content-Transfer-Encoding: quoted-printable + + + + From: Michael Fuhr + Date: 02/13/06 07:46:05 + To: Adnan DURSUN + Cc: pgsql-performance@postgresql.org + Subject: Re: [PERFORM] SQL Function Performance + + On Sun, Feb 12, 2006 at 10:25:28PM +0200, Adnan DURSUN wrote: + >> My database has an SQL function. The result comes in 30-40 = +seconds + >> when i use the SQL function. On the other hand; The result comes + >> 300-400 milliseconds when i run the SQL statement. Any idea ?? + + >Have you analyzed the tables? If that's not the problem then could + >you post the EXPLAIN ANALYZE output for the direct query and for a + >prepared query? For the prepared query do this: + + EXPLAIN ANALYZE for direct query : + + QUERY PLAN + "HashAggregate (cost=3D29.37..29.40 rows=3D1 width=3D58) (actual = +time=3D12.114..12.114 rows=3D0 loops=3D1)" + " -> Nested Loop (cost=3D9.55..29.36 rows=3D1 width=3D58) (actual = +time=3D12.107..12.107 rows=3D0 loops=3D1)" + " Join Filter: (((""inner"".hat_no)::text =3D = +(""outer"".hat_no)::text) AND (""inner"".sefer_kod =3D = +""outer"".sefer_kod) AND (""inner"".plan_tarihi =3D = +""outer"".plan_tarihi) AND (""inner"".bin_yer_kod =3D = +""outer"".bin_yer_kod) AND (""inner"".koltuk_no =3D = +""outer"".koltuk_no))" + " -> Nested Loop (cost=3D9.55..26.15 rows=3D1 width=3D93) = +(actual time=3D12.102..12.102 rows=3D0 loops=3D1)" + " -> Nested Loop (cost=3D9.55..20.60 rows=3D1 = +width=3D65) (actual time=3D8.984..12.012 rows=3D1 loops=3D1)" + " -> Nested Loop (cost=3D9.55..14.62 rows=3D1 = +width=3D48) (actual time=3D6.155..7.919 rows=3D41 loops=3D1)" + " Join Filter: (""outer"".sefer_tip_kod =3D = +""inner"".kod)" + " -> Hash Join (cost=3D9.55..13.58 = +rows=3D1 width=3D52) (actual time=3D6.129..6.846 rows=3D41 loops=3D1)" + " Hash Cond: (""outer"".kod =3D = +""inner"".varis_yer_kod)" + " -> Seq Scan on t_yer y2 = +(cost=3D0.00..3.44 rows=3D115 width=3D14) (actual time=3D0.018..0.374 = +rows=3D115 loops=3D1)" + " Filter: ((iptal)::text =3D = +'H'::text)" + " -> Hash (cost=3D9.55..9.55 = +rows=3D1 width=3D46) (actual time=3D6.058..6.058 rows=3D41 loops=3D1)" + " -> Merge Join = +(cost=3D9.45..9.55 rows=3D1 width=3D46) (actual time=3D4.734..5.894 = +rows=3D41 loops=3D1)" + " Merge Cond: = +(""outer"".kod =3D ""inner"".kalkis_yer_kod)" + " -> Index Scan using = +t_yer_pkey on t_yer y1 (cost=3D0.00..9.62 rows=3D115 width=3D14) = +(actual time=3D0.021..0.183 rows=3D40 loops=3D1)" + " Filter: = +((iptal)::text =3D 'H'::text)" + " -> Sort = +(cost=3D9.45..9.45 rows=3D1 width=3D40) (actual time=3D4.699..4.768 = +rows=3D41 loops=3D1)" + " Sort Key: = +h.kalkis_yer_kod" + " -> Nested Loop = +(cost=3D4.51..9.44 rows=3D1 width=3D40) (actual time=3D0.410..4.427 = +rows=3D41 loops=3D1)" + " Join = +Filter: ((""inner"".""no"")::text =3D (""outer"".hat_no)::text)" + " -> Hash = +Join (cost=3D4.51..8.09 rows=3D1 width=3D27) (actual = +time=3D0.384..1.036 rows=3D41 loops=3D1)" + " Hash = +Cond: ((""outer"".durumu)::text =3D (""inner"".kod)::text)" + " -> = +Hash Join (cost=3D2.25..5.80 rows=3D3 width=3D32) (actual = +time=3D0.193..0.652 rows=3D41 loops=3D1)" + " = +Hash Cond: ((""outer"".ek_dev)::text =3D (""inner"".kod)::text)" + " = +-> Seq Scan on t_seferler s (cost=3D0.00..3.21 rows=3D41 width=3D37) = +(actual time=3D0.009..0.256 rows=3D41 loops=3D1)" + " = + Filter: (((iptal)::text =3D 'H'::text) AND ((iptal)::text =3D = +'H'::text) AND ((firma_no)::text =3D '1'::text))" + " = +-> Hash (cost=3D2.25..2.25 rows=3D2 width=3D5) (actual = +time=3D0.156..0.156 rows=3D2 loops=3D1)" + " = + -> Seq Scan on t_domains d1 (cost=3D0.00..2.25 rows=3D2 = +width=3D5) (actual time=3D0.055..0.138 rows=3D2 loops=3D1)" + " = + Filter: ((name)::text =3D 'EKDEV'::text)" + " -> = +Hash (cost=3D2.25..2.25 rows=3D2 width=3D5) (actual time=3D0.164..0.164 = +rows=3D2 loops=3D1)" + " = +-> Seq Scan on t_domains d2 (cost=3D0.00..2.25 rows=3D2 width=3D5) = +(actual time=3D0.057..0.142 rows=3D2 loops=3D1)" + " = + Filter: ((name)::text =3D 'SFR_DURUMU'::text)" + " -> Seq = +Scan on t_hatlar h (cost=3D0.00..1.23 rows=3D10 width=3D18) (actual = +time=3D0.004..0.042 rows=3D10 loops=3D41)" + " = +Filter: ('1'::text =3D (firma_no)::text)" + " -> Seq Scan on t_sefer_tip t = +(cost=3D0.00..1.03 rows=3D1 width=3D9) (actual time=3D0.005..0.009 = +rows=3D1 loops=3D41)" + " Filter: (((iptal)::text =3D = +'H'::text) AND ('1'::text =3D (firma_no)::text))" + " -> Index Scan using = +t_lokal_plan_sefer_liste_idx on t_lokal_plan lp (cost=3D0.00..5.97 = +rows=3D1 width=3D22) (actual time=3D0.091..0.092 rows=3D0 loops=3D41)" + " Index Cond: (((lp.firma_no)::text =3D = +'1'::text) AND ((""outer"".hat_no)::text =3D (lp.hat_no)::text) AND = +(""outer"".kod =3D lp.sefer_kod) AND (lp.kalkis_tarihi =3D = +'2006-02-13'::date))" + " Filter: (lokal_kod =3D 62)" + " -> Index Scan using t_koltuk_son_durum_pkey on = +t_koltuk_son_durum sd (cost=3D0.00..5.53 rows=3D1 width=3D28) (actual = +time=3D0.079..0.079 rows=3D0 loops=3D1)" + " Index Cond: (('1'::text =3D = +(sd.firma_no)::text) AND ((""outer"".hat_no)::text =3D = +(sd.hat_no)::text) AND (""outer"".kod =3D sd.sefer_kod) AND = +(""outer"".plan_tarihi =3D sd.plan_tarihi) AND (""outer"".yer_kod =3D = +sd.bin_yer_kod))" + " Filter: ((islem)::text =3D 'S'::text)" + " -> Index Scan using t_koltuk_islem_kod_ukey on = +t_koltuk_islem i (cost=3D0.00..3.18 rows=3D1 width=3D57) (never = +executed)" + " Index Cond: (i.kod =3D ""outer"".islem_kod)" + " Filter: ((firma_no)::text =3D '1'::text)" + "Total runtime: 13.984 ms" + + + Adnan DURSUN + ASRIN Bili=FEim Ltd.=DEti + Ankara / TURKEY + +------=_NextPart_000_0009_01C630E6.B18BAC50 +Content-Type: text/html; + charset="iso-8859-9" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +

 
+
+
+
+
+
From: Michael Fuhr
+
Date: = +02/13/06=20 + 07:46:05
+
To: Adnan DURSUN
+
Cc: pgsql-performance@postgr= +esql.org
+
Subject: Re: = +[PERFORM]=20 + SQL Function Performance
+
 
+
On Sun, Feb 12, 2006 at 10:25:28PM +0200, Adnan DURSUN = +wrote:
+
>> My database has an SQL function. The result comes in = +30-40=20 + seconds
+
>> when i use the SQL function. On the other hand; The = +result=20 + comes
+
>> 300-400 milliseconds when i run the SQL statement. Any = +idea=20 + ??
+
 
+
>Have you analyzed the tables?  If that's not the = +problem=20 + then could
+
>you post the EXPLAIN ANALYZE output for the direct query = +and for=20 + a
+
>prepared query?  For the prepared query do = +this:
+
 
+
EXPLAIN ANALYZE for direct query :
+
 
+
QUERY PLAN
"HashAggregate  (cost=3D29.37..29.40 = +rows=3D1 width=3D58)=20 + (actual time=3D12.114..12.114 rows=3D0 loops=3D1)"
"  = +->  Nested=20 + Loop  (cost=3D9.55..29.36 rows=3D1 width=3D58) (actual = +time=3D12.107..12.107=20 + rows=3D0 loops=3D1)"
"        = +Join Filter:=20 + (((""inner"".hat_no)::text =3D (""outer"".hat_no)::text) AND=20 + (""inner"".sefer_kod =3D ""outer"".sefer_kod) AND = +(""inner"".plan_tarihi =3D=20 + ""outer"".plan_tarihi) AND (""inner"".bin_yer_kod =3D = +""outer"".bin_yer_kod)=20 + AND (""inner"".koltuk_no =3D=20 + = +""outer"".koltuk_no))"
"       =20 + ->  Nested Loop  (cost=3D9.55..26.15 rows=3D1 = +width=3D93) (actual=20 + time=3D12.102..12.102 rows=3D0=20 + = +loops=3D1)"
"         &nb= +sp;   =20 + ->  Nested Loop  (cost=3D9.55..20.60 rows=3D1 = +width=3D65) (actual=20 + time=3D8.984..12.012 rows=3D1=20 + = +loops=3D1)"
"         &nb= +sp;         =20 + ->  Nested Loop  (cost=3D9.55..14.62 rows=3D1 = +width=3D48) (actual=20 + time=3D6.155..7.919 rows=3D41=20 + = +loops=3D1)"
"         &nb= +sp;           &nbs= +p;   =20 + Join Filter: (""outer"".sefer_tip_kod =3D=20 + = +""inner"".kod)"
"         = +;            = +    =20 + ->  Hash Join  (cost=3D9.55..13.58 rows=3D1 width=3D52) = +(actual=20 + time=3D6.129..6.846 rows=3D41=20 + = +loops=3D1)"
"         &nb= +sp;           &nbs= +p;         =20 + Hash Cond: (""outer"".kod =3D=20 + = +""inner"".varis_yer_kod)"
"       &= +nbsp;           &n= +bsp;           =20 + ->  Seq Scan on t_yer y2  (cost=3D0.00..3.44 rows=3D115 = +width=3D14)=20 + (actual time=3D0.018..0.374 rows=3D115=20 + = +loops=3D1)"
"         &nb= +sp;           &nbs= +p;            = +;   =20 + Filter: ((iptal)::text =3D=20 + = +'H'::text)"
"         &nb= +sp;           &nbs= +p;         =20 + ->  Hash  (cost=3D9.55..9.55 rows=3D1 width=3D46) = +(actual=20 + time=3D6.058..6.058 rows=3D41=20 + = +loops=3D1)"
"         &nb= +sp;           &nbs= +p;            = +;   =20 + ->  Merge Join  (cost=3D9.45..9.55 rows=3D1 width=3D46) = +(actual=20 + time=3D4.734..5.894 rows=3D41=20 + = +loops=3D1)"
"         &nb= +sp;           &nbs= +p;            = +;         =20 + Merge Cond: (""outer"".kod =3D=20 + = +""inner"".kalkis_yer_kod)"
"       = +            &= +nbsp;           &n= +bsp;           =20 + ->  Index Scan using t_yer_pkey on t_yer y1  = +(cost=3D0.00..9.62=20 + rows=3D115 width=3D14) (actual time=3D0.021..0.183 rows=3D40=20 + = +loops=3D1)"
"         &nb= +sp;           &nbs= +p;            = +;            = +   =20 + Filter: ((iptal)::text =3D=20 + = +'H'::text)"
"         &nb= +sp;           &nbs= +p;            = +;         =20 + ->  Sort  (cost=3D9.45..9.45 rows=3D1 width=3D40) = +(actual=20 + time=3D4.699..4.768 rows=3D41=20 + = +loops=3D1)"
"         &nb= +sp;           &nbs= +p;            = +;            = +   =20 + Sort Key:=20 + = +h.kalkis_yer_kod"
"        &nb= +sp;           &nbs= +p;            = +;            = +    =20 + ->  Nested Loop  (cost=3D4.51..9.44 rows=3D1 = +width=3D40) (actual=20 + time=3D0.410..4.427 rows=3D41=20 + = +loops=3D1)"
"         &nb= +sp;           &nbs= +p;            = +;            = +         =20 + Join Filter: ((""inner"".""no"")::text =3D=20 + = +(""outer"".hat_no)::text)"
"       = +            &= +nbsp;           &n= +bsp;           &nb= +sp;           =20 + ->  Hash Join  (cost=3D4.51..8.09 rows=3D1 width=3D27) = +(actual=20 + time=3D0.384..1.036 rows=3D41=20 + = +loops=3D1)"
"         &nb= +sp;           &nbs= +p;            = +;            = +            &= +nbsp;  =20 + Hash Cond: ((""outer"".durumu)::text =3D=20 + = +(""inner"".kod)::text)"
"       &nb= +sp;           &nbs= +p;            = +;            = +            &= +nbsp;    =20 + ->  Hash Join  (cost=3D2.25..5.80 rows=3D3 width=3D32) = +(actual=20 + time=3D0.193..0.652 rows=3D41=20 + = +loops=3D1)"
"         &nb= +sp;           &nbs= +p;            = +;            = +            &= +nbsp;        =20 + Hash Cond: ((""outer"".ek_dev)::text =3D=20 + = +(""inner"".kod)::text)"
"       &nb= +sp;           &nbs= +p;            = +;            = +            &= +nbsp;          =20 + ->  Seq Scan on t_seferler s  (cost=3D0.00..3.21 = +rows=3D41=20 + width=3D37) (actual time=3D0.009..0.256 rows=3D41=20 + = +loops=3D1)"
"         &nb= +sp;           &nbs= +p;            = +;            = +            &= +nbsp;           &n= +bsp;  =20 + Filter: (((iptal)::text =3D 'H'::text) AND ((iptal)::text =3D = +'H'::text) AND=20 + ((firma_no)::text =3D=20 + = +'1'::text))"
"         &n= +bsp;           &nb= +sp;           &nbs= +p;            = +;            = +         =20 + ->  Hash  (cost=3D2.25..2.25 rows=3D2 width=3D5) = +(actual=20 + time=3D0.156..0.156 rows=3D2=20 + = +loops=3D1)"
"         &nb= +sp;           &nbs= +p;            = +;            = +            &= +nbsp;           &n= +bsp;  =20 + ->  Seq Scan on t_domains d1  (cost=3D0.00..2.25 = +rows=3D2 width=3D5)=20 + (actual time=3D0.055..0.138 rows=3D2=20 + = +loops=3D1)"
"         &nb= +sp;           &nbs= +p;            = +;            = +            &= +nbsp;           &n= +bsp;        =20 + Filter: ((name)::text =3D=20 + = +'EKDEV'::text)"
"         = +;            = +            &= +nbsp;           &n= +bsp;           &nb= +sp;   =20 + ->  Hash  (cost=3D2.25..2.25 rows=3D2 width=3D5) = +(actual=20 + time=3D0.164..0.164 rows=3D2=20 + = +loops=3D1)"
"         &nb= +sp;           &nbs= +p;            = +;            = +            &= +nbsp;        =20 + ->  Seq Scan on t_domains d2  (cost=3D0.00..2.25 = +rows=3D2 width=3D5)=20 + (actual time=3D0.057..0.142 rows=3D2=20 + = +loops=3D1)"
"         &nb= +sp;           &nbs= +p;            = +;            = +            &= +nbsp;           &n= +bsp;  =20 + Filter: ((name)::text =3D=20 + = +'SFR_DURUMU'::text)"
"        = +            &= +nbsp;           &n= +bsp;           &nb= +sp;          =20 + ->  Seq Scan on t_hatlar h  (cost=3D0.00..1.23 = +rows=3D10 width=3D18)=20 + (actual time=3D0.004..0.042 rows=3D10=20 + = +loops=3D41)"
"         &n= +bsp;           &nb= +sp;           &nbs= +p;            = +;            = +   =20 + Filter: ('1'::text =3D=20 + = +(firma_no)::text)"
"        &n= +bsp;           &nb= +sp;    =20 + ->  Seq Scan on t_sefer_tip t  (cost=3D0.00..1.03 = +rows=3D1 width=3D9)=20 + (actual time=3D0.005..0.009 rows=3D1=20 + = +loops=3D41)"
"         &n= +bsp;           &nb= +sp;         =20 + Filter: (((iptal)::text =3D 'H'::text) AND ('1'::text =3D=20 + = +(firma_no)::text))"
"        &= +nbsp;          =20 + ->  Index Scan using t_lokal_plan_sefer_liste_idx on = +t_lokal_plan=20 + lp  (cost=3D0.00..5.97 rows=3D1 width=3D22) (actual = +time=3D0.091..0.092 rows=3D0=20 + = +loops=3D41)"
"         &n= +bsp;           &nb= +sp;   =20 + Index Cond: (((lp.firma_no)::text =3D '1'::text) AND = +((""outer"".hat_no)::text=20 + =3D (lp.hat_no)::text) AND (""outer"".kod =3D lp.sefer_kod) AND=20 + (lp.kalkis_tarihi =3D=20 + = +'2006-02-13'::date))"
"        = +;            = +     =20 + Filter: (lokal_kod =3D=20 + = +62)"
"          &nbs= +p;  =20 + ->  Index Scan using t_koltuk_son_durum_pkey on = +t_koltuk_son_durum=20 + sd  (cost=3D0.00..5.53 rows=3D1 width=3D28) (actual = +time=3D0.079..0.079 rows=3D0=20 + = +loops=3D1)"
"         &nb= +sp;         =20 + Index Cond: (('1'::text =3D (sd.firma_no)::text) AND = +((""outer"".hat_no)::text=20 + =3D (sd.hat_no)::text) AND (""outer"".kod =3D sd.sefer_kod) AND=20 + (""outer"".plan_tarihi =3D sd.plan_tarihi) AND (""outer"".yer_kod = +=3D=20 + = +sd.bin_yer_kod))"
"        &nb= +sp;          =20 + Filter: ((islem)::text =3D=20 + 'S'::text)"
"        = +->  Index=20 + Scan using t_koltuk_islem_kod_ukey on t_koltuk_islem i =20 + (cost=3D0.00..3.18 rows=3D1 width=3D57) (never=20 + = +executed)"
"         &nbs= +p;   =20 + Index Cond: (i.kod =3D=20 + = +""outer"".islem_kod)"
"        = +;     =20 + Filter: ((firma_no)::text =3D '1'::text)"
"Total runtime: 13.984=20 + ms"
+
 
+
Adnan DURSUN
+
ASRIN Bili=FEim Ltd.=DEti
+
Ankara / TURKEY
+ = +
 
+ +------=_NextPart_000_0009_01C630E6.B18BAC50-- + +From pgsql-performance-owner@postgresql.org Sat Feb 18 00:09:45 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id D1AA89DCB6D + for ; + Mon, 13 Feb 2006 16:09:30 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 04893-01 + for ; + Mon, 13 Feb 2006 16:09:24 -0400 (AST) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 4FB2C9DC83C + for ; + Mon, 13 Feb 2006 16:09:22 -0400 (AST) +Received: from mail.goldpocket.com (mail1.goldpocket.com [38.101.116.14]) + by svr4.postgresql.org (Postfix) with ESMTP id 166885AF0D8 + for ; + Mon, 13 Feb 2006 20:09:22 +0000 (GMT) +Received: from localhost (unknown [127.0.0.1]) + by mail.goldpocket.com (Postfix) with ESMTP id E10CBE048842 + for ; + Mon, 13 Feb 2006 20:09:18 +0000 (UTC) +Received: from mail.goldpocket.com ([127.0.0.1]) + by localhost (mail.goldpocket.com [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 26063-02 for ; + Mon, 13 Feb 2006 12:09:15 -0800 (PST) +Received: from mail1.goldpocket.com (srvgpimail1.gpi.local [10.10.0.13]) + by mail.goldpocket.com (Postfix) with ESMTP id C7ABEE048875 + for ; + Mon, 13 Feb 2006 12:09:15 -0800 (PST) +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_01C630D9.5D2CCD2B" +Subject: Re: SQL Function Performance +Date: Mon, 13 Feb 2006 12:06:27 -0800 +Message-ID: <9D938282F8C6EE43B748B910386DE93E0138B3F1@srvgpimail1.GPI.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] SQL Function Performance +Thread-Index: AcYw1jt0alHbJHoJQXqivW5pflL82wAAr1vd +From: "Mark Liberman" +To: "Adnan DURSUN" , +X-Virus-Scanned: amavisd-new at goldpocket.com +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.001 required=5 tests=[HTML_MESSAGE=0.001] +X-Spam-Score: 0.001 +X-Spam-Level: +X-Archive-Number: 200602/292 +X-Sequence-Number: 17278 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C630D9.5D2CCD2B +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +I've run into this issue. It basically comes down to the plan that is = +being used inside the function is not the same as the plan used when you = +issue the query manually outside of the function. Although I'm no = +expert on when plans are prepared and re-evaluated for functions, I know = +that they are not re-evaluated each time to execute the function. + +So, what I did in such cases was to build up the sql query in a text = +variable inside my function, and then use the EXECUTE command inside the = +function. When you use the EXECUTE command, the plan is prepared each = +time. I know there is some minimal overhead of preparing the plan each = +time, but it seems like it's minor compared to the saving's you'll get. + +- Mark + + +------_=_NextPart_001_01C630D9.5D2CCD2B +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + +RE: [PERFORM] SQL Function Performance + + + + +

I've run into this issue. It basically comes down to = +the plan that is being used inside the function is not the same as the = +plan used when you issue the query manually outside of the = +function.  Although I'm no expert on when plans are prepared and = +re-evaluated for functions, I know that they are not re-evaluated each = +time to execute the function.
+
+So, what I did in such cases was to build up the sql query in a text = +variable inside my function, and then use the EXECUTE command inside the = +function.  When you use the EXECUTE command, the plan is prepared = +each time.  I know there is some minimal overhead of preparing the = +plan each time, but it seems like it's minor compared to the saving's = +you'll get.
+
+- Mark
+
+
+

+ + + +------_=_NextPart_001_01C630D9.5D2CCD2B-- + +From pgsql-performance-owner@postgresql.org Mon Feb 13 16:24:16 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id D4C209DCB6D + for ; + Mon, 13 Feb 2006 16:24:15 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 04328-09 + for ; + Mon, 13 Feb 2006 16:24:16 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from hotmail.com (bay106-dav2.bay106.hotmail.com [65.54.161.74]) + by postgresql.org (Postfix) with ESMTP id 8897D9DC887 + for ; + Mon, 13 Feb 2006 16:24:11 -0400 (AST) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Mon, 13 Feb 2006 12:24:08 -0800 +Message-ID: +Received: from 85.105.24.123 by BAY106-DAV2.phx.gbl with DAV; + Mon, 13 Feb 2006 20:24:06 +0000 +X-Originating-IP: [85.105.24.123] +X-Originating-Email: [a_dursun@hotmail.com] +X-Sender: a_dursun@hotmail.com +From: "Adnan DURSUN" +To: , + +Subject: Re: SQL Function Performance +Date: Mon, 13 Feb 2006 22:23:52 +0200 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0007_01C630EC.2B9136F0" +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-OriginalArrivalTime: 13 Feb 2006 20:24:08.0972 (UTC) + FILETIME=[71AC34C0:01C630DB] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=3.125 required=5 tests=[AWL=0.005, + DNS_FROM_RFC_ABUSE=0.479, DNS_FROM_RFC_POST=1.44, HTML_MESSAGE=0.001, + MSGID_FROM_MTA_HEADER=0, WEIRD_QUOTING=1.2] +X-Spam-Score: 3.125 +X-Spam-Level: *** +X-Archive-Number: 200602/145 +X-Sequence-Number: 17131 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0007_01C630EC.2B9136F0 +Content-Type: text/plain; + charset="iso-8859-9" +Content-Transfer-Encoding: quoted-printable + + + From: Michael Fuhr + Date: 02/13/06 07:46:05 + To: Adnan DURSUN + Cc: pgsql-performance@postgresql.org + Subject: Re: [PERFORM] SQL Function Performance + + On Sun, Feb 12, 2006 at 10:25:28PM +0200, Adnan DURSUN wrote: + >> My database has an SQL function. The result comes in 30-40 seconds + >> when i use the SQL function. On the other hand; The result comes + >> 300-400 milliseconds when i run the SQL statement. Any idea ?? + + >Have you analyzed the tables? If that's not the problem then could + >you post the EXPLAIN ANALYZE output for the direct query and for a + >prepared query? For the prepared query do this: + + >EXPLAIN ANALYZE EXECUTE stmt (...); + + Here is the EXPLAIN ANALYZE output for prepared statement : + + QUERY PLAN + "HashAggregate (cost=3D29.37..29.40 rows=3D1 width=3D58) (actual = +time=3D10.600..10.600 rows=3D0 loops=3D1)" + " -> Nested Loop (cost=3D9.55..29.36 rows=3D1 width=3D58) (actual = +time=3D10.594..10.594 rows=3D0 loops=3D1)" + " Join Filter: (((""inner"".hat_no)::text =3D = +(""outer"".hat_no)::text) AND (""inner"".sefer_kod =3D = +""outer"".sefer_kod) AND (""inner"".plan_tarihi =3D = +""outer"".plan_tarihi) AND (""inner"".bin_yer_kod =3D = +""outer"".bin_yer_kod) AND (""inner"".koltuk_no =3D = +""outer"".koltuk_no))" + " -> Nested Loop (cost=3D9.55..26.15 rows=3D1 width=3D93) = +(actual time=3D10.588..10.588 rows=3D0 loops=3D1)" + " -> Nested Loop (cost=3D9.55..20.60 rows=3D1 = +width=3D65) (actual time=3D7.422..10.499 rows=3D1 loops=3D1)" + " -> Nested Loop (cost=3D9.55..14.62 rows=3D1 = +width=3D48) (actual time=3D5.455..7.247 rows=3D41 loops=3D1)" + " Join Filter: (""outer"".sefer_tip_kod =3D = +""inner"".kod)" + " -> Hash Join (cost=3D9.55..13.58 rows=3D1 = +width=3D52) (actual time=3D5.432..6.131 rows=3D41 loops=3D1)" + " Hash Cond: (""outer"".kod =3D = +""inner"".varis_yer_kod)" + " -> Seq Scan on t_yer y2 = +(cost=3D0.00..3.44 rows=3D115 width=3D14) (actual time=3D0.018..0.375 = +rows=3D115 loops=3D1)" + " Filter: ((iptal)::text =3D = +'H'::text)" + " -> Hash (cost=3D9.55..9.55 rows=3D1 = +width=3D46) (actual time=3D5.352..5.352 rows=3D41 loops=3D1)" + " -> Merge Join = +(cost=3D9.45..9.55 rows=3D1 width=3D46) (actual time=3D4.713..5.182 = +rows=3D41 loops=3D1)" + " Merge Cond: = +(""outer"".kod =3D ""inner"".kalkis_yer_kod)" + " -> Index Scan using = +t_yer_pkey on t_yer y1 (cost=3D0.00..9.62 rows=3D115 width=3D14) = +(actual time=3D0.021..0.176 rows=3D40 loops=3D1)" + " Filter: = +((iptal)::text =3D 'H'::text)" + " -> Sort = +(cost=3D9.45..9.45 rows=3D1 width=3D40) (actual time=3D4.678..4.747 = +rows=3D41 loops=3D1)" + " Sort Key: = +h.kalkis_yer_kod" + " -> Nested Loop = +(cost=3D4.51..9.44 rows=3D1 width=3D40) (actual time=3D0.412..4.389 = +rows=3D41 loops=3D1)" + " Join Filter: = +((""inner"".""no"")::text =3D (""outer"".hat_no)::text)" + " -> Hash Join = + (cost=3D4.51..8.09 rows=3D1 width=3D27) (actual time=3D0.386..1.137 = +rows=3D41 loops=3D1)" + " Hash = +Cond: ((""outer"".durumu)::text =3D (""inner"".kod)::text)" + " -> = +Hash Join (cost=3D2.25..5.80 rows=3D3 width=3D32) (actual = +time=3D0.193..0.751 rows=3D41 loops=3D1)" + " = +Hash Cond: ((""outer"".ek_dev)::text =3D (""inner"".kod)::text)" + " = +-> Seq Scan on t_seferler s (cost=3D0.00..3.21 rows=3D41 width=3D37) = +(actual time=3D0.009..0.258 rows=3D41 loops=3D1)" + " = + Filter: (((iptal)::text =3D 'H'::text) AND ((iptal)::text =3D = +'H'::text) AND ((firma_no)::text =3D '1'::text))" + " = +-> Hash (cost=3D2.25..2.25 rows=3D2 width=3D5) (actual = +time=3D0.141..0.141 rows=3D2 loops=3D1)" + " = + -> Seq Scan on t_domains d1 (cost=3D0.00..2.25 rows=3D2 width=3D5) = +(actual time=3D0.048..0.131 rows=3D2 loops=3D1)" + " = + Filter: ((name)::text =3D 'EKDEV'::text)" + " -> = +Hash (cost=3D2.25..2.25 rows=3D2 width=3D5) (actual time=3D0.160..0.160 = +rows=3D2 loops=3D1)" + " = +-> Seq Scan on t_domains d2 (cost=3D0.00..2.25 rows=3D2 width=3D5) = +(actual time=3D0.056..0.139 rows=3D2 loops=3D1)" + " = + Filter: ((name)::text =3D 'SFR_DURUMU'::text)" + " -> Seq Scan = +on t_hatlar h (cost=3D0.00..1.23 rows=3D10 width=3D18) (actual = +time=3D0.004..0.045 rows=3D10 loops=3D41)" + " Filter: = +('1'::text =3D (firma_no)::text)" + " -> Seq Scan on t_sefer_tip t = +(cost=3D0.00..1.03 rows=3D1 width=3D9) (actual time=3D0.004..0.009 = +rows=3D1 loops=3D41)" + " Filter: (((iptal)::text =3D = +'H'::text) AND ('1'::text =3D (firma_no)::text))" + " -> Index Scan using t_lokal_plan_sefer_liste_idx = +on t_lokal_plan lp (cost=3D0.00..5.97 rows=3D1 width=3D22) (actual = +time=3D0.071..0.072 rows=3D0 loops=3D41)" + " Index Cond: (((lp.firma_no)::text =3D = +'1'::text) AND ((""outer"".hat_no)::text =3D (lp.hat_no)::text) AND = +(""outer"".kod =3D lp.sefer_kod) AND (lp.kalkis_tarihi =3D = +'2006-02-13'::date))" + " Filter: (lokal_kod =3D 62)" + " -> Index Scan using t_koltuk_son_durum_pkey on = +t_koltuk_son_durum sd (cost=3D0.00..5.53 rows=3D1 width=3D28) (actual = +time=3D0.078..0.078 rows=3D0 loops=3D1)" + " Index Cond: (('1'::text =3D (sd.firma_no)::text) = +AND ((""outer"".hat_no)::text =3D (sd.hat_no)::text) AND (""outer"".kod = +=3D sd.sefer_kod) AND (""outer"".plan_tarihi =3D sd.plan_tarihi) AND = +(""outer"".yer_kod =3D sd.bin_yer_kod))" + " Filter: ((islem)::text =3D 'S'::text)" + " -> Index Scan using t_koltuk_islem_kod_ukey on = +t_koltuk_islem i (cost=3D0.00..3.18 rows=3D1 width=3D57) (never = +executed)" + " Index Cond: (i.kod =3D ""outer"".islem_kod)" + " Filter: ((firma_no)::text =3D '1'::text)" + "Total runtime: 11.856 ms" + + + Adnan DURSUN + ASRIN Bili=FEim Ltd.=DEti + Ankara / TURKEY + +------=_NextPart_000_0007_01C630EC.2B9136F0 +Content-Type: text/html; + charset="iso-8859-9" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
 
+
+
+
+
From: Michael Fuhr
+
Date: 02/13/06=20 + 07:46:05
+
To: Adnan DURSUN
+
Cc: pgsql-performance@postgr= +esql.org
+
Subject: Re: = +[PERFORM] SQL=20 + Function Performance
+
 
+
On Sun, Feb 12, 2006 at 10:25:28PM +0200, Adnan DURSUN = +wrote:
+
>> My database has an SQL function. The result comes in = +30-40=20 + seconds
+
>> when i use the SQL function. On the other hand; The = +result=20 + comes
+
>> 300-400 milliseconds when i run the SQL statement. Any = +idea=20 + ??
+
 
+
>Have you analyzed the tables?  If that's not the = +problem=20 + then could
+
>you post the EXPLAIN ANALYZE output for the direct query and = +for=20 + a
+
>prepared query?  For the prepared query do = +this:
+
 
+
>EXPLAIN ANALYZE EXECUTE stmt (...);
+
 
+
 Here is the EXPLAIN ANALYZE output for prepared statement = +:
+
 
+
QUERY PLAN
"HashAggregate  (cost=3D29.37..29.40 rows=3D1 = +width=3D58)=20 + (actual time=3D10.600..10.600 rows=3D0 loops=3D1)"
"  = +->  Nested=20 + Loop  (cost=3D9.55..29.36 rows=3D1 width=3D58) (actual = +time=3D10.594..10.594=20 + rows=3D0 loops=3D1)"
"        = +Join Filter:=20 + (((""inner"".hat_no)::text =3D (""outer"".hat_no)::text) AND=20 + (""inner"".sefer_kod =3D ""outer"".sefer_kod) AND = +(""inner"".plan_tarihi =3D=20 + ""outer"".plan_tarihi) AND (""inner"".bin_yer_kod =3D = +""outer"".bin_yer_kod) AND=20 + (""inner"".koltuk_no =3D=20 + ""outer"".koltuk_no))"
"       =20 + ->  Nested Loop  (cost=3D9.55..26.15 rows=3D1 width=3D93) = +(actual=20 + time=3D10.588..10.588 rows=3D0=20 + = +loops=3D1)"
"         &nb= +sp;   =20 + ->  Nested Loop  (cost=3D9.55..20.60 rows=3D1 width=3D65) = +(actual=20 + time=3D7.422..10.499 rows=3D1=20 + = +loops=3D1)"
"         &nb= +sp;         =20 + ->  Nested Loop  (cost=3D9.55..14.62 rows=3D1 width=3D48) = +(actual=20 + time=3D5.455..7.247 rows=3D41=20 + = +loops=3D1)"
"         &nb= +sp;           &nbs= +p;   =20 + Join Filter: (""outer"".sefer_tip_kod =3D=20 + = +""inner"".kod)"
"         = +;            = +    =20 + ->  Hash Join  (cost=3D9.55..13.58 rows=3D1 width=3D52) = +(actual=20 + time=3D5.432..6.131 rows=3D41=20 + = +loops=3D1)"
"         &nb= +sp;           &nbs= +p;         =20 + Hash Cond: (""outer"".kod =3D=20 + = +""inner"".varis_yer_kod)"
"       &= +nbsp;           &n= +bsp;           =20 + ->  Seq Scan on t_yer y2  (cost=3D0.00..3.44 rows=3D115 = +width=3D14)=20 + (actual time=3D0.018..0.375 rows=3D115=20 + = +loops=3D1)"
"         &nb= +sp;           &nbs= +p;            = +;   =20 + Filter: ((iptal)::text =3D=20 + = +'H'::text)"
"         &nb= +sp;           &nbs= +p;         =20 + ->  Hash  (cost=3D9.55..9.55 rows=3D1 width=3D46) (actual = + + time=3D5.352..5.352 rows=3D41=20 + = +loops=3D1)"
"         &nb= +sp;           &nbs= +p;            = +;   =20 + ->  Merge Join  (cost=3D9.45..9.55 rows=3D1 width=3D46) = +(actual=20 + time=3D4.713..5.182 rows=3D41=20 + = +loops=3D1)"
"         &nb= +sp;           &nbs= +p;            = +;         =20 + Merge Cond: (""outer"".kod =3D=20 + = +""inner"".kalkis_yer_kod)"
"       = +            &= +nbsp;           &n= +bsp;           =20 + ->  Index Scan using t_yer_pkey on t_yer y1  = +(cost=3D0.00..9.62=20 + rows=3D115 width=3D14) (actual time=3D0.021..0.176 rows=3D40=20 + = +loops=3D1)"
"         &nb= +sp;           &nbs= +p;            = +;            = +   =20 + Filter: ((iptal)::text =3D=20 + = +'H'::text)"
"         &nb= +sp;           &nbs= +p;            = +;         =20 + ->  Sort  (cost=3D9.45..9.45 rows=3D1 width=3D40) (actual = + + time=3D4.678..4.747 rows=3D41=20 + = +loops=3D1)"
"         &nb= +sp;           &nbs= +p;            = +;            = +   =20 + Sort Key:=20 + = +h.kalkis_yer_kod"
"        &nb= +sp;           &nbs= +p;            = +;            = +    =20 + ->  Nested Loop  (cost=3D4.51..9.44 rows=3D1 width=3D40) = +(actual=20 + time=3D0.412..4.389 rows=3D41=20 + = +loops=3D1)"
"         &nb= +sp;           &nbs= +p;            = +;            = +         =20 + Join Filter: ((""inner"".""no"")::text =3D=20 + = +(""outer"".hat_no)::text)"
"       = +            &= +nbsp;           &n= +bsp;           &nb= +sp;           =20 + ->  Hash Join  (cost=3D4.51..8.09 rows=3D1 width=3D27) = +(actual=20 + time=3D0.386..1.137 rows=3D41=20 + = +loops=3D1)"
"         &nb= +sp;           &nbs= +p;            = +;            = +            &= +nbsp;  =20 + Hash Cond: ((""outer"".durumu)::text =3D=20 + = +(""inner"".kod)::text)"
"       &nb= +sp;           &nbs= +p;            = +;            = +            &= +nbsp;    =20 + ->  Hash Join  (cost=3D2.25..5.80 rows=3D3 width=3D32) = +(actual=20 + time=3D0.193..0.751 rows=3D41=20 + = +loops=3D1)"
"         &nb= +sp;           &nbs= +p;            = +;            = +            &= +nbsp;        =20 + Hash Cond: ((""outer"".ek_dev)::text =3D=20 + = +(""inner"".kod)::text)"
"       &nb= +sp;           &nbs= +p;            = +;            = +            &= +nbsp;          =20 + ->  Seq Scan on t_seferler s  (cost=3D0.00..3.21 = +rows=3D41 width=3D37)=20 + (actual time=3D0.009..0.258 rows=3D41=20 + = +loops=3D1)"
"         &nb= +sp;           &nbs= +p;            = +;            = +            &= +nbsp;           &n= +bsp;  =20 + Filter: (((iptal)::text =3D 'H'::text) AND ((iptal)::text =3D = +'H'::text) AND=20 + ((firma_no)::text =3D=20 + = +'1'::text))"
"         &n= +bsp;           &nb= +sp;           &nbs= +p;            = +;            = +         =20 + ->  Hash  (cost=3D2.25..2.25 rows=3D2 width=3D5) (actual=20 + time=3D0.141..0.141 rows=3D2=20 + = +loops=3D1)"
"         &nb= +sp;           &nbs= +p;            = +;            = +            &= +nbsp;           &n= +bsp;  =20 + ->  Seq Scan on t_domains d1  (cost=3D0.00..2.25 rows=3D2 = +width=3D5)=20 + (actual time=3D0.048..0.131 rows=3D2=20 + = +loops=3D1)"
"         &nb= +sp;           &nbs= +p;            = +;            = +            &= +nbsp;           &n= +bsp;        =20 + Filter: ((name)::text =3D=20 + = +'EKDEV'::text)"
"         = +;            = +            &= +nbsp;           &n= +bsp;           &nb= +sp;   =20 + ->  Hash  (cost=3D2.25..2.25 rows=3D2 width=3D5) (actual=20 + time=3D0.160..0.160 rows=3D2=20 + = +loops=3D1)"
"         &nb= +sp;           &nbs= +p;            = +;            = +            &= +nbsp;        =20 + ->  Seq Scan on t_domains d2  (cost=3D0.00..2.25 rows=3D2 = +width=3D5)=20 + (actual time=3D0.056..0.139 rows=3D2=20 + = +loops=3D1)"
"         &nb= +sp;           &nbs= +p;            = +;            = +            &= +nbsp;           &n= +bsp;  =20 + Filter: ((name)::text =3D=20 + = +'SFR_DURUMU'::text)"
"        = +            &= +nbsp;           &n= +bsp;           &nb= +sp;          =20 + ->  Seq Scan on t_hatlar h  (cost=3D0.00..1.23 rows=3D10 = +width=3D18)=20 + (actual time=3D0.004..0.045 rows=3D10=20 + = +loops=3D41)"
"         &n= +bsp;           &nb= +sp;           &nbs= +p;            = +;            = +   =20 + Filter: ('1'::text =3D=20 + = +(firma_no)::text)"
"        &n= +bsp;           &nb= +sp;    =20 + ->  Seq Scan on t_sefer_tip t  (cost=3D0.00..1.03 = +rows=3D1 width=3D9)=20 + (actual time=3D0.004..0.009 rows=3D1=20 + = +loops=3D41)"
"         &n= +bsp;           &nb= +sp;         =20 + Filter: (((iptal)::text =3D 'H'::text) AND ('1'::text =3D=20 + = +(firma_no)::text))"
"        &= +nbsp;          =20 + ->  Index Scan using t_lokal_plan_sefer_liste_idx on = +t_lokal_plan=20 + lp  (cost=3D0.00..5.97 rows=3D1 width=3D22) (actual = +time=3D0.071..0.072 rows=3D0=20 + = +loops=3D41)"
"         &n= +bsp;           &nb= +sp;   =20 + Index Cond: (((lp.firma_no)::text =3D '1'::text) AND = +((""outer"".hat_no)::text =3D=20 + (lp.hat_no)::text) AND (""outer"".kod =3D lp.sefer_kod) AND = +(lp.kalkis_tarihi =3D=20 + = +'2006-02-13'::date))"
"        = +;            = +     =20 + Filter: (lokal_kod =3D=20 + = +62)"
"          &nbs= +p;  =20 + ->  Index Scan using t_koltuk_son_durum_pkey on = +t_koltuk_son_durum=20 + sd  (cost=3D0.00..5.53 rows=3D1 width=3D28) (actual = +time=3D0.078..0.078 rows=3D0=20 + = +loops=3D1)"
"         &nb= +sp;         =20 + Index Cond: (('1'::text =3D (sd.firma_no)::text) AND = +((""outer"".hat_no)::text =3D=20 + (sd.hat_no)::text) AND (""outer"".kod =3D sd.sefer_kod) AND=20 + (""outer"".plan_tarihi =3D sd.plan_tarihi) AND (""outer"".yer_kod =3D=20 + = +sd.bin_yer_kod))"
"        &nb= +sp;          =20 + Filter: ((islem)::text =3D=20 + 'S'::text)"
"        ->  = +Index=20 + Scan using t_koltuk_islem_kod_ukey on t_koltuk_islem i  = +(cost=3D0.00..3.18=20 + rows=3D1 width=3D57) (never=20 + = +executed)"
"         &nbs= +p;   =20 + Index Cond: (i.kod =3D=20 + = +""outer"".islem_kod)"
"        = +;     =20 + Filter: ((firma_no)::text =3D '1'::text)"
"Total runtime: 11.856=20 +ms"
+
 
+
Adnan DURSUN
+
ASRIN Bili=FEim Ltd.=DEti
+
Ankara / TURKEY
+
 
+ +------=_NextPart_000_0007_01C630EC.2B9136F0-- + +From pgsql-performance-owner@postgresql.org Mon Feb 13 17:59:18 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 22C2F9DCC29 + for ; + Mon, 13 Feb 2006 17:59:18 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 33077-05 + for ; + Mon, 13 Feb 2006 17:59:19 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from hotmail.com (bay106-dav24.bay106.hotmail.com [65.54.161.96]) + by postgresql.org (Postfix) with ESMTP id A56529DCC22 + for ; + Mon, 13 Feb 2006 17:59:15 -0400 (AST) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Mon, 13 Feb 2006 13:59:17 -0800 +Message-ID: +Received: from 85.105.24.123 by BAY106-DAV24.phx.gbl with DAV; + Mon, 13 Feb 2006 21:59:16 +0000 +X-Originating-IP: [85.105.24.123] +X-Originating-Email: [a_dursun@hotmail.com] +X-Sender: a_dursun@hotmail.com +From: "Adnan DURSUN" +To: , + +Subject: Re: SQL Function Performance +Date: Mon, 13 Feb 2006 23:58:59 +0200 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0003_01C630F9.74C5AE20" +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-OriginalArrivalTime: 13 Feb 2006 21:59:17.0205 (UTC) + FILETIME=[BC0B7050:01C630E8] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=2.476 required=5 tests=[AWL=0.556, + DNS_FROM_RFC_ABUSE=0.479, DNS_FROM_RFC_POST=1.44, HTML_MESSAGE=0.001, + MSGID_FROM_MTA_HEADER=0] +X-Spam-Score: 2.476 +X-Spam-Level: ** +X-Archive-Number: 200602/146 +X-Sequence-Number: 17132 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0003_01C630F9.74C5AE20 +Content-Type: text/plain; + charset="iso-8859-9" +Content-Transfer-Encoding: quoted-printable + +>From: Mark Liberman +>Date: 02/13/06 22:09:48 +>To: Adnan DURSUN; pgsql-performance@postgresql.org +>Subject: RE: [PERFORM] SQL Function Performance + +>I've run into this issue. It basically comes down to the plan that is = +being used inside the function is not the same as the plan used when you = +issue the query manually >outside of the function. Although I'm no = +expert on when plans are prepared and re-evaluated for functions, I know = +that they are not re-evaluated each time to execute the >function. + + + in my case; both direct query and sql function gererate same execution = +plan. Also, execution plan belongs to the sql function better than = +direct sql query plan. But, direct sql result comes less than 1 second. = +sql function result comes about in 50 seconds. + +Adnan DURSUN +ASRIN Bili=FEim Ltd.=DEti +------=_NextPart_000_0003_01C630F9.74C5AE20 +Content-Type: text/html; + charset="iso-8859-9" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
+ +
+
>Date: = +02/13/06=20 +22:09:48
+
>To: Adnan DURSUN; pgsql-performance@postgr= +esql.org
+
>Subject: RE: = +[PERFORM]=20 +SQL Function Performance
+
 
+

>I've run into this issue. It basically comes down = +to the=20 +plan that is being used inside the function is not the same as the plan = +used=20 +when you issue the query manually >outside of the function.  = +Although=20 +I'm no expert on when plans are prepared and re-evaluated for functions, = +I know=20 +that they are not re-evaluated each time to execute the=20 +>function.

+

 in my case; both direct query and sql function = +gererate=20 +same execution plan. Also, execution plan belongs to the sql function = +better=20 +than direct sql query plan. But, direct sql result comes less than 1 = +second. sql=20 +function result comes about in 50 seconds.

+
+
Adnan DURSUN
+
ASRIN Bili=FEim Ltd.=DEti
+ +------=_NextPart_000_0003_01C630F9.74C5AE20-- + +From pgsql-performance-owner@postgresql.org Sat Feb 18 00:09:50 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 612389DCC18 + for ; + Mon, 13 Feb 2006 19:45:16 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 56314-06 + for ; + Mon, 13 Feb 2006 19:45:18 -0400 (AST) +X-Greylist: delayed 03:35:57.7871 by SQLgrey- +Received: from mail.goldpocket.com (mail1.goldpocket.com [38.101.116.14]) + by postgresql.org (Postfix) with ESMTP id 42CB09DCABF + for ; + Mon, 13 Feb 2006 19:45:14 -0400 (AST) +Received: from localhost (unknown [127.0.0.1]) + by mail.goldpocket.com (Postfix) with ESMTP id 5CF6CE048842 + for ; + Mon, 13 Feb 2006 23:45:16 +0000 (UTC) +Received: from mail.goldpocket.com ([127.0.0.1]) + by localhost (mail.goldpocket.com [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 25068-12 for ; + Mon, 13 Feb 2006 15:45:16 -0800 (PST) +Received: from mail1.goldpocket.com (srvgpimail1.gpi.local [10.10.0.13]) + by mail.goldpocket.com (Postfix) with ESMTP id E717CE048B96 + for ; + Mon, 13 Feb 2006 15:45:13 -0800 (PST) +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_01C630F7.88CCFE47" +Subject: Re: SQL Function Performance +Date: Mon, 13 Feb 2006 15:45:13 -0800 +Message-ID: <9D938282F8C6EE43B748B910386DE93E0138B3F3@srvgpimail1.GPI.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] SQL Function Performance +Thread-Index: AcYw6L7Ca3r79fBcT3K2lqotVv907AADWC7J +From: "Mark Liberman" +To: "Adnan DURSUN" , +X-Virus-Scanned: amavisd-new at goldpocket.com +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.001 required=5 tests=[HTML_MESSAGE=0.001] +X-Spam-Score: 0.001 +X-Spam-Level: +X-Archive-Number: 200602/293 +X-Sequence-Number: 17279 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C630F7.88CCFE47 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +> in my case; both direct query and sql function gererate same execution = +plan. Also, execution plan belongs to the sql function better than = +direct sql > query plan. But, direct sql result comes less than 1 = +second. sql function result comes about in 50 seconds. + +How are you getting at the plan inside your function? If you just do an = +EXPLAIN on the function call you get a FUNCTION SCAN line in your plan, = +which tells you nothing. I remember I had to work through some process = +for catching the output of the Explain plan in a cursor and returning = +that to actually see the plan. I saw in a previous response he = +suggested using a PREPARE and EXECUTE against that. I'm not sure that's = +the same as what's going on in the function (although I could be wrong). + +Just humor me and try creating the sql query in the fuction in a text = +variable and then Executing it. =20 + +Prior to that, however, you might try just recreating the function. The = +plan may be re-evaluated at that point. + +- Mark + + + +------_=_NextPart_001_01C630F7.88CCFE47 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + +RE: [PERFORM] SQL Function Performance + + + + +

> in my case; both direct query and sql function = +gererate same execution plan. Also, execution plan belongs to the sql = +function better than direct sql > query plan. But, direct sql result = +comes less than 1 second. sql function result comes about in 50 = +seconds.
+
+How are you getting at the plan inside your function?  If you just = +do an EXPLAIN on the function call you get a FUNCTION SCAN line in your = +plan, which tells you nothing.  I remember I had to work through = +some process for catching the output of the Explain plan in a cursor and = +returning that to actually see the plan.  I saw in a previous = +response he suggested using a PREPARE and EXECUTE against that.  = +I'm not sure that's the same as what's going on in the function = +(although I could be wrong).
+
+Just humor me and try creating the sql query in the fuction in a text = +variable and then Executing it. 
+
+Prior to that, however, you might try just recreating the = +function.  The plan may be re-evaluated at that point.
+
+- Mark
+
+
+
+

+ + + +------_=_NextPart_001_01C630F7.88CCFE47-- + +From pgsql-performance-owner@postgresql.org Mon Feb 13 20:17:09 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 7DAED9DCC4F + for ; + Mon, 13 Feb 2006 20:17:08 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 62690-07 + for ; + Mon, 13 Feb 2006 20:17:11 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from hotmail.com (bay106-dav1.bay106.hotmail.com [65.54.161.73]) + by postgresql.org (Postfix) with ESMTP id 3223B9DCC44 + for ; + Mon, 13 Feb 2006 20:17:06 -0400 (AST) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Mon, 13 Feb 2006 16:17:09 -0800 +Message-ID: +Received: from 85.105.24.123 by BAY106-DAV1.phx.gbl with DAV; + Tue, 14 Feb 2006 00:17:08 +0000 +X-Originating-IP: [85.105.24.123] +X-Originating-Email: [a_dursun@hotmail.com] +X-Sender: a_dursun@hotmail.com +From: "Adnan DURSUN" +To: , + +Subject: Re: SQL Function Performance +Date: Tue, 14 Feb 2006 02:16:49 +0200 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0003_01C6310C.B62192E0" +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-OriginalArrivalTime: 14 Feb 2006 00:17:09.0297 (UTC) + FILETIME=[FE988210:01C630FB] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=2.369 required=5 tests=[AWL=0.449, + DNS_FROM_RFC_ABUSE=0.479, DNS_FROM_RFC_POST=1.44, HTML_MESSAGE=0.001, + MSGID_FROM_MTA_HEADER=0] +X-Spam-Score: 2.369 +X-Spam-Level: ** +X-Archive-Number: 200602/147 +X-Sequence-Number: 17133 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0003_01C6310C.B62192E0 +Content-Type: text/plain; + charset="iso-8859-9" +Content-Transfer-Encoding: quoted-printable + +-------Original Message------- + +From: Mark Liberman +Date: 02/14/06 01:46:16 +To: Adnan DURSUN; pgsql-performance@postgresql.org +Subject: RE: [PERFORM] SQL Function Performance + +>> in my case; both direct query and sql function gererate same = +execution plan. Also, execution plan belongs to the sql function better = +than direct sql=20 +>> query plan. But, direct sql result comes less than 1 second. sql = +function result comes about in 50 seconds. + +>How are you getting at the plan inside your function? If you just do = +an EXPLAIN on the function call you get a FUNCTION SCAN line in your = +plan, which tells you >nothing. I remember I had to work through some = +process for catching the output of the Explain plan in a cursor and = +returning that to actually see the plan. I saw in a >previous response = +he suggested using a PREPARE and EXECUTE against that. I'm not sure = +that's the same as what's going on in the function (although I could be = +>wrong). + + Yes, i have got sql function prepared execution plan using PREPARE = +and EXECUTE that he suggested to me.=20 + + +>Just humor me and try creating the sql query in the fuction in a text = +variable and then Executing it.=20 + + But i believe that, that behavior of PostgreSQL is not good. It = +should handle this case. PostgreSQL has this "sql function" = +functionality and it should + give good serve...Of course, i will do your suggesion if i dont solve = +it. + +>Prior to that, however, you might try just recreating the function. = +The plan may be re-evaluated at that point. + Ok. i did it many times. But nothing was changed.. +- Mark + + + +Adnan DURSUN +ASRIN Bili=FEim Ltd.=DEti + + + + +------=_NextPart_000_0003_01C6310C.B62192E0 +Content-Type: text/html; + charset="iso-8859-9" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
+
-------Original = +Message-------
+
 
+
+
From: Mark Liberman
+
Date: 02/14/06 = +01:46:16
+
To: Adnan DURSUN; pgsql-performance@postgr= +esql.org
+
Subject: RE: = +[PERFORM] SQL=20 +Function Performance
+
 
+

>> in my case; both direct query and sql = +function gererate=20 +same execution plan. Also, execution plan belongs to the sql function = +better=20 +than direct sql
>> query plan. But, direct sql result comes = +less than=20 +1 second. sql function result comes about in 50 seconds.

>How = +are you=20 +getting at the plan inside your function?  If you just do an = +EXPLAIN on the=20 +function call you get a FUNCTION SCAN line in your plan, which tells you = + +>nothing.  I remember I had to work through some process for = +catching=20 +the output of the Explain plan in a cursor and returning that to = +actually see=20 +the plan.  I saw in a >previous response he suggested using a = +PREPARE=20 +and EXECUTE against that.  I'm not sure that's the same as what's = +going on=20 +in the function (although I could be >wrong).

   = +Yes, i have=20 +got sql function prepared execution plan using PREPARE and EXECUTE that = +he=20 +suggested to me.

+


>Just humor me and try creating the sql query in the fuction = +in a text=20 +variable and then Executing it. 

   But i believe = +that,=20 +that behavior of PostgreSQL is not good. It should handle this case. = +PostgreSQL=20 +has this "sql function" functionality and it=20 +should
   give good serve...Of course, i will do your=20 +suggesion if i dont solve it.

>Prior to that, however, you = +might try=20 +just recreating the function.  The plan may be re-evaluated at that = + +point.
    Ok. i did it many times. But nothing was=20 +changed..
- Mark

+
 
+
Adnan DURSUN
+
ASRIN Bili=FEim Ltd.=DEti
+


+
 
+ +------=_NextPart_000_0003_01C6310C.B62192E0-- + +From pgsql-performance-owner@postgresql.org Mon Feb 13 20:57:11 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 555E99DC825 + for ; + Mon, 13 Feb 2006 20:57:11 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 68141-07 + for ; + Mon, 13 Feb 2006 20:57:14 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 278689DC821 + for ; + Mon, 13 Feb 2006 20:57:08 -0400 (AST) +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 k1E0v7vc007001; + Mon, 13 Feb 2006 19:57:07 -0500 (EST) +To: "Adnan DURSUN" +cc: pgsql-performance@postgresql.org, mike@fuhr.org +Subject: Re: SQL Function Performance +In-reply-to: +References: +Comments: In-reply-to "Adnan DURSUN" + message dated "Mon, 13 Feb 2006 22:23:52 +0200" +Date: Mon, 13 Feb 2006 19:57:07 -0500 +Message-ID: <7000.1139878627@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.109 required=5 tests=[AWL=0.109] +X-Spam-Score: 0.109 +X-Spam-Level: +X-Archive-Number: 200602/148 +X-Sequence-Number: 17134 + +"Adnan DURSUN" writes: +>>>> EXPLAIN ANALYZE EXECUTE stmt (...); + +> Here is the EXPLAIN ANALYZE output for prepared statement : + +This is exactly the same as the other plan --- you did not parameterize +the query. To see what's going on, you need to insert PREPARE +parameters in the places where the function uses plpgsql variables. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Feb 13 21:31:59 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 842039DCB6D + for ; + Mon, 13 Feb 2006 21:31:58 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 76071-06 + for ; + Mon, 13 Feb 2006 21:32:01 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) + by postgresql.org (Postfix) with ESMTP id 26E6B9DCA62 + for ; + Mon, 13 Feb 2006 21:31:55 -0400 (AST) +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 k1E1Vt7V055954 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); + Mon, 13 Feb 2006 18:31:57 -0700 (MST) + (envelope-from mfuhr@winnie.fuhr.org) +Received: from winnie.fuhr.org (localhost [127.0.0.1]) + by winnie.fuhr.org (8.13.4/8.13.4) with ESMTP id k1E1VsoG074994; + Mon, 13 Feb 2006 18:31:54 -0700 (MST) + (envelope-from mfuhr@winnie.fuhr.org) +Received: (from mfuhr@localhost) + by winnie.fuhr.org (8.13.4/8.13.4/Submit) id k1E1VsKB074993; + Mon, 13 Feb 2006 18:31:54 -0700 (MST) (envelope-from mfuhr) +Date: Mon, 13 Feb 2006 18:31:54 -0700 +From: Michael Fuhr +To: Tom Lane +Cc: Adnan DURSUN , pgsql-performance@postgresql.org +Subject: Re: SQL Function Performance +Message-ID: <20060214013154.GA74883@winnie.fuhr.org> +References: + <7000.1139878627@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <7000.1139878627@sss.pgh.pa.us> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120, UPPERCASE_25_50=0] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200602/149 +X-Sequence-Number: 17135 + +On Mon, Feb 13, 2006 at 07:57:07PM -0500, Tom Lane wrote: +> "Adnan DURSUN" writes: +> >>>> EXPLAIN ANALYZE EXECUTE stmt (...); +> +> > Here is the EXPLAIN ANALYZE output for prepared statement : +> +> This is exactly the same as the other plan --- you did not parameterize +> the query. To see what's going on, you need to insert PREPARE +> parameters in the places where the function uses plpgsql variables. + +Actually it was an SQL function, but that also does PREPARE/EXECUTE, +right? + +Adnan, what Tom is saying is that I requested this (simplified): + +PREPARE stmt (integer) AS SELECT * FROM foo WHERE id = $1; +EXPLAIN ANALYZE EXECUTE stmt (12345); + +but instead you appear to have done this: + +PREPARE stmt AS SELECT * FROM foo WHERE id = 12345; +EXPLAIN ANALYZE EXECUTE stmt; + +We can tell because if you had done it the first way (parameterized) +then the EXPLAIN ANALYZE output would have shown the parameters as +$1, $2, $3, etc., which it didn't. + +-- +Michael Fuhr + +From pgsql-performance-owner@postgresql.org Sat Feb 18 00:09:54 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 06E939DCA62 + for ; + Mon, 13 Feb 2006 22:32:27 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 86923-07 + for ; + Mon, 13 Feb 2006 22:32:31 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id 82C119DC86C + for ; + Mon, 13 Feb 2006 22:32:24 -0400 (AST) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 8F30A3093C; Tue, 14 Feb 2006 03:32:27 +0100 (MET) +From: Chris +X-Newsgroups: pgsql.performance +Subject: Re: Optimizing performance of a like '%...%' condition +Date: Tue, 14 Feb 2006 13:32:32 +1100 +Organization: Hub.Org Networking Services +Lines: 19 +Message-ID: <43F14140.8050005@gmail.com> +References: <1139586432.014319.114830@g47g2000cwa.googlegroups.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +To: Nico +User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) +X-Accept-Language: en-us, en +In-Reply-To: <1139586432.014319.114830@g47g2000cwa.googlegroups.com> +X-Antivirus: avast! (VPS 0607-0, 13/02/2006), Outbound message +X-Antivirus-Status: Clean +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200602/294 +X-Sequence-Number: 17280 + + +> Indexing the t_name.name field, I can increase speed, but only if I +> restrict my search to something like : +> +> select * +> from t_name +> where t_name.name like 'my_search%' +> +> (In this case it takes generally less than 1 second) +> +> +> My question : Are there algorithms or tools that can speed up such a +> type of queries ("like" condition begining with a "%" symbol) ? + +Apart from indexing the field you could use full text indexing. See +http://techdocs.postgresql.org/techdocs/fulltextindexing.php + + +What other types of queries are you running that you want to speed up ? + +From pgsql-performance-owner@postgresql.org Tue Feb 14 05:34:30 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 06A2E9DC803 + for ; + Tue, 14 Feb 2006 05:34:29 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 65971-09 + for ; + Tue, 14 Feb 2006 05:34:19 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from hotmail.com (bay106-dav19.bay106.hotmail.com [65.54.161.91]) + by postgresql.org (Postfix) with ESMTP id 182CD9DC80C + for ; + Tue, 14 Feb 2006 05:34:15 -0400 (AST) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Tue, 14 Feb 2006 01:34:17 -0800 +Message-ID: +Received: from 85.105.24.123 by BAY106-DAV19.phx.gbl with DAV; + Tue, 14 Feb 2006 09:34:17 +0000 +X-Originating-IP: [85.105.24.123] +X-Originating-Email: [a_dursun@hotmail.com] +X-Sender: a_dursun@hotmail.com +From: "Adnan DURSUN" +To: +Subject: Re: SQL Function Performance +Date: Tue, 14 Feb 2006 11:33:57 +0200 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0003_01C6315A.8B2FEF70" +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-OriginalArrivalTime: 14 Feb 2006 09:34:17.0848 (UTC) + FILETIME=[D3909780:01C63149] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=2.883 required=5 tests=[AWL=-0.237, + DNS_FROM_RFC_ABUSE=0.479, DNS_FROM_RFC_POST=1.44, HTML_MESSAGE=0.001, + MSGID_FROM_MTA_HEADER=0, WEIRD_QUOTING=1.2] +X-Spam-Score: 2.883 +X-Spam-Level: ** +X-Archive-Number: 200602/150 +X-Sequence-Number: 17136 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0003_01C6315A.8B2FEF70 +Content-Type: text/plain; + charset="iso-8859-9" +Content-Transfer-Encoding: quoted-printable + + +From: Michael Fuhr +Date: 02/14/06 03:32:28 +To: Tom Lane +Cc: Adnan DURSUN; pgsql-performance@postgresql.org +Subject: Re: [PERFORM] SQL Function Performance + +On Mon, Feb 13, 2006 at 07:57:07PM -0500, Tom Lane wrote: +>> "Adnan DURSUN" writes: +>> >>>> EXPLAIN ANALYZE EXECUTE stmt (...); +>> +>> > Here is the EXPLAIN ANALYZE output for prepared statement : +>> +>> This is exactly the same as the other plan --- you did not = +parameterize +>> the query. To see what's going on, you need to insert PREPARE +>> parameters in the places where the function uses plpgsql variables. + +>Actually it was an SQL function, but that also does PREPARE/EXECUTE, +>right? + +>Adnan, what Tom is saying is that I requested this (simplified): + +>PREPARE stmt (integer) AS SELECT * FROM foo WHERE id =3D $1; +>EXPLAIN ANALYZE EXECUTE stmt (12345); + +Ok. I am sending right execution plan. I made mistake apologize me.. + + QUERY PLAN +"HashAggregate (cost=3D276.73..276.76 rows=3D1 width=3D58) (actual = +time=3D192648.385..192648.385 rows=3D0 loops=3D1)" +" -> Nested Loop (cost=3D5.90..276.71 rows=3D1 width=3D58) (actual = +time=3D192648.377..192648.377 rows=3D0 loops=3D1)" +" Join Filter: (((""inner"".hat_no)::text =3D = +(""outer"".hat_no)::text) AND (""inner"".sefer_kod =3D = +""outer"".sefer_kod) AND (""inner"".plan_tarihi =3D = +""outer"".plan_tarihi) AND (""inner"".bin_yer_kod =3D = +""outer"".bin_yer_kod) AND (""inner"".koltuk_no =3D ""outer"".koltuk_no) = +AND (((""inner"".islem_tarihi =3D $2) AND (($5)::text =3D 'I'::text)) OR = +((""outer"".kalkis_tarihi =3D $2) AND (($5)::text =3D 'K'::text))) AND = +(((""outer"".lokal_kod =3D $3) AND (($4)::text =3D 'K'::text)) OR = +((""inner"".ypt_lcl_kod =3D $3) AND (($4)::text =3D 'I'::text))))" +" -> Nested Loop (cost=3D5.90..267.19 rows=3D3 width=3D101) = +(actual time=3D76.240..30974.777 rows=3D63193 loops=3D1)" +" -> Nested Loop (cost=3D5.90..123.48 rows=3D26 = +width=3D73) (actual time=3D32.082..4357.786 rows=3D14296 loops=3D1)" +" -> Nested Loop (cost=3D3.62..15.29 rows=3D1 = +width=3D48) (actual time=3D1.279..46.882 rows=3D41 loops=3D1)" +" Join Filter: ((""inner"".kod)::text =3D = +(""outer"".durumu)::text)" +" -> Nested Loop (cost=3D3.62..13.01 rows=3D1 = +width=3D53) (actual time=3D1.209..40.010 rows=3D41 loops=3D1)" +" -> Nested Loop (cost=3D3.62..8.49 = +rows=3D1 width=3D47) (actual time=3D1.150..38.928 rows=3D41 loops=3D1)" +" Join Filter: = +((""inner"".""no"")::text =3D (""outer"".hat_no)::text)" +" -> Nested Loop = +(cost=3D2.25..6.79 rows=3D1 width=3D28) (actual time=3D0.710..24.708 = +rows=3D41 loops=3D1)" +" Join Filter: = +(""inner"".sefer_tip_kod =3D ""outer"".kod)" +" -> Seq Scan on t_sefer_tip = +t (cost=3D0.00..1.03 rows=3D1 width=3D9) (actual time=3D0.117..0.126 = +rows=3D1 loops=3D1)" +" Filter: = +(((iptal)::text =3D 'H'::text) AND (($1)::text =3D (firma_no)::text))" +" -> Hash Join = +(cost=3D2.25..5.74 rows=3D2 width=3D32) (actual time=3D0.567..24.349 = +rows=3D41 loops=3D1)" +" Hash Cond: = +((""outer"".ek_dev)::text =3D (""inner"".kod)::text)" +" -> Seq Scan on = +t_seferler s (cost=3D0.00..3.21 rows=3D34 width=3D37) (actual = +time=3D0.077..23.466 rows=3D41 loops=3D1)" +" Filter: = +(((iptal)::text =3D 'H'::text) AND ((iptal)::text =3D 'H'::text) AND = +((firma_no)::text =3D ($1)::text))" +" -> Hash = +(cost=3D2.25..2.25 rows=3D2 width=3D5) (actual time=3D0.451..0.451 = +rows=3D2 loops=3D1)" +" -> Seq Scan on = +t_domains d1 (cost=3D0.00..2.25 rows=3D2 width=3D5) (actual = +time=3D0.346..0.429 rows=3D2 loops=3D1)" +" Filter: = +((name)::text =3D 'EKDEV'::text)" +" -> Merge Join = +(cost=3D1.37..1.59 rows=3D9 width=3D24) (actual time=3D0.032..0.313 = +rows=3D10 loops=3D41)" +" Merge Cond: (""outer"".kod = +=3D ""inner"".kalkis_yer_kod)" +" -> Index Scan using = +t_yer_pkey on t_yer y1 (cost=3D0.00..9.62 rows=3D115 width=3D14) = +(actual time=3D0.013..0.164 rows=3D40 loops=3D41)" +" Filter: = +((iptal)::text =3D 'H'::text)" +" -> Sort = +(cost=3D1.37..1.39 rows=3D9 width=3D18) (actual time=3D0.007..0.025 = +rows=3D10 loops=3D41)" +" Sort Key: = +h.kalkis_yer_kod" +" -> Seq Scan on = +t_hatlar h (cost=3D0.00..1.23 rows=3D9 width=3D18) (actual = +time=3D0.078..0.125 rows=3D10 loops=3D1)" +" Filter: = +(($1)::text =3D (firma_no)::text)" +" -> Index Scan using t_yer_pkey on = +t_yer y2 (cost=3D0.00..4.51 rows=3D1 width=3D14) (actual = +time=3D0.011..0.015 rows=3D1 loops=3D41)" +" Index Cond: = +(""outer"".varis_yer_kod =3D y2.kod)" +" Filter: ((iptal)::text =3D = +'H'::text)" +" -> Seq Scan on t_domains d2 = +(cost=3D0.00..2.25 rows=3D2 width=3D5) (actual time=3D0.054..0.140 = +rows=3D2 loops=3D41)" +" Filter: ((name)::text =3D = +'SFR_DURUMU'::text)" +" -> Bitmap Heap Scan on t_lokal_plan lp = +(cost=3D2.28..107.70 rows=3D33 width=3D30) (actual time=3D9.709..103.130 = +rows=3D349 loops=3D41)" +" Recheck Cond: (((lp.firma_no)::text =3D = +($1)::text) AND ((""outer"".hat_no)::text =3D (lp.hat_no)::text) AND = +(""outer"".kod =3D lp.sefer_kod))" +" -> Bitmap Index Scan on t_lokal_plan_pkey = +(cost=3D0.00..2.28 rows=3D33 width=3D0) (actual time=3D8.340..8.340 = +rows=3D349 loops=3D41)" +" Index Cond: (((lp.firma_no)::text =3D = +($1)::text) AND ((""outer"".hat_no)::text =3D (lp.hat_no)::text) AND = +(""outer"".kod =3D lp.sefer_kod))" +" -> Index Scan using t_koltuk_son_durum_pkey on = +t_koltuk_son_durum sd (cost=3D0.00..5.51 rows=3D1 width=3D28) (actual = +time=3D0.467..1.829 rows=3D4 loops=3D14296)" +" Index Cond: ((($1)::text =3D (sd.firma_no)::text) = +AND ((""outer"".hat_no)::text =3D (sd.hat_no)::text) AND (""outer"".kod = +=3D sd.sefer_kod) AND (""outer"".plan_tarihi =3D sd.plan_tarihi) AND = +(""outer"".yer_kod =3D sd.bin_yer_kod))" +" Filter: ((islem)::text =3D 'S'::text)" +" -> Index Scan using t_koltuk_islem_kod_ukey on t_koltuk_islem = +i (cost=3D0.00..3.13 rows=3D1 width=3D65) (actual time=3D2.534..2.538 = +rows=3D1 loops=3D63193)" +" Index Cond: (i.kod =3D ""outer"".islem_kod)" +" Filter: ((firma_no)::text =3D ($1)::text)" +"Total runtime: 192649.904 ms" + +Adnan DURSUN +ASRIN Bili=FEim Ltd.=DEti + +------=_NextPart_000_0003_01C6315A.8B2FEF70 +Content-Type: text/html; + charset="iso-8859-9" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
+
 
+
+
From: Michael Fuhr
+
Date: 02/14/06 = +03:32:28
+
To: Tom Lane
+
Cc: Adnan DURSUN; pgsql-performance@postgr= +esql.org
+
Subject: Re: = +[PERFORM] SQL=20 +Function Performance
+
 
+
On Mon, Feb 13, 2006 at 07:57:07PM -0500, Tom Lane wrote:
+
>> "Adnan DURSUN" <a_dursun@hotmail.com> = +writes:
+
>> >>>> EXPLAIN ANALYZE EXECUTE stmt (...);
+
>>
+
>> >    Here is the EXPLAIN ANALYZE = +output for=20 +prepared statement :
+
>>
+
>> This is exactly the same as the other plan --- you did not = + +parameterize
+
>> the query.  To see what's going on, you need to = +insert=20 +PREPARE
+
>> parameters in the places where the function uses plpgsql=20 +variables.
+
 
+
>Actually it was an SQL function, but that also does=20 +PREPARE/EXECUTE,
+
>right?
+
 
+
>Adnan, what Tom is saying is that I requested this = +(simplified):
+
 
+
>PREPARE stmt (integer) AS SELECT * FROM foo WHERE id =3D = +$1;
+
>EXPLAIN ANALYZE EXECUTE stmt (12345);
+
 
+
Ok. I am sending right execution plan.  I made mistake = +apologize=20 +me..
+
 
+
+
   QUERY PLAN
"HashAggregate  = +(cost=3D276.73..276.76 rows=3D1=20 +width=3D58) (actual time=3D192648.385..192648.385 rows=3D0 = +loops=3D1)"
" =20 +->  Nested Loop  (cost=3D5.90..276.71 rows=3D1 width=3D58) = +(actual=20 +time=3D192648.377..192648.377 rows=3D0=20 +loops=3D1)"
"        Join Filter:=20 +(((""inner"".hat_no)::text =3D (""outer"".hat_no)::text) AND = +(""inner"".sefer_kod=20 +=3D ""outer"".sefer_kod) AND (""inner"".plan_tarihi =3D = +""outer"".plan_tarihi) AND=20 +(""inner"".bin_yer_kod =3D ""outer"".bin_yer_kod) AND = +(""inner"".koltuk_no =3D=20 +""outer"".koltuk_no) AND (((""inner"".islem_tarihi =3D $2) AND = +(($5)::text =3D=20 +'I'::text)) OR ((""outer"".kalkis_tarihi =3D $2) AND (($5)::text =3D = +'K'::text)))=20 +AND (((""outer"".lokal_kod =3D $3) AND (($4)::text =3D 'K'::text)) OR=20 +((""inner"".ypt_lcl_kod =3D $3) AND (($4)::text =3D=20 +'I'::text))))"
"        = +->  Nested=20 +Loop  (cost=3D5.90..267.19 rows=3D3 width=3D101) (actual = +time=3D76.240..30974.777=20 +rows=3D63193=20 +loops=3D1)"
"         &nb= +sp;   =20 +->  Nested Loop  (cost=3D5.90..123.48 rows=3D26 width=3D73) = +(actual=20 +time=3D32.082..4357.786 rows=3D14296=20 +loops=3D1)"
"         &nb= +sp;         =20 +->  Nested Loop  (cost=3D3.62..15.29 rows=3D1 width=3D48) = +(actual=20 +time=3D1.279..46.882 rows=3D41=20 +loops=3D1)"
"         &nb= +sp;           &nbs= +p;   =20 +Join Filter: ((""inner"".kod)::text =3D=20 +(""outer"".durumu)::text)"
"       = +            &= +nbsp;     =20 +->  Nested Loop  (cost=3D3.62..13.01 rows=3D1 width=3D53) = +(actual=20 +time=3D1.209..40.010 rows=3D41=20 +loops=3D1)"
"         &nb= +sp;           &nbs= +p;         =20 +->  Nested Loop  (cost=3D3.62..8.49 rows=3D1 width=3D47) = +(actual=20 +time=3D1.150..38.928 rows=3D41=20 +loops=3D1)"
"         &nb= +sp;           &nbs= +p;            = +;   =20 +Join Filter: ((""inner"".""no"")::text =3D=20 +(""outer"".hat_no)::text)"
"       = +            &= +nbsp;           &n= +bsp;     =20 +->  Nested Loop  (cost=3D2.25..6.79 rows=3D1 width=3D28) = +(actual=20 +time=3D0.710..24.708 rows=3D41=20 +loops=3D1)"
"         &nb= +sp;           &nbs= +p;            = +;         =20 +Join Filter: (""inner"".sefer_tip_kod =3D=20 +""outer"".kod)"
"         = +;            = +            &= +nbsp;         =20 +->  Seq Scan on t_sefer_tip t  (cost=3D0.00..1.03 rows=3D1 = +width=3D9)=20 +(actual time=3D0.117..0.126 rows=3D1=20 +loops=3D1)"
"         &nb= +sp;           &nbs= +p;            = +;            = +   =20 +Filter: (((iptal)::text =3D 'H'::text) AND (($1)::text =3D=20 +(firma_no)::text))"
"        &= +nbsp;           &n= +bsp;           &nb= +sp;          =20 +->  Hash Join  (cost=3D2.25..5.74 rows=3D2 width=3D32) = +(actual=20 +time=3D0.567..24.349 rows=3D41=20 +loops=3D1)"
"         &nb= +sp;           &nbs= +p;            = +;            = +   =20 +Hash Cond: ((""outer"".ek_dev)::text =3D=20 +(""inner"".kod)::text)"
"       &nb= +sp;           &nbs= +p;            = +;            = +     =20 +->  Seq Scan on t_seferler s  (cost=3D0.00..3.21 rows=3D34 = +width=3D37)=20 +(actual time=3D0.077..23.466 rows=3D41=20 +loops=3D1)"
"         &nb= +sp;           &nbs= +p;            = +;            = +         =20 +Filter: (((iptal)::text =3D 'H'::text) AND ((iptal)::text =3D 'H'::text) = +AND=20 +((firma_no)::text =3D=20 +($1)::text))"
"         &= +nbsp;           &n= +bsp;           &nb= +sp;           &nbs= +p;   =20 +->  Hash  (cost=3D2.25..2.25 rows=3D2 width=3D5) (actual=20 +time=3D0.451..0.451 rows=3D2=20 +loops=3D1)"
"         &nb= +sp;           &nbs= +p;            = +;            = +         =20 +->  Seq Scan on t_domains d1  (cost=3D0.00..2.25 rows=3D2 = +width=3D5)=20 +(actual time=3D0.346..0.429 rows=3D2=20 +loops=3D1)"
"         &nb= +sp;           &nbs= +p;            = +;            = +            &= +nbsp;  =20 +Filter: ((name)::text =3D=20 +'EKDEV'::text)"
"         = +;            = +            &= +nbsp;   =20 +->  Merge Join  (cost=3D1.37..1.59 rows=3D9 width=3D24) = +(actual=20 +time=3D0.032..0.313 rows=3D10=20 +loops=3D41)"
"         &n= +bsp;           &nb= +sp;           &nbs= +p;         =20 +Merge Cond: (""outer"".kod =3D=20 +""inner"".kalkis_yer_kod)"
"       = +            &= +nbsp;           &n= +bsp;           =20 +->  Index Scan using t_yer_pkey on t_yer y1  = +(cost=3D0.00..9.62=20 +rows=3D115 width=3D14) (actual time=3D0.013..0.164 rows=3D40=20 +loops=3D41)"
"         &n= +bsp;           &nb= +sp;           &nbs= +p;            = +;   =20 +Filter: ((iptal)::text =3D=20 +'H'::text)"
"         &nb= +sp;           &nbs= +p;            = +;         =20 +->  Sort  (cost=3D1.37..1.39 rows=3D9 width=3D18) (actual=20 +time=3D0.007..0.025 rows=3D10=20 +loops=3D41)"
"         &n= +bsp;           &nb= +sp;           &nbs= +p;            = +;   =20 +Sort Key:=20 +h.kalkis_yer_kod"
"        &nb= +sp;           &nbs= +p;            = +;            = +    =20 +->  Seq Scan on t_hatlar h  (cost=3D0.00..1.23 rows=3D9 = +width=3D18)=20 +(actual time=3D0.078..0.125 rows=3D10=20 +loops=3D1)"
"         &nb= +sp;           &nbs= +p;            = +;            = +         =20 +Filter: (($1)::text =3D=20 +(firma_no)::text)"
"        &n= +bsp;           &nb= +sp;          =20 +->  Index Scan using t_yer_pkey on t_yer y2  = +(cost=3D0.00..4.51=20 +rows=3D1 width=3D14) (actual time=3D0.011..0.015 rows=3D1=20 +loops=3D41)"
"         &n= +bsp;           &nb= +sp;           &nbs= +p;   =20 +Index Cond: (""outer"".varis_yer_kod =3D=20 +y2.kod)"
"          = +            &= +nbsp;           &n= +bsp;  =20 +Filter: ((iptal)::text =3D=20 +'H'::text)"
"         &nb= +sp;           &nbs= +p;   =20 +->  Seq Scan on t_domains d2  (cost=3D0.00..2.25 rows=3D2 = +width=3D5)=20 +(actual time=3D0.054..0.140 rows=3D2=20 +loops=3D41)"
"         &n= +bsp;           &nb= +sp;         =20 +Filter: ((name)::text =3D=20 +'SFR_DURUMU'::text)"
"        = +           =20 +->  Bitmap Heap Scan on t_lokal_plan lp  = +(cost=3D2.28..107.70 rows=3D33=20 +width=3D30) (actual time=3D9.709..103.130 rows=3D349=20 +loops=3D41)"
"         &n= +bsp;           &nb= +sp;   =20 +Recheck Cond: (((lp.firma_no)::text =3D ($1)::text) AND = +((""outer"".hat_no)::text=20 +=3D (lp.hat_no)::text) AND (""outer"".kod =3D=20 +lp.sefer_kod))"
"         = +;            = +    =20 +->  Bitmap Index Scan on t_lokal_plan_pkey  = +(cost=3D0.00..2.28=20 +rows=3D33 width=3D0) (actual time=3D8.340..8.340 rows=3D349=20 +loops=3D41)"
"         &n= +bsp;           &nb= +sp;         =20 +Index Cond: (((lp.firma_no)::text =3D ($1)::text) AND = +((""outer"".hat_no)::text =3D=20 +(lp.hat_no)::text) AND (""outer"".kod =3D=20 +lp.sefer_kod))"
"         = +;    =20 +->  Index Scan using t_koltuk_son_durum_pkey on = +t_koltuk_son_durum=20 +sd  (cost=3D0.00..5.51 rows=3D1 width=3D28) (actual = +time=3D0.467..1.829 rows=3D4=20 +loops=3D14296)"
"         = +;          =20 +Index Cond: ((($1)::text =3D (sd.firma_no)::text) AND = +((""outer"".hat_no)::text =3D=20 +(sd.hat_no)::text) AND (""outer"".kod =3D sd.sefer_kod) AND = +(""outer"".plan_tarihi=20 +=3D sd.plan_tarihi) AND (""outer"".yer_kod =3D=20 +sd.bin_yer_kod))"
"        &nb= +sp;          =20 +Filter: ((islem)::text =3D=20 +'S'::text)"
"        ->  = +Index=20 +Scan using t_koltuk_islem_kod_ukey on t_koltuk_islem i  = +(cost=3D0.00..3.13=20 +rows=3D1 width=3D65) (actual time=3D2.534..2.538 rows=3D1=20 +loops=3D63193)"
"         = +;    =20 +Index Cond: (i.kod =3D=20 +""outer"".islem_kod)"
"        = +;     =20 +Filter: ((firma_no)::text =3D ($1)::text)"
"Total runtime: 192649.904 = + +ms"
+
Adnan DURSUN
+
ASRIN Bili=FEim Ltd.=DEti
+
 
+ +------=_NextPart_000_0003_01C6315A.8B2FEF70-- + +From pgsql-performance-owner@postgresql.org Tue Feb 14 05:47:42 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id BD1629DCBB1 + for ; + Tue, 14 Feb 2006 05:47:41 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 70979-03 + for ; + Tue, 14 Feb 2006 05:47:41 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from eads-av-smtp2.gmessaging.net (eads-av-smtp2.gmessaging.net + [194.51.201.3]) by postgresql.org (Postfix) with ESMTP id AA4FE9DCAE5 + for ; + Tue, 14 Feb 2006 05:47:36 -0400 (AST) +Received: from eads-relay2.cesson.gm-adm (localhost [127.0.0.1]) + by eads-av-smtp2.gmessaging.net + (iPlanet Messaging Server 5.2 HotFix 2.04 (built Feb 8 2005)) + with ESMTP id <0IUO00M2R8B4YW@eads-av-smtp2.gmessaging.net> for + pgsql-performance@postgresql.org; Tue, 14 Feb 2006 10:47:37 +0100 (MET) +Received: from fr0-mailsp01.res.airbus.corp ([10.254.251.54]) + by eads-av-smtp2.gmessaging.net + (iPlanet Messaging Server 5.2 HotFix 2.04 (built Feb 8 2005)) + with ESMTP id <0IUO00L098H14A@eads-av-smtp2.gmessaging.net> for + pgsql-performance@postgresql.org; Tue, 14 Feb 2006 10:46:20 +0100 (MET) +Received: from fr0-mailsp01.res.airbus.corp (localhost.localdomain + [127.0.0.1]) + by fr0-mailsp01.res.airbus.corp (8.12.11/8.12.10) with ESMTP id + k1E9kAxO021017 + for ; Tue, 14 Feb 2006 10:46:10 +0100 +Received: from fr0-mailrt10.res.airbus.corp ([152.9.126.24]) + by fr0-mailsp01.res.airbus.corp (8.12.11/8.12.10) with ESMTP id + k1E9jukp020673 + for ; Tue, 14 Feb 2006 10:46:09 +0100 +Received: from fr0-mailrt03.res.airbus.corp ([152.9.126.22]) + by fr0-mailrt10.res.airbus.corp with Microsoft SMTPSVC(5.0.2195.6713); + Tue, 14 Feb 2006 10:45:56 +0100 +Received: from FR0-MAILMB20.res.airbus.corp ([152.9.126.74]) + by fr0-mailrt03.res.airbus.corp with Microsoft SMTPSVC(5.0.2195.6713); + Tue, 14 Feb 2006 10:44:59 +0100 +Date: Tue, 14 Feb 2006 10:44:59 +0100 +From: "FERREIRA, William (VALTECH)" +Subject: copy and postgresql.conf +To: pgsql-performance@postgresql.org +Message-id: + <414D259CE29DE54DAD534037C83CE4B7269627@FR0-MAILMB20.res.airbus.corp> +MIME-version: 1.0 +X-MIMEOLE: Produced By Microsoft Exchange V6.0.6603.0 +Content-type: text/plain; charset=iso-8859-1 +Content-transfer-encoding: 7BIT +Content-class: urn:content-classes:message +Thread-topic: [PERFORM] execution plan : Oracle vs PostgreSQL +Thread-index: AcYrWvBdkwxsSiPCROC7MhAtgaOy8wF7dDog +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +X-OriginalArrivalTime: 14 Feb 2006 09:44:59.0911 (UTC) + FILETIME=[5243A170:01C6314B] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.229 required=5 tests=[AWL=0.229] +X-Spam-Score: 0.229 +X-Spam-Level: +X-Archive-Number: 200602/151 +X-Sequence-Number: 17137 + + +hi, + +i load data from files using copy method. +Files contain between 2 and 7 millions of rows, spread on 5 tables. + +For loading all the data, it takes 40mn, and the same processing takes 17mn with Oracle. +I think that this time can be improved by changing postgresql configuration file. +But which parameters i need to manipulate and with which values ? + +Here are the specifications of my system : +V250 architecture sun4u +2xCPU UltraSparc IIIi 1.28 GHz. +8 Go RAM. + +Regards. + + Will + + +This e-mail is intended only for the above addressee. It may contain +privileged information. If you are not the addressee you must not copy, +distribute, disclose or use any of the information in it. If you have +received it in error please delete it and immediately notify the sender. +Security Notice: all e-mail, sent to or from this address, may be +accessed by someone other than the recipient, for system management and +security reasons. This access is controlled under Regulation of +Investigatory Powers Act 2000, Lawful Business Practises. + +From pgsql-performance-owner@postgresql.org Tue Feb 14 07:38:32 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 0EE839DC95C + for ; + Tue, 14 Feb 2006 07:38:31 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 87146-09 + for ; + Tue, 14 Feb 2006 07:38:33 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from correo6.acens.net (correo6.acens.net [217.116.0.39]) + by postgresql.org (Postfix) with ESMTP id 750809DC80A + for ; + Tue, 14 Feb 2006 07:38:27 -0400 (AST) +Received: (qmail 23825 invoked from network); 14 Feb 2006 11:35:54 -0000 +Received: from unknown (HELO albert.sedifa.com) ([83.175.220.10]) + (envelope-sender ) + by correo6.acens.net (qmail-ldap-1.03) with SMTP + for ; 14 Feb 2006 11:35:53 -0000 +From: Albert Cervera Areny +Organization: Sedifa, S.L. +To: pgsql-performance@postgresql.org +Subject: Re: copy and postgresql.conf +Date: Tue, 14 Feb 2006 12:38:24 +0100 +User-Agent: KMail/1.7.2 +References: + <414D259CE29DE54DAD534037C83CE4B7269627@FR0-MAILMB20.res.airbus.corp> +In-Reply-To: + <414D259CE29DE54DAD534037C83CE4B7269627@FR0-MAILMB20.res.airbus.corp> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +Message-Id: <200602141238.25230.albert@sedifa.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200602/152 +X-Sequence-Number: 17138 + +Hi William, + which PostgreSQL version are you using? Newer (8.0+) versions have some=20 +important performance improvements for the COPY command. + + Also, you'll notice significant improvements by creating primary & foreign= +=20 +keys after the copy command. I think config tweaking can improve key and=20 +index creation but I don't think you can improve the COPY command itself. + + There are also many threads in this list commenting on this issue, you'll= +=20 +find it easely in the archives. + +A Dimarts 14 Febrer 2006 10:44, FERREIRA, William (VALTECH) va escriure: +> hi, +> +> i load data from files using copy method. +> Files contain between 2 and 7 millions of rows, spread on 5 tables. +> +> For loading all the data, it takes 40mn, and the same processing takes 17= +mn +> with Oracle. I think that this time can be improved by changing postgresql +> configuration file. But which parameters i need to manipulate and with +> which values ? +> +> Here are the specifications of my system : +> V250 architecture sun4u +> 2xCPU UltraSparc IIIi 1.28 GHz. +> 8 Go RAM. +> +> Regards. +> +> Will +> +> +> This e-mail is intended only for the above addressee. It may contain +> privileged information. If you are not the addressee you must not copy, +> distribute, disclose or use any of the information in it. If you have +> received it in error please delete it and immediately notify the sender. +> Security Notice: all e-mail, sent to or from this address, may be +> accessed by someone other than the recipient, for system management and +> security reasons. This access is controlled under Regulation of +> Investigatory Powers Act 2000, Lawful Business Practises. +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 4: Have you searched our list archives? +> +> http://archives.postgresql.org + +=2D-=20 +Albert Cervera Areny +Dept. Inform=E0tica Sedifa, S.L. + +Av. Can Bordoll, 149 +08202 - Sabadell (Barcelona) +Tel. 93 715 51 11 +=46ax. 93 715 51 12 + +=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 +=2E....................... AVISO LEGAL ............................ +La presente comunicaci=F3n y sus anexos tiene como destinatario la +persona a la que va dirigida, por lo que si usted lo recibe +por error debe notificarlo al remitente y eliminarlo de su +sistema, no pudiendo utilizarlo, total o parcialmente, para +ning=FAn fin. Su contenido puede tener informaci=F3n confidencial o +protegida legalmente y =FAnicamente expresa la opini=F3n del +remitente. El uso del correo electr=F3nico v=EDa Internet no +permite asegurar ni la confidencialidad de los mensajes +ni su correcta recepci=F3n. En el caso de que el +destinatario no consintiera la utilizaci=F3n del correo electr=F3nico, +deber=E1 ponerlo en nuestro conocimiento inmediatamente. +=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 +=2E.......................... DISCLAIMER ............................. +This message and its attachments are intended exclusively for the +named addressee. If you receive this message in error, please +immediately delete it from your system and notify the sender. You +may not use this message or any part of it for any purpose. +The message may contain information that is confidential or +protected by law, and any opinions expressed are those of the +individual sender. Internet e-mail guarantees neither the +confidentiality nor the proper receipt of the message sent. +If the addressee of this message does not consent to the use +of internet e-mail, please inform us inmmediately. +=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 + + +=20 + +From pgsql-performance-owner@postgresql.org Tue Feb 14 09:27:44 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 1B2839DC80A + for ; + Tue, 14 Feb 2006 09:27:44 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 09615-06 + for ; + Tue, 14 Feb 2006 09:27:43 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from eads-av-smtp3.gmessaging.net (eads-av-smtp3.gmessaging.net + [194.51.201.27]) + by postgresql.org (Postfix) with ESMTP id D8D839DC804 + for ; + Tue, 14 Feb 2006 09:27:28 -0400 (AST) +Received: from eads-relay3.cesson.gm-adm (localhost [127.0.0.1]) + by eads-av-smtp3.gmessaging.net + (iPlanet Messaging Server 5.2 HotFix 2.04 (built Feb 8 2005)) + with ESMTP id <0IUO00IDJIK6PD@eads-av-smtp3.gmessaging.net> for + pgsql-performance@postgresql.org; Tue, 14 Feb 2006 14:27:31 +0100 (MET) +Received: from fr0-mailsp02.res.airbus.corp ([10.254.251.55]) + by eads-av-smtp3.gmessaging.net + (iPlanet Messaging Server 5.2 HotFix 2.04 (built Feb 8 2005)) + with ESMTP id <0IUO00HUQIP9EA@eads-av-smtp3.gmessaging.net> for + pgsql-performance@postgresql.org; Tue, 14 Feb 2006 14:27:13 +0100 (MET) +Received: from fr0-mailsp02.res.airbus.corp (localhost.localdomain + [127.0.0.1]) + by fr0-mailsp02.res.airbus.corp (8.12.11/8.12.10) with ESMTP id + k1EDR6pq015756 + for ; Tue, 14 Feb 2006 14:27:06 +0100 +Received: from fr0-mailrt10.res.airbus.corp ([152.9.126.24]) + by fr0-mailsp02.res.airbus.corp (8.12.11/8.12.10) + with ESMTP id k1EDR4ua015745; Tue, 14 Feb 2006 14:27:04 +0100 +Received: from fr0-mailrt04.res.airbus.corp ([152.9.126.23]) + by fr0-mailrt10.res.airbus.corp with Microsoft SMTPSVC(5.0.2195.6713); + Tue, 14 Feb 2006 14:26:57 +0100 +Received: from FR0-MAILMB20.res.airbus.corp ([152.9.126.74]) + by fr0-mailrt04.res.airbus.corp with Microsoft SMTPSVC(5.0.2195.6713); + Tue, 14 Feb 2006 14:26:57 +0100 +Date: Tue, 14 Feb 2006 14:26:57 +0100 +From: "FERREIRA, William (VALTECH)" +Subject: Re: copy and postgresql.conf +To: Albert Cervera Areny , pgsql-performance@postgresql.org +Message-id: + <414D259CE29DE54DAD534037C83CE4B7011E485B@FR0-MAILMB20.res.airbus.corp> +MIME-version: 1.0 +X-MIMEOLE: Produced By Microsoft Exchange V6.0.6603.0 +Content-type: text/plain; charset=iso-8859-1 +Content-transfer-encoding: quoted-printable +Content-class: urn:content-classes:message +Thread-topic: [PERFORM] copy and postgresql.conf +Thread-index: AcYxW7v5tWFL6KKqSuGmx9SIz1YjVAADnEtw +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +X-OriginalArrivalTime: 14 Feb 2006 13:26:57.0237 (UTC) + FILETIME=[54025050:01C6316A] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.223 required=5 tests=[AWL=0.223] +X-Spam-Score: 0.223 +X-Spam-Level: +X-Archive-Number: 200602/153 +X-Sequence-Number: 17139 + + +thanks, + +i'm using postgresql 8.0.3 +there is no primary key and no index on my tables + +regards + +-----Message d'origine----- +De : pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org]De la part de Albert +Cervera Areny +Envoy=E9 : mardi 14 f=E9vrier 2006 12:38 +=C0 : pgsql-performance@postgresql.org +Objet : Re: [PERFORM] copy and postgresql.conf + + + +Hi William, + which PostgreSQL version are you using? Newer (8.0+) versions have some + +important performance improvements for the COPY command. + + Also, you'll notice significant improvements by creating primary & foreign + +keys after the copy command. I think config tweaking can improve key and + +index creation but I don't think you can improve the COPY command itself. + + There are also many threads in this list commenting on this issue, you'll + +find it easely in the archives. + +A Dimarts 14 Febrer 2006 10:44, FERREIRA, William (VALTECH) va escriure: +> hi, +> +> i load data from files using copy method. +> Files contain between 2 and 7 millions of rows, spread on 5 tables. +> +> For loading all the data, it takes 40mn, and the same processing takes= + 17mn +> with Oracle. I think that this time can be improved by changing= + postgresql +> configuration file. But which parameters i need to manipulate and with +> which values ? +> +> Here are the specifications of my system : +> V250 architecture sun4u +> 2xCPU UltraSparc IIIi 1.28 GHz. +> 8 Go RAM. +> +> Regards. +> +> Will +> +> +> This e-mail is intended only for the above addressee. It may contain +> privileged information. If you are not the addressee you must not copy, +> distribute, disclose or use any of the information in it. If you have +> received it in error please delete it and immediately notify the sender. +> Security Notice: all e-mail, sent to or from this address, may be +> accessed by someone other than the recipient, for system management and +> security reasons. This access is controlled under Regulation of +> Investigatory Powers Act 2000, Lawful Business Practises. +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 4: Have you searched our list archives? +> +> http://archives.postgresql.org + +-- + +Albert Cervera Areny +Dept. Inform=E0tica Sedifa, S.L. + +Av. Can Bordoll, 149 +08202 - Sabadell (Barcelona) +Tel. 93 715 51 11 +Fax. 93 715 51 12 + +=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 +........................ AVISO LEGAL ............................ +La presente comunicaci=F3n y sus anexos tiene como destinatario la +persona a la que va dirigida, por lo que si usted lo recibe +por error debe notificarlo al remitente y eliminarlo de su +sistema, no pudiendo utilizarlo, total o parcialmente, para +ning=FAn fin. Su contenido puede tener informaci=F3n confidencial o +protegida legalmente y =FAnicamente expresa la opini=F3n del +remitente. El uso del correo electr=F3nico v=EDa Internet no +permite asegurar ni la confidencialidad de los mensajes +ni su correcta recepci=F3n. En el caso de que el +destinatario no consintiera la utilizaci=F3n del correo electr=F3nico, +deber=E1 ponerlo en nuestro conocimiento inmediatamente. +=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 +........................... DISCLAIMER ............................. +This message and its attachments are intended exclusively for the +named addressee. If you receive this message in error, please +immediately delete it from your system and notify the sender. You +may not use this message or any part of it for any purpose. +The message may contain information that is confidential or +protected by law, and any opinions expressed are those of the +individual sender. Internet e-mail guarantees neither the +confidentiality nor the proper receipt of the message sent. +If the addressee of this message does not consent to the use +of internet e-mail, please inform us inmmediately. +=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 + + + + + +---------------------------(end of broadcast)--------------------------- +TIP 5: don't forget to increase your free space map settings + + + +This mail has originated outside your organization, +either from an external partner or the Global Internet. +Keep this in mind if you answer this message. + +=0D +This e-mail is intended only for the above addressee. It may contain +privileged information. If you are not the addressee you must not copy, +distribute, disclose or use any of the information in it. If you have +received it in error please delete it and immediately notify the sender. +Security Notice: all e-mail, sent to or from this address, may be +accessed by someone other than the recipient, for system management and +security reasons. This access is controlled under Regulation of +Investigatory Powers Act 2000, Lawful Business Practises. + +From pgsql-performance-owner@postgresql.org Tue Feb 14 11:25:26 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 4BA879DD07B + for ; + Tue, 14 Feb 2006 11:25:25 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 48456-01-6 + for ; + Tue, 14 Feb 2006 11:25:23 -0400 (AST) +X-Greylist: whitelisted by SQLgrey- +Received: from smtp6-g19.free.fr (smtp6-g19.free.fr [212.27.42.36]) + by postgresql.org (Postfix) with ESMTP id 8BCF89DCC9D + for ; + Tue, 14 Feb 2006 11:24:09 -0400 (AST) +Received: from imp2-g19.free.fr (imp2-g19.free.fr [212.27.42.2]) + by smtp6-g19.free.fr (Postfix) with ESMTP id 515BF18195 + for ; + Tue, 14 Feb 2006 16:24:11 +0100 (CET) +Received: by imp2-g19.free.fr (Postfix, from userid 33) + id 29BA47ACEE; Tue, 14 Feb 2006 16:24:11 +0100 (MET) +Received: from wormhole.x-echo.com (wormhole.x-echo.com [193.252.148.11]) + by imp2-g19.free.fr (IMP) with HTTP + for ; Tue, 14 Feb 2006 16:24:11 +0100 +Message-ID: <1139930651.43f1f61b04773@imp2-g19.free.fr> +Date: Tue, 14 Feb 2006 16:24:11 +0100 +From: martial.bizel@free.fr +To: pgsql-performance@postgresql.org +Subject: out of memory +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 8bit +User-Agent: Internet Messaging Program (IMP) 3.2.5 +X-Originating-IP: 193.252.148.11 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.55 required=5 tests=[NO_REAL_NAME=0.55] +X-Spam-Score: 0.55 +X-Spam-Level: +X-Archive-Number: 200602/154 +X-Sequence-Number: 17140 + +Hello, + +I've error "out of memory" with these traces : + + +TopMemoryContext: 32768 total in 3 blocks; 5152 free (1 chunks); 27616 used +TopTransactionContext: 8192 total in 1 blocks; 8136 free (0 chunks); 56 used +DeferredTriggerXact: 0 total in 0 blocks; 0 free (0 chunks); 0 used +MessageContext: 24576 total in 2 blocks; 2688 free (14 chunks); 21888 used +PortalMemory: 8192 total in 1 blocks; 8040 free (0 chunks); 152 used +PortalHeapMemory: 8192 total in 1 blocks; 3936 free (0 chunks); 4256 used +PortalHeapMemory: 23552 total in 5 blocks; 1160 free (4 chunks); 22392 used +ExecutorState: 8192 total in 1 blocks; 3280 free (4 chunks); 4912 used +ExprContext: 0 total in 0 blocks; 0 free (0 chunks); 0 used +ExprContext: 0 total in 0 blocks; 0 free (0 chunks); 0 used +ExecutorState: 24576 total in 2 blocks; 11264 free (14 chunks); 13312 used +ExprContext: 8192 total in 1 blocks; 8128 free (0 chunks); 64 used +AggContext: -1976573952 total in 287 blocks; 25024 free (414 chunks); +-1976598976 used +DynaHashTable: 503439384 total in 70 blocks; 6804760 free (257 chunks); +496634624 used +ExprContext: 0 total in 0 blocks; 0 free (0 chunks); 0 used +ExprContext: 8192 total in 1 blocks; 8176 free (0 chunks); 16 used +ExprContext: 0 total in 0 blocks; 0 free (0 chunks); 0 used +ExprContext: 0 total in 0 blocks; 0 free (0 chunks); 0 used +ExprContext: 0 total in 0 blocks; 0 free (0 chunks); 0 used +CacheMemoryContext: 516096 total in 6 blocks; 126648 free (2 chunks); 389448 +used +test_query: 1024 total in 1 blocks; 640 free (0 chunks); 384 used +test_date: 1024 total in 1 blocks; 640 free (0 chunks); 384 used +query_string_query_string_key: 1024 total in 1 blocks; 640 free (0 chunks); 384 +used +query_string_pkey: 1024 total in 1 blocks; 640 free (0 chunks); 384 used +pg_index_indrelid_index: 1024 total in 1 blocks; 640 free (0 chunks); 384 used +pg_attrdef_adrelid_adnum_index: 1024 total in 1 blocks; 320 free (0 chunks); 704 +used +pg_amop_opc_strategy_index: 1024 total in 1 blocks; 320 free (0 chunks); 704 +used +pg_shadow_usename_index: 1024 total in 1 blocks; 640 free (0 chunks); 384 used +pg_amop_opr_opc_index: 1024 total in 1 blocks; 320 free (0 chunks); 704 used +pg_conversion_oid_index: 1024 total in 1 blocks; 640 free (0 chunks); 384 used +pg_language_name_index: 1024 total in 1 blocks; 640 free (0 chunks); 384 used +pg_statistic_relid_att_index: 1024 total in 1 blocks; 320 free (0 chunks); 704 +used +pg_attribute_relid_attnam_index: 1024 total in 1 blocks; 320 free (0 chunks); +704 used +pg_shadow_usesysid_index: 1024 total in 1 blocks; 640 free (0 chunks); 384 used +pg_cast_source_target_index: 1024 total in 1 blocks; 320 free (0 chunks); 704 +used +pg_conversion_name_nsp_index: 1024 total in 1 blocks; 320 free (0 chunks); 704 +used +pg_trigger_tgrelid_tgname_index: 1024 total in 1 blocks; 320 free (0 chunks); +704 used +pg_namespace_nspname_index: 1024 total in 1 blocks; 640 free (0 chunks); 384 +used +pg_conversion_default_index: 2048 total in 1 blocks; 704 free (0 chunks); 1344 +used +pg_class_relname_nsp_index: 1024 total in 1 blocks; 320 free (0 chunks); 704 +used +pg_aggregate_fnoid_index: 1024 total in 1 blocks; 640 free (0 chunks); 384 used +pg_inherits_relid_seqno_index: 1024 total in 1 blocks; 320 free (0 chunks); 704 +used +pg_language_oid_index: 1024 total in 1 blocks; 640 free (0 chunks); 384 used +pg_type_typname_nsp_index: 1024 total in 1 blocks; 320 free (0 chunks); 704 used +pg_group_sysid_index: 1024 total in 1 blocks; 640 free (0 chunks); 384 used +pg_namespace_oid_index: 1024 total in 1 blocks; 640 free (0 chunks); 384 used +pg_proc_proname_args_nsp_index: 2048 total in 1 blocks; 704 free (0 chunks); +1344 used +pg_opclass_am_name_nsp_index: 2048 total in 1 blocks; 768 free (0 chunks); 1280 +used +pg_group_name_index: 1024 total in 1 blocks; 640 free (0 chunks); 384 used +pg_proc_oid_index: 1024 total in 1 blocks; 640 free (0 chunks); 384 used +pg_operator_oid_index: 1024 total in 1 blocks; 640 free (0 chunks); 384 used +pg_amproc_opc_procnum_index: 1024 total in 1 blocks; 320 free (0 chunks); 704 +used +pg_index_indexrelid_index: 1024 total in 1 blocks; 640 free (0 chunks); 384 used +pg_operator_oprname_l_r_n_index: 2048 total in 1 blocks; 704 free (0 chunks); +1344 used +pg_opclass_oid_index: 1024 total in 1 blocks; 640 free (0 chunks); 384 used +pg_rewrite_rel_rulename_index: 1024 total in 1 blocks; 320 free (0 chunks); 704 +used +pg_type_oid_index: 1024 total in 1 blocks; 640 free (0 chunks); 384 used +pg_attribute_relid_attnum_index: 1024 total in 1 blocks; 320 free (0 chunks); +704 used +pg_class_oid_index: 1024 total in 1 blocks; 640 free (0 chunks); 384 used +MdSmgr: 8192 total in 1 blocks; 5712 free (0 chunks); 2480 used +DynaHash: 8192 total in 1 blocks; 6912 free (0 chunks); 1280 used +DynaHashTable: 8192 total in 1 blocks; 2008 free (0 chunks); 6184 used +DynaHashTable: 8192 total in 1 blocks; 5080 free (0 chunks); 3112 used +DynaHashTable: 8192 total in 1 blocks; 2008 free (0 chunks); 6184 used +DynaHashTable: 8192 total in 1 blocks; 3016 free (0 chunks); 5176 used +DynaHashTable: 8192 total in 1 blocks; 4040 free (0 chunks); 4152 used +DynaHashTable: 24576 total in 2 blocks; 13240 free (4 chunks); 11336 used +DynaHashTable: 0 total in 0 blocks; 0 free (0 chunks); 0 used +DynaHashTable: 0 total in 0 blocks; 0 free (0 chunks); 0 used +DynaHashTable: 0 total in 0 blocks; 0 free (0 chunks); 0 used +DynaHashTable: 0 total in 0 blocks; 0 free (0 chunks); 0 used +DynaHashTable: 0 total in 0 blocks; 0 free (0 chunks); 0 used +ErrorContext: 8192 total in 1 blocks; 8176 free (6 chunks); 16 used +2006-02-14 16:06:14 [25816] ERROR: out of memory +DETAIL: Failed on request of size 88. +ERROR: out of memory +DETAIL: Failed on request of size 88. + + +Anybody could help me ?? + +Thanks a lot + +MB + + +From pgsql-performance-owner@postgresql.org Tue Feb 14 11:32:53 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 756FC9DC952 + for ; + Tue, 14 Feb 2006 11:32:52 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 49899-05 + for ; + Tue, 14 Feb 2006 11:32:52 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id EFB549DC80A + for ; + Tue, 14 Feb 2006 11:32:45 -0400 (AST) +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 k1EFWn5D015116; + Tue, 14 Feb 2006 10:32:49 -0500 (EST) +To: martial.bizel@free.fr +cc: pgsql-performance@postgresql.org +Subject: Re: out of memory +In-reply-to: <1139930651.43f1f61b04773@imp2-g19.free.fr> +References: <1139930651.43f1f61b04773@imp2-g19.free.fr> +Comments: In-reply-to martial.bizel@free.fr + message dated "Tue, 14 Feb 2006 16:24:11 +0100" +Date: Tue, 14 Feb 2006 10:32:49 -0500 +Message-ID: <15115.1139931169@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.109 required=5 tests=[AWL=0.109] +X-Spam-Score: 0.109 +X-Spam-Level: +X-Archive-Number: 200602/155 +X-Sequence-Number: 17141 + +martial.bizel@free.fr writes: +> I've error "out of memory" with these traces : + +Doing what? + +> AggContext: -1976573952 total in 287 blocks; 25024 free (414 chunks); +> -1976598976 used +> DynaHashTable: 503439384 total in 70 blocks; 6804760 free (257 chunks); +> 496634624 used + +I'd guess that a HashAgg operation ran out of memory ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Feb 14 11:51:27 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id A4E6B9DC823 + for ; + Tue, 14 Feb 2006 11:51:26 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 52202-05 + for ; + Tue, 14 Feb 2006 11:51:30 -0400 (AST) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 78AAE9DC854 + for ; + Tue, 14 Feb 2006 11:51:23 -0400 (AST) +Received: from timberline.ca (unknown [66.244.194.163]) + by svr4.postgresql.org (Postfix) with ESMTP id C68D65AF09F + for ; + Tue, 14 Feb 2006 15:51:28 +0000 (GMT) +Received: from tfic21 ([172.16.10.21]) + by timberline.ca (8.12.9/8.12.9) with ESMTP id k1EFpN6F020512 + for ; + Tue, 14 Feb 2006 07:51:23 -0800 (PST) +Message-Id: <200602141551.k1EFpN6F020512@timberline.ca> +From: "Jay Greenfield" +To: +Subject: Postgres slower than MS ACCESS +Date: Tue, 14 Feb 2006 07:51:23 -0800 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0056_01C6313B.737644C0" +X-Mailer: Microsoft Office Outlook, Build 11.0.6353 +Thread-Index: AcYxffGUGtP2JAusQ8OsAeSbQ5+cJg== +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.001 required=5 tests=[HTML_MESSAGE=0.001] +X-Spam-Score: 0.001 +X-Spam-Level: +X-Archive-Number: 200602/156 +X-Sequence-Number: 17142 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0056_01C6313B.737644C0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit + +I am running some simple queries to benchmark Postgres 8.1 against MS Access +and Postgres is 2 to 3 times slower that Access. + + + +Hardware: + +Dell Optiplex GX280 + +P4 3.20 GHz + +3GB RAM + +Windows XP SP1 + + + +Database has one table with 1.2 million rows + + + +Query: + +UPDATE ntdn SET gha=area/10000 + + + +I could post the EXPLAIN ANALYZE results but its 4,000+ lines long + + + +I've run various tests on a number of Postgres parameters; none of which +have come close to Access' time of 5.00 min. Postgres times range between +24 min and 121 min. + + + +Some of the Postgres variables and ranges I've tested. + + + +work_mem: 1,000 to 2,000,000 + +temp_buffers: 1,000 to 10,000 + +shared_buffers: 1,000 to 64,000 + +sort_mem: 1,024,000 + +fsync on / off + + + +Why does Access run so much faster? How can I get Postgres to run as fast +as Access? + + + +Thanks, + + + +Jay + + + + + + + + + + + + + + +------=_NextPart_000_0056_01C6313B.737644C0 +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + +
+ +

I am running some simple queries to benchmark +Postgres 8.1 against MS Access and Postgres is 2 to 3 times slower that +Access. 

+ +

 

+ +

Hardware:

+ +

Dell Optiplex = +GX280

+ +

P4 3.20 GHz

+ +

3GB RAM

+ +

Windows XP SP1

+ +

 

+ +

Database has one table with 1.2 million = +rows

+ +

 

+ +

Query:

+ +

UPDATE ntdn SET = +gha=3Darea/10000

+ +

 

+ +

I could post the EXPLAIN ANALYZE results but = +its +4,000+ lines long

+ +

 

+ +

I’ve run various tests on a number of = +Postgres +parameters; none of which have come close to Access’ time of 5.00 = +min.  Postgres +times range between 24 min and 121 min.

+ +

 

+ +

Some of the Postgres variables and ranges = +I’ve +tested.

+ +

 

+ +

work_mem:  1,000 to = +2,000,000

+ +

temp_buffers:  1,000 to = +10,000

+ +

shared_buffers:  1,000 to = +64,000

+ +

sort_mem:  = +1,024,000

+ +

fsync on / off

+ +

 

+ +

Why does Access run so much faster?  How = +can I +get Postgres to run as fast as Access?

+ +

 

+ +

Thanks,

+ +

 

+ +

Jay

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +
+ + + + + +------=_NextPart_000_0056_01C6313B.737644C0-- + + +From pgsql-performance-owner@postgresql.org Tue Feb 14 12:03:43 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 9E20B9DC81F + for ; + Tue, 14 Feb 2006 12:03:42 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 55659-06 + for ; + Tue, 14 Feb 2006 12:03:40 -0400 (AST) +X-Greylist: whitelisted by SQLgrey- +Received: from smtp2-g19.free.fr (smtp2-g19.free.fr [212.27.42.28]) + by postgresql.org (Postfix) with ESMTP id 343489DC823 + for ; + Tue, 14 Feb 2006 12:03:40 -0400 (AST) +Received: from imp6-g19.free.fr (imp6-g19.free.fr [212.27.42.6]) + by smtp2-g19.free.fr (Postfix) with ESMTP id 1CB946CC25; + Tue, 14 Feb 2006 17:03:39 +0100 (CET) +Received: by imp6-g19.free.fr (Postfix, from userid 33) + id 7E5A42E0C6; Tue, 14 Feb 2006 17:03:38 +0100 (MET) +Received: from wormhole.x-echo.com (wormhole.x-echo.com [193.252.148.11]) + by imp6-g19.free.fr (IMP) with HTTP + for ; Tue, 14 Feb 2006 17:03:38 +0100 +Message-ID: <1139933018.43f1ff5a5e542@imp6-g19.free.fr> +Date: Tue, 14 Feb 2006 17:03:38 +0100 +From: martial.bizel@free.fr +To: Tom Lane +Cc: pgsql-performance@postgresql.org +Subject: Re: out of memory +References: <1139930651.43f1f61b04773@imp2-g19.free.fr> + <15115.1139931169@sss.pgh.pa.us> +In-Reply-To: <15115.1139931169@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 8bit +User-Agent: Internet Messaging Program (IMP) 3.2.5 +X-Originating-IP: 193.252.148.11 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.63 required=5 tests=[AWL=0.080, NO_REAL_NAME=0.55] +X-Spam-Score: 0.63 +X-Spam-Level: +X-Archive-Number: 200602/157 +X-Sequence-Number: 17143 + +Thanks for your response, + +I've made this request : + +SELECT query_string, DAY.ocu from search_data.query_string, + (SELECT SUM(occurence) as ocu, query +FROM daily.queries_detail_statistics + WHERE date >= '2006-01-01' AND date <= '2006-01-30' + AND portal IN (1,2) + GROUP BY query + ORDER BY ocu DESC + LIMIT 1000) as DAY + WHERE DAY.query=id; + +and after few minutes, i've error "out of memory" with this execution plan : +Nested Loop (cost=8415928.63..8418967.13 rows=1001 width=34) + -> Subquery Scan "day" (cost=8415928.63..8415941.13 rows=1000 width=16) + -> Limit (cost=8415928.63..8415931.13 rows=1000 width=12) + -> Sort (cost=8415928.63..8415932.58 rows=1582 width=12) + Sort Key: sum(occurence) + -> HashAggregate (cost=8415840.61..8415844.56 rows=1582 +width=12) + -> Seq Scan on queries_detail_statistics +(cost=0.00..8414056.00 rows=356922 width=12) + Filter: ((date >= '2006-01-01'::date) AND (date +<= '2006-01-30'::date) AND (((portal)::text = '1'::text) OR ((portal)::text = +'2'::text))) + -> Index Scan using query_string_pkey on query_string (cost=0.00..3.01 +rows=1 width=34) + Index Cond: ("outer".query = query_string.id) +(10 rows) + +if HashAgg operation ran out of memory, what can i do ? + +thanks a lot +martial + +> martial.bizel@free.fr writes: +> > I've error "out of memory" with these traces : +> +> Doing what? +> +> > AggContext: -1976573952 total in 287 blocks; 25024 free (414 chunks); +> > -1976598976 used +> > DynaHashTable: 503439384 total in 70 blocks; 6804760 free (257 chunks); +> > 496634624 used +> +> I'd guess that a HashAgg operation ran out of memory ... +> +> regards, tom lane +> +> ---------------------------(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 Tue Feb 14 12:04:52 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 477C69DC83F + for ; + Tue, 14 Feb 2006 12:04:52 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 54716-09 + for ; + Tue, 14 Feb 2006 12:04:49 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id E83BA9DC823 + for ; + Tue, 14 Feb 2006 12:04:48 -0400 (AST) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Tue, 14 Feb 2006 16:04:45 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 14 Feb 2006 10:04:45 -0600 +Subject: Re: Postgres slower than MS ACCESS +From: Scott Marlowe +To: Jay Greenfield +Cc: pgsql-performance@postgresql.org +In-Reply-To: <200602141551.k1EFpN6F020512@timberline.ca> +References: <200602141551.k1EFpN6F020512@timberline.ca> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1139933084.22740.177.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Tue, 14 Feb 2006 10:04:45 -0600 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.168 required=5 tests=[AWL=0.167, + UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 0.168 +X-Spam-Level: +X-Archive-Number: 200602/158 +X-Sequence-Number: 17144 + +On Tue, 2006-02-14 at 09:51, Jay Greenfield wrote: +> I am running some simple queries to benchmark Postgres 8.1 against MS +> Access and Postgres is 2 to 3 times slower that Access. + +A BUNCH OF STUFF SNIPPED + +> Why does Access run so much faster? How can I get Postgres to run as +> fast as Access? + +Because Access is not a multi-user database management system designed +to handle anywhere from a couple to several thousand users at the same +time? + +PostgreSQL can do this update while still allowing users to access the +data in the database, and can handle updates to the same table at the +same time, as long as they aren't hitting the same rows. + +They're two entirely different beasts. + +One is good at batch processing moderate amounts of data for one user at +a time. The other is good for real time processing of very large +amounts of data for a fairly large number of users while running at an +acceptable, if slower speed. + +From pgsql-performance-owner@postgresql.org Tue Feb 14 12:06:46 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 723849DC823 + for ; + Tue, 14 Feb 2006 12:06:46 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 56987-02 + for ; + Tue, 14 Feb 2006 12:06:44 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id 8A56C9DC81F + for ; + Tue, 14 Feb 2006 12:06:43 -0400 (AST) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Tue, 14 Feb 2006 16:06:41 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 14 Feb 2006 10:06:41 -0600 +Subject: Re: out of memory +From: Scott Marlowe +To: martial.bizel@free.fr +Cc: Tom Lane , pgsql-performance@postgresql.org +In-Reply-To: <1139933018.43f1ff5a5e542@imp6-g19.free.fr> +References: <1139930651.43f1f61b04773@imp2-g19.free.fr> + <15115.1139931169@sss.pgh.pa.us> + <1139933018.43f1ff5a5e542@imp6-g19.free.fr> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1139933201.22740.179.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Tue, 14 Feb 2006 10:06:41 -0600 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.167 required=5 tests=[AWL=0.166, + UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 0.167 +X-Spam-Level: +X-Archive-Number: 200602/159 +X-Sequence-Number: 17145 + +On Tue, 2006-02-14 at 10:03, martial.bizel@free.fr wrote: +> Thanks for your response, + +SNIP + +> if HashAgg operation ran out of memory, what can i do ? + +1: Don't top post. + +2: Have you run analyze? Normally when hash agg runs out of memory, the +planner THOUGHT the hash agg would fit in memory, but it was larger than +expected. This is commonly a problem when you haven't run analyze. + +From pgsql-performance-owner@postgresql.org Tue Feb 14 12:13:42 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id E3BEC9DC81F + for ; + Tue, 14 Feb 2006 12:13:41 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 58984-03 + for ; + Tue, 14 Feb 2006 12:13:39 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from correo7.acens.net (correo7.acens.net [217.116.0.41]) + by postgresql.org (Postfix) with ESMTP id 8DFAF9DC823 + for ; + Tue, 14 Feb 2006 12:13:37 -0400 (AST) +Received: (qmail 687 invoked from network); 14 Feb 2006 16:07:17 -0000 +Received: from unknown (HELO albert.sedifa.com) ([83.175.220.10]) + (envelope-sender ) + by correo7.acens.net (qmail-ldap-1.03) with SMTP + for ; 14 Feb 2006 16:07:15 -0000 +From: Albert Cervera Areny +Organization: Sedifa, S.L. +To: pgsql-performance@postgresql.org +Subject: Re: copy and postgresql.conf +Date: Tue, 14 Feb 2006 17:06:59 +0100 +User-Agent: KMail/1.7.2 +References: + <414D259CE29DE54DAD534037C83CE4B7011E485B@FR0-MAILMB20.res.airbus.corp> +In-Reply-To: + <414D259CE29DE54DAD534037C83CE4B7011E485B@FR0-MAILMB20.res.airbus.corp> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +Message-Id: <200602141706.59745.albert@sedifa.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.09 required=5 tests=[AWL=0.090] +X-Spam-Score: 0.09 +X-Spam-Level: +X-Archive-Number: 200602/160 +X-Sequence-Number: 17146 + +Sorry, COPY improvements came with 8.1=20 +(http://www.postgresql.org/docs/whatsnew) + +A Dimarts 14 Febrer 2006 14:26, FERREIRA, William (VALTECH) va escriure: +> thanks, +> +> i'm using postgresql 8.0.3 +> there is no primary key and no index on my tables +> +> regards +> +> -----Message d'origine----- +> De : pgsql-performance-owner@postgresql.org +> [mailto:pgsql-performance-owner@postgresql.org]De la part de Albert +> Cervera Areny +> Envoy=E9 : mardi 14 f=E9vrier 2006 12:38 +> =C0 : pgsql-performance@postgresql.org +> Objet : Re: [PERFORM] copy and postgresql.conf +> +> +> +> Hi William, +> which PostgreSQL version are you using? Newer (8.0+) versions have some +> +> important performance improvements for the COPY command. +> +> Also, you'll notice significant improvements by creating primary & forei= +gn +> +> keys after the copy command. I think config tweaking can improve key and +> +> index creation but I don't think you can improve the COPY command itself. +> +> There are also many threads in this list commenting on this issue, you'll +> +> find it easely in the archives. +> +> A Dimarts 14 Febrer 2006 10:44, FERREIRA, William (VALTECH) va escriure: +> > hi, +> > +> > i load data from files using copy method. +> > Files contain between 2 and 7 millions of rows, spread on 5 tables. +> > +> > For loading all the data, it takes 40mn, and the same processing takes +> > 17mn with Oracle. I think that this time can be improved by changing +> > postgresql configuration file. But which parameters i need to manipulate +> > and with which values ? +> > +> > Here are the specifications of my system : +> > V250 architecture sun4u +> > 2xCPU UltraSparc IIIi 1.28 GHz. +> > 8 Go RAM. +> > +> > Regards. +> > +> > Will +> > +> > +> > This e-mail is intended only for the above addressee. It may contain +> > privileged information. If you are not the addressee you must not copy, +> > distribute, disclose or use any of the information in it. If you have +> > received it in error please delete it and immediately notify the sender. +> > Security Notice: all e-mail, sent to or from this address, may be +> > accessed by someone other than the recipient, for system management and +> > security reasons. This access is controlled under Regulation of +> > Investigatory Powers Act 2000, Lawful Business Practises. +> > +> > ---------------------------(end of broadcast)--------------------------- +> > TIP 4: Have you searched our list archives? +> > +> > http://archives.postgresql.org +> +> -- +> +> Albert Cervera Areny +> Dept. Inform=E0tica Sedifa, S.L. +> +> Av. Can Bordoll, 149 +> 08202 - Sabadell (Barcelona) +> Tel. 93 715 51 11 +> Fax. 93 715 51 12 +> +> =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 +> ........................ AVISO LEGAL ............................ +> La presente comunicaci=F3n y sus anexos tiene como destinatario la +> persona a la que va dirigida, por lo que si usted lo recibe +> por error debe notificarlo al remitente y eliminarlo de su +> sistema, no pudiendo utilizarlo, total o parcialmente, para +> ning=FAn fin. Su contenido puede tener informaci=F3n confidencial o +> protegida legalmente y =FAnicamente expresa la opini=F3n del +> remitente. El uso del correo electr=F3nico v=EDa Internet no +> permite asegurar ni la confidencialidad de los mensajes +> ni su correcta recepci=F3n. En el caso de que el +> destinatario no consintiera la utilizaci=F3n del correo electr=F3nico, +> deber=E1 ponerlo en nuestro conocimiento inmediatamente. +> =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 +> ........................... DISCLAIMER ............................. +> This message and its attachments are intended exclusively for the +> named addressee. If you receive this message in error, please +> immediately delete it from your system and notify the sender. You +> may not use this message or any part of it for any purpose. +> The message may contain information that is confidential or +> protected by law, and any opinions expressed are those of the +> individual sender. Internet e-mail guarantees neither the +> confidentiality nor the proper receipt of the message sent. +> If the addressee of this message does not consent to the use +> of internet e-mail, please inform us inmmediately. +> =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 +> +> +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 5: don't forget to increase your free space map settings +> +> +> +> This mail has originated outside your organization, +> either from an external partner or the Global Internet. +> Keep this in mind if you answer this message. +> +> +> This e-mail is intended only for the above addressee. It may contain +> privileged information. If you are not the addressee you must not copy, +> distribute, disclose or use any of the information in it. If you have +> received it in error please delete it and immediately notify the sender. +> Security Notice: all e-mail, sent to or from this address, may be +> accessed by someone other than the recipient, for system management and +> security reasons. This access is controlled under Regulation of +> Investigatory Powers Act 2000, Lawful Business Practises. + +=2D-=20 +Albert Cervera Areny +Dept. Inform=E0tica Sedifa, S.L. + +Av. Can Bordoll, 149 +08202 - Sabadell (Barcelona) +Tel. 93 715 51 11 +=46ax. 93 715 51 12 + +=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 +=2E....................... AVISO LEGAL ............................ +La presente comunicaci=F3n y sus anexos tiene como destinatario la +persona a la que va dirigida, por lo que si usted lo recibe +por error debe notificarlo al remitente y eliminarlo de su +sistema, no pudiendo utilizarlo, total o parcialmente, para +ning=FAn fin. Su contenido puede tener informaci=F3n confidencial o +protegida legalmente y =FAnicamente expresa la opini=F3n del +remitente. El uso del correo electr=F3nico v=EDa Internet no +permite asegurar ni la confidencialidad de los mensajes +ni su correcta recepci=F3n. En el caso de que el +destinatario no consintiera la utilizaci=F3n del correo electr=F3nico, +deber=E1 ponerlo en nuestro conocimiento inmediatamente. +=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 +=2E.......................... DISCLAIMER ............................. +This message and its attachments are intended exclusively for the +named addressee. If you receive this message in error, please +immediately delete it from your system and notify the sender. You +may not use this message or any part of it for any purpose. +The message may contain information that is confidential or +protected by law, and any opinions expressed are those of the +individual sender. Internet e-mail guarantees neither the +confidentiality nor the proper receipt of the message sent. +If the addressee of this message does not consent to the use +of internet e-mail, please inform us inmmediately. +=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 + + +=20 + +From pgsql-performance-owner@postgresql.org Tue Feb 14 12:15:24 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 152719DC81F + for ; + Tue, 14 Feb 2006 12:15:24 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 59306-02 + for ; + Tue, 14 Feb 2006 12:15:22 -0400 (AST) +X-Greylist: whitelisted by SQLgrey- +Received: from smtp3-g19.free.fr (smtp3-g19.free.fr [212.27.42.29]) + by postgresql.org (Postfix) with ESMTP id F27B89DC80A + for ; + Tue, 14 Feb 2006 12:15:21 -0400 (AST) +Received: from imp6-g19.free.fr (imp6-g19.free.fr [212.27.42.6]) + by smtp3-g19.free.fr (Postfix) with ESMTP id 6D95044422; + Tue, 14 Feb 2006 17:15:21 +0100 (CET) +Received: by imp6-g19.free.fr (Postfix, from userid 33) + id EFBEA2E0F4; Tue, 14 Feb 2006 17:15:20 +0100 (MET) +Received: from wormhole.x-echo.com (wormhole.x-echo.com [193.252.148.11]) + by imp6-g19.free.fr (IMP) with HTTP + for ; Tue, 14 Feb 2006 17:15:20 +0100 +Message-ID: <1139933720.43f20218cfe3a@imp6-g19.free.fr> +Date: Tue, 14 Feb 2006 17:15:20 +0100 +From: martial.bizel@free.fr +To: Scott Marlowe +Cc: Tom Lane , pgsql-performance@postgresql.org +Subject: Re: out of memory +References: <1139930651.43f1f61b04773@imp2-g19.free.fr> + <15115.1139931169@sss.pgh.pa.us> + <1139933018.43f1ff5a5e542@imp6-g19.free.fr> + <1139933201.22740.179.camel@state.g2switchworks.com> +In-Reply-To: <1139933201.22740.179.camel@state.g2switchworks.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 8bit +User-Agent: Internet Messaging Program (IMP) 3.2.5 +X-Originating-IP: 193.252.148.11 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.646 required=5 tests=[AWL=0.096, NO_REAL_NAME=0.55] +X-Spam-Score: 0.646 +X-Spam-Level: +X-Archive-Number: 200602/161 +X-Sequence-Number: 17147 + +Yes, I've launched ANALYZE command before sending request. +I precise that's postgres version is 7.3.4 + +> On Tue, 2006-02-14 at 10:03, martial.bizel@free.fr wrote: +> > Thanks for your response, +> +> SNIP +> +> > if HashAgg operation ran out of memory, what can i do ? +> +> 1: Don't top post. +> +> 2: Have you run analyze? Normally when hash agg runs out of memory, the +> planner THOUGHT the hash agg would fit in memory, but it was larger than +> expected. This is commonly a problem when you haven't run analyze. +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 5: don't forget to increase your free space map settings +> + + + +From pgsql-performance-owner@postgresql.org Tue Feb 14 12:17:15 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id D081D9DC881 + for ; + Tue, 14 Feb 2006 12:17:14 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 59463-02 + for ; + Tue, 14 Feb 2006 12:17:12 -0400 (AST) +X-Greylist: delayed 00:25:42.506916 by SQLgrey- +Received: from timberline.ca (unknown [66.244.194.163]) + by postgresql.org (Postfix) with ESMTP id 9DF2C9DC83F + for ; + Tue, 14 Feb 2006 12:17:09 -0400 (AST) +Received: from tfic21 ([172.16.10.21]) + by timberline.ca (8.12.9/8.12.9) with ESMTP id k1EGH8iO021425 + for ; + Tue, 14 Feb 2006 08:17:09 -0800 (PST) +Message-Id: <200602141617.k1EGH8iO021425@timberline.ca> +From: "Jay Greenfield" +To: +Subject: Re: Postgres slower than MS ACCESS +Date: Tue, 14 Feb 2006 08:17:08 -0800 +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: <1139933084.22740.177.camel@state.g2switchworks.com> +Thread-Index: AcYxgHEdMx884UH3RvijaSItLyJrBAAAQP/Q +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.001 required=5 tests=[AWL=0.001] +X-Spam-Score: 0.001 +X-Spam-Level: +X-Archive-Number: 200602/162 +X-Sequence-Number: 17148 + +Is it possible to configure Postgres to behave like Access - a single user +and use as much of the recourses as required? + +Thanks, + +Jay. +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Scott Marlowe +Sent: Tuesday, February 14, 2006 8:05 AM +To: Jay Greenfield +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Postgres slower than MS ACCESS + +On Tue, 2006-02-14 at 09:51, Jay Greenfield wrote: +> I am running some simple queries to benchmark Postgres 8.1 against MS +> Access and Postgres is 2 to 3 times slower that Access. + +A BUNCH OF STUFF SNIPPED + +> Why does Access run so much faster? How can I get Postgres to run as +> fast as Access? + +Because Access is not a multi-user database management system designed +to handle anywhere from a couple to several thousand users at the same +time? + +PostgreSQL can do this update while still allowing users to access the +data in the database, and can handle updates to the same table at the +same time, as long as they aren't hitting the same rows. + +They're two entirely different beasts. + +One is good at batch processing moderate amounts of data for one user at +a time. The other is good for real time processing of very large +amounts of data for a fairly large number of users while running at an +acceptable, if slower speed. + +---------------------------(end of broadcast)--------------------------- +TIP 9: In versions below 8.0, the planner will ignore your desire to + choose an index scan if your joining column's datatypes do not + match + + +From pgsql-performance-owner@postgresql.org Tue Feb 14 12:21:41 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 67DC79DCC53 + for ; + Tue, 14 Feb 2006 12:21:40 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 60100-03 + for ; + Tue, 14 Feb 2006 12:21:38 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id 474D59DCB82 + for ; + Tue, 14 Feb 2006 12:21:38 -0400 (AST) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Tue, 14 Feb 2006 16:21:37 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 14 Feb 2006 10:21:37 -0600 +Subject: Re: out of memory +From: Scott Marlowe +To: martial.bizel@free.fr +Cc: Tom Lane , pgsql-performance@postgresql.org +In-Reply-To: <1139933720.43f20218cfe3a@imp6-g19.free.fr> +References: <1139930651.43f1f61b04773@imp2-g19.free.fr> + <15115.1139931169@sss.pgh.pa.us> + <1139933018.43f1ff5a5e542@imp6-g19.free.fr> + <1139933201.22740.179.camel@state.g2switchworks.com> + <1139933720.43f20218cfe3a@imp6-g19.free.fr> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1139934097.22740.182.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Tue, 14 Feb 2006 10:21:37 -0600 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.167 required=5 tests=[AWL=0.166, + UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 0.167 +X-Spam-Level: +X-Archive-Number: 200602/163 +X-Sequence-Number: 17149 + +On Tue, 2006-02-14 at 10:15, martial.bizel@free.fr wrote: +> Yes, I've launched ANALYZE command before sending request. +> I precise that's postgres version is 7.3.4 + +So what does explain analyze show for this query, if anything? Can you +increase your sort_mem or shared_buffers (I forget which hash_agg uses +off the top of my head...) if necessary to make it work. Note you can +increase sort_mem on the fly for a given connection. + +From pgsql-performance-owner@postgresql.org Tue Feb 14 12:23:12 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 576F49DC80A + for ; + Tue, 14 Feb 2006 12:23:12 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 59427-04 + for ; + Tue, 14 Feb 2006 12:23:10 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id 0BD299DC81F + for ; + Tue, 14 Feb 2006 12:23:09 -0400 (AST) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Tue, 14 Feb 2006 16:23:09 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 14 Feb 2006 10:23:09 -0600 +Subject: Re: Postgres slower than MS ACCESS +From: Scott Marlowe +To: Jay Greenfield +Cc: pgsql-performance@postgresql.org +In-Reply-To: <200602141617.k1EGH8iO021425@timberline.ca> +References: <200602141617.k1EGH8iO021425@timberline.ca> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1139934189.22740.184.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Tue, 14 Feb 2006 10:23:09 -0600 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.166 required=5 tests=[AWL=0.165, + UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 0.166 +X-Spam-Level: +X-Archive-Number: 200602/164 +X-Sequence-Number: 17150 + +On Tue, 2006-02-14 at 10:17, Jay Greenfield wrote: +> Is it possible to configure Postgres to behave like Access - a single user +> and use as much of the recourses as required? + +No. If you want something akin to that, try SQL Lite. it's not as +featureful as PostgreSQL, but it's closer to it than Access. + +From pgsql-performance-owner@postgresql.org Wed Feb 15 09:47:30 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 9A3249DCAB8 + for ; + Wed, 15 Feb 2006 09:47:29 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 22753-10 + for ; + Wed, 15 Feb 2006 09:47:32 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.logix-tt.com (serval.logix-tt.com [213.239.221.42]) + by postgresql.org (Postfix) with ESMTP id 09C0E9DCA8F + for ; + Wed, 15 Feb 2006 09:47:26 -0400 (AST) +Received: from kingfisher.intern.logix-tt.com (Md49f.m.pppool.de + [89.49.212.159]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logix-tt.com (Postfix) with ESMTP id DD8E624407F; + Wed, 15 Feb 2006 14:47:33 +0100 (CET) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id ED5C81816770F; + Tue, 14 Feb 2006 17:29:33 +0100 (CET) +Message-ID: <43F2056C.2040109@logix-tt.com> +Date: Tue, 14 Feb 2006 17:29:32 +0100 +From: Markus Schaber +Organization: Logical Tracking and Tracing International AG, Switzerland +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "FERREIRA, William (VALTECH)" +Cc: pgsql-performance@postgresql.org +Subject: Re: copy and postgresql.conf +References: + <414D259CE29DE54DAD534037C83CE4B7269627@FR0-MAILMB20.res.airbus.corp> +In-Reply-To: + <414D259CE29DE54DAD534037C83CE4B7269627@FR0-MAILMB20.res.airbus.corp> +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.121 required=5 tests=[AWL=0.121] +X-Spam-Score: 0.121 +X-Spam-Level: +X-Archive-Number: 200602/190 +X-Sequence-Number: 17176 + +Hi, Ferreira, + +FERREIRA, William (VALTECH) wrote: + +> i load data from files using copy method. +> Files contain between 2 and 7 millions of rows, spread on 5 tables. +> +> For loading all the data, it takes 40mn, and the same processing takes 17mn with Oracle. +> I think that this time can be improved by changing postgresql configuration file. +> But which parameters i need to manipulate and with which values ? + +Increase the size of the wal. + +If its just a develpoment environment, or you don't mind data +inconsistency in case of a crash, disable fsync. + +HTH, +Markus + + +-- +Markus Schaber | Logical Tracking&Tracing International AG +Dipl. Inf. | Software Development GIS + +Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org + +From pgsql-performance-owner@postgresql.org Tue Feb 14 12:32:38 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 31DBD9DC842 + for ; + Tue, 14 Feb 2006 12:32:37 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 61286-02 + for ; + Tue, 14 Feb 2006 12:32:35 -0400 (AST) +X-Greylist: whitelisted by SQLgrey- +Received: from smtp6-g19.free.fr (smtp6-g19.free.fr [212.27.42.36]) + by postgresql.org (Postfix) with ESMTP id 7F5299DC804 + for ; + Tue, 14 Feb 2006 12:32:34 -0400 (AST) +Received: from imp1-g19.free.fr (imp1-g19.free.fr [212.27.42.1]) + by smtp6-g19.free.fr (Postfix) with ESMTP id 2AC94182F8 + for ; + Tue, 14 Feb 2006 17:32:34 +0100 (CET) +Received: by imp1-g19.free.fr (Postfix, from userid 33) + id E6A85D9E02; Tue, 14 Feb 2006 17:32:33 +0100 (MET) +Received: from wormhole.x-echo.com (wormhole.x-echo.com [193.252.148.11]) + by imp1-g19.free.fr (IMP) with HTTP + for ; Tue, 14 Feb 2006 17:32:33 +0100 +Message-ID: <1139934753.43f20621ba78d@imp1-g19.free.fr> +Date: Tue, 14 Feb 2006 17:32:33 +0100 +From: martial.bizel@free.fr +To: pgsql-performance@postgresql.org +Subject: Re: out of memory +References: <1139930651.43f1f61b04773@imp2-g19.free.fr> + <15115.1139931169@sss.pgh.pa.us> + <1139933018.43f1ff5a5e542@imp6-g19.free.fr> + <1139933201.22740.179.camel@state.g2switchworks.com> + <1139933720.43f20218cfe3a@imp6-g19.free.fr> + <1139934097.22740.182.camel@state.g2switchworks.com> +In-Reply-To: <1139934097.22740.182.camel@state.g2switchworks.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 8bit +User-Agent: Internet Messaging Program (IMP) 3.2.5 +X-Originating-IP: 193.252.148.11 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.653 required=5 tests=[AWL=0.103, NO_REAL_NAME=0.55] +X-Spam-Score: 0.653 +X-Spam-Level: +X-Archive-Number: 200602/165 +X-Sequence-Number: 17151 + +command explain analyze crash with the "out of memory" error + +I precise that I've tried a lot of values from parameters shared_buffer and +sort_mem + +now, in config file, values are : +sort_mem=32768 +and shared_buffer=30000 + +server has 4Go RAM. +and kernel.shmmax=307200000 + + + +> On Tue, 2006-02-14 at 10:15, martial.bizel@free.fr wrote: +> > Yes, I've launched ANALYZE command before sending request. +> > I precise that's postgres version is 7.3.4 +> +> So what does explain analyze show for this query, if anything? Can you +> increase your sort_mem or shared_buffers (I forget which hash_agg uses +> off the top of my head...) if necessary to make it work. Note you can +> increase sort_mem on the fly for a given connection. +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 5: don't forget to increase your free space map settings +> + + + +From pgsql-performance-owner@postgresql.org Tue Feb 14 12:45:17 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id B127D9DCC2C + for ; + Tue, 14 Feb 2006 12:45:16 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 63091-05 + for ; + Tue, 14 Feb 2006 12:45:15 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from outbound-smtp.firstam.com (outbound-smtp8.firstam.com + [69.87.54.13]) by postgresql.org (Postfix) with ESMTP id 3AC269DCBC7 + for ; + Tue, 14 Feb 2006 12:45:13 -0400 (AST) +Received: from 10.48.129.31 by outbound-smtp.firstam.com with ESMTP ( + Hello SMTP Relay); Tue, 14 Feb 2006 08:45:08 -0800 +X-Server-Uuid: 1D7F689F-39FD-4AFF-8F38-B634E01B4C93 +Received: from unknown (HELO pisgsna01smmx01.ana.firstamdata.com) ( + [172.17.88.35]) by FAEMSNA01SMXS01.firstam.com with ESMTP; 14 Feb 2006 + 08:45:09 -0800 +Received: from pisgsna01sxch21.ana.firstamdata.com (Not + Verified[172.17.88.71]) by pisgsna01smmx01.ana.firstamdata.com with + NetIQ MailMarshal 6.0 Service Pack 1a (v6,0,3,33) id ; + Tue, 14 Feb 2006 08:45:08 -0800 +Received: from pisgsna01sxch01.ana.firstamdata.com ([172.17.88.70]) by + pisgsna01sxch21.ana.firstamdata.com with Microsoft + SMTPSVC(6.0.3790.1830); Tue, 14 Feb 2006 08:45:08 -0800 +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Subject: 0ut of Memory Error during Vacuum Analyze +Date: Tue, 14 Feb 2006 08:45:08 -0800 +Message-ID: + +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] 0ut of Memory Error during Vacuum Analyze +Thread-Index: AcYxgLw/qZEccBTqSIiBrHFWvkPSPgAA0WuA +From: "Tomeh, Husam" +To: pgsql-performance@postgresql.org +X-OriginalArrivalTime: 14 Feb 2006 16:45:08.0581 (UTC) + FILETIME=[03CD6950:01C63186] +X-TMWD-Spam-Summary: SEV=1.1; DFV=A2006021406; IFV=2.0.6,4.0-7; RPD=4.00.0004; + RPDID=303030312E30413039303230362E34334632303731322E303031373A5343464D413534333432342D462D2F4E4553574B563534472F71554B6D71577A564237673D3D; + ENG=IBF; TS=20060214164509; CAT=NONE; CON=NONE; +X-WSS-ID: 6FECD69E3Z41841275-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, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200602/166 +X-Sequence-Number: 17152 + +=20 +This is the second time I'm getting out of memory error when I start a +database vacuum or try to vacuum any table. Note this machine has been +used for data load batch purposes.=20 + +=3D# vacuum analyze code; +ERROR: out of memory +DETAIL: Failed on request of size 1073741820. + +I'm running Postgres 8.1.1 on RedHat 2.6 kernel (HP server).=20 +My maintenance work area never been changed. It's set to 1GB. +(maintenance_work_mem =3D 1048576). Physical memory: 32 GB. =20 + +Bouncing the database does not help.=20 + +Two workarounds I have used so far: + +=20 1) Decreasing the maintenance_work_mem to 512MB, vacuum analyze would= + +work just fine. + +Or=20 + +=20 2) Bouncing the server (maintaining the original 1GB +maintenance_work_mem) would also work. + +I have not had that error on the production instances (which are +identical copies of the loading instance) - only the loading instance.. + +Any explanation as to why and how to avoid that ? Thanks + + +---- +=20 +=20 Husam =20 +********************************************************************** +This message contains confidential information intended only for the use = +of the addressee(s) named above and may contain information that is legal= +ly privileged. If you are not the addressee, or the person responsible f= +or delivering it to the addressee, you are hereby notified that reading, = +disseminating, distributing or copying this message is strictly prohibite= +d. If you have received this message by mistake, please immediately noti= +fy us by replying to the message and delete the original message immediat= +ely thereafter. + +Thank you. +=0D +=20 FADLD Tag +********************************************************************** + + +From pgsql-performance-owner@postgresql.org Tue Feb 14 12:50:40 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 9208F9DC8AE + for ; + Tue, 14 Feb 2006 12:50:39 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 61772-09 + for ; + Tue, 14 Feb 2006 12:50:38 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id 11DBC9DC89D + for ; + Tue, 14 Feb 2006 12:50:36 -0400 (AST) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Tue, 14 Feb 2006 16:50:35 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 14 Feb 2006 10:50:35 -0600 +Subject: Re: out of memory +From: Scott Marlowe +To: martial.bizel@free.fr +Cc: pgsql-performance@postgresql.org +In-Reply-To: <1139934753.43f20621ba78d@imp1-g19.free.fr> +References: <1139930651.43f1f61b04773@imp2-g19.free.fr> + <15115.1139931169@sss.pgh.pa.us> + <1139933018.43f1ff5a5e542@imp6-g19.free.fr> + <1139933201.22740.179.camel@state.g2switchworks.com> + <1139933720.43f20218cfe3a@imp6-g19.free.fr> + <1139934097.22740.182.camel@state.g2switchworks.com> + <1139934753.43f20621ba78d@imp1-g19.free.fr> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1139935835.22740.188.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Tue, 14 Feb 2006 10:50:35 -0600 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.166 required=5 tests=[AWL=0.165, + UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 0.166 +X-Spam-Level: +X-Archive-Number: 200602/167 +X-Sequence-Number: 17153 + +On Tue, 2006-02-14 at 10:32, martial.bizel@free.fr wrote: +> command explain analyze crash with the "out of memory" error +> +> I precise that I've tried a lot of values from parameters shared_buffer and +> sort_mem +> +> now, in config file, values are : +> sort_mem=32768 +> and shared_buffer=30000 + +OK, on the command line, try increasing the sort_mem until hash_agg can +work. With a 4 gig machine, you should be able to go as high as needed +here, I'd think. Try as high as 500000 or so or more. Then when +explain analyze works, compare the actual versus estimated number of +rows. + +From pgsql-performance-owner@postgresql.org Tue Feb 14 13:05:33 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 26E309DCB8C + for ; + Tue, 14 Feb 2006 13:05:32 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 69076-02 + for ; + Tue, 14 Feb 2006 13:05:30 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from eads-av-smtp4.gmessaging.net (eads-av-smtp4.gmessaging.net + [194.51.201.29]) + by postgresql.org (Postfix) with ESMTP id 528F09DCC2C + for ; + Tue, 14 Feb 2006 13:05:28 -0400 (AST) +Received: from eads-relay4.cesson.gm-adm (localhost [127.0.0.1]) + by eads-av-smtp4.gmessaging.net + (iPlanet Messaging Server 5.2 HotFix 2.04 (built Feb 8 2005)) + with ESMTP id <0IUO005R6SSWI0@eads-av-smtp4.gmessaging.net> for + pgsql-performance@postgresql.org; Tue, 14 Feb 2006 18:05:23 +0100 (MET) +Received: from fr0-mailsp02.res.airbus.corp ([10.254.251.55]) + by eads-av-smtp4.gmessaging.net + (iPlanet Messaging Server 5.2 HotFix 2.04 (built Feb 8 2005)) + with ESMTP id <0IUO00833SSTQC@eads-av-smtp4.gmessaging.net> for + pgsql-performance@postgresql.org; Tue, 14 Feb 2006 18:05:20 +0100 (MET) +Received: from fr0-mailsp02.res.airbus.corp (localhost.localdomain + [127.0.0.1]) + by fr0-mailsp02.res.airbus.corp (8.12.11/8.12.10) with ESMTP id + k1EH5Fex031334 + for ; Tue, 14 Feb 2006 18:05:15 +0100 +Received: from fr0-mailrt11.res.airbus.corp ([152.9.126.25]) + by fr0-mailsp02.res.airbus.corp (8.12.11/8.12.10) + with ESMTP id k1EH4xsE031162; Tue, 14 Feb 2006 18:05:14 +0100 +Received: from fr0-mailrt04.res.airbus.corp ([152.9.126.23]) + by fr0-mailrt11.res.airbus.corp with Microsoft SMTPSVC(5.0.2195.6713); + Tue, 14 Feb 2006 18:05:13 +0100 +Received: from FR0-MAILMB20.res.airbus.corp ([152.9.126.74]) + by fr0-mailrt04.res.airbus.corp with Microsoft SMTPSVC(5.0.2195.6713); + Tue, 14 Feb 2006 18:05:09 +0100 +Date: Tue, 14 Feb 2006 18:05:09 +0100 +From: "FERREIRA, William (VALTECH)" +Subject: Re: copy and postgresql.conf +To: Albert Cervera Areny , pgsql-performance@postgresql.org +Message-id: + <414D259CE29DE54DAD534037C83CE4B7011E4864@FR0-MAILMB20.res.airbus.corp> +MIME-version: 1.0 +X-MIMEOLE: Produced By Microsoft Exchange V6.0.6603.0 +Content-type: text/plain; charset=iso-8859-1 +Content-transfer-encoding: quoted-printable +Content-class: urn:content-classes:message +Thread-topic: [PERFORM] copy and postgresql.conf +Thread-index: AcYxgh0JqGmgdW2VSlie39PaFfKDPgABq2OA +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +X-OriginalArrivalTime: 14 Feb 2006 17:05:09.0690 (UTC) + FILETIME=[CFB819A0:01C63188] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.218 required=5 tests=[AWL=0.218] +X-Spam-Score: 0.218 +X-Spam-Level: +X-Archive-Number: 200602/168 +X-Sequence-Number: 17154 + + +30% faster !!! i will test this new version ... + +thanks a lot + +-----Message d'origine----- +De : pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org]De la part de Albert +Cervera Areny +Envoy=E9 : mardi 14 f=E9vrier 2006 17:07 +=C0 : pgsql-performance@postgresql.org +Objet : Re: [PERFORM] copy and postgresql.conf + + + +Sorry, COPY improvements came with 8.1 + +(http://www.postgresql.org/docs/whatsnew) + +A Dimarts 14 Febrer 2006 14:26, FERREIRA, William (VALTECH) va escriure: +> thanks, +> +> i'm using postgresql 8.0.3 +> there is no primary key and no index on my tables +> +> regards +> +> -----Message d'origine----- +> De : pgsql-performance-owner@postgresql.org +> [mailto:pgsql-performance-owner@postgresql.org]De la part de Albert +> Cervera Areny +> Envoy=E9 : mardi 14 f=E9vrier 2006 12:38 +> =C0 : pgsql-performance@postgresql.org +> Objet : Re: [PERFORM] copy and postgresql.conf +> +> +> +> Hi William, +> which PostgreSQL version are you using? Newer (8.0+) versions have some +> +> important performance improvements for the COPY command. +> +> Also, you'll notice significant improvements by creating primary &= + foreign +> +> keys after the copy command. I think config tweaking can improve key and +> +> index creation but I don't think you can improve the COPY command itself. +> +> There are also many threads in this list commenting on this issue,= + you'll +> +> find it easely in the archives. +> +> A Dimarts 14 Febrer 2006 10:44, FERREIRA, William (VALTECH) va escriure: +> > hi, +> > +> > i load data from files using copy method. +> > Files contain between 2 and 7 millions of rows, spread on 5 tables. +> > +> > For loading all the data, it takes 40mn, and the same processing takes +> > 17mn with Oracle. I think that this time can be improved by changing +> > postgresql configuration file. But which parameters i need to= + manipulate +> > and with which values ? +> > +> > Here are the specifications of my system : +> > V250 architecture sun4u +> > 2xCPU UltraSparc IIIi 1.28 GHz. +> > 8 Go RAM. +> > +> > Regards. +> > +> > Will +> > +> > +> > This e-mail is intended only for the above addressee. It may contain +> > privileged information. If you are not the addressee you must not copy, +> > distribute, disclose or use any of the information in it. If you have +> > received it in error please delete it and immediately notify the= + sender. +> > Security Notice: all e-mail, sent to or from this address, may be +> > accessed by someone other than the recipient, for system management and +> > security reasons. This access is controlled under Regulation of +> > Investigatory Powers Act 2000, Lawful Business Practises. +> > +> > ---------------------------(end of= + broadcast)--------------------------- +> > TIP 4: Have you searched our list archives? +> > +> > http://archives.postgresql.org +> +> -- +> +> Albert Cervera Areny +> Dept. Inform=E0tica Sedifa, S.L. +> +> Av. Can Bordoll, 149 +> 08202 - Sabadell (Barcelona) +> Tel. 93 715 51 11 +> Fax. 93 715 51 12 +> +> =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 +> ........................ AVISO LEGAL ............................ +> La presente comunicaci=F3n y sus anexos tiene como destinatario la +> persona a la que va dirigida, por lo que si usted lo recibe +> por error debe notificarlo al remitente y eliminarlo de su +> sistema, no pudiendo utilizarlo, total o parcialmente, para +> ning=FAn fin. Su contenido puede tener informaci=F3n confidencial o +> protegida legalmente y =FAnicamente expresa la opini=F3n del +> remitente. El uso del correo electr=F3nico v=EDa Internet no +> permite asegurar ni la confidencialidad de los mensajes +> ni su correcta recepci=F3n. En el caso de que el +> destinatario no consintiera la utilizaci=F3n del correo electr=F3nico, +> deber=E1 ponerlo en nuestro conocimiento inmediatamente. +> =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 +> ........................... DISCLAIMER ............................. +> This message and its attachments are intended exclusively for the +> named addressee. If you receive this message in error, please +> immediately delete it from your system and notify the sender. You +> may not use this message or any part of it for any purpose. +> The message may contain information that is confidential or +> protected by law, and any opinions expressed are those of the +> individual sender. Internet e-mail guarantees neither the +> confidentiality nor the proper receipt of the message sent. +> If the addressee of this message does not consent to the use +> of internet e-mail, please inform us inmmediately. +> =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 +> +> +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 5: don't forget to increase your free space map settings +> +> +> +> This mail has originated outside your organization, +> either from an external partner or the Global Internet. +> Keep this in mind if you answer this message. +> +> +> This e-mail is intended only for the above addressee. It may contain +> privileged information. If you are not the addressee you must not copy, +> distribute, disclose or use any of the information in it. If you have +> received it in error please delete it and immediately notify the sender. +> Security Notice: all e-mail, sent to or from this address, may be +> accessed by someone other than the recipient, for system management and +> security reasons. This access is controlled under Regulation of +> Investigatory Powers Act 2000, Lawful Business Practises. + +-- + +Albert Cervera Areny +Dept. Inform=E0tica Sedifa, S.L. + +Av. Can Bordoll, 149 +08202 - Sabadell (Barcelona) +Tel. 93 715 51 11 +Fax. 93 715 51 12 + +=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 +........................ AVISO LEGAL ............................ +La presente comunicaci=F3n y sus anexos tiene como destinatario la +persona a la que va dirigida, por lo que si usted lo recibe +por error debe notificarlo al remitente y eliminarlo de su +sistema, no pudiendo utilizarlo, total o parcialmente, para +ning=FAn fin. Su contenido puede tener informaci=F3n confidencial o +protegida legalmente y =FAnicamente expresa la opini=F3n del +remitente. El uso del correo electr=F3nico v=EDa Internet no +permite asegurar ni la confidencialidad de los mensajes +ni su correcta recepci=F3n. En el caso de que el +destinatario no consintiera la utilizaci=F3n del correo electr=F3nico, +deber=E1 ponerlo en nuestro conocimiento inmediatamente. +=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 +........................... DISCLAIMER ............................. +This message and its attachments are intended exclusively for the +named addressee. If you receive this message in error, please +immediately delete it from your system and notify the sender. You +may not use this message or any part of it for any purpose. +The message may contain information that is confidential or +protected by law, and any opinions expressed are those of the +individual sender. Internet e-mail guarantees neither the +confidentiality nor the proper receipt of the message sent. +If the addressee of this message does not consent to the use +of internet e-mail, please inform us inmmediately. +=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 + + + + + +---------------------------(end of broadcast)--------------------------- +TIP 5: don't forget to increase your free space map settings + + + +This mail has originated outside your organization, +either from an external partner or the Global Internet. +Keep this in mind if you answer this message. + +=0D +This e-mail is intended only for the above addressee. It may contain +privileged information. If you are not the addressee you must not copy, +distribute, disclose or use any of the information in it. If you have +received it in error please delete it and immediately notify the sender. +Security Notice: all e-mail, sent to or from this address, may be +accessed by someone other than the recipient, for system management and +security reasons. This access is controlled under Regulation of +Investigatory Powers Act 2000, Lawful Business Practises. + +From pgsql-performance-owner@postgresql.org Tue Feb 14 13:19:26 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id A94FA9DC842 + for ; + Tue, 14 Feb 2006 13:19:25 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 69439-07 + for ; + Tue, 14 Feb 2006 13:19:23 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from ns.snowman.net (ns.snowman.net [66.92.160.21]) + by postgresql.org (Postfix) with ESMTP id 7AFD69DC804 + for ; + Tue, 14 Feb 2006 13:19:22 -0400 (AST) +Received: by ns.snowman.net (Postfix, from userid 1000) + id B072117BAA; Tue, 14 Feb 2006 12:20:22 -0500 (EST) +Date: Tue, 14 Feb 2006 12:20:22 -0500 +From: Stephen Frost +To: Jay Greenfield +Cc: pgsql-performance@postgresql.org +Subject: Re: Postgres slower than MS ACCESS +Message-ID: <20060214172022.GC4474@ns.snowman.net> +Mail-Followup-To: Jay Greenfield , + pgsql-performance@postgresql.org +References: <200602141551.k1EFpN6F020512@timberline.ca> +MIME-Version: 1.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; boundary="wahTu2FS/smxRA7d" +Content-Disposition: inline +In-Reply-To: <200602141551.k1EFpN6F020512@timberline.ca> +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: 12:13:57 up 248 days, 9:22, 13 users, load average: 0.38, 0.60, 0.60 +User-Agent: Mutt/1.5.11 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.111 required=5 tests=[AWL=0.111] +X-Spam-Score: 0.111 +X-Spam-Level: +X-Archive-Number: 200602/169 +X-Sequence-Number: 17155 + + +--wahTu2FS/smxRA7d +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +Content-Transfer-Encoding: quoted-printable + +* Jay Greenfield (jag@timberline.ca) wrote: +> Database has one table with 1.2 million rows +> Query: +>=20 +> UPDATE ntdn SET gha=3Darea/10000 +>=20 +> I could post the EXPLAIN ANALYZE results but its 4,000+ lines long + +How do you get 4,000+ lines of explain analyze for one update query in a +database with only one table? Something a bit fishy there. Perhaps you=20 +mean explain verbose, though I don't really see how that'd be so long=20 +either, but it'd be closer. Could you provide some more sane +information? + +> I've run various tests on a number of Postgres parameters; none of which +> have come close to Access' time of 5.00 min. Postgres times range between +> 24 min and 121 min. +>=20 +> Some of the Postgres variables and ranges I've tested. +> work_mem: 1,000 to 2,000,000 +> temp_buffers: 1,000 to 10,000 +> shared_buffers: 1,000 to 64,000 +> sort_mem: 1,024,000 +> fsync on / off +>=20 +> Why does Access run so much faster? How can I get Postgres to run as fast +> as Access? + +While it's true that Access almost certainly takes some shortcuts, 24 +minutes for an update across 1.2 millon rows seems an awefully long time +for Postgres. Is this table exceptionally large in same way (ie: lots=20 +of columns)? I expect running with fsync off would be closer to 'Access +mode' though it has risks (of course). Also, it might be faster to +insert into a seperate table rather than run a huge update like that in +Postgres. Also, if there are indexes on the table in question, you +might drop them before doing the update/insert and recreate them after +the query has finished. + +You really havn't provided anywhere near enough information to figure +out what the actual problem is here. Access does take shortcuts but the +times you're posting for Postgres seem quite far off based on the +hardware and commands you've described... + + Thanks, + + Stephen + +--wahTu2FS/smxRA7d +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: Digital signature +Content-Disposition: inline + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.2 (GNU/Linux) + +iD8DBQFD8hFWrzgMPqB3kigRAp9WAJ9eeECf1tV9jOQNH1qWEeq1pGa6hgCfRlZM +9rzEn6mVVcY9JrDoQn6yXpM= +=VMWg +-----END PGP SIGNATURE----- + +--wahTu2FS/smxRA7d-- + +From pgsql-performance-owner@postgresql.org Tue Feb 14 13:36:57 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 2387E9DC881 + for ; + Tue, 14 Feb 2006 13:36:57 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 73935-03 + for ; + Tue, 14 Feb 2006 13:36:56 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id D4C819DC81F + for ; + Tue, 14 Feb 2006 13:36:54 -0400 (AST) +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 k1EHaq4n019748; + Tue, 14 Feb 2006 12:36:52 -0500 (EST) +To: martial.bizel@free.fr +cc: Scott Marlowe , + pgsql-performance@postgresql.org +Subject: Re: out of memory +In-reply-to: <1139933720.43f20218cfe3a@imp6-g19.free.fr> +References: <1139930651.43f1f61b04773@imp2-g19.free.fr> + <15115.1139931169@sss.pgh.pa.us> + <1139933018.43f1ff5a5e542@imp6-g19.free.fr> + <1139933201.22740.179.camel@state.g2switchworks.com> + <1139933720.43f20218cfe3a@imp6-g19.free.fr> +Comments: In-reply-to martial.bizel@free.fr + message dated "Tue, 14 Feb 2006 17:15:20 +0100" +Date: Tue, 14 Feb 2006 12:36:52 -0500 +Message-ID: <19747.1139938612@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.109 required=5 tests=[AWL=0.109] +X-Spam-Score: 0.109 +X-Spam-Level: +X-Archive-Number: 200602/170 +X-Sequence-Number: 17156 + +martial.bizel@free.fr writes: +> Yes, I've launched ANALYZE command before sending request. +> I precise that's postgres version is 7.3.4 + +Can't possibly be 7.3.4, that version didn't have HashAggregate. + +How many distinct values of "query" actually exist in the table? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Feb 14 13:47:36 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id CE1D09DC89D + for ; + Tue, 14 Feb 2006 13:47:35 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 75835-05 + for ; + Tue, 14 Feb 2006 13:47:35 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id A1E4A9DC881 + for ; + Tue, 14 Feb 2006 13:47:33 -0400 (AST) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Tue, 14 Feb 2006 17:47:33 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 14 Feb 2006 11:47:33 -0600 +Subject: Re: out of memory +From: Scott Marlowe +To: Tom Lane +Cc: martial.bizel@free.fr, pgsql-performance@postgresql.org +In-Reply-To: <19747.1139938612@sss.pgh.pa.us> +References: <1139930651.43f1f61b04773@imp2-g19.free.fr> + <15115.1139931169@sss.pgh.pa.us> + <1139933018.43f1ff5a5e542@imp6-g19.free.fr> + <1139933201.22740.179.camel@state.g2switchworks.com> + <1139933720.43f20218cfe3a@imp6-g19.free.fr> + <19747.1139938612@sss.pgh.pa.us> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1139939253.22740.193.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Tue, 14 Feb 2006 11:47:33 -0600 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.165 required=5 tests=[AWL=0.164, + UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 0.165 +X-Spam-Level: +X-Archive-Number: 200602/171 +X-Sequence-Number: 17157 + +On Tue, 2006-02-14 at 11:36, Tom Lane wrote: +> martial.bizel@free.fr writes: +> > Yes, I've launched ANALYZE command before sending request. +> > I precise that's postgres version is 7.3.4 +> +> Can't possibly be 7.3.4, that version didn't have HashAggregate. +> +> How many distinct values of "query" actually exist in the table? + +I thought that looked odd. + +From pgsql-performance-owner@postgresql.org Tue Feb 14 13:50:53 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 06B9F9DC987 + for ; + Tue, 14 Feb 2006 13:50:53 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 75126-06 + for ; + Tue, 14 Feb 2006 13:50:52 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id D43099DC93D + for ; + Tue, 14 Feb 2006 13:50:50 -0400 (AST) +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 k1EHolRk019987; + Tue, 14 Feb 2006 12:50:47 -0500 (EST) +To: "Tomeh, Husam" +cc: pgsql-performance@postgresql.org +Subject: Re: 0ut of Memory Error during Vacuum Analyze +In-reply-to: + +References: + +Comments: In-reply-to "Tomeh, Husam" + message dated "Tue, 14 Feb 2006 08:45:08 -0800" +Date: Tue, 14 Feb 2006 12:50:47 -0500 +Message-ID: <19986.1139939447@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.109 required=5 tests=[AWL=0.109] +X-Spam-Score: 0.109 +X-Spam-Level: +X-Archive-Number: 200602/172 +X-Sequence-Number: 17158 + +"Tomeh, Husam" writes: +> =# vacuum analyze code; +> ERROR: out of memory +> DETAIL: Failed on request of size 1073741820. + +That looks a whole lot like a corrupt-data issue. The apparent +dependency on maintenance_work_mem is probably illusory --- I suspect +some of your trials are selecting the corrupted row to use in the +ANALYZE stats, and others are randomly selecting other rows. + +If you are able to pg_dump the table in question then this theory is +wrong, but I'd suggest trying that first. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Feb 14 16:42:46 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id E50DF9DC9DC + for ; + Tue, 14 Feb 2006 16:42:45 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 55056-03 + for ; + Tue, 14 Feb 2006 16:42:46 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id B44CF9DC9AC + for ; + Tue, 14 Feb 2006 16:42:42 -0400 (AST) +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 k1EKgib4022348; + Tue, 14 Feb 2006 15:42:44 -0500 (EST) +To: Stephen Frost +cc: Jay Greenfield , pgsql-performance@postgresql.org +Subject: Re: Postgres slower than MS ACCESS +In-reply-to: <20060214172022.GC4474@ns.snowman.net> +References: <200602141551.k1EFpN6F020512@timberline.ca> + <20060214172022.GC4474@ns.snowman.net> +Comments: In-reply-to Stephen Frost + message dated "Tue, 14 Feb 2006 12:20:22 -0500" +Date: Tue, 14 Feb 2006 15:42:44 -0500 +Message-ID: <22347.1139949764@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.109 required=5 tests=[AWL=0.109] +X-Spam-Score: 0.109 +X-Spam-Level: +X-Archive-Number: 200602/173 +X-Sequence-Number: 17159 + +Stephen Frost writes: +> While it's true that Access almost certainly takes some shortcuts, 24 +> minutes for an update across 1.2 millon rows seems an awefully long time +> for Postgres. + +I did some experiments along this line with a trivial table (2 integer +columns) of 1.28M rows. I used CVS tip with all parameters at defaults. +With no indexes, an UPDATE took about 50 seconds. With one index, it +took 628 seconds. It's not hard to believe you could get to Jay's +figures with multiple indexes. + +Looking in the postmaster log, I see I was getting checkpoints every few +seconds. Increasing checkpoint_segments to 30 (a factor of 10) brought +it down to 355 seconds, and then increasing shared_buffers to 20000 +brought it down to 165 sec. Separating WAL and data onto different +disks would have helped too, no doubt, but I'm too lazy to try it. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Feb 14 16:54:11 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id D4D699DCA08 + for ; + Tue, 14 Feb 2006 16:54:10 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 63420-01 + for ; + Tue, 14 Feb 2006 16:54:11 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from ns.snowman.net (ns.snowman.net [66.92.160.21]) + by postgresql.org (Postfix) with ESMTP id 912299DC9DC + for ; + Tue, 14 Feb 2006 16:54:08 -0400 (AST) +Received: by ns.snowman.net (Postfix, from userid 1000) + id 532A617B80; Tue, 14 Feb 2006 15:55:10 -0500 (EST) +Date: Tue, 14 Feb 2006 15:55:10 -0500 +From: Stephen Frost +To: Tom Lane +Cc: Jay Greenfield , pgsql-performance@postgresql.org +Subject: Re: Postgres slower than MS ACCESS +Message-ID: <20060214205510.GJ4474@ns.snowman.net> +Mail-Followup-To: Tom Lane , + Jay Greenfield , + pgsql-performance@postgresql.org +References: <200602141551.k1EFpN6F020512@timberline.ca> + <20060214172022.GC4474@ns.snowman.net> + <22347.1139949764@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; boundary="0mMlreQBxyBIiF/S" +Content-Disposition: inline +In-Reply-To: <22347.1139949764@sss.pgh.pa.us> +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: 15:53:07 up 248 days, 13:02, 13 users, load average: 0.41, 0.60, + 0.62 +User-Agent: Mutt/1.5.11 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.111 required=5 tests=[AWL=0.111] +X-Spam-Score: 0.111 +X-Spam-Level: +X-Archive-Number: 200602/174 +X-Sequence-Number: 17160 + + +--0mMlreQBxyBIiF/S +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +Content-Transfer-Encoding: quoted-printable + +* Tom Lane (tgl@sss.pgh.pa.us) wrote: +> Stephen Frost writes: +> > While it's true that Access almost certainly takes some shortcuts, 24 +> > minutes for an update across 1.2 millon rows seems an awefully long time +> > for Postgres. +>=20 +> I did some experiments along this line with a trivial table (2 integer +> columns) of 1.28M rows. I used CVS tip with all parameters at defaults. +> With no indexes, an UPDATE took about 50 seconds. With one index, it +> took 628 seconds. It's not hard to believe you could get to Jay's +> figures with multiple indexes. + +With multiple indexes, you might want to drop them and recreate them +when you're updating an entire table. + +> Looking in the postmaster log, I see I was getting checkpoints every few +> seconds. Increasing checkpoint_segments to 30 (a factor of 10) brought +> it down to 355 seconds, and then increasing shared_buffers to 20000 +> brought it down to 165 sec. Separating WAL and data onto different +> disks would have helped too, no doubt, but I'm too lazy to try it. + +Sure, this was kind of my point, we need more information about the +database if we're going to have much of a chance of improving the +results he's seeing. 165 seconds is certainly a great deal better than +24 minutes. :) + + Thanks, + + Stephen + +--0mMlreQBxyBIiF/S +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: Digital signature +Content-Disposition: inline + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.2 (GNU/Linux) + +iD8DBQFD8kOurzgMPqB3kigRAuwyAJsETf99Trk9jD6S08LKlJIjDkkpkgCfaVWJ +c+1NSnXyravhObn5jZ0QgRA= +=Im0L +-----END PGP SIGNATURE----- + +--0mMlreQBxyBIiF/S-- + +From pgsql-performance-owner@postgresql.org Tue Feb 14 16:56:21 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id C97EB9DCA10 + for ; + Tue, 14 Feb 2006 16:56:20 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 61122-06 + for ; + Tue, 14 Feb 2006 16:56:21 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from timberline.ca (unknown [66.244.194.163]) + by postgresql.org (Postfix) with ESMTP id 647379DC81F + for ; + Tue, 14 Feb 2006 16:56:18 -0400 (AST) +Received: from tfic21 ([172.16.10.21]) + by timberline.ca (8.12.9/8.12.9) with ESMTP id k1EKuIiO002595; + Tue, 14 Feb 2006 12:56:18 -0800 (PST) +Message-Id: <200602142056.k1EKuIiO002595@timberline.ca> +From: "Jay Greenfield" +To: "'Tom Lane'" , "'Stephen Frost'" +Cc: +Subject: Re: Postgres slower than MS ACCESS +Date: Tue, 14 Feb 2006 12:56:18 -0800 +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: <22347.1139949764@sss.pgh.pa.us> +Thread-Index: AcYxpzcUbMvnwwQZSimYi6A6pa5EcAAAUZHQ +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.06 required=5 tests=[AWL=0.060] +X-Spam-Score: 0.06 +X-Spam-Level: +X-Archive-Number: 200602/175 +X-Sequence-Number: 17161 + +> How do you get 4,000+ lines of explain analyze for one update query in a +> database with only one table? Something a bit fishy there. Perhaps you +> mean explain verbose, though I don't really see how that'd be so long +> either, but it'd be closer. Could you provide some more sane +> information? + +My mistake - there was 4,000 lines in the EXPLAIN ANALYZE VERBOSE output. +Here is the output of EXPLAIN ANALYZE: + +QUERY PLAN +"Seq Scan on ntdn (cost=0.00..3471884.39 rows=1221391 width=1592) (actual +time=57292.580..1531300.003 rows=1221391 loops=1)" +"Total runtime: 4472646.988 ms" + + +> Is this table exceptionally large in same way (ie: lots +> of columns)? + +The table is 1.2 million rows X 246 columns. The only index is the primary +key. I will try to remove that index to see if that improves performance at +all. + +Jay + +-----Original Message----- +From: Tom Lane [mailto:tgl@sss.pgh.pa.us] +Sent: Tuesday, February 14, 2006 12:43 PM +To: Stephen Frost +Cc: Jay Greenfield; pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Postgres slower than MS ACCESS + +Stephen Frost writes: +> While it's true that Access almost certainly takes some shortcuts, 24 +> minutes for an update across 1.2 millon rows seems an awefully long time +> for Postgres. + +I did some experiments along this line with a trivial table (2 integer +columns) of 1.28M rows. I used CVS tip with all parameters at defaults. +With no indexes, an UPDATE took about 50 seconds. With one index, it +took 628 seconds. It's not hard to believe you could get to Jay's +figures with multiple indexes. + +Looking in the postmaster log, I see I was getting checkpoints every few +seconds. Increasing checkpoint_segments to 30 (a factor of 10) brought +it down to 355 seconds, and then increasing shared_buffers to 20000 +brought it down to 165 sec. Separating WAL and data onto different +disks would have helped too, no doubt, but I'm too lazy to try it. + + regards, tom lane + + +From pgsql-performance-owner@postgresql.org Tue Feb 14 17:02:34 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id B4BF49DC9DC + for ; + Tue, 14 Feb 2006 17:02:33 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 62588-07 + for ; + Tue, 14 Feb 2006 17:02:34 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id C21809DC9AC + for ; + Tue, 14 Feb 2006 17:02:30 -0400 (AST) +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 k1EL2WSs022609; + Tue, 14 Feb 2006 16:02:32 -0500 (EST) +To: "Jay Greenfield" +cc: "'Stephen Frost'" , pgsql-performance@postgresql.org +Subject: Re: Postgres slower than MS ACCESS +In-reply-to: <200602142056.k1EKuIiO002595@timberline.ca> +References: <200602142056.k1EKuIiO002595@timberline.ca> +Comments: In-reply-to "Jay Greenfield" + message dated "Tue, 14 Feb 2006 12:56:18 -0800" +Date: Tue, 14 Feb 2006 16:02:32 -0500 +Message-ID: <22608.1139950952@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.109 required=5 tests=[AWL=0.109] +X-Spam-Score: 0.109 +X-Spam-Level: +X-Archive-Number: 200602/176 +X-Sequence-Number: 17162 + +"Jay Greenfield" writes: +> The table is 1.2 million rows X 246 columns. The only index is the primary +> key. I will try to remove that index to see if that improves performance at +> all. + +Hmm, the large number of columns might have something to do with it ... +what datatypes are the columns? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Feb 14 17:05:27 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id AF2D99DC816 + for ; + Tue, 14 Feb 2006 17:05:26 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 66468-02 + for ; + Tue, 14 Feb 2006 17:05:27 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) + by postgresql.org (Postfix) with ESMTP id BB9889DC859 + for ; + Tue, 14 Feb 2006 17:05:23 -0400 (AST) +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 k1EL455n057128 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); + Tue, 14 Feb 2006 14:04:08 -0700 (MST) + (envelope-from mfuhr@winnie.fuhr.org) +Received: from winnie.fuhr.org (localhost [127.0.0.1]) + by winnie.fuhr.org (8.13.4/8.13.4) with ESMTP id k1EL45A1036325; + Tue, 14 Feb 2006 14:04:05 -0700 (MST) + (envelope-from mfuhr@winnie.fuhr.org) +Received: (from mfuhr@localhost) + by winnie.fuhr.org (8.13.4/8.13.4/Submit) id k1EL45br036324; + Tue, 14 Feb 2006 14:04:05 -0700 (MST) (envelope-from mfuhr) +Date: Tue, 14 Feb 2006 14:04:05 -0700 +From: Michael Fuhr +To: Adnan DURSUN +Cc: pgsql-performance@postgresql.org +Subject: Re: SQL Function Performance +Message-ID: <20060214210404.GA28693@winnie.fuhr.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, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200602/177 +X-Sequence-Number: 17163 + +On Tue, Feb 14, 2006 at 11:33:57AM +0200, Adnan DURSUN wrote: +> -> Nested Loop (cost=5.90..267.19 rows=3 width=101) (actual time=76.240..30974.777 rows=63193 loops=1) +> -> Nested Loop (cost=5.90..123.48 rows=26 width=73) (actual time=32.082..4357.786 rows=14296 loops=1) + +A prepared query is planned before the parameters' values are known, +so the planner can't take full advantage of column statistics to +estimate row counts. The planner must therefore decide on a plan +that should be reasonable in most cases; apparently this isn't one +of those cases, as the disparity between estimated and actual rows +shows. Maybe Tom (one of the core developers) can comment on whether +anything can be done to improve the plan in this case. + +Absent a better solution, you could write a PL/pgSQL function and +build the query as a text string, then EXECUTE it. That would give +you a new plan each time, one that can take better advantage of +statistics, at the cost of having to plan the query each time you +call the function (but you probably don't care about that cost +as long as the overall results are better). Here's an example: + +CREATE FUNCTION fooquery(qval text) RETURNS SETOF foo AS $$ +DECLARE + row foo%ROWTYPE; + query text; +BEGIN + query := 'SELECT * FROM foo WHERE val = ' || quote_literal(qval); + + FOR row IN EXECUTE query LOOP + RETURN NEXT row; + END LOOP; + + RETURN; +END; +$$ LANGUAGE plpgsql STABLE STRICT; + +-- +Michael Fuhr + +From pgsql-performance-owner@postgresql.org Tue Feb 14 17:25:34 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 51E2D9DCA41 + for ; + Tue, 14 Feb 2006 17:25:34 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 70059-02-2 + for ; + Tue, 14 Feb 2006 17:25:35 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from timberline.ca (unknown [66.244.194.163]) + by postgresql.org (Postfix) with ESMTP id BA6F29DCA47 + for ; + Tue, 14 Feb 2006 17:25:31 -0400 (AST) +Received: from tfic21 ([172.16.10.21]) + by timberline.ca (8.12.9/8.12.9) with ESMTP id k1ELPWiO003835; + Tue, 14 Feb 2006 13:25:32 -0800 (PST) +Message-Id: <200602142125.k1ELPWiO003835@timberline.ca> +From: "Jay Greenfield" +To: "'Tom Lane'" +Cc: "'Stephen Frost'" , +Subject: Re: Postgres slower than MS ACCESS +Date: Tue, 14 Feb 2006 13:25:32 -0800 +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: <22608.1139950952@sss.pgh.pa.us> +Thread-Index: AcYxqf2QLZnOGhtSQveGzMVvFPv7RgAAwWeA +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.08 required=5 tests=[AWL=0.080] +X-Spam-Score: 0.08 +X-Spam-Level: +X-Archive-Number: 200602/178 +X-Sequence-Number: 17164 + +> Hmm, the large number of columns might have something to do with it ... +> what datatypes are the columns? + +All sorts, but mostly float4 and varchar(2 to 10) + +Jay + +-----Original Message----- +From: Tom Lane [mailto:tgl@sss.pgh.pa.us] +Sent: Tuesday, February 14, 2006 1:03 PM +To: Jay Greenfield +Cc: 'Stephen Frost'; pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Postgres slower than MS ACCESS + +"Jay Greenfield" writes: +> The table is 1.2 million rows X 246 columns. The only index is the +primary +> key. I will try to remove that index to see if that improves performance +at +> all. + +Hmm, the large number of columns might have something to do with it ... +what datatypes are the columns? + + regards, tom lane + + +From pgsql-performance-owner@postgresql.org Tue Feb 14 17:33:21 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 091CB9DC859 + for ; + Tue, 14 Feb 2006 17:33:21 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 70354-09 + for ; + Tue, 14 Feb 2006 17:33:22 -0400 (AST) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id F41499DC804 + for ; + Tue, 14 Feb 2006 17:33:18 -0400 (AST) +Received: from ottexbe01.corp.distributel.ca (ottexbe01.corp.distributel.ca + [206.80.252.36]) + by svr4.postgresql.org (Postfix) with ESMTP id 19DDB5AF082 + for ; + Tue, 14 Feb 2006 21:33:21 +0000 (GMT) +Received: from 10.14.61.42 ([10.14.61.42]) by ottexbe01.corp.distributel.ca + ([192.168.16.70]) via Exchange Front-End Server 10.14.61.70 + ([10.14.61.70]) with Microsoft Exchange Server HTTP-DAV ; + Tue, 14 Feb 2006 21:33:18 +0000 +Received: from paul.mtl.distributel.net by 10.14.61.70; + 14 Feb 2006 16:36:54 -0500 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="=-raE4ZBrCD2Rk1P3VcQ+t" +MIME-Version: 1.0 +Content-class: urn:content-classes:message +X-MimeOLE: Produced By Microsoft Exchange V6.5 +Subject: 8.2.1 on FreeBSD 5.4-RELEASE +Date: Tue, 14 Feb 2006 16:36:54 -0500 +Message-ID: <1139953014.96994.30.camel@paul> +X-MS-Has-Attach: yes +X-MS-TNEF-Correlator: +Thread-Topic: 8.2.1 on FreeBSD 5.4-RELEASE +Thread-Index: AcYxrkVM3y3D9S7CQwanbg8ptqRQmg== +From: "Paul Khavkine" +To: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.001 required=5 tests=[UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 0.001 +X-Spam-Level: +X-Archive-Number: 200602/179 +X-Sequence-Number: 17165 + + +--=-raE4ZBrCD2Rk1P3VcQ+t +Content-Type: text/plain +Content-Transfer-Encoding: quoted-printable + + + +Hi Guys. + + +We are running v8.1.2 on FreeBSD 5.4-RELEASE and the server is running +with above averege load. + +When i do top i see alot of postmaster processes in "sbwait" state: + +# uptime +4:29PM up 23 days, 20:01, 3 users, load averages: 3.73, 1.97, 1.71 + +# top +82808 pgsql 1 4 0 15580K 12008K sbwait 0 107:06 7.52% +postgres +82804 pgsql 1 4 0 15612K 12028K sbwait 0 106:13 7.08% +postgres +82806 pgsql 1 4 0 15576K 12008K sbwait 0 106:07 6.84% +postgres +82793 pgsql 1 4 0 15576K 12008K sbwait 0 106:05 6.54% +postgres +82801 pgsql 1 4 0 15612K 12032K sbwait 0 106:13 5.57% +postgres +82800 pgsql 1 4 0 15580K 12012K sbwait 0 105:45 4.88% +postgres + 6613 pgsql 1 4 0 15612K 12020K sbwait 0 28:47 4.59% +postgres +82798 pgsql 1 4 0 15612K 12036K sbwait 0 106:10 4.49% +postgres +82799 pgsql 1 4 0 15612K 12036K sbwait 0 106:27 4.39% +postgres +82797 pgsql 1 4 0 15612K 12036K sbwait 1 106:23 4.25% +postgres +82748 pgsql 1 4 0 15564K 11864K sbwait 0 48:12 3.08% +postgres +82747 pgsql 1 4 0 15560K 11848K sbwait 0 47:58 3.08% +postgres +82749 pgsql 1 4 0 15564K 11868K sbwait 0 48:27 1.95% +postgres +82751 pgsql 1 4 0 15564K 11864K sbwait 0 48:14 1.66% +postgres +82739 pgsql 1 4 0 15564K 11868K sbwait 1 48:38 1.37% +postgres +82750 pgsql 1 4 0 15564K 11864K sbwait 0 48:07 1.27% +postgres + + +The server is not very busy, but it has more or less as many writes as +reads. + +I have not seen more then 10-15 simultaneous queries. + + +Any idea why idle postmaster consume 3-5% CPU ? + +This is a FreeBSD 5.4-RELEASE server with 2x3G Xeon CPUs, 2G memory, +RAID1 mirrored U320 drives. + + +Thanx +Paul + + +--=-raE4ZBrCD2Rk1P3VcQ+t +Content-Type: application/pgp-signature; name=signature.asc +Content-Description: This is a digitally signed message part + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.2 (FreeBSD) + +iQCVAwUAQ/JNdvkjFY05CfyYAQJJPwP8C0Rc+pTMqgZ5rQOFoYRfM8daXPqpldjD ++yjgdDHD8d+4bwGWKCpNSPzq9hqW7bZPH3yAVxuww34VpEhKUIfj8kyMBnwGlaFn +MReMpkyLsgp/fiXcROmnmBrE2VzMv2G4gApWsrTpxNiuba6XFAd5uNHMC6846o9W +s/k1LJolhHA= +=Q2X9 +-----END PGP SIGNATURE----- + +--=-raE4ZBrCD2Rk1P3VcQ+t-- + +From pgsql-performance-owner@postgresql.org Tue Feb 14 17:47:48 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 2A3EE9DC87C + for ; + Tue, 14 Feb 2006 17:47:48 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 73050-03 + for ; + Tue, 14 Feb 2006 17:47:48 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from brmea-mail-2.sun.com (brmea-mail-2.Sun.COM [192.18.98.43]) + by postgresql.org (Postfix) with ESMTP id DB2D89DCA10 + for ; + Tue, 14 Feb 2006 17:47:44 -0400 (AST) +Received: from fe-amer-05.sun.com ([192.18.108.179]) + by brmea-mail-2.sun.com (8.12.10/8.12.9) with ESMTP id k1ELlk8u027328 + for ; + Tue, 14 Feb 2006 14:47:46 -0700 (MST) +Received: from conversion-daemon.mail-amer.sun.com by mail-amer.sun.com + (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) + id <0IUP00L015F9WK00@mail-amer.sun.com> (original mail from + J.K.Shah@Sun.COM) for pgsql-performance@postgresql.org; + Tue, 14 Feb 2006 14:47:46 -0700 (MST) +Received: from [129.148.168.2] by mail-amer.sun.com + (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) + with ESMTPSA id <0IUP0036W5VIPXI1@mail-amer.sun.com>; Tue, + 14 Feb 2006 14:47:45 -0700 (MST) +Date: Tue, 14 Feb 2006 16:47:20 -0500 +From: "Jignesh K. Shah" +Subject: Re: copy and postgresql.conf +In-reply-to: + <414D259CE29DE54DAD534037C83CE4B7011E4864@FR0-MAILMB20.res.airbus.corp> +To: "FERREIRA, William (VALTECH)" +Cc: Albert Cervera Areny , pgsql-performance@postgresql.org +Message-id: <43F24FE8.2060400@sun.com> +Organization: Sun Microsystems +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=ISO-8859-1 +Content-transfer-encoding: 8BIT +X-Accept-Language: en-us, en +References: + <414D259CE29DE54DAD534037C83CE4B7011E4864@FR0-MAILMB20.res.airbus.corp> +User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050322) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.121 required=5 tests=[AWL=0.120, + UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 0.121 +X-Spam-Level: +X-Archive-Number: 200602/180 +X-Sequence-Number: 17166 + +What version of Solaris are you using? + +Do you have the recommendations while using COPY on Solaris? +http://blogs.sun.com/roller/page/jkshah?entry=postgresql_on_solaris_better_use + +wal_sync_method = fsync +wal_buffers = 128 +checkpoint_segments = 128 +bgwriter_percent = 0 +bgwriter_maxpages = 0 + + +And also for /etc/system on Solaris 10, 9 SPARC use the following + +set maxphys=1048576 +set md:md_maxphys=1048576 +set segmap_percent=50 +set ufs:freebehind=0 +set msgsys:msginfo_msgmni = 3584 +set semsys:seminfo_semmni = 4096 +set shmsys:shminfo_shmmax = 15392386252 +set shmsys:shminfo_shmmni = 4096 + + +Can you try putting in one run with this values and send back your +experiences on whether it helps your workload or not? + +Atleast I saw improvements using the above settings with COPY with +Postgres 8.0 and Postgres 8.1 on Solaris. + +Regards, +Jignesh + + + + +FERREIRA, William (VALTECH) wrote: + +>30% faster !!! i will test this new version ... +> +>thanks a lot +> +>-----Message d'origine----- +>De : pgsql-performance-owner@postgresql.org +>[mailto:pgsql-performance-owner@postgresql.org]De la part de Albert +>Cervera Areny +>Envoy� : mardi 14 f�vrier 2006 17:07 +>� : pgsql-performance@postgresql.org +>Objet : Re: [PERFORM] copy and postgresql.conf +> +> +> +>Sorry, COPY improvements came with 8.1 +> +>(http://www.postgresql.org/docs/whatsnew) +> +>A Dimarts 14 Febrer 2006 14:26, FERREIRA, William (VALTECH) va escriure: +> +> +>>thanks, +>> +>>i'm using postgresql 8.0.3 +>>there is no primary key and no index on my tables +>> +>>regards +>> +>>-----Message d'origine----- +>>De : pgsql-performance-owner@postgresql.org +>>[mailto:pgsql-performance-owner@postgresql.org]De la part de Albert +>>Cervera Areny +>>Envoy� : mardi 14 f�vrier 2006 12:38 +>>� : pgsql-performance@postgresql.org +>>Objet : Re: [PERFORM] copy and postgresql.conf +>> +>> +>> +>>Hi William, +>> which PostgreSQL version are you using? Newer (8.0+) versions have some +>> +>>important performance improvements for the COPY command. +>> +>> Also, you'll notice significant improvements by creating primary & foreign +>> +>>keys after the copy command. I think config tweaking can improve key and +>> +>>index creation but I don't think you can improve the COPY command itself. +>> +>> There are also many threads in this list commenting on this issue, you'll +>> +>>find it easely in the archives. +>> +>>A Dimarts 14 Febrer 2006 10:44, FERREIRA, William (VALTECH) va escriure: +>> +>> +>>>hi, +>>> +>>>i load data from files using copy method. +>>>Files contain between 2 and 7 millions of rows, spread on 5 tables. +>>> +>>>For loading all the data, it takes 40mn, and the same processing takes +>>>17mn with Oracle. I think that this time can be improved by changing +>>>postgresql configuration file. But which parameters i need to manipulate +>>>and with which values ? +>>> +>>>Here are the specifications of my system : +>>>V250 architecture sun4u +>>>2xCPU UltraSparc IIIi 1.28 GHz. +>>>8 Go RAM. +>>> +>>>Regards. +>>> +>>> Will +>>> +>>> +>>>This e-mail is intended only for the above addressee. It may contain +>>>privileged information. If you are not the addressee you must not copy, +>>>distribute, disclose or use any of the information in it. If you have +>>>received it in error please delete it and immediately notify the sender. +>>>Security Notice: all e-mail, sent to or from this address, may be +>>>accessed by someone other than the recipient, for system management and +>>>security reasons. This access is controlled under Regulation of +>>>Investigatory Powers Act 2000, Lawful Business Practises. +>>> +>>>---------------------------(end of broadcast)--------------------------- +>>>TIP 4: Have you searched our list archives? +>>> +>>> http://archives.postgresql.org +>>> +>>> +>>-- +>> +>>Albert Cervera Areny +>>Dept. Inform�tica Sedifa, S.L. +>> +>>Av. Can Bordoll, 149 +>>08202 - Sabadell (Barcelona) +>>Tel. 93 715 51 11 +>>Fax. 93 715 51 12 +>> +>>==================================================================== +>>........................ AVISO LEGAL ............................ +>>La presente comunicaci�n y sus anexos tiene como destinatario la +>>persona a la que va dirigida, por lo que si usted lo recibe +>>por error debe notificarlo al remitente y eliminarlo de su +>>sistema, no pudiendo utilizarlo, total o parcialmente, para +>>ning�n fin. Su contenido puede tener informaci�n confidencial o +>>protegida legalmente y �nicamente expresa la opini�n del +>>remitente. El uso del correo electr�nico v�a Internet no +>>permite asegurar ni la confidencialidad de los mensajes +>>ni su correcta recepci�n. En el caso de que el +>>destinatario no consintiera la utilizaci�n del correo electr�nico, +>>deber� ponerlo en nuestro conocimiento inmediatamente. +>>==================================================================== +>>........................... DISCLAIMER ............................. +>>This message and its attachments are intended exclusively for the +>>named addressee. If you receive this message in error, please +>>immediately delete it from your system and notify the sender. You +>>may not use this message or any part of it for any purpose. +>>The message may contain information that is confidential or +>>protected by law, and any opinions expressed are those of the +>>individual sender. Internet e-mail guarantees neither the +>>confidentiality nor the proper receipt of the message sent. +>>If the addressee of this message does not consent to the use +>>of internet e-mail, please inform us inmmediately. +>>==================================================================== +>> +>> +>> +>> +>> +>>---------------------------(end of broadcast)--------------------------- +>>TIP 5: don't forget to increase your free space map settings +>> +>> +>> +>>This mail has originated outside your organization, +>>either from an external partner or the Global Internet. +>>Keep this in mind if you answer this message. +>> +>> +>>This e-mail is intended only for the above addressee. It may contain +>>privileged information. If you are not the addressee you must not copy, +>>distribute, disclose or use any of the information in it. If you have +>>received it in error please delete it and immediately notify the sender. +>>Security Notice: all e-mail, sent to or from this address, may be +>>accessed by someone other than the recipient, for system management and +>>security reasons. This access is controlled under Regulation of +>>Investigatory Powers Act 2000, Lawful Business Practises. +>> +>> +> +>-- +> +>Albert Cervera Areny +>Dept. Inform�tica Sedifa, S.L. +> +>Av. Can Bordoll, 149 +>08202 - Sabadell (Barcelona) +>Tel. 93 715 51 11 +>Fax. 93 715 51 12 +> +>==================================================================== +>........................ AVISO LEGAL ............................ +>La presente comunicaci�n y sus anexos tiene como destinatario la +>persona a la que va dirigida, por lo que si usted lo recibe +>por error debe notificarlo al remitente y eliminarlo de su +>sistema, no pudiendo utilizarlo, total o parcialmente, para +>ning�n fin. Su contenido puede tener informaci�n confidencial o +>protegida legalmente y �nicamente expresa la opini�n del +>remitente. El uso del correo electr�nico v�a Internet no +>permite asegurar ni la confidencialidad de los mensajes +>ni su correcta recepci�n. En el caso de que el +>destinatario no consintiera la utilizaci�n del correo electr�nico, +>deber� ponerlo en nuestro conocimiento inmediatamente. +>==================================================================== +>........................... DISCLAIMER ............................. +>This message and its attachments are intended exclusively for the +>named addressee. If you receive this message in error, please +>immediately delete it from your system and notify the sender. You +>may not use this message or any part of it for any purpose. +>The message may contain information that is confidential or +>protected by law, and any opinions expressed are those of the +>individual sender. Internet e-mail guarantees neither the +>confidentiality nor the proper receipt of the message sent. +>If the addressee of this message does not consent to the use +>of internet e-mail, please inform us inmmediately. +>==================================================================== +> +> +> +> +> +>---------------------------(end of broadcast)--------------------------- +>TIP 5: don't forget to increase your free space map settings +> +> +> +>This mail has originated outside your organization, +>either from an external partner or the Global Internet. +>Keep this in mind if you answer this message. +> +> +>This e-mail is intended only for the above addressee. It may contain +>privileged information. If you are not the addressee you must not copy, +>distribute, disclose or use any of the information in it. If you have +>received it in error please delete it and immediately notify the sender. +>Security Notice: all e-mail, sent to or from this address, may be +>accessed by someone other than the recipient, for system management and +>security reasons. This access is controlled under Regulation of +>Investigatory Powers Act 2000, Lawful Business Practises. +> +>---------------------------(end of broadcast)--------------------------- +>TIP 6: explain analyze is your friend +> +> + +From pgsql-performance-owner@postgresql.org Tue Feb 14 18:01:38 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 806A29DC9BC + for ; + Tue, 14 Feb 2006 18:01:37 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 75219-04 + for ; + Tue, 14 Feb 2006 18:01:39 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from outbound-smtp.firstam.com (outbound-smtp5.firstam.com + [69.87.54.10]) by postgresql.org (Postfix) with ESMTP id 3A7049DC816 + for ; + Tue, 14 Feb 2006 18:01:34 -0400 (AST) +Received: from 10.48.129.31 by outbound-smtp.firstam.com with ESMTP ( + Hello SMTP Relay); Tue, 14 Feb 2006 14:01:30 -0800 +X-Server-Uuid: 6B41F939-E8F2-471D-A9AE-316CEEC949DD +Received: from unknown (HELO pisgsna01smmx01.ana.firstamdata.com) ( + [172.17.88.35]) by FAEMSNA01SMXS02.FIRSTAM.COM with ESMTP; 14 Feb 2006 + 14:01:31 -0800 +Received: from pisgsna01sxch21.ana.firstamdata.com (Not + Verified[172.17.88.71]) by pisgsna01smmx01.ana.firstamdata.com with + NetIQ MailMarshal 6.0 Service Pack 1a (v6,0,3,33) id ; + Tue, 14 Feb 2006 14:01:30 -0800 +Received: from pisgsna01sxch01.ana.firstamdata.com ([172.17.88.70]) by + pisgsna01sxch21.ana.firstamdata.com with Microsoft + SMTPSVC(6.0.3790.1830); Tue, 14 Feb 2006 14:01:29 -0800 +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Subject: Re: 0ut of Memory Error during Vacuum Analyze and +Date: Tue, 14 Feb 2006 14:01:29 -0800 +Message-ID: + +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] 0ut of Memory Error during Vacuum Analyze and + Create Index +Thread-Index: AcYxj0GGJCMK/HGIThWfj78gyKsuHAAIoBkg +From: "Tomeh, Husam" +To: "Tom Lane" +cc: pgsql-performance@postgresql.org +X-OriginalArrivalTime: 14 Feb 2006 22:01:29.0978 (UTC) + FILETIME=[3598BDA0:01C631B2] +X-TMWD-Spam-Summary: SEV=1.1; DFV=A2006021408; IFV=2.0.6,4.0-7; RPD=4.00.0004; + RPDID=303030312E30413039303230342E34334632353133392E303035323A5343464D413534333432342D462D2F4E4553574B563534472F71554B6D71577A564237673D3D; + ENG=IBF; TS=20060214220130; CAT=NONE; CON=NONE; +X-WSS-ID: 6FEC8CB040415199-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, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200602/181 +X-Sequence-Number: 17167 + +=20 +I have run pg_dump and had no errors. I also got this error when +creating one index but not another. When I lowered my +maintenance_work_mem, the create index succeeded.=20 + +Regards, + +---- +=20 +=20 Husam =20 + +-----Original Message----- +From: Tom Lane [mailto:tgl@sss.pgh.pa.us]=20 +Sent: Tuesday, February 14, 2006 9:51 AM +To: Tomeh, Husam +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] 0ut of Memory Error during Vacuum Analyze + +"Tomeh, Husam" writes: +> =3D# vacuum analyze code; +> ERROR: out of memory +> DETAIL: Failed on request of size 1073741820. + +That looks a whole lot like a corrupt-data issue. The apparent +dependency on maintenance_work_mem is probably illusory --- I suspect +some of your trials are selecting the corrupted row to use in the +ANALYZE stats, and others are randomly selecting other rows. + +If you are able to pg_dump the table in question then this theory is +wrong, but I'd suggest trying that first. + +=09 regards, tom lane +********************************************************************** +This message contains confidential information intended only for the use = +of the addressee(s) named above and may contain information that is legal= +ly privileged. If you are not the addressee, or the person responsible f= +or delivering it to the addressee, you are hereby notified that reading, = +disseminating, distributing or copying this message is strictly prohibite= +d. If you have received this message by mistake, please immediately noti= +fy us by replying to the message and delete the original message immediat= +ely thereafter. + +Thank you. +=0D +=20 FADLD Tag +********************************************************************** + + +From pgsql-performance-owner@postgresql.org Tue Feb 14 18:15:43 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id A7F7F9DC804 + for ; + Tue, 14 Feb 2006 18:15:42 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81707-07 + for ; + Tue, 14 Feb 2006 18:15:44 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 681F59DC81F + for ; + Tue, 14 Feb 2006 18:15:40 -0400 (AST) +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 k1EMFfUl023301; + Tue, 14 Feb 2006 17:15:41 -0500 (EST) +To: "Tomeh, Husam" +cc: pgsql-performance@postgresql.org +Subject: Re: 0ut of Memory Error during Vacuum Analyze and Create Index +In-reply-to: + +References: + +Comments: In-reply-to "Tomeh, Husam" + message dated "Tue, 14 Feb 2006 14:01:29 -0800" +Date: Tue, 14 Feb 2006 17:15:41 -0500 +Message-ID: <23300.1139955341@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.109 required=5 tests=[AWL=0.109] +X-Spam-Score: 0.109 +X-Spam-Level: +X-Archive-Number: 200602/182 +X-Sequence-Number: 17168 + +"Tomeh, Husam" writes: +> I have run pg_dump and had no errors. I also got this error when +> creating one index but not another. When I lowered my +> maintenance_work_mem, the create index succeeded. + +Create index too? Hm. That begins to sound more like a memory leak. +Do you have any custom data types or anything like that in this +table? Can you put together a self-contained test case using dummy +data? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Feb 14 18:36:09 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 3F8629DC804 + for ; + Tue, 14 Feb 2006 18:36:09 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 86375-05 + for ; + Tue, 14 Feb 2006 18:36:10 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from hotmail.com (bay106-dav24.bay106.hotmail.com [65.54.161.96]) + by postgresql.org (Postfix) with ESMTP id E135C9DC8A3 + for ; + Tue, 14 Feb 2006 18:36:06 -0400 (AST) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Tue, 14 Feb 2006 14:36:08 -0800 +Message-ID: +Received: from 85.105.24.123 by BAY106-DAV24.phx.gbl with DAV; + Tue, 14 Feb 2006 22:36:08 +0000 +X-Originating-IP: [85.105.24.123] +X-Originating-Email: [a_dursun@hotmail.com] +X-Sender: a_dursun@hotmail.com +From: "Adnan DURSUN" +To: +Subject: Re: SQL Function Performance +Date: Wed, 15 Feb 2006 00:35:59 +0200 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0003_01C631C7.CAD3D110" +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-OriginalArrivalTime: 14 Feb 2006 22:36:08.0928 (UTC) + FILETIME=[0CBF5600:01C631B7] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=2.26 required=5 tests=[AWL=0.340, + DNS_FROM_RFC_ABUSE=0.479, DNS_FROM_RFC_POST=1.44, HTML_MESSAGE=0.001, + MSGID_FROM_MTA_HEADER=0] +X-Spam-Score: 2.26 +X-Spam-Level: ** +X-Archive-Number: 200602/183 +X-Sequence-Number: 17169 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0003_01C631C7.CAD3D110 +Content-Type: text/plain; + charset="iso-8859-9" +Content-Transfer-Encoding: quoted-printable + + + +-------Original Message------- + +From: Michael Fuhr +Date: 02/14/06 23:05:55 +To: Adnan DURSUN +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] SQL Function Performance + +>On Tue, Feb 14, 2006 at 11:33:57AM +0200, Adnan DURSUN wrote: +>> -> Nested Loop (cost=3D5.90..267.19 rows=3D3 width=3D101) = +(actual time=3D76.240..30974.777 rows=3D63193 loops=3D1) +>> -> Nested Loop (cost=3D5.90..123.48 rows=3D26 = +width=3D73) (actual time=3D32.082..4357.786 rows=3D14296 loops=3D1) + +>Absent a better solution, you could write a PL/pgSQL function and +>build the query as a text string, then EXECUTE it. That would give +>you a new plan each time, one that can take better advantage of +>statistics, at the cost of having to plan the query each time you +>call the function (but you probably don't care about that cost +>as long as the overall results are better). Here's an example: + + Yes, i did it. i wrote a PL/pgSQL function. Now results come at 100 = +ms.. :-) +I dont like that method but i have to do it for perfomance.... + +Many thanks to everyone who helps... + +Adnan DURSUN +ASRIN Bilisim Ltd. +Ankara /TURKEY +---------------------------(end of broadcast)--------------------------- +TIP 2: Don't 'kill -9' the postmaster +------=_NextPart_000_0003_01C631C7.CAD3D110 +Content-Type: text/html; + charset="iso-8859-9" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
+
 
+
 
+
-------Original = +Message-------
+
 
+
+
From: Michael Fuhr
+
Date: 02/14/06 = +23:05:55
+
To: Adnan DURSUN
+
Cc: pgsql-performance@postgr= +esql.org
+
Subject: Re: = +[PERFORM] SQL=20 +Function Performance
+
 
+
>On Tue, Feb 14, 2006 at 11:33:57AM +0200, Adnan DURSUN = +wrote:
+
>>        =20 +->  Nested Loop  (cost=3D5.90..267.19 rows=3D3 = +width=3D101)=20 +(actual time=3D76.240..30974.777 rows=3D63193 loops=3D1)
+
>>          = +    =20 +->  Nested Loop  (cost=3D5.90..123.48 rows=3D26 = +width=3D73)=20 +(actual time=3D32.082..4357.786 rows=3D14296 loops=3D1)
+
 
+
>Absent a better solution, you could write a PL/pgSQL function = +and
+
>build the query as a text string, then EXECUTE = +it.  That=20 +would give
+
>you a new plan each time, one that can take better advantage = +of
+
>statistics, at the cost of having to plan the query each time = +you
+
>call the function (but you probably don't care about that = +cost
+
>as long as the overall results are better).  Here's = +an=20 +example:
+
 
+
    Yes, i did it. i wrote a PL/pgSQL function. Now = +results=20 +come at 100 ms.. :-)
+
I dont like that method but i have to do it for = +perfomance....
+
 
+
Many thanks to everyone who helps...
+
 
+
+
Adnan DURSUN
+
ASRIN Bilisim Ltd.
+
Ankara /TURKEY
+
---------------------------(end of=20 +broadcast)---------------------------
+
TIP 2: Don't 'kill -9' the = +postmaster
+ +------=_NextPart_000_0003_01C631C7.CAD3D110-- + +From pgsql-performance-owner@postgresql.org Tue Feb 14 19:14:07 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 44B739DC811 + for ; + Tue, 14 Feb 2006 19:14:06 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91307-08 + for ; + Tue, 14 Feb 2006 19:14:06 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from uproxy.gmail.com (uproxy.gmail.com [66.249.92.199]) + by postgresql.org (Postfix) with ESMTP id D78E79DC9ED + for ; + Tue, 14 Feb 2006 19:14:01 -0400 (AST) +Received: by uproxy.gmail.com with SMTP id m2so821660ugc + for ; + Tue, 14 Feb 2006 15:14:03 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=l0qMKjD4ry6BNsfRsLwrKbsmFHC5id4uzVXDEDS4V6Bti96OJgrVdEaMnv3Ln7QavT1lRbjm/FqOW7sOr7CoXbLGdVTSOpLRgZfk6LmN2C0g8bAYLNA3kLcfO+t4OXqO4OGRhaHp/2WZoGd7TxefElGZssqTNItMsHyiwq91Wd8= +Received: by 10.66.166.3 with SMTP id o3mr1615495uge; + Tue, 14 Feb 2006 15:14:03 -0800 (PST) +Received: by 10.66.221.12 with HTTP; Tue, 14 Feb 2006 15:14:03 -0800 (PST) +Message-ID: <1ca1c1410602141514w2bcd1401p7c417241030c0778@mail.gmail.com> +Date: Tue, 14 Feb 2006 15:14:03 -0800 +From: Aaron Turner +To: pgsql-performance@postgresql.org +Subject: Re: 10+hrs vs 15min because of just one index +Cc: Tom Lane , "Jim C. Nasby" , + "Matthew T. O'Connor" , PFC +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <1ca1c1410602100016p2b5fdcc4wbf45612d7efc5fdf@mail.gmail.com> + <43ECC9BF.2030107@zeut.net> + <1ca1c1410602100924s191e7cddo4bda80d8f8d7cb6d@mail.gmail.com> + <20060211212453.GT57845@pervasive.com> + <1ca1c1410602112358h1e0e9696lff8f172769dc587e@mail.gmail.com> + <16809.1139759674@sss.pgh.pa.us> + <1ca1c1410602121133y279ea488nc38f049ac6ebc7f4@mail.gmail.com> + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.231 required=5 tests=[AWL=0.231] +X-Spam-Score: 0.231 +X-Spam-Level: +X-Archive-Number: 200602/184 +X-Sequence-Number: 17170 + +Well just a little update: + +1) Looks like I'm definately RAM constrained. Just placed an order +for another 4GB. +2) I ended up dropping the primary key too which helped with disk +thrashing a lot (average disk queue wait was between 500ms and 8500ms +before and 250-500ms after) +3) Playing with most of the settings in the postgresql.conf actually +dropped performance significantly. Looks like I'm starving the disk +cache. +4) I'm going to assume going to a bytea helped some (width is 54 vs +66) but nothing really measurable + +Thanks everyone for your help! + +-- +Aaron Turner +http://synfin.net/ + +From pgsql-performance-owner@postgresql.org Tue Feb 14 19:40:31 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id EB9D09DC811 + for ; + Tue, 14 Feb 2006 19:40:30 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 98786-02 + for ; + Tue, 14 Feb 2006 19:40:33 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from outbound-smtp.firstam.com (outbound-smtp6.firstam.com + [69.87.54.11]) by postgresql.org (Postfix) with ESMTP id 2235F9DCA0A + for ; + Tue, 14 Feb 2006 19:40:24 -0400 (AST) +Received: from 10.48.129.31 by outbound-smtp.firstam.com with ESMTP ( + Hello SMTP Relay); Tue, 14 Feb 2006 15:40:17 -0800 +X-Server-Uuid: A2519771-17FD-438B-B41E-237CBEBED851 +Received: from unknown (HELO pisgsna01smmx01.ana.firstamdata.com) ( + [172.17.88.35]) by FAEMSNA01SMXS01.firstam.com with ESMTP; 14 Feb 2006 + 15:40:18 -0800 +Received: from pisgsna01sxch21.ana.firstamdata.com (Not + Verified[172.17.88.71]) by pisgsna01smmx01.ana.firstamdata.com with + NetIQ MailMarshal 6.0 Service Pack 1a (v6,0,3,33) id ; + Tue, 14 Feb 2006 15:40:17 -0800 +Received: from pisgsna01sxch01.ana.firstamdata.com ([172.17.88.70]) by + pisgsna01sxch21.ana.firstamdata.com with Microsoft + SMTPSVC(6.0.3790.1830); Tue, 14 Feb 2006 15:40:17 -0800 +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Subject: Re: 0ut of Memory Error during Vacuum Analyze and +Date: Tue, 14 Feb 2006 15:40:17 -0800 +Message-ID: + +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] 0ut of Memory Error during Vacuum Analyze and + Create Index +Thread-Index: AcYxtDfcVw4iOnseR7C2B8xZVhkciAAB0nPQ +From: "Tomeh, Husam" +To: "Tom Lane" +cc: pgsql-performance@postgresql.org +X-OriginalArrivalTime: 14 Feb 2006 23:40:17.0449 (UTC) + FILETIME=[02A50990:01C631C0] +X-TMWD-Spam-Summary: SEV=1.1; DFV=A2006021409; IFV=2.0.6,4.0-7; RPD=4.00.0004; + RPDID=303030312E30413039303230312E34334632363836302E303035393A5343464D413534333432342D462D2F4E4553574B563534472F71554B6D71577A564237673D3D; + ENG=IBF; TS=20060214234018; CAT=NONE; CON=NONE; +X-WSS-ID: 6FECB5EB3O81921105-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, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200602/185 +X-Sequence-Number: 17171 + + +No special data types. The table is pretty large one with over 15GB. The +index is about 1.5 GB. Here's the table structure : + +=20 Column | Type | Modifiers +-----------------+-----------------------+----------- +=20county_id | numeric(5,0) | not null +=20batch_dt | numeric(8,0) | not null +=20batch_seq | numeric(5,0) | not null +=20mtg_seq_nbr | numeric(1,0) | not null +=20mtg_rec_dt | numeric(8,0) | +=20mtg_doc_nbr | character varying(12) | +=20mtg_rec_bk | character varying(6) | +=20mtg_rec_pg | character varying(6) | +=20mtg_amt | numeric(11,0) | +=20lndr_cd | character varying(10) | +=20lndr_nm | character varying(30) | +=20mtg_assm_ind | character(1) | +=20mtg_typ | character varying(5) | +=20adj_rate_ind | character(1) | +=20mtg_term_nbr | numeric(5,0) | +=20mtg_term_cd | character varying(4) | +=20mtg_due_dt | numeric(8,0) | +=20mtg_deed_typ | character varying(6) | +=20reverse_mtg_ind | character(1) | +=20refi_ind | character(1) | +=20conform_ind | character(1) | +=20cnstr_ln_ind | character(1) | +=20title_co_cd | character varying(5) | +=20state_id | numeric(5,0) | +=20msa | numeric(4,0) | +Indexes: +=20 "uq_mortgage" UNIQUE, btree (county_id, batch_dt, batch_seq, +mtg_seq_nbr) +=20 "mortgage_idxc_county_id_mtg_rec_dt" btree (county_id, mtg_rec_dt) +=20 "mortgage_idxc_state_id_mtg_rec_dt" btree (state_id, mtg_rec_dt) + +--------- + +=20Here's the test I did with maintenance_work_mem =3D 1GB: + + +mtrac=3D# show maintenance_work_mem ; +=20maintenance_work_mem +---------------------- +=201048576 <=3D=3D=3D=3D=3D=3D +(1 row) + +mtrac=3D# +mtrac=3D# +mtrac=3D# create index mort_ht on mortgage(county_id,mtg_rec_dt); +ERROR: out of memory <=3D=3D= +=3D +DETAIL: Failed on request of size 134217728. <=3D=3D=3D + +............ Then I changed the parameter to 512 MB: =20 + + +mtrac=3D# show maintenance_work_mem ; +=20maintenance_work_mem +---------------------- +=20524288 <=3D=3D=3D +(1 row) + +mtrac=3D# create index mort_ht_512 on mortgage(county_id,mtg_rec_dt); +CREATE INDEX +----------------------------------------------- + + + +Regards, +---- +=20 +=20 Husam =20 + +-----Original Message----- +From: Tom Lane [mailto:tgl@sss.pgh.pa.us]=20 +Sent: Tuesday, February 14, 2006 2:16 PM +To: Tomeh, Husam +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] 0ut of Memory Error during Vacuum Analyze and +Create Index + +"Tomeh, Husam" writes: +> I have run pg_dump and had no errors. I also got this error when +> creating one index but not another. When I lowered my +> maintenance_work_mem, the create index succeeded.=20 + +Create index too? Hm. That begins to sound more like a memory leak. +Do you have any custom data types or anything like that in this +table? Can you put together a self-contained test case using dummy +data? + +=09 regards, tom lane +********************************************************************** +This message contains confidential information intended only for the use = +of the addressee(s) named above and may contain information that is legal= +ly privileged. If you are not the addressee, or the person responsible f= +or delivering it to the addressee, you are hereby notified that reading, = +disseminating, distributing or copying this message is strictly prohibite= +d. If you have received this message by mistake, please immediately noti= +fy us by replying to the message and delete the original message immediat= +ely thereafter. + +Thank you. +=0D +=20 FADLD Tag +********************************************************************** + + +From pgsql-performance-owner@postgresql.org Tue Feb 14 19:49:20 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 8AFF19DC80F + for ; + Tue, 14 Feb 2006 19:49:19 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 97961-06 + for ; + Tue, 14 Feb 2006 19:49:22 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 713159DC955 + for ; + Tue, 14 Feb 2006 19:49:16 -0400 (AST) +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 k1ENnIDW024286; + Tue, 14 Feb 2006 18:49:18 -0500 (EST) +To: "Tomeh, Husam" +cc: pgsql-performance@postgresql.org +Subject: Re: 0ut of Memory Error during Vacuum Analyze and Create Index +In-reply-to: + +References: + +Comments: In-reply-to "Tomeh, Husam" + message dated "Tue, 14 Feb 2006 15:40:17 -0800" +Date: Tue, 14 Feb 2006 18:49:18 -0500 +Message-ID: <24285.1139960958@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.109 required=5 tests=[AWL=0.109] +X-Spam-Score: 0.109 +X-Spam-Level: +X-Archive-Number: 200602/186 +X-Sequence-Number: 17172 + +"Tomeh, Husam" writes: +> mtrac=# show maintenance_work_mem ; +> maintenance_work_mem +> ---------------------- +> 1048576 <====== +> (1 row) + +> mtrac=# +> mtrac=# +> mtrac=# create index mort_ht on mortgage(county_id,mtg_rec_dt); +> ERROR: out of memory <=== +> DETAIL: Failed on request of size 134217728. <=== + +It would be useful to look at the detailed allocation info that this +(should have) put into the postmaster log. Also, if you could get +a stack trace back from the error, that would be even more useful. +To do that, + * start psql + * determine PID of connected backend (use pg_backend_pid()) + * in another window, as postgres user, + gdb /path/to/postgres backend-PID + gdb> break errfinish + gdb> cont + * issue failing command in psql + * when breakpoint is reached, + gdb> bt + ... stack trace printed here ... + gdb> q + + regards, tom lane + +From pgsql-novice-owner@postgresql.org Wed Feb 15 03:29:49 2006 +X-Original-To: pgsql-novice-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 253BC9DC9A8 + for ; + Wed, 15 Feb 2006 03:29:49 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 44996-09 + for ; + Wed, 15 Feb 2006 03:29:49 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.203]) + by postgresql.org (Postfix) with ESMTP id CF1989DC940 + for ; Wed, 15 Feb 2006 03:29:46 -0400 (AST) +Received: by xproxy.gmail.com with SMTP id s9so978721wxc + for ; Tue, 14 Feb 2006 23:29:47 -0800 (PST) +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=FiOel6+JeePbtPdEZPcxMVkHIKrUgnHHdMjsmK80cTU3EllWLl2ARzJLiPT6tJ/nWTRbkfTVxiL1SVNqk64vRdEBhtY3t7RtBrwFWfLGw/iML9PQldT+i4hPJPEElfVm4XN/O8+X9ETh5VXz4KE6oVnxeg5iPs//tqynhff1vyw= +Received: by 10.70.94.13 with SMTP id r13mr5438670wxb; + Tue, 14 Feb 2006 23:29:47 -0800 (PST) +Received: by 10.70.60.20 with HTTP; Tue, 14 Feb 2006 23:29:47 -0800 (PST) +Message-ID: <580055310602142329u448d044bi@mail.gmail.com> +Date: Wed, 15 Feb 2006 12:59:47 +0530 +From: Pradeep Parmar +To: pgsql-novice@postgresql.org, pgsql-performance@postgresql.org +Subject: could not send data to client: Broken pipe +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_722_19018361.1139988587419" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.846 required=5 tests=[AWL=-0.100, HTML_10_20=0.945, + HTML_MESSAGE=0.001] +X-Spam-Score: 0.846 +X-Spam-Level: +X-Archive-Number: 200602/105 +X-Sequence-Number: 15783 + +------=_Part_722_19018361.1139988587419 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Hi, + +I'm using Postgres 7.4. I have a web application built with php4 using +postgres7.4 + +I was going through /var/log/messages of my linux box ( SLES 9). I +encountered the following messages quite a few times. + +>postgres[20199]: [4-1] ERROR: could not send data to client: Broken pipe +>postgres[30391]: [6-1] LOG: could not send data to client: Broken pipe +>postgres[30570]: [6-1] LOG: could not send data to client: Broken pipe + +Can anyone help me in interpreting these messages? +What is causing this error msg? What is the severity? + + +Regards + +-- Pradeep + +------=_Part_722_19018361.1139988587419 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Hi,
+
+I'm using Postgres 7.4. I have a web application built with php4 using post= +gres7.4
+
+I was going through /var/log/messages of my linux box ( SLES 9). I encounte= +red the following messages quite a few times.
+
+>postgres[20199]: [4-1] ERROR:  could not send data to client: Brok= +en pipe
+>postgres[30391]: [6-1] LOG:  could not send data to client: Broken= + pipe
+>postgres[30570]: [6-1] LOG:  could not send data to client: Broken= + pipe
+
+Can anyone help me in interpreting these messages?
+What is causing this error msg? What is the severity?
+
+
+Regards
+
+-- Pradeep
+ +------=_Part_722_19018361.1139988587419-- + +From pgsql-performance-owner@postgresql.org Sat Feb 18 00:10:04 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 122AA9DC82D + for ; + Wed, 15 Feb 2006 04:34:12 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 69226-02 + for ; + Wed, 15 Feb 2006 04:34:08 -0400 (AST) +X-Greylist: whitelisted by SQLgrey- +Received: from smtp1-g19.free.fr (smtp1-g19.free.fr [212.27.42.27]) + by postgresql.org (Postfix) with ESMTP id 484B49DC803 + for ; + Wed, 15 Feb 2006 04:34:05 -0400 (AST) +Received: from imp6-g19.free.fr (imp6-g19.free.fr [212.27.42.6]) + by smtp1-g19.free.fr (Postfix) with ESMTP id A009A69240 + for ; + Wed, 15 Feb 2006 09:34:06 +0100 (CET) +Received: by imp6-g19.free.fr (Postfix, from userid 33) + id 6B9CC2CDD0; Wed, 15 Feb 2006 09:34:06 +0100 (MET) +Received: from wormhole.x-echo.com (wormhole.x-echo.com [193.252.148.11]) + by imp6-g19.free.fr (IMP) with HTTP + for ; Wed, 15 Feb 2006 09:34:06 +0100 +Message-ID: <1139992446.43f2e77e50629@imp6-g19.free.fr> +Date: Wed, 15 Feb 2006 09:34:06 +0100 +From: martial.bizel@free.fr +To: pgsql-performance@postgresql.org +Subject: Re: out of memory +References: <1139930651.43f1f61b04773@imp2-g19.free.fr> + <15115.1139931169@sss.pgh.pa.us> + <1139933018.43f1ff5a5e542@imp6-g19.free.fr> + <1139933201.22740.179.camel@state.g2switchworks.com> + <1139933720.43f20218cfe3a@imp6-g19.free.fr> + <1139934097.22740.182.camel@state.g2switchworks.com> + <1139934753.43f20621ba78d@imp1-g19.free.fr> + <1139935835.22740.188.camel@state.g2switchworks.com> +In-Reply-To: <1139935835.22740.188.camel@state.g2switchworks.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 8bit +User-Agent: Internet Messaging Program (IMP) 3.2.5 +X-Originating-IP: 193.252.148.11 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.656 required=5 tests=[AWL=0.106, NO_REAL_NAME=0.55] +X-Spam-Score: 0.656 +X-Spam-Level: +X-Archive-Number: 200602/295 +X-Sequence-Number: 17281 + +Good morning, + +I've increased sort_mem until 2Go !! +and the error "out of memory" appears again. + +Here the request I try to pass with her explain plan, + + Nested Loop (cost=2451676.23..2454714.73 rows=1001 width=34) + -> Subquery Scan "day" (cost=2451676.23..2451688.73 rows=1000 width=16) + -> Limit (cost=2451676.23..2451678.73 rows=1000 width=12) + -> Sort (cost=2451676.23..2451684.63 rows=3357 width=12) + Sort Key: sum(occurence) + -> HashAggregate (cost=2451471.24..2451479.63 rows=3357 +width=12) + -> Index Scan using test_date on +queries_detail_statistics (cost=0.00..2449570.55 rows=380138 width=12) + Index Cond: ((date >= '2006-01-01'::date) AND +(date <= '2006-01-30'::date)) + Filter: (((portal)::text = '1'::text) OR +((portal)::text = '2'::text)) + -> Index Scan using query_string_pkey on query_string (cost=0.00..3.01 +rows=1 width=34) + Index Cond: ("outer".query = query_string.id) +(11 rows) + +Any new ideas ?, +thanks + +MB. + + + + +> On Tue, 2006-02-14 at 10:32, martial.bizel@free.fr wrote: +> > command explain analyze crash with the "out of memory" error +> > +> > I precise that I've tried a lot of values from parameters shared_buffer and +> > sort_mem +> > +> > now, in config file, values are : +> > sort_mem=32768 +> > and shared_buffer=30000 +> +> OK, on the command line, try increasing the sort_mem until hash_agg can +> work. With a 4 gig machine, you should be able to go as high as needed +> here, I'd think. Try as high as 500000 or so or more. Then when +> explain analyze works, compare the actual versus estimated number of +> rows. +> + + + +From pgsql-novice-owner@postgresql.org Sat Feb 18 00:14:19 2006 +X-Original-To: pgsql-novice-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 8AD349DC959; + Wed, 15 Feb 2006 05:40:31 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 80730-03; Wed, 15 Feb 2006 05:40:32 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) + by postgresql.org (Postfix) with ESMTP id 6902C9DC803; + Wed, 15 Feb 2006 05:40:28 -0400 (AST) +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 7EFBA4245AD; Wed, 15 Feb 2006 09:39:47 +0000 (GMT) +Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP id 42D8515EA4; + Wed, 15 Feb 2006 09:39:47 +0000 (GMT) +Message-ID: <43F2F6E2.1020004@archonet.com> +Date: Wed, 15 Feb 2006 09:39:46 +0000 +From: Richard Huxton +User-Agent: Thunderbird 1.5 (X11/20051201) +MIME-Version: 1.0 +To: Pradeep Parmar +Cc: pgsql-novice@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: [PERFORM] could not send data to client: Broken pipe +References: <580055310602142329u448d044bi@mail.gmail.com> +In-Reply-To: <580055310602142329u448d044bi@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, score=0.117 required=5 tests=[AWL=0.117] +X-Spam-Score: 0.117 +X-Spam-Level: +X-Archive-Number: 200602/154 +X-Sequence-Number: 15832 + +Pradeep Parmar wrote: +> Hi, +> +> I'm using Postgres 7.4. I have a web application built with php4 using +> postgres7.4 +> +> I was going through /var/log/messages of my linux box ( SLES 9). I +> encountered the following messages quite a few times. +> +>> postgres[20199]: [4-1] ERROR: could not send data to client: Broken pipe +>> postgres[30391]: [6-1] LOG: could not send data to client: Broken pipe +>> postgres[30570]: [6-1] LOG: could not send data to client: Broken pipe +> +> Can anyone help me in interpreting these messages? +> What is causing this error msg? What is the severity? + +Not really a performance question, but at a guess your client went away. +Is there anything to indicate this in your php/apache logs? Can you +reproduce it by hitting cancel in your web-browser? + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Wed Feb 15 06:28:21 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 0902A9DCA4B + for ; + Wed, 15 Feb 2006 06:28:20 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 87006-05 + for ; + Wed, 15 Feb 2006 06:28:20 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from eads-av-smtp2.gmessaging.net (eads-av-smtp2.gmessaging.net + [194.51.201.3]) by postgresql.org (Postfix) with ESMTP id 819FD9DC9CA + for ; + Wed, 15 Feb 2006 06:28:15 -0400 (AST) +Received: from eads-relay2.cesson.gm-adm (localhost [127.0.0.1]) + by eads-av-smtp2.gmessaging.net + (iPlanet Messaging Server 5.2 HotFix 2.04 (built Feb 8 2005)) + with ESMTP id <0IUQ007LR4SMAX@eads-av-smtp2.gmessaging.net> for + pgsql-performance@postgresql.org; Wed, 15 Feb 2006 11:28:12 +0100 (MET) +Received: from fr0-mailsp01.res.airbus.corp ([10.254.251.54]) + by eads-av-smtp2.gmessaging.net + (iPlanet Messaging Server 5.2 HotFix 2.04 (built Feb 8 2005)) + with ESMTP id <0IUQ00JJD4Z7GL@eads-av-smtp2.gmessaging.net> for + pgsql-performance@postgresql.org; Wed, 15 Feb 2006 11:26:10 +0100 (MET) +Received: from fr0-mailsp01.res.airbus.corp (localhost.localdomain + [127.0.0.1]) + by fr0-mailsp01.res.airbus.corp (8.12.11/8.12.10) with ESMTP id + k1FAPqlC027007 + for ; Wed, 15 Feb 2006 11:25:52 +0100 +Received: from fr0-mailrt10.res.airbus.corp ([152.9.126.24]) + by fr0-mailsp01.res.airbus.corp (8.12.11/8.12.10) + with ESMTP id k1FAPhSY026866; Wed, 15 Feb 2006 11:25:50 +0100 +Received: from fr0-mailrt03.res.airbus.corp ([152.9.126.22]) + by fr0-mailrt10.res.airbus.corp with Microsoft SMTPSVC(5.0.2195.6713); + Wed, 15 Feb 2006 11:25:47 +0100 +Received: from FR0-MAILMB20.res.airbus.corp ([152.9.126.74]) + by fr0-mailrt03.res.airbus.corp with Microsoft SMTPSVC(5.0.2195.6713); + Wed, 15 Feb 2006 11:25:46 +0100 +Date: Wed, 15 Feb 2006 11:25:46 +0100 +From: "FERREIRA, William (VALTECH)" +Subject: Re: copy and postgresql.conf +To: J.K.Shah@Sun.COM +Cc: Albert Cervera Areny , pgsql-performance@postgresql.org +Message-id: + <414D259CE29DE54DAD534037C83CE4B7011E486F@FR0-MAILMB20.res.airbus.corp> +MIME-version: 1.0 +X-MIMEOLE: Produced By Microsoft Exchange V6.0.6603.0 +Content-type: text/plain; charset=iso-8859-1 +Content-transfer-encoding: quoted-printable +Content-class: urn:content-classes:message +Thread-topic: [PERFORM] copy and postgresql.conf +Thread-index: AcYxsE69jOS15zrkRNqqPR3D+RkWhQAaXf8Q +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +X-OriginalArrivalTime: 15 Feb 2006 10:25:46.0983 (UTC) + FILETIME=[2F3EEF70:01C6321A] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.213 required=5 tests=[AWL=0.213] +X-Spam-Score: 0.213 +X-Spam-Level: +X-Archive-Number: 200602/189 +X-Sequence-Number: 17175 + + +i'm using Solaris8 +i tried changing only postgresql parameters +and time has increased of 10mn + +i keep in mind your idea, we will soon upgraded to solaris 10 + +regards + + Will + +-----Message d'origine----- +De : J.K.Shah@Sun.COM [mailto:J.K.Shah@Sun.COM] +Envoy=E9 : mardi 14 f=E9vrier 2006 22:47 +=C0 : FERREIRA, William (VALTECH) +Cc : Albert Cervera Areny; pgsql-performance@postgresql.org +Objet : Re: [PERFORM] copy and postgresql.conf + + + +What version of Solaris are you using? + +Do you have the recommendations while using COPY on Solaris? +http://blogs.sun.com/roller/page/jkshah?entry= +=3Dpostgresql_on_solaris_better_use + +wal_sync_method =3D fsync +wal_buffers =3D 128 +checkpoint_segments =3D 128 +bgwriter_percent =3D 0 +bgwriter_maxpages =3D 0 + + +And also for /etc/system on Solaris 10, 9 SPARC use the following + +set maxphys=3D1048576 +set md:md_maxphys=3D1048576 +set segmap_percent=3D50 +set ufs:freebehind=3D0 +set msgsys:msginfo_msgmni =3D 3584 +set semsys:seminfo_semmni =3D 4096 +set shmsys:shminfo_shmmax =3D 15392386252 +set shmsys:shminfo_shmmni =3D 4096 + + +Can you try putting in one run with this values and send back your=0D +experiences on whether it helps your workload or not? + +Atleast I saw improvements using the above settings with COPY with=0D +Postgres 8.0 and Postgres 8.1 on Solaris. + +Regards, +Jignesh + + + + +FERREIRA, William (VALTECH) wrote: + +>30% faster !!! i will test this new version ... +> +>thanks a lot +> +>-----Message d'origine----- +>De : pgsql-performance-owner@postgresql.org +>[mailto:pgsql-performance-owner@postgresql.org]De la part de Albert +>Cervera Areny +>Envoy=E9 : mardi 14 f=E9vrier 2006 17:07 +>=C0 : pgsql-performance@postgresql.org +>Objet : Re: [PERFORM] copy and postgresql.conf +> +> +> +>Sorry, COPY improvements came with 8.1 +> +>(http://www.postgresql.org/docs/whatsnew) +> +>A Dimarts 14 Febrer 2006 14:26, FERREIRA, William (VALTECH) va escriure: +> =0D +> +>>thanks, +>> +>>i'm using postgresql 8.0.3 +>>there is no primary key and no index on my tables +>> +>>regards +>> +>>-----Message d'origine----- +>>De : pgsql-performance-owner@postgresql.org +>>[mailto:pgsql-performance-owner@postgresql.org]De la part de Albert +>>Cervera Areny +>>Envoy=E9 : mardi 14 f=E9vrier 2006 12:38 +>>=C0 : pgsql-performance@postgresql.org +>>Objet : Re: [PERFORM] copy and postgresql.conf +>> +>> +>> +>>Hi William, +>> which PostgreSQL version are you using? Newer (8.0+) versions have some +>> +>>important performance improvements for the COPY command. +>> +>> Also, you'll notice significant improvements by creating primary &= + foreign +>> +>>keys after the copy command. I think config tweaking can improve key and +>> +>>index creation but I don't think you can improve the COPY command itself. +>> +>> There are also many threads in this list commenting on this issue,= + you'll +>> +>>find it easely in the archives. +>> +>>A Dimarts 14 Febrer 2006 10:44, FERREIRA, William (VALTECH) va escriure: +>> =0D +>> +>>>hi, +>>> +>>>i load data from files using copy method. +>>>Files contain between 2 and 7 millions of rows, spread on 5 tables. +>>> +>>>For loading all the data, it takes 40mn, and the same processing takes +>>>17mn with Oracle. I think that this time can be improved by changing +>>>postgresql configuration file. But which parameters i need to manipulate +>>>and with which values ? +>>> +>>>Here are the specifications of my system : +>>>V250 architecture sun4u +>>>2xCPU UltraSparc IIIi 1.28 GHz. +>>>8 Go RAM. +>>> +>>>Regards. +>>> +>>> Will +>>> +>>> +>>>This e-mail is intended only for the above addressee. It may contain +>>>privileged information. If you are not the addressee you must not copy, +>>>distribute, disclose or use any of the information in it. If you have +>>>received it in error please delete it and immediately notify the sender. +>>>Security Notice: all e-mail, sent to or from this address, may be +>>>accessed by someone other than the recipient, for system management and +>>>security reasons. This access is controlled under Regulation of +>>>Investigatory Powers Act 2000, Lawful Business Practises. +>>> +>>>---------------------------(end of broadcast)--------------------------- +>>>TIP 4: Have you searched our list archives? +>>> +>>> http://archives.postgresql.org +>>> =0D +>>> +>>-- +>> +>>Albert Cervera Areny +>>Dept. Inform=E0tica Sedifa, S.L. +>> +>>Av. Can Bordoll, 149 +>>08202 - Sabadell (Barcelona) +>>Tel. 93 715 51 11 +>>Fax. 93 715 51 12 +>> +>>=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 +>>........................ AVISO LEGAL ............................ +>>La presente comunicaci=F3n y sus anexos tiene como destinatario la +>>persona a la que va dirigida, por lo que si usted lo recibe +>>por error debe notificarlo al remitente y eliminarlo de su +>>sistema, no pudiendo utilizarlo, total o parcialmente, para +>>ning=FAn fin. Su contenido puede tener informaci=F3n confidencial o +>>protegida legalmente y =FAnicamente expresa la opini=F3n del +>>remitente. El uso del correo electr=F3nico v=EDa Internet no +>>permite asegurar ni la confidencialidad de los mensajes +>>ni su correcta recepci=F3n. En el caso de que el +>>destinatario no consintiera la utilizaci=F3n del correo electr=F3nico, +>>deber=E1 ponerlo en nuestro conocimiento inmediatamente. +>>=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 +>>........................... DISCLAIMER ............................. +>>This message and its attachments are intended exclusively for the +>>named addressee. If you receive this message in error, please +>>immediately delete it from your system and notify the sender. You +>>may not use this message or any part of it for any purpose. +>>The message may contain information that is confidential or +>>protected by law, and any opinions expressed are those of the +>>individual sender. Internet e-mail guarantees neither the +>>confidentiality nor the proper receipt of the message sent. +>>If the addressee of this message does not consent to the use +>>of internet e-mail, please inform us inmmediately. +>>=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 +>> +>> +>> +>> +>> +>>---------------------------(end of broadcast)--------------------------- +>>TIP 5: don't forget to increase your free space map settings +>> +>> +>> +>>This mail has originated outside your organization, +>>either from an external partner or the Global Internet. +>>Keep this in mind if you answer this message. +>> +>> +>>This e-mail is intended only for the above addressee. It may contain +>>privileged information. If you are not the addressee you must not copy, +>>distribute, disclose or use any of the information in it. If you have +>>received it in error please delete it and immediately notify the sender. +>>Security Notice: all e-mail, sent to or from this address, may be +>>accessed by someone other than the recipient, for system management and +>>security reasons. This access is controlled under Regulation of +>>Investigatory Powers Act 2000, Lawful Business Practises. +>> =0D +>> +> +>-- +> +>Albert Cervera Areny +>Dept. Inform=E0tica Sedifa, S.L. +> +>Av. Can Bordoll, 149 +>08202 - Sabadell (Barcelona) +>Tel. 93 715 51 11 +>Fax. 93 715 51 12 +> +>=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 +>........................ AVISO LEGAL ............................ +>La presente comunicaci=F3n y sus anexos tiene como destinatario la +>persona a la que va dirigida, por lo que si usted lo recibe +>por error debe notificarlo al remitente y eliminarlo de su +>sistema, no pudiendo utilizarlo, total o parcialmente, para +>ning=FAn fin. Su contenido puede tener informaci=F3n confidencial o +>protegida legalmente y =FAnicamente expresa la opini=F3n del +>remitente. El uso del correo electr=F3nico v=EDa Internet no +>permite asegurar ni la confidencialidad de los mensajes +>ni su correcta recepci=F3n. En el caso de que el +>destinatario no consintiera la utilizaci=F3n del correo electr=F3nico, +>deber=E1 ponerlo en nuestro conocimiento inmediatamente. +>=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 +>........................... DISCLAIMER ............................. +>This message and its attachments are intended exclusively for the +>named addressee. If you receive this message in error, please +>immediately delete it from your system and notify the sender. You +>may not use this message or any part of it for any purpose. +>The message may contain information that is confidential or +>protected by law, and any opinions expressed are those of the +>individual sender. Internet e-mail guarantees neither the +>confidentiality nor the proper receipt of the message sent. +>If the addressee of this message does not consent to the use +>of internet e-mail, please inform us inmmediately. +>=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 +> +> +> +> +> +>---------------------------(end of broadcast)--------------------------- +>TIP 5: don't forget to increase your free space map settings +> +> +> +>This mail has originated outside your organization, +>either from an external partner or the Global Internet. +>Keep this in mind if you answer this message. +> +> +>This e-mail is intended only for the above addressee. It may contain +>privileged information. If you are not the addressee you must not copy, +>distribute, disclose or use any of the information in it. If you have +>received it in error please delete it and immediately notify the sender. +>Security Notice: all e-mail, sent to or from this address, may be +>accessed by someone other than the recipient, for system management and +>security reasons. This access is controlled under Regulation of +>Investigatory Powers Act 2000, Lawful Business Practises. +> +>---------------------------(end of broadcast)--------------------------- +>TIP 6: explain analyze is your friend +> =0D +> + +=0D +This mail has originated outside your organization, +either from an external partner or the Global Internet. +Keep this in mind if you answer this message. + +=0D +This e-mail is intended only for the above addressee. It may contain +privileged information. If you are not the addressee you must not copy, +distribute, disclose or use any of the information in it. If you have +received it in error please delete it and immediately notify the sender. +Security Notice: all e-mail, sent to or from this address, may be +accessed by someone other than the recipient, for system management and +security reasons. This access is controlled under Regulation of +Investigatory Powers Act 2000, Lawful Business Practises. + +From pgsql-performance-owner@postgresql.org Sat Feb 18 00:11:04 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id BB3789DC894 + for ; + Wed, 15 Feb 2006 08:56:30 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 13528-10 + for ; + Wed, 15 Feb 2006 08:56:33 -0400 (AST) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 2E3C89DC884 + for ; + Wed, 15 Feb 2006 08:56:28 -0400 (AST) +Received: from mail.ritek.hu (82-131-192-50.vnet.hu [82.131.192.50]) + by svr4.postgresql.org (Postfix) with ESMTP id 3E91E5AF1FA + for ; + Wed, 15 Feb 2006 12:56:30 +0000 (GMT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mail.ritek.hu (Postfix) with ESMTP id 15D6A19C15C + for ; + Wed, 15 Feb 2006 13:56:21 +0100 (CET) +Received: from mail.ritek.hu ([127.0.0.1]) + by localhost (mail.ritek.hu [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 18480-05 for ; + Wed, 15 Feb 2006 13:56:17 +0100 (CET) +Received: from [10.1.2.11] (unknown [10.1.2.11]) + by mail.ritek.hu (Postfix) with ESMTP id BDC7119C158 + for ; + Wed, 15 Feb 2006 13:56:17 +0100 (CET) +Message-ID: <43F3251F.9080901@ritek.hu> +Date: Wed, 15 Feb 2006 13:57:03 +0100 +From: Antal Attila +User-Agent: Thunderbird 1.5 (Windows/20051201) +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Stored proc and optimizer question +Content-Type: text/plain; charset=ISO-8859-2; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at ritek.hu +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200602/303 +X-Sequence-Number: 17289 + +Hi! + +I have a question about the query optimizer and the function scan. See +the next case: + +CREATE TABLE a (id SERIAL PRIMARY KEY, userid INT4, col TEXT); +CREATE TABLE b (id SERIAL PRIMARY KEY, userid INT4, a_id INT4 REFERENCES +a (id), col TEXT); +CREATE INDEX idx_a_uid ON a(userid); +CREATE INDEX idx_b_uid ON b(userid); +CREATE INDEX idx_a_col ON a(col); +CREATE INDEX idx_b_col ON b(col); + +First solution: + + CREATE VIEW ab_view AS + SELECT a.id AS id, + a.userid AS userid_a, b.userid AS userid_b, + a.col AS col_a, b.col AS col_b + FROM a LEFT JOIN b ON (a.id = b.a_id); + + EXPLAIN ANALYSE SELECT * FROM ab_view + WHERE userid_a = 23 AND userid_b = 23 AND col_a LIKE 's%' + ORDER BY col_b + LIMIT 10 OFFSET 10; + + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------ + Limit (cost=15.70..15.70 rows=1 width=76) (actual time=0.108..0.108 +rows=0 loops=1) + -> Sort (cost=15.69..15.70 rows=1 width=76) (actual +time=0.104..0.104 rows=0 loops=1) + Sort Key: b.col + -> Nested Loop (cost=3.32..15.68 rows=1 width=76) (actual +time=0.085..0.085 rows=0 loops=1) + Join Filter: ("outer".id = "inner".a_id) + -> Bitmap Heap Scan on a (cost=2.30..6.13 rows=1 +width=40) (actual time=0.082..0.082 rows=0 loops=1) + Recheck Cond: (userid = 23) + Filter: (col ~~ 's%'::text) + -> BitmapAnd (cost=2.30..2.30 rows=1 width=0) +(actual time=0.077..0.077 rows=0 loops=1) + -> Bitmap Index Scan on idx_a_uid +(cost=0.00..1.02 rows=6 width=0) (actual time=0.075..0.075 rows=0 loops=1) + Index Cond: (userid = 23) + -> Bitmap Index Scan on idx_a_col +(cost=0.00..1.03 rows=6 width=0) (never executed) + Index Cond: ((col >= 's'::text) AND +(col < 't'::text)) + -> Bitmap Heap Scan on b (cost=1.02..9.49 rows=5 +width=40) (never executed) + Recheck Cond: (userid = 23) + -> Bitmap Index Scan on idx_b_uid +(cost=0.00..1.02 rows=5 width=0) (never executed) + Index Cond: (userid = 23) + Total runtime: 0.311 ms + + +In the first solution the query optimizer can work on the view and the +full execution of the query will be optimal. But I have to use 2 +condition for the userid fields (userid_a = 23 AND userid_b = 23 ). If I +have to eliminate the duplication I can try to use stored function. + +Second solution: + CREATE FUNCTION ab_select(INT4) RETURNS setof ab_view AS $$ + SELECT a.id AS id, + a.userid AS userid_a, b.userid AS userid_b, + a.col AS col_a, b.col AS col_b + FROM a LEFT JOIN b ON (a.id = b.a_id AND b.userid = $1) + WHERE a.userid = $1; + $$ LANGUAGE SQL STABLE; + + EXPLAIN ANALYSE SELECT * FROM ab_select(23) + WHERE col_a LIKE 's%' + ORDER BY col_b + LIMIT 10 OFFSET 10; + + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------- + Limit (cost=15.07..15.07 rows=1 width=76) (actual time=1.034..1.034 +rows=0 loops=1) + -> Sort (cost=15.06..15.07 rows=5 width=76) (actual +time=1.030..1.030 rows=0 loops=1) + Sort Key: col_b + -> Function Scan on ab_select (cost=0.00..15.00 rows=5 +width=76) (actual time=1.004..1.004 rows=0 loops=1) + Filter: (col_a ~~ 's%'::text) + Total runtime: 1.103 ms + +The second solution have 2 advantage: + 1. The second query is more beautiful and shorter. + 2. You can rewrite easier the stored function without modify the query. + +But I have heartache, because the optimizer give up the game. It cannot +optimize the query globally (inside and outside the stored function) in +spite of the STABLE keyword. It use function scan on the result of the +stored function. + +How can I eliminate the function scan while I want to keep the advantages? + +In my opinion the optimizer cannot replace the function scan with a more +optimal plan, but this feature may be implemented in the next versions +of PostgreSQL. I would like to suggest this. + +I built this case theoretically, but I have more stored procedure which +works with bad performance therefore. + +Regards, +Antal Attila + +From pgsql-performance-owner@postgresql.org Wed Feb 15 10:08:25 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id A5D669DC9E4 + for ; + Wed, 15 Feb 2006 10:08:24 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 30466-06 + for ; + Wed, 15 Feb 2006 10:08:27 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from eads-av-smtp3.gmessaging.net (eads-av-smtp3.gmessaging.net + [194.51.201.27]) + by postgresql.org (Postfix) with ESMTP id 4A5CF9DCAB8 + for ; + Wed, 15 Feb 2006 10:08:20 -0400 (AST) +Received: from eads-relay3.cesson.gm-adm (localhost [127.0.0.1]) + by eads-av-smtp3.gmessaging.net + (iPlanet Messaging Server 5.2 HotFix 2.04 (built Feb 8 2005)) + with ESMTP id <0IUQ00MECF5N9W@eads-av-smtp3.gmessaging.net> for + pgsql-performance@postgresql.org; Wed, 15 Feb 2006 15:08:24 +0100 (MET) +Received: from fr0-mailsp01.res.airbus.corp ([10.254.251.54]) + by eads-av-smtp3.gmessaging.net + (iPlanet Messaging Server 5.2 HotFix 2.04 (built Feb 8 2005)) + with ESMTP id <0IUQ00DR3F9090@eads-av-smtp3.gmessaging.net> for + pgsql-performance@postgresql.org; Wed, 15 Feb 2006 15:07:53 +0100 (MET) +Received: from fr0-mailsp01.res.airbus.corp (localhost.localdomain + [127.0.0.1]) + by fr0-mailsp01.res.airbus.corp (8.12.11/8.12.10) with ESMTP id + k1FE7lQ2029366 + for ; Wed, 15 Feb 2006 15:07:47 +0100 +Received: from fr0-mailrt10.res.airbus.corp ([152.9.126.24]) + by fr0-mailsp01.res.airbus.corp (8.12.11/8.12.10) + with ESMTP id k1FE7eGG029266; Wed, 15 Feb 2006 15:07:46 +0100 +Received: from fr0-mailrt03.res.airbus.corp ([152.9.126.22]) + by fr0-mailrt10.res.airbus.corp with Microsoft SMTPSVC(5.0.2195.6713); + Wed, 15 Feb 2006 15:07:40 +0100 +Received: from FR0-MAILMB20.res.airbus.corp ([152.9.126.74]) + by fr0-mailrt03.res.airbus.corp with Microsoft SMTPSVC(5.0.2195.6713); + Wed, 15 Feb 2006 15:07:40 +0100 +Date: Wed, 15 Feb 2006 15:07:40 +0100 +From: "FERREIRA, William (VALTECH)" +Subject: Re: copy and postgresql.conf +To: Albert Cervera Areny , pgsql-performance@postgresql.org +Message-id: + <414D259CE29DE54DAD534037C83CE4B7011E4871@FR0-MAILMB20.res.airbus.corp> +MIME-version: 1.0 +X-MIMEOLE: Produced By Microsoft Exchange V6.0.6603.0 +Content-type: text/plain; charset=iso-8859-1 +Content-transfer-encoding: quoted-printable +Content-class: urn:content-classes:message +Thread-topic: [PERFORM] copy and postgresql.conf +Thread-index: AcYxgh0JqGmgdW2VSlie39PaFfKDPgAtqhoQ +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +X-OriginalArrivalTime: 15 Feb 2006 14:07:40.0686 (UTC) + FILETIME=[2ED4CAE0:01C63239] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.209 required=5 tests=[AWL=0.209] +X-Spam-Score: 0.209 +X-Spam-Level: +X-Archive-Number: 200602/191 +X-Sequence-Number: 17177 + + +i tested the last version version of PostgreSQL +and for the same test : +before : 40mn +and now : 12mn :) +faster than Oracle (exactly what i wanted :p ) + +thanks to everybody + + Will + + +-----Message d'origine----- +De : pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org]De la part de Albert +Cervera Areny +Envoy=E9 : mardi 14 f=E9vrier 2006 17:07 +=C0 : pgsql-performance@postgresql.org +Objet : Re: [PERFORM] copy and postgresql.conf + + + +Sorry, COPY improvements came with 8.1 + +(http://www.postgresql.org/docs/whatsnew) + +A Dimarts 14 Febrer 2006 14:26, FERREIRA, William (VALTECH) va escriure: +> thanks, +> +> i'm using postgresql 8.0.3 +> there is no primary key and no index on my tables +> +> regards +> +> -----Message d'origine----- +> De : pgsql-performance-owner@postgresql.org +> [mailto:pgsql-performance-owner@postgresql.org]De la part de Albert +> Cervera Areny +> Envoy=E9 : mardi 14 f=E9vrier 2006 12:38 +> =C0 : pgsql-performance@postgresql.org +> Objet : Re: [PERFORM] copy and postgresql.conf +> +> +> +> Hi William, +> which PostgreSQL version are you using? Newer (8.0+) versions have some +> +> important performance improvements for the COPY command. +> +> Also, you'll notice significant improvements by creating primary &= + foreign +> +> keys after the copy command. I think config tweaking can improve key and +> +> index creation but I don't think you can improve the COPY command itself. +> +> There are also many threads in this list commenting on this issue,= + you'll +> +> find it easely in the archives. +> +> A Dimarts 14 Febrer 2006 10:44, FERREIRA, William (VALTECH) va escriure: +> > hi, +> > +> > i load data from files using copy method. +> > Files contain between 2 and 7 millions of rows, spread on 5 tables. +> > +> > For loading all the data, it takes 40mn, and the same processing takes +> > 17mn with Oracle. I think that this time can be improved by changing +> > postgresql configuration file. But which parameters i need to= + manipulate +> > and with which values ? +> > +> > Here are the specifications of my system : +> > V250 architecture sun4u +> > 2xCPU UltraSparc IIIi 1.28 GHz. +> > 8 Go RAM. +> > +> > Regards. +> > +> > Will +> > +> > +> > This e-mail is intended only for the above addressee. It may contain +> > privileged information. If you are not the addressee you must not copy, +> > distribute, disclose or use any of the information in it. If you have +> > received it in error please delete it and immediately notify the= + sender. +> > Security Notice: all e-mail, sent to or from this address, may be +> > accessed by someone other than the recipient, for system management and +> > security reasons. This access is controlled under Regulation of +> > Investigatory Powers Act 2000, Lawful Business Practises. +> > +> > ---------------------------(end of= + broadcast)--------------------------- +> > TIP 4: Have you searched our list archives? +> > +> > http://archives.postgresql.org +> +> -- +> +> Albert Cervera Areny +> Dept. Inform=E0tica Sedifa, S.L. +> +> Av. Can Bordoll, 149 +> 08202 - Sabadell (Barcelona) +> Tel. 93 715 51 11 +> Fax. 93 715 51 12 +> +> =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 +> ........................ AVISO LEGAL ............................ +> La presente comunicaci=F3n y sus anexos tiene como destinatario la +> persona a la que va dirigida, por lo que si usted lo recibe +> por error debe notificarlo al remitente y eliminarlo de su +> sistema, no pudiendo utilizarlo, total o parcialmente, para +> ning=FAn fin. Su contenido puede tener informaci=F3n confidencial o +> protegida legalmente y =FAnicamente expresa la opini=F3n del +> remitente. El uso del correo electr=F3nico v=EDa Internet no +> permite asegurar ni la confidencialidad de los mensajes +> ni su correcta recepci=F3n. En el caso de que el +> destinatario no consintiera la utilizaci=F3n del correo electr=F3nico, +> deber=E1 ponerlo en nuestro conocimiento inmediatamente. +> =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 +> ........................... DISCLAIMER ............................. +> This message and its attachments are intended exclusively for the +> named addressee. If you receive this message in error, please +> immediately delete it from your system and notify the sender. You +> may not use this message or any part of it for any purpose. +> The message may contain information that is confidential or +> protected by law, and any opinions expressed are those of the +> individual sender. Internet e-mail guarantees neither the +> confidentiality nor the proper receipt of the message sent. +> If the addressee of this message does not consent to the use +> of internet e-mail, please inform us inmmediately. +> =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 +> +> +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 5: don't forget to increase your free space map settings +> +> +> +> This mail has originated outside your organization, +> either from an external partner or the Global Internet. +> Keep this in mind if you answer this message. +> +> +> This e-mail is intended only for the above addressee. It may contain +> privileged information. If you are not the addressee you must not copy, +> distribute, disclose or use any of the information in it. If you have +> received it in error please delete it and immediately notify the sender. +> Security Notice: all e-mail, sent to or from this address, may be +> accessed by someone other than the recipient, for system management and +> security reasons. This access is controlled under Regulation of +> Investigatory Powers Act 2000, Lawful Business Practises. + +-- + +Albert Cervera Areny +Dept. Inform=E0tica Sedifa, S.L. + +Av. Can Bordoll, 149 +08202 - Sabadell (Barcelona) +Tel. 93 715 51 11 +Fax. 93 715 51 12 + +=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 +........................ AVISO LEGAL ............................ +La presente comunicaci=F3n y sus anexos tiene como destinatario la +persona a la que va dirigida, por lo que si usted lo recibe +por error debe notificarlo al remitente y eliminarlo de su +sistema, no pudiendo utilizarlo, total o parcialmente, para +ning=FAn fin. Su contenido puede tener informaci=F3n confidencial o +protegida legalmente y =FAnicamente expresa la opini=F3n del +remitente. El uso del correo electr=F3nico v=EDa Internet no +permite asegurar ni la confidencialidad de los mensajes +ni su correcta recepci=F3n. En el caso de que el +destinatario no consintiera la utilizaci=F3n del correo electr=F3nico, +deber=E1 ponerlo en nuestro conocimiento inmediatamente. +=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 +........................... DISCLAIMER ............................. +This message and its attachments are intended exclusively for the +named addressee. If you receive this message in error, please +immediately delete it from your system and notify the sender. You +may not use this message or any part of it for any purpose. +The message may contain information that is confidential or +protected by law, and any opinions expressed are those of the +individual sender. Internet e-mail guarantees neither the +confidentiality nor the proper receipt of the message sent. +If the addressee of this message does not consent to the use +of internet e-mail, please inform us inmmediately. +=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 + + + + + +---------------------------(end of broadcast)--------------------------- +TIP 5: don't forget to increase your free space map settings + + + +This mail has originated outside your organization, +either from an external partner or the Global Internet. +Keep this in mind if you answer this message. + +=0D +This e-mail is intended only for the above addressee. It may contain +privileged information. If you are not the addressee you must not copy, +distribute, disclose or use any of the information in it. If you have +received it in error please delete it and immediately notify the sender. +Security Notice: all e-mail, sent to or from this address, may be +accessed by someone other than the recipient, for system management and +security reasons. This access is controlled under Regulation of +Investigatory Powers Act 2000, Lawful Business Practises. + +From pgsql-performance-owner@postgresql.org Wed Feb 15 10:14:18 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 0D7E79DCB6E + for ; + Wed, 15 Feb 2006 10:14:18 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28997-10 + for ; + Wed, 15 Feb 2006 10:14:21 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from brmea-mail-4.sun.com (brmea-mail-4.Sun.COM [192.18.98.36]) + by postgresql.org (Postfix) with ESMTP id 0442A9DCB31 + for ; + Wed, 15 Feb 2006 10:14:13 -0400 (AST) +Received: from fe-amer-01.sun.com ([192.18.108.175]) + by brmea-mail-4.sun.com (8.12.10/8.12.9) with ESMTP id k1FEEHuf003173 + for ; + Wed, 15 Feb 2006 07:14:17 -0700 (MST) +Received: from conversion-daemon.mail-amer.sun.com by mail-amer.sun.com + (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) + id <0IUQ00601EM0RQ00@mail-amer.sun.com> (original mail from + J.K.Shah@Sun.COM) for pgsql-performance@postgresql.org; + Wed, 15 Feb 2006 07:14:17 -0700 (MST) +Received: from [192.168.1.3] ([66.30.240.129]) + by mail-amer.sun.com (Sun Java System Messaging Server 6.2-4.02 (built + Sep 9 + 2005)) with ESMTPSA id <0IUQ00EMPFJOM3S0@mail-amer.sun.com>; Wed, + 15 Feb 2006 07:14:17 -0700 (MST) +Date: Wed, 15 Feb 2006 09:14:10 -0500 +From: "Jignesh K. Shah" +Subject: Re: copy and postgresql.conf +In-reply-to: + <414D259CE29DE54DAD534037C83CE4B7011E4871@FR0-MAILMB20.res.airbus.corp> +To: "FERREIRA, William (VALTECH)" +Cc: Albert Cervera Areny , pgsql-performance@postgresql.org +Message-id: <43F33732.3050501@sun.com> +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=ISO-8859-1 +Content-transfer-encoding: 8BIT +X-Accept-Language: en-us, en +References: + <414D259CE29DE54DAD534037C83CE4B7011E4871@FR0-MAILMB20.res.airbus.corp> +User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.121 required=5 tests=[AWL=0.120, + UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 0.121 +X-Spam-Level: +X-Archive-Number: 200602/192 +X-Sequence-Number: 17178 + +What's your postgresql.conf parameter for the equivalent ones that I +suggested? +I believe your wal_buffers and checkpoint_segments could be bigger. If +that's the case then yep you are fine. + +As for the background writer I am seeing mixed results yet so not sure +about that. + +But thanks for the feedback. + +-Jignesh + + +FERREIRA, William (VALTECH) wrote: + +>i tested the last version version of PostgreSQL +>and for the same test : +>before : 40mn +>and now : 12mn :) +>faster than Oracle (exactly what i wanted :p ) +> +>thanks to everybody +> +> Will +> +> +>-----Message d'origine----- +>De : pgsql-performance-owner@postgresql.org +>[mailto:pgsql-performance-owner@postgresql.org]De la part de Albert +>Cervera Areny +>Envoy� : mardi 14 f�vrier 2006 17:07 +>� : pgsql-performance@postgresql.org +>Objet : Re: [PERFORM] copy and postgresql.conf +> +> +> +>Sorry, COPY improvements came with 8.1 +> +>(http://www.postgresql.org/docs/whatsnew) +> +>A Dimarts 14 Febrer 2006 14:26, FERREIRA, William (VALTECH) va escriure: +> +> +>>thanks, +>> +>>i'm using postgresql 8.0.3 +>>there is no primary key and no index on my tables +>> +>>regards +>> +>>-----Message d'origine----- +>>De : pgsql-performance-owner@postgresql.org +>>[mailto:pgsql-performance-owner@postgresql.org]De la part de Albert +>>Cervera Areny +>>Envoy� : mardi 14 f�vrier 2006 12:38 +>>� : pgsql-performance@postgresql.org +>>Objet : Re: [PERFORM] copy and postgresql.conf +>> +>> +>> +>>Hi William, +>> which PostgreSQL version are you using? Newer (8.0+) versions have some +>> +>>important performance improvements for the COPY command. +>> +>> Also, you'll notice significant improvements by creating primary & foreign +>> +>>keys after the copy command. I think config tweaking can improve key and +>> +>>index creation but I don't think you can improve the COPY command itself. +>> +>> There are also many threads in this list commenting on this issue, you'll +>> +>>find it easely in the archives. +>> +>>A Dimarts 14 Febrer 2006 10:44, FERREIRA, William (VALTECH) va escriure: +>> +>> +>>>hi, +>>> +>>>i load data from files using copy method. +>>>Files contain between 2 and 7 millions of rows, spread on 5 tables. +>>> +>>>For loading all the data, it takes 40mn, and the same processing takes +>>>17mn with Oracle. I think that this time can be improved by changing +>>>postgresql configuration file. But which parameters i need to manipulate +>>>and with which values ? +>>> +>>>Here are the specifications of my system : +>>>V250 architecture sun4u +>>>2xCPU UltraSparc IIIi 1.28 GHz. +>>>8 Go RAM. +>>> +>>>Regards. +>>> +>>> Will +>>> +>>> +>>>This e-mail is intended only for the above addressee. It may contain +>>>privileged information. If you are not the addressee you must not copy, +>>>distribute, disclose or use any of the information in it. If you have +>>>received it in error please delete it and immediately notify the sender. +>>>Security Notice: all e-mail, sent to or from this address, may be +>>>accessed by someone other than the recipient, for system management and +>>>security reasons. This access is controlled under Regulation of +>>>Investigatory Powers Act 2000, Lawful Business Practises. +>>> +>>>---------------------------(end of broadcast)--------------------------- +>>>TIP 4: Have you searched our list archives? +>>> +>>> http://archives.postgresql.org +>>> +>>> +>>-- +>> +>>Albert Cervera Areny +>>Dept. Inform�tica Sedifa, S.L. +>> +>>Av. Can Bordoll, 149 +>>08202 - Sabadell (Barcelona) +>>Tel. 93 715 51 11 +>>Fax. 93 715 51 12 +>> +>>==================================================================== +>>........................ AVISO LEGAL ............................ +>>La presente comunicaci�n y sus anexos tiene como destinatario la +>>persona a la que va dirigida, por lo que si usted lo recibe +>>por error debe notificarlo al remitente y eliminarlo de su +>>sistema, no pudiendo utilizarlo, total o parcialmente, para +>>ning�n fin. Su contenido puede tener informaci�n confidencial o +>>protegida legalmente y �nicamente expresa la opini�n del +>>remitente. El uso del correo electr�nico v�a Internet no +>>permite asegurar ni la confidencialidad de los mensajes +>>ni su correcta recepci�n. En el caso de que el +>>destinatario no consintiera la utilizaci�n del correo electr�nico, +>>deber� ponerlo en nuestro conocimiento inmediatamente. +>>==================================================================== +>>........................... DISCLAIMER ............................. +>>This message and its attachments are intended exclusively for the +>>named addressee. If you receive this message in error, please +>>immediately delete it from your system and notify the sender. You +>>may not use this message or any part of it for any purpose. +>>The message may contain information that is confidential or +>>protected by law, and any opinions expressed are those of the +>>individual sender. Internet e-mail guarantees neither the +>>confidentiality nor the proper receipt of the message sent. +>>If the addressee of this message does not consent to the use +>>of internet e-mail, please inform us inmmediately. +>>==================================================================== +>> +>> +>> +>> +>> +>>---------------------------(end of broadcast)--------------------------- +>>TIP 5: don't forget to increase your free space map settings +>> +>> +>> +>>This mail has originated outside your organization, +>>either from an external partner or the Global Internet. +>>Keep this in mind if you answer this message. +>> +>> +>>This e-mail is intended only for the above addressee. It may contain +>>privileged information. If you are not the addressee you must not copy, +>>distribute, disclose or use any of the information in it. If you have +>>received it in error please delete it and immediately notify the sender. +>>Security Notice: all e-mail, sent to or from this address, may be +>>accessed by someone other than the recipient, for system management and +>>security reasons. This access is controlled under Regulation of +>>Investigatory Powers Act 2000, Lawful Business Practises. +>> +>> +> +>-- +> +>Albert Cervera Areny +>Dept. Inform�tica Sedifa, S.L. +> +>Av. Can Bordoll, 149 +>08202 - Sabadell (Barcelona) +>Tel. 93 715 51 11 +>Fax. 93 715 51 12 +> +>==================================================================== +>........................ AVISO LEGAL ............................ +>La presente comunicaci�n y sus anexos tiene como destinatario la +>persona a la que va dirigida, por lo que si usted lo recibe +>por error debe notificarlo al remitente y eliminarlo de su +>sistema, no pudiendo utilizarlo, total o parcialmente, para +>ning�n fin. Su contenido puede tener informaci�n confidencial o +>protegida legalmente y �nicamente expresa la opini�n del +>remitente. El uso del correo electr�nico v�a Internet no +>permite asegurar ni la confidencialidad de los mensajes +>ni su correcta recepci�n. En el caso de que el +>destinatario no consintiera la utilizaci�n del correo electr�nico, +>deber� ponerlo en nuestro conocimiento inmediatamente. +>==================================================================== +>........................... DISCLAIMER ............................. +>This message and its attachments are intended exclusively for the +>named addressee. If you receive this message in error, please +>immediately delete it from your system and notify the sender. You +>may not use this message or any part of it for any purpose. +>The message may contain information that is confidential or +>protected by law, and any opinions expressed are those of the +>individual sender. Internet e-mail guarantees neither the +>confidentiality nor the proper receipt of the message sent. +>If the addressee of this message does not consent to the use +>of internet e-mail, please inform us inmmediately. +>==================================================================== +> +> +> +> +> +>---------------------------(end of broadcast)--------------------------- +>TIP 5: don't forget to increase your free space map settings +> +> +> +>This mail has originated outside your organization, +>either from an external partner or the Global Internet. +>Keep this in mind if you answer this message. +> +> +>This e-mail is intended only for the above addressee. It may contain +>privileged information. If you are not the addressee you must not copy, +>distribute, disclose or use any of the information in it. If you have +>received it in error please delete it and immediately notify the sender. +>Security Notice: all e-mail, sent to or from this address, may be +>accessed by someone other than the recipient, for system management and +>security reasons. This access is controlled under Regulation of +>Investigatory Powers Act 2000, Lawful Business Practises. +> +>---------------------------(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 Feb 15 10:23:07 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 831E99DC9E4 + for ; + Wed, 15 Feb 2006 10:23:06 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 32892-03 + for ; + Wed, 15 Feb 2006 10:23:10 -0400 (AST) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 1D4C49DC953 + for ; + Wed, 15 Feb 2006 10:23:04 -0400 (AST) +Received: from insiderscore.com (mail01.insiderscore.com [69.84.139.233]) + by svr4.postgresql.org (Postfix) with ESMTP id 00A6E5AF048 + for ; + Wed, 15 Feb 2006 14:23:06 +0000 (GMT) +Received: from [10.10.10.105] (mail01.insiderscore.com [69.84.139.233]) + by insiderscore.com (Postfix) with ESMTP id 2930011C4393; + Wed, 15 Feb 2006 09:23:04 -0500 (EST) +In-Reply-To: <200602142056.k1EKuIiO002595@timberline.ca> +References: <200602142056.k1EKuIiO002595@timberline.ca> +Mime-Version: 1.0 (Apple Message framework v746.2) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <24B89C42-C597-4571-8BD1-A89073C3C035@torgo.978.org> +Cc: "'Tom Lane'" , "'Stephen Frost'" , + +Content-Transfer-Encoding: 7bit +From: Jeff Trout +Subject: Re: Postgres slower than MS ACCESS +Date: Wed, 15 Feb 2006 09:23:03 -0500 +To: Jay Greenfield +X-Mailer: Apple Mail (2.746.2) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.16 required=5 tests=[AWL=0.160] +X-Spam-Score: 0.16 +X-Spam-Level: +X-Archive-Number: 200602/193 +X-Sequence-Number: 17179 + + +On Feb 14, 2006, at 3:56 PM, Jay Greenfield wrote: + +>> How do you get 4,000+ lines of explain analyze for one update +>> query in a +>> database with only one table? Something a bit fishy there. +>> Perhaps you +>> mean explain verbose, though I don't really see how that'd be so long +>> either, but it'd be closer. Could you provide some more sane +>> information? +> +> My mistake - there was 4,000 lines in the EXPLAIN ANALYZE VERBOSE +> output. +> Here is the output of EXPLAIN ANALYZE: +> +> QUERY PLAN +> "Seq Scan on ntdn (cost=0.00..3471884.39 rows=1221391 width=1592) +> (actual +> time=57292.580..1531300.003 rows=1221391 loops=1)" +> "Total runtime: 4472646.988 ms" +> + +Have you been vacuuming or running autovacuum? +If you keep running queries like this you're certianly going to have +a ton of dead tuples, which would def explain these times too. + +-- +Jeff Trout +http://www.jefftrout.com/ +http://www.stuarthamm.net/ + + + +From pgsql-performance-owner@postgresql.org Wed Feb 15 10:27:09 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 4E43A9DC9E4 + for ; + Wed, 15 Feb 2006 10:27:09 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34800-02 + for ; + Wed, 15 Feb 2006 10:27:11 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from eads-av-smtp3.gmessaging.net (eads-av-smtp3.gmessaging.net + [194.51.201.27]) + by postgresql.org (Postfix) with ESMTP id 244A59DC897 + for ; + Wed, 15 Feb 2006 10:27:04 -0400 (AST) +Received: from eads-relay3.cesson.gm-adm (localhost [127.0.0.1]) + by eads-av-smtp3.gmessaging.net + (iPlanet Messaging Server 5.2 HotFix 2.04 (built Feb 8 2005)) + with ESMTP id <0IUQ00M9DFUK9W@eads-av-smtp3.gmessaging.net> for + pgsql-performance@postgresql.org; Wed, 15 Feb 2006 15:27:09 +0100 (MET) +Received: from fr0-mailsp02.res.airbus.corp ([10.254.251.55]) + by eads-av-smtp3.gmessaging.net + (iPlanet Messaging Server 5.2 HotFix 2.04 (built Feb 8 2005)) + with ESMTP id <0IUQ0000SG35U3@eads-av-smtp3.gmessaging.net> for + pgsql-performance@postgresql.org; Wed, 15 Feb 2006 15:25:59 +0100 (MET) +Received: from fr0-mailsp02.res.airbus.corp (localhost.localdomain + [127.0.0.1]) + by fr0-mailsp02.res.airbus.corp (8.12.11/8.12.10) with ESMTP id + k1FEPpm1009828 + for ; Wed, 15 Feb 2006 15:25:51 +0100 +Received: from fr0-mailrt10.res.airbus.corp ([152.9.126.24]) + by fr0-mailsp02.res.airbus.corp (8.12.11/8.12.10) + with ESMTP id k1FEPnNQ009788; Wed, 15 Feb 2006 15:25:50 +0100 +Received: from fr0-mailrt04.res.airbus.corp ([152.9.126.23]) + by fr0-mailrt10.res.airbus.corp with Microsoft SMTPSVC(5.0.2195.6713); + Wed, 15 Feb 2006 15:25:41 +0100 +Received: from FR0-MAILMB20.res.airbus.corp ([152.9.126.74]) + by fr0-mailrt04.res.airbus.corp with Microsoft SMTPSVC(5.0.2195.6713); + Wed, 15 Feb 2006 15:25:41 +0100 +Date: Wed, 15 Feb 2006 15:25:41 +0100 +From: "FERREIRA, William (VALTECH)" +Subject: Re: copy and postgresql.conf +To: J.K.Shah@Sun.COM +Cc: Albert Cervera Areny , pgsql-performance@postgresql.org +Message-id: + <414D259CE29DE54DAD534037C83CE4B7011E4874@FR0-MAILMB20.res.airbus.corp> +MIME-version: 1.0 +X-MIMEOLE: Produced By Microsoft Exchange V6.0.6603.0 +Content-type: text/plain; charset=iso-8859-1 +Content-transfer-encoding: quoted-printable +Content-class: urn:content-classes:message +Thread-topic: [PERFORM] copy and postgresql.conf +Thread-index: AcYyOk6S8/2QFMVRQqSQqUaVFCOEfgAANFiw +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +X-OriginalArrivalTime: 15 Feb 2006 14:25:41.0349 (UTC) + FILETIME=[B2F4E150:01C6323B] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.205 required=5 tests=[AWL=0.205] +X-Spam-Score: 0.205 +X-Spam-Level: +X-Archive-Number: 200602/194 +X-Sequence-Number: 17180 + + +with PostgreSQL 8.1.3, here are my parameters (it's the default= + configuration) + +wal_sync_method =3D fsync +wal_buffers =3D 8 +checkpoint_segments =3D 3 +bgwriter_lru_percent =3D 1.0 +bgwriter_lru_maxpages =3D 5 +bgwriter_all_percent =3D 0.333 +bgwriter_all_maxpages =3D 5 + +and you think times can be improved again ? + +-----Message d'origine----- +De : J.K.Shah@Sun.COM [mailto:J.K.Shah@Sun.COM] +Envoy=E9 : mercredi 15 f=E9vrier 2006 15:14 +=C0 : FERREIRA, William (VALTECH) +Cc : Albert Cervera Areny; pgsql-performance@postgresql.org +Objet : Re: [PERFORM] copy and postgresql.conf + + + +What's your postgresql.conf parameter for the equivalent ones that I=0D +suggested? +I believe your wal_buffers and checkpoint_segments could be bigger. If=0D +that's the case then yep you are fine. + +As for the background writer I am seeing mixed results yet so not sure=0D +about that. + +But thanks for the feedback. + +-Jignesh + + +FERREIRA, William (VALTECH) wrote: + +>i tested the last version version of PostgreSQL +>and for the same test : +>before : 40mn +>and now : 12mn :) +>faster than Oracle (exactly what i wanted :p ) +> +>thanks to everybody +> +> Will +> +> +>-----Message d'origine----- +>De : pgsql-performance-owner@postgresql.org +>[mailto:pgsql-performance-owner@postgresql.org]De la part de Albert +>Cervera Areny +>Envoy=E9 : mardi 14 f=E9vrier 2006 17:07 +>=C0 : pgsql-performance@postgresql.org +>Objet : Re: [PERFORM] copy and postgresql.conf +> +> +> +>Sorry, COPY improvements came with 8.1 +> +>(http://www.postgresql.org/docs/whatsnew) +> +>A Dimarts 14 Febrer 2006 14:26, FERREIRA, William (VALTECH) va escriure: +> =0D +> +>>thanks, +>> +>>i'm using postgresql 8.0.3 +>>there is no primary key and no index on my tables +>> +>>regards +>> +>>-----Message d'origine----- +>>De : pgsql-performance-owner@postgresql.org +>>[mailto:pgsql-performance-owner@postgresql.org]De la part de Albert +>>Cervera Areny +>>Envoy=E9 : mardi 14 f=E9vrier 2006 12:38 +>>=C0 : pgsql-performance@postgresql.org +>>Objet : Re: [PERFORM] copy and postgresql.conf +>> +>> +>> +>>Hi William, +>> which PostgreSQL version are you using? Newer (8.0+) versions have some +>> +>>important performance improvements for the COPY command. +>> +>> Also, you'll notice significant improvements by creating primary &= + foreign +>> +>>keys after the copy command. I think config tweaking can improve key and +>> +>>index creation but I don't think you can improve the COPY command itself. +>> +>> There are also many threads in this list commenting on this issue,= + you'll +>> +>>find it easely in the archives. +>> +>>A Dimarts 14 Febrer 2006 10:44, FERREIRA, William (VALTECH) va escriure: +>> =0D +>> +>>>hi, +>>> +>>>i load data from files using copy method. +>>>Files contain between 2 and 7 millions of rows, spread on 5 tables. +>>> +>>>For loading all the data, it takes 40mn, and the same processing takes +>>>17mn with Oracle. I think that this time can be improved by changing +>>>postgresql configuration file. But which parameters i need to manipulate +>>>and with which values ? +>>> +>>>Here are the specifications of my system : +>>>V250 architecture sun4u +>>>2xCPU UltraSparc IIIi 1.28 GHz. +>>>8 Go RAM. +>>> +>>>Regards. +>>> +>>> Will +>>> +>>> +>>>This e-mail is intended only for the above addressee. It may contain +>>>privileged information. If you are not the addressee you must not copy, +>>>distribute, disclose or use any of the information in it. If you have +>>>received it in error please delete it and immediately notify the sender. +>>>Security Notice: all e-mail, sent to or from this address, may be +>>>accessed by someone other than the recipient, for system management and +>>>security reasons. This access is controlled under Regulation of +>>>Investigatory Powers Act 2000, Lawful Business Practises. +>>> +>>>---------------------------(end of broadcast)--------------------------- +>>>TIP 4: Have you searched our list archives? +>>> +>>> http://archives.postgresql.org +>>> =0D +>>> +>>-- +>> +>>Albert Cervera Areny +>>Dept. Inform=E0tica Sedifa, S.L. +>> +>>Av. Can Bordoll, 149 +>>08202 - Sabadell (Barcelona) +>>Tel. 93 715 51 11 +>>Fax. 93 715 51 12 +>> +>>=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 +>>........................ AVISO LEGAL ............................ +>>La presente comunicaci=F3n y sus anexos tiene como destinatario la +>>persona a la que va dirigida, por lo que si usted lo recibe +>>por error debe notificarlo al remitente y eliminarlo de su +>>sistema, no pudiendo utilizarlo, total o parcialmente, para +>>ning=FAn fin. Su contenido puede tener informaci=F3n confidencial o +>>protegida legalmente y =FAnicamente expresa la opini=F3n del +>>remitente. El uso del correo electr=F3nico v=EDa Internet no +>>permite asegurar ni la confidencialidad de los mensajes +>>ni su correcta recepci=F3n. En el caso de que el +>>destinatario no consintiera la utilizaci=F3n del correo electr=F3nico, +>>deber=E1 ponerlo en nuestro conocimiento inmediatamente. +>>=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 +>>........................... DISCLAIMER ............................. +>>This message and its attachments are intended exclusively for the +>>named addressee. If you receive this message in error, please +>>immediately delete it from your system and notify the sender. You +>>may not use this message or any part of it for any purpose. +>>The message may contain information that is confidential or +>>protected by law, and any opinions expressed are those of the +>>individual sender. Internet e-mail guarantees neither the +>>confidentiality nor the proper receipt of the message sent. +>>If the addressee of this message does not consent to the use +>>of internet e-mail, please inform us inmmediately. +>>=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 +>> +>> +>> +>> +>> +>>---------------------------(end of broadcast)--------------------------- +>>TIP 5: don't forget to increase your free space map settings +>> +>> +>> +>>This mail has originated outside your organization, +>>either from an external partner or the Global Internet. +>>Keep this in mind if you answer this message. +>> +>> +>>This e-mail is intended only for the above addressee. It may contain +>>privileged information. If you are not the addressee you must not copy, +>>distribute, disclose or use any of the information in it. If you have +>>received it in error please delete it and immediately notify the sender. +>>Security Notice: all e-mail, sent to or from this address, may be +>>accessed by someone other than the recipient, for system management and +>>security reasons. This access is controlled under Regulation of +>>Investigatory Powers Act 2000, Lawful Business Practises. +>> =0D +>> +> +>-- +> +>Albert Cervera Areny +>Dept. Inform=E0tica Sedifa, S.L. +> +>Av. Can Bordoll, 149 +>08202 - Sabadell (Barcelona) +>Tel. 93 715 51 11 +>Fax. 93 715 51 12 +> +>=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 +>........................ AVISO LEGAL ............................ +>La presente comunicaci=F3n y sus anexos tiene como destinatario la +>persona a la que va dirigida, por lo que si usted lo recibe +>por error debe notificarlo al remitente y eliminarlo de su +>sistema, no pudiendo utilizarlo, total o parcialmente, para +>ning=FAn fin. Su contenido puede tener informaci=F3n confidencial o +>protegida legalmente y =FAnicamente expresa la opini=F3n del +>remitente. El uso del correo electr=F3nico v=EDa Internet no +>permite asegurar ni la confidencialidad de los mensajes +>ni su correcta recepci=F3n. En el caso de que el +>destinatario no consintiera la utilizaci=F3n del correo electr=F3nico, +>deber=E1 ponerlo en nuestro conocimiento inmediatamente. +>=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 +>........................... DISCLAIMER ............................. +>This message and its attachments are intended exclusively for the +>named addressee. If you receive this message in error, please +>immediately delete it from your system and notify the sender. You +>may not use this message or any part of it for any purpose. +>The message may contain information that is confidential or +>protected by law, and any opinions expressed are those of the +>individual sender. Internet e-mail guarantees neither the +>confidentiality nor the proper receipt of the message sent. +>If the addressee of this message does not consent to the use +>of internet e-mail, please inform us inmmediately. +>=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 +> +> +> +> +> +>---------------------------(end of broadcast)--------------------------- +>TIP 5: don't forget to increase your free space map settings +> +> +> +>This mail has originated outside your organization, +>either from an external partner or the Global Internet. +>Keep this in mind if you answer this message. +> +> +>This e-mail is intended only for the above addressee. It may contain +>privileged information. If you are not the addressee you must not copy, +>distribute, disclose or use any of the information in it. If you have +>received it in error please delete it and immediately notify the sender. +>Security Notice: all e-mail, sent to or from this address, may be +>accessed by someone other than the recipient, for system management and +>security reasons. This access is controlled under Regulation of +>Investigatory Powers Act 2000, Lawful Business Practises. +> +>---------------------------(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 +> =0D +> + +=0D +This mail has originated outside your organization, +either from an external partner or the Global Internet. +Keep this in mind if you answer this message. + +=0D +This e-mail is intended only for the above addressee. It may contain +privileged information. If you are not the addressee you must not copy, +distribute, disclose or use any of the information in it. If you have +received it in error please delete it and immediately notify the sender. +Security Notice: all e-mail, sent to or from this address, may be +accessed by someone other than the recipient, for system management and +security reasons. This access is controlled under Regulation of +Investigatory Powers Act 2000, Lawful Business Practises. + +From pgsql-performance-owner@postgresql.org Wed Feb 15 11:07:49 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 07D2C9DC99D + for ; + Wed, 15 Feb 2006 11:07:49 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 41310-04 + for ; + Wed, 15 Feb 2006 11:07:52 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from brmea-mail-1.sun.com (brmea-mail-1.Sun.COM [192.18.98.31]) + by postgresql.org (Postfix) with ESMTP id 47A539DC897 + for ; + Wed, 15 Feb 2006 11:07:41 -0400 (AST) +Received: from fe-amer-06.sun.com ([192.18.108.180]) + by brmea-mail-1.sun.com (8.12.10/8.12.9) with ESMTP id k1FF7jSD019882 + for ; + Wed, 15 Feb 2006 08:07:45 -0700 (MST) +Received: from conversion-daemon.mail-amer.sun.com by mail-amer.sun.com + (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) + id <0IUQ00M01HHZ0Y00@mail-amer.sun.com> (original mail from + J.K.Shah@Sun.COM) for pgsql-performance@postgresql.org; + Wed, 15 Feb 2006 08:07:45 -0700 (MST) +Received: from [129.148.168.2] by mail-amer.sun.com + (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) + with ESMTPSA id <0IUQ005CWI0SBVK2@mail-amer.sun.com>; Wed, + 15 Feb 2006 08:07:45 -0700 (MST) +Date: Wed, 15 Feb 2006 10:07:02 -0500 +From: "Jignesh K. Shah" +Subject: Re: copy and postgresql.conf +In-reply-to: + <414D259CE29DE54DAD534037C83CE4B7011E4874@FR0-MAILMB20.res.airbus.corp> +To: "FERREIRA, William (VALTECH)" +Cc: pgsql-performance@postgresql.org +Message-id: <43F34396.7000801@sun.com> +Organization: Sun Microsystems +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=ISO-8859-1 +Content-transfer-encoding: 8BIT +X-Accept-Language: en-us, en +References: + <414D259CE29DE54DAD534037C83CE4B7011E4874@FR0-MAILMB20.res.airbus.corp> +User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050322) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.101 required=5 tests=[AWL=0.100, + UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 0.101 +X-Spam-Level: +X-Archive-Number: 200602/195 +X-Sequence-Number: 17181 + +Actually fsync is not the default on solaris (verify using "show all;) + +(If you look closely in postgresql.conf it is commented out and +mentioned as default but show all tells a different story) + +In all my cases I saw the default as + wal_sync_method | open_datasync + +Also I had seen quite an improvement by changing the default +checkpoint_segments from 3 to 64 or 128 and also increasing wal_buffers +to 64 depending on how heavy is your load. + +Also open_datasync type of operations benefit with forcedirectio on +Solaris and hence either move wal to forcedirectio mounted file system +or try changing default sync to fsync (the *said* default) + +Now if you use fsync then you need a bigger file system cache since by +default Solaris's segmap mechanism only maps 12% of your physical ram to +be used for file system buffer cache. Increasing segmap_percent to 50 on +SPARC allows to use 50% of your RAM to be mapped to be used for 50% ( +NOTE: It does not reserve but just allow mapping of the memory which can +be used for file system buffer cache) + +Changing maxphys allows the file system buffer cache to coalesce writes +from the 8Ks that PostgreSQL is doing to bigger writes/reads. Also since +you are now exploiting file system buffer cache, file system Logging is +very much recommended (available from a later update of Solaris 8 I +believe). + + +Regards, +Jignesh + + + + + +FERREIRA, William (VALTECH) wrote: + +>with PostgreSQL 8.1.3, here are my parameters (it's the default configuration) +> +>wal_sync_method = fsync +>wal_buffers = 8 +>checkpoint_segments = 3 +>bgwriter_lru_percent = 1.0 +>bgwriter_lru_maxpages = 5 +>bgwriter_all_percent = 0.333 +>bgwriter_all_maxpages = 5 +> +>and you think times can be improved again ? +> +>-----Message d'origine----- +>De : J.K.Shah@Sun.COM [mailto:J.K.Shah@Sun.COM] +>Envoy� : mercredi 15 f�vrier 2006 15:14 +>� : FERREIRA, William (VALTECH) +>Cc : Albert Cervera Areny; pgsql-performance@postgresql.org +>Objet : Re: [PERFORM] copy and postgresql.conf +> +> +> +>What's your postgresql.conf parameter for the equivalent ones that I +>suggested? +>I believe your wal_buffers and checkpoint_segments could be bigger. If +>that's the case then yep you are fine. +> +>As for the background writer I am seeing mixed results yet so not sure +>about that. +> +>But thanks for the feedback. +> +>-Jignesh +> +> +>FERREIRA, William (VALTECH) wrote: +> +> +> +>>i tested the last version version of PostgreSQL +>>and for the same test : +>>before : 40mn +>>and now : 12mn :) +>>faster than Oracle (exactly what i wanted :p ) +>> +>>thanks to everybody +>> +>> Will +>> +>> +>>-----Message d'origine----- +>>De : pgsql-performance-owner@postgresql.org +>>[mailto:pgsql-performance-owner@postgresql.org]De la part de Albert +>>Cervera Areny +>>Envoy� : mardi 14 f�vrier 2006 17:07 +>>� : pgsql-performance@postgresql.org +>>Objet : Re: [PERFORM] copy and postgresql.conf +>> +>> +>> +>>Sorry, COPY improvements came with 8.1 +>> +>>(http://www.postgresql.org/docs/whatsnew) +>> +>>A Dimarts 14 Febrer 2006 14:26, FERREIRA, William (VALTECH) va escriure: +>> +>> +>> +>> +>>>thanks, +>>> +>>>i'm using postgresql 8.0.3 +>>>there is no primary key and no index on my tables +>>> +>>>regards +>>> +>>>-----Message d'origine----- +>>>De : pgsql-performance-owner@postgresql.org +>>>[mailto:pgsql-performance-owner@postgresql.org]De la part de Albert +>>>Cervera Areny +>>>Envoy� : mardi 14 f�vrier 2006 12:38 +>>>� : pgsql-performance@postgresql.org +>>>Objet : Re: [PERFORM] copy and postgresql.conf +>>> +>>> +>>> +>>>Hi William, +>>> which PostgreSQL version are you using? Newer (8.0+) versions have some +>>> +>>>important performance improvements for the COPY command. +>>> +>>> Also, you'll notice significant improvements by creating primary & foreign +>>> +>>>keys after the copy command. I think config tweaking can improve key and +>>> +>>>index creation but I don't think you can improve the COPY command itself. +>>> +>>> There are also many threads in this list commenting on this issue, you'll +>>> +>>>find it easely in the archives. +>>> +>>>A Dimarts 14 Febrer 2006 10:44, FERREIRA, William (VALTECH) va escriure: +>>> +>>> +>>> +>>> +>>>>hi, +>>>> +>>>>i load data from files using copy method. +>>>>Files contain between 2 and 7 millions of rows, spread on 5 tables. +>>>> +>>>>For loading all the data, it takes 40mn, and the same processing takes +>>>>17mn with Oracle. I think that this time can be improved by changing +>>>>postgresql configuration file. But which parameters i need to manipulate +>>>>and with which values ? +>>>> +>>>>Here are the specifications of my system : +>>>>V250 architecture sun4u +>>>>2xCPU UltraSparc IIIi 1.28 GHz. +>>>>8 Go RAM. +>>>> +>>>>Regards. +>>>> +>>>> Will +>>>> +>>>> +>>>>This e-mail is intended only for the above addressee. It may contain +>>>>privileged information. If you are not the addressee you must not copy, +>>>>distribute, disclose or use any of the information in it. If you have +>>>>received it in error please delete it and immediately notify the sender. +>>>>Security Notice: all e-mail, sent to or from this address, may be +>>>>accessed by someone other than the recipient, for system management and +>>>>security reasons. This access is controlled under Regulation of +>>>>Investigatory Powers Act 2000, Lawful Business Practises. +>>>> +>>>>---------------------------(end of broadcast)--------------------------- +>>>>TIP 4: Have you searched our list archives? +>>>> +>>>> http://archives.postgresql.org +>>>> +>>>> +>>>> +>>>> +>>>-- +>>> +>>>Albert Cervera Areny +>>>Dept. Inform�tica Sedifa, S.L. +>>> +>>>Av. Can Bordoll, 149 +>>>08202 - Sabadell (Barcelona) +>>>Tel. 93 715 51 11 +>>>Fax. 93 715 51 12 +>>> +>>>==================================================================== +>>>........................ AVISO LEGAL ............................ +>>>La presente comunicaci�n y sus anexos tiene como destinatario la +>>>persona a la que va dirigida, por lo que si usted lo recibe +>>>por error debe notificarlo al remitente y eliminarlo de su +>>>sistema, no pudiendo utilizarlo, total o parcialmente, para +>>>ning�n fin. Su contenido puede tener informaci�n confidencial o +>>>protegida legalmente y �nicamente expresa la opini�n del +>>>remitente. El uso del correo electr�nico v�a Internet no +>>>permite asegurar ni la confidencialidad de los mensajes +>>>ni su correcta recepci�n. En el caso de que el +>>>destinatario no consintiera la utilizaci�n del correo electr�nico, +>>>deber� ponerlo en nuestro conocimiento inmediatamente. +>>>==================================================================== +>>>........................... DISCLAIMER ............................. +>>>This message and its attachments are intended exclusively for the +>>>named addressee. If you receive this message in error, please +>>>immediately delete it from your system and notify the sender. You +>>>may not use this message or any part of it for any purpose. +>>>The message may contain information that is confidential or +>>>protected by law, and any opinions expressed are those of the +>>>individual sender. Internet e-mail guarantees neither the +>>>confidentiality nor the proper receipt of the message sent. +>>>If the addressee of this message does not consent to the use +>>>of internet e-mail, please inform us inmmediately. +>>>==================================================================== +>>> +>>> +>>> +>>> +>>> +>>>---------------------------(end of broadcast)--------------------------- +>>>TIP 5: don't forget to increase your free space map settings +>>> +>>> +>>> +>>>This mail has originated outside your organization, +>>>either from an external partner or the Global Internet. +>>>Keep this in mind if you answer this message. +>>> +>>> +>>>This e-mail is intended only for the above addressee. It may contain +>>>privileged information. If you are not the addressee you must not copy, +>>>distribute, disclose or use any of the information in it. If you have +>>>received it in error please delete it and immediately notify the sender. +>>>Security Notice: all e-mail, sent to or from this address, may be +>>>accessed by someone other than the recipient, for system management and +>>>security reasons. This access is controlled under Regulation of +>>>Investigatory Powers Act 2000, Lawful Business Practises. +>>> +>>> +>>> +>>> +>>-- +>> +>>Albert Cervera Areny +>>Dept. Inform�tica Sedifa, S.L. +>> +>>Av. Can Bordoll, 149 +>>08202 - Sabadell (Barcelona) +>>Tel. 93 715 51 11 +>>Fax. 93 715 51 12 +>> +>>==================================================================== +>>........................ AVISO LEGAL ............................ +>>La presente comunicaci�n y sus anexos tiene como destinatario la +>>persona a la que va dirigida, por lo que si usted lo recibe +>>por error debe notificarlo al remitente y eliminarlo de su +>>sistema, no pudiendo utilizarlo, total o parcialmente, para +>>ning�n fin. Su contenido puede tener informaci�n confidencial o +>>protegida legalmente y �nicamente expresa la opini�n del +>>remitente. El uso del correo electr�nico v�a Internet no +>>permite asegurar ni la confidencialidad de los mensajes +>>ni su correcta recepci�n. En el caso de que el +>>destinatario no consintiera la utilizaci�n del correo electr�nico, +>>deber� ponerlo en nuestro conocimiento inmediatamente. +>>==================================================================== +>>........................... DISCLAIMER ............................. +>>This message and its attachments are intended exclusively for the +>>named addressee. If you receive this message in error, please +>>immediately delete it from your system and notify the sender. You +>>may not use this message or any part of it for any purpose. +>>The message may contain information that is confidential or +>>protected by law, and any opinions expressed are those of the +>>individual sender. Internet e-mail guarantees neither the +>>confidentiality nor the proper receipt of the message sent. +>>If the addressee of this message does not consent to the use +>>of internet e-mail, please inform us inmmediately. +>>==================================================================== +>> +>> +>> +>> +>> +>>---------------------------(end of broadcast)--------------------------- +>>TIP 5: don't forget to increase your free space map settings +>> +>> +>> +>>This mail has originated outside your organization, +>>either from an external partner or the Global Internet. +>>Keep this in mind if you answer this message. +>> +>> +>>This e-mail is intended only for the above addressee. It may contain +>>privileged information. If you are not the addressee you must not copy, +>>distribute, disclose or use any of the information in it. If you have +>>received it in error please delete it and immediately notify the sender. +>>Security Notice: all e-mail, sent to or from this address, may be +>>accessed by someone other than the recipient, for system management and +>>security reasons. This access is controlled under Regulation of +>>Investigatory Powers Act 2000, Lawful Business Practises. +>> +>>---------------------------(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 +>> +>> +>> +>> +> +> +>This mail has originated outside your organization, +>either from an external partner or the Global Internet. +>Keep this in mind if you answer this message. +> +> +>This e-mail is intended only for the above addressee. It may contain +>privileged information. If you are not the addressee you must not copy, +>distribute, disclose or use any of the information in it. If you have +>received it in error please delete it and immediately notify the sender. +>Security Notice: all e-mail, sent to or from this address, may be +>accessed by someone other than the recipient, for system management and +>security reasons. This access is controlled under Regulation of +>Investigatory Powers Act 2000, Lawful Business Practises. +> +>---------------------------(end of broadcast)--------------------------- +>TIP 3: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faq +> +> + +From pgsql-performance-owner@postgresql.org Wed Feb 15 11:18:18 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 735FF9DC827 + for ; + Wed, 15 Feb 2006 11:18:17 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 42162-08 + for ; + Wed, 15 Feb 2006 11:18:20 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 1C5CF9DC80D + for ; + Wed, 15 Feb 2006 11:18:13 -0400 (AST) +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 k1FFIIVI000197; + Wed, 15 Feb 2006 10:18:18 -0500 (EST) +To: "FERREIRA, William (VALTECH)" +cc: J.K.Shah@Sun.COM, Albert Cervera Areny , + pgsql-performance@postgresql.org +Subject: Re: copy and postgresql.conf +In-reply-to: + <414D259CE29DE54DAD534037C83CE4B7011E4874@FR0-MAILMB20.res.airbus.corp> +References: + <414D259CE29DE54DAD534037C83CE4B7011E4874@FR0-MAILMB20.res.airbus.corp> +Comments: In-reply-to "FERREIRA, + William (VALTECH)" + message dated "Wed, 15 Feb 2006 15:25:41 +0100" +Date: Wed, 15 Feb 2006 10:18:18 -0500 +Message-ID: <196.1140016698@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.109 required=5 tests=[AWL=0.109] +X-Spam-Score: 0.109 +X-Spam-Level: +X-Archive-Number: 200602/196 +X-Sequence-Number: 17182 + +"FERREIRA, William (VALTECH)" writes: +> with PostgreSQL 8.1.3, here are my parameters (it's the default configuration) + +> wal_sync_method = fsync +> wal_buffers = 8 +> checkpoint_segments = 3 +> bgwriter_lru_percent = 1.0 +> bgwriter_lru_maxpages = 5 +> bgwriter_all_percent = 0.333 +> bgwriter_all_maxpages = 5 + +> and you think times can be improved again ? + +Increasing checkpoint_segments will definitely help for any write-intensive +situation. It costs you in disk space of course, as well as the time +needed for post-crash recovery. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Feb 15 11:51:11 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 4682B9DCA32 + for ; + Wed, 15 Feb 2006 11:51:11 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 46343-10 + for ; + Wed, 15 Feb 2006 11:51:15 -0400 (AST) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id B430A9DC835 + for ; + Wed, 15 Feb 2006 11:51:08 -0400 (AST) +Received: from mail.ritek.hu (82-131-192-50.vnet.hu [82.131.192.50]) + by svr4.postgresql.org (Postfix) with ESMTP id BE6205AF0D8 + for ; + Wed, 15 Feb 2006 15:51:13 +0000 (GMT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mail.ritek.hu (Postfix) with ESMTP id CDC7419C123 + for ; + Wed, 15 Feb 2006 16:51:04 +0100 (CET) +Received: from mail.ritek.hu ([127.0.0.1]) + by localhost (mail.ritek.hu [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 25347-10 for ; + Wed, 15 Feb 2006 16:51:01 +0100 (CET) +Received: from [10.1.2.11] (unknown [10.1.2.11]) + by mail.ritek.hu (Postfix) with ESMTP id 926CC19C114 + for ; + Wed, 15 Feb 2006 16:51:01 +0100 (CET) +Message-ID: <43F34E13.5080502@ritek.hu> +Date: Wed, 15 Feb 2006 16:51:47 +0100 +From: Antal Attila +User-Agent: Thunderbird 1.5 (Windows/20051201) +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Stored proc and optimizer question +Content-Type: text/plain; charset=ISO-8859-2; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at ritek.hu +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200602/197 +X-Sequence-Number: 17183 + +Hi! + +I have a question about the query optimizer and the function scan. See +the next case: + +CREATE TABLE a (id SERIAL PRIMARY KEY, userid INT4, col TEXT); +CREATE TABLE b (id SERIAL PRIMARY KEY, userid INT4, a_id INT4 REFERENCES +a (id), col TEXT); +CREATE INDEX idx_a_uid ON a(userid); +CREATE INDEX idx_b_uid ON b(userid); +CREATE INDEX idx_a_col ON a(col); +CREATE INDEX idx_b_col ON b(col); + +First solution: + + CREATE VIEW ab_view AS + SELECT a.id AS id, + a.userid AS userid_a, b.userid AS userid_b, + a.col AS col_a, b.col AS col_b + FROM a LEFT JOIN b ON (a.id = b.a_id); + + EXPLAIN ANALYSE SELECT * FROM ab_view + WHERE userid_a = 23 AND userid_b = 23 AND col_a LIKE 's%' + ORDER BY col_b + LIMIT 10 OFFSET 10; + + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------ +Limit (cost=15.70..15.70 rows=1 width=76) (actual time=0.108..0.108 +rows=0 loops=1) + -> Sort (cost=15.69..15.70 rows=1 width=76) (actual +time=0.104..0.104 rows=0 loops=1) + Sort Key: b.col + -> Nested Loop (cost=3.32..15.68 rows=1 width=76) (actual +time=0.085..0.085 rows=0 loops=1) + Join Filter: ("outer".id = "inner".a_id) + -> Bitmap Heap Scan on a (cost=2.30..6.13 rows=1 +width=40) (actual time=0.082..0.082 rows=0 loops=1) + Recheck Cond: (userid = 23) + Filter: (col ~~ 's%'::text) + -> BitmapAnd (cost=2.30..2.30 rows=1 width=0) +(actual time=0.077..0.077 rows=0 loops=1) + -> Bitmap Index Scan on idx_a_uid +(cost=0.00..1.02 rows=6 width=0) (actual time=0.075..0.075 rows=0 loops=1) + Index Cond: (userid = 23) + -> Bitmap Index Scan on idx_a_col +(cost=0.00..1.03 rows=6 width=0) (never executed) + Index Cond: ((col >= 's'::text) AND +(col < 't'::text)) + -> Bitmap Heap Scan on b (cost=1.02..9.49 rows=5 +width=40) (never executed) + Recheck Cond: (userid = 23) + -> Bitmap Index Scan on idx_b_uid +(cost=0.00..1.02 rows=5 width=0) (never executed) + Index Cond: (userid = 23) +Total runtime: 0.311 ms + + +In the first solution the query optimizer can work on the view and the +full execution of the query will be optimal. But I have to use 2 +condition for the userid fields (userid_a = 23 AND userid_b = 23 ). If I +have to eliminate the duplication I can try to use stored function. + +Second solution: + CREATE FUNCTION ab_select(INT4) RETURNS setof ab_view AS $$ + SELECT a.id AS id, + a.userid AS userid_a, b.userid AS userid_b, + a.col AS col_a, b.col AS col_b + FROM a LEFT JOIN b ON (a.id = b.a_id AND b.userid = $1) + WHERE a.userid = $1; + $$ LANGUAGE SQL STABLE; + + EXPLAIN ANALYSE SELECT * FROM ab_select(23) + WHERE col_a LIKE 's%' + ORDER BY col_b + LIMIT 10 OFFSET 10; + + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------- +Limit (cost=15.07..15.07 rows=1 width=76) (actual time=1.034..1.034 +rows=0 loops=1) + -> Sort (cost=15.06..15.07 rows=5 width=76) (actual +time=1.030..1.030 rows=0 loops=1) + Sort Key: col_b + -> Function Scan on ab_select (cost=0.00..15.00 rows=5 +width=76) (actual time=1.004..1.004 rows=0 loops=1) + Filter: (col_a ~~ 's%'::text) +Total runtime: 1.103 ms + +The second solution have 2 advantage: + 1. The second query is more beautiful and shorter. + 2. You can rewrite easier the stored function without modify the query. + +But I have heartache, because the optimizer give up the game. It cannot +optimize the query globally (inside and outside the stored function) in +spite of the STABLE keyword. It use function scan on the result of the +stored function. + +How can I eliminate the function scan while I want to keep the advantages? + +In my opinion the optimizer cannot replace the function scan with a more +optimal plan, but this feature may be implemented in the next versions +of PostgreSQL. I would like to suggest this. + +I built this case theoretically, but I have more stored procedure which +works with bad performance therefore. + +Regards, +Antal Attila + + +From pgsql-performance-owner@postgresql.org Wed Feb 15 11:55:27 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 793A59DC827 + for ; + Wed, 15 Feb 2006 11:55:27 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 52339-03 + for ; + Wed, 15 Feb 2006 11:55:32 -0400 (AST) +X-Greylist: whitelisted by SQLgrey- +Received: from smtp1-g19.free.fr (smtp1-g19.free.fr [212.27.42.27]) + by postgresql.org (Postfix) with ESMTP id 3DB459DC803 + for ; + Wed, 15 Feb 2006 11:55:25 -0400 (AST) +Received: from imp2-g19.free.fr (imp2-g19.free.fr [212.27.42.2]) + by smtp1-g19.free.fr (Postfix) with ESMTP id 96C866E2F3 + for ; + Wed, 15 Feb 2006 16:55:30 +0100 (CET) +Received: by imp2-g19.free.fr (Postfix, from userid 33) + id 850E57AD50; Wed, 15 Feb 2006 16:55:30 +0100 (MET) +Received: from wormhole.x-echo.com (wormhole.x-echo.com [193.252.148.11]) + by imp2-g19.free.fr (IMP) with HTTP + for ; Wed, 15 Feb 2006 16:55:30 +0100 +Message-ID: <1140018930.43f34ef260de0@imp2-g19.free.fr> +Date: Wed, 15 Feb 2006 16:55:30 +0100 +From: martial.bizel@free.fr +To: pgsql-performance@postgresql.org +Subject: out of memory +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 8bit +User-Agent: Internet Messaging Program (IMP) 3.2.5 +X-Originating-IP: 193.252.148.11 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.652 required=5 tests=[AWL=0.102, NO_REAL_NAME=0.55] +X-Spam-Score: 0.652 +X-Spam-Level: +X-Archive-Number: 200602/198 +X-Sequence-Number: 17184 + + +Good morning, + + + + +I've increased sort_mem until 2Go !! +and the error "out of memory" appears again. + +Here the request I try to pass with her explain plan, + + Nested Loop (cost=2451676.23..2454714.73 rows=1001 width=34) + -> Subquery Scan "day" (cost=2451676.23..2451688.73 rows=1000 width=16) + -> Limit (cost=2451676.23..2451678.73 rows=1000 width=12) + -> Sort (cost=2451676.23..2451684.63 rows=3357 width=12) + Sort Key: sum(occurence) + -> HashAggregate (cost=2451471.24..2451479.63 rows=3357 +width=12) + -> Index Scan using test_date on +queries_detail_statistics (cost=0.00..2449570.55 rows=380138 width=12) + Index Cond: ((date >= '2006-01-01'::date) AND +(date <= '2006-01-30'::date)) + Filter: (((portal)::text = '1'::text) OR +((portal)::text = '2'::text)) + -> Index Scan using query_string_pkey on query_string (cost=0.00..3.01 +rows=1 width=34) + Index Cond: ("outer".query = query_string.id) +(11 rows) + +Any new ideas ?, +thanks + +MB. + + + + +> On Tue, 2006-02-14 at 10:32, martial.bizel@free.fr wrote: +> > command explain analyze crash with the "out of memory" error +> > +> > I precise that I've tried a lot of values from parameters shared_buffer and +> > sort_mem +> > +> > now, in config file, values are : +> > sort_mem=32768 +> > and shared_buffer=30000 +> +> OK, on the command line, try increasing the sort_mem until hash_agg can +> work. With a 4 gig machine, you should be able to go as high as needed +> here, I'd think. Try as high as 500000 or so or more. Then when +> explain analyze works, compare the actual versus estimated number of +> rows. +> + + +From pgsql-performance-owner@postgresql.org Wed Feb 15 11:56:05 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 922119DCB4E + for ; + Wed, 15 Feb 2006 11:56:04 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 51010-04 + for ; + Wed, 15 Feb 2006 11:56:09 -0400 (AST) +X-Greylist: whitelisted by SQLgrey- +Received: from smtp1-g19.free.fr (smtp1-g19.free.fr [212.27.42.27]) + by postgresql.org (Postfix) with ESMTP id 571489DCB34 + for ; + Wed, 15 Feb 2006 11:56:02 -0400 (AST) +Received: from imp2-g19.free.fr (imp2-g19.free.fr [212.27.42.2]) + by smtp1-g19.free.fr (Postfix) with ESMTP id AE55969231 + for ; + Wed, 15 Feb 2006 16:56:07 +0100 (CET) +Received: by imp2-g19.free.fr (Postfix, from userid 33) + id 971A17AD3C; Wed, 15 Feb 2006 16:56:07 +0100 (MET) +Received: from wormhole.x-echo.com (wormhole.x-echo.com [193.252.148.11]) + by imp2-g19.free.fr (IMP) with HTTP + for ; Wed, 15 Feb 2006 16:56:07 +0100 +Message-ID: <1140018967.43f34f1761803@imp2-g19.free.fr> +Date: Wed, 15 Feb 2006 16:56:07 +0100 +From: martial.bizel@free.fr +To: pgsql-performance@postgresql.org +Subject: Re: explain hashAggregate +References: <20060215090446.2F3AC1B819F@mx1.hub.org> + <1140018387.43f34cd36a076@imp2-g19.free.fr> +In-Reply-To: <1140018387.43f34cd36a076@imp2-g19.free.fr> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 8bit +User-Agent: Internet Messaging Program (IMP) 3.2.5 +X-Originating-IP: 193.252.148.11 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.654 required=5 tests=[AWL=0.104, NO_REAL_NAME=0.55] +X-Spam-Score: 0.654 +X-Spam-Level: +X-Archive-Number: 200602/199 +X-Sequence-Number: 17185 + +Good morning, + +I try to understand how optimizer uses HashAggregate instead of GroupAggregate +and I want to know what is exactly this two functionnality (benefits +/inconvenients) + +In my case, I've this explain plan. +----------------------- + Nested Loop (cost=2451676.23..2454714.73 rows=1001 width=34) + -> Subquery Scan "day" (cost=2451676.23..2451688.73 rows=1000 width=16) + -> Limit (cost=2451676.23..2451678.73 rows=1000 width=12) + -> Sort (cost=2451676.23..2451684.63 rows=3357 width=12) + Sort Key: sum(occurence) + -> HashAggregate (cost=2451471.24..2451479.63 rows=3357 +width=12) + -> Index Scan using test_date on +queries_detail_statistics (cost=0.00..2449570.55 rows=380138 width=12) + Index Cond: ((date >= '2006-01-01'::date) AND +(date <= '2006-01-30'::date)) + Filter: (((portal)::text = '1'::text) OR +((portal)::text = '2'::text)) + -> Index Scan using query_string_pkey on query_string (cost=0.00..3.01 +rows=1 width=34) + Index Cond: ("outer".query = query_string.id) +---------------------------- +How to get necessary memory RAM for this explain plan ? + + + +thanks a lot + + +From pgsql-performance-owner@postgresql.org Wed Feb 15 12:21:42 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 5AC9C9DCA0F + for ; + Wed, 15 Feb 2006 12:21:42 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 57297-01 + for ; + Wed, 15 Feb 2006 12:21:40 -0400 (AST) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 068049DCA09 + for ; + Wed, 15 Feb 2006 12:21:40 -0400 (AST) +Received: from out4.smtp.messagingengine.com (out4.smtp.messagingengine.com + [66.111.4.28]) + by svr4.postgresql.org (Postfix) with ESMTP id 88A565AF09C + for ; + Wed, 15 Feb 2006 16:21:39 +0000 (GMT) +Received: from frontend1.internal (mysql-sessions.internal [10.202.2.149]) + by frontend1.messagingengine.com (Postfix) with ESMTP id 6BCEED34081 + for ; + Wed, 15 Feb 2006 11:21:36 -0500 (EST) +Received: from web2.messagingengine.com ([10.202.2.211]) + by frontend1.internal (MEProxy); Wed, 15 Feb 2006 11:21:36 -0500 +Received: by web2.messagingengine.com (Postfix, from userid 99) + id F028C11BD2; Wed, 15 Feb 2006 11:21:30 -0500 (EST) +Message-Id: <1140020490.9369.254450363@webmail.messagingengine.com> +X-Sasl-Enc: AzRAfOFSKxvgoo4KELskwaGgYWxwIYsiICfCytmXgArZ 1140020490 +From: "Jeremy Haile" +To: pgsql-performance@postgresql.org +Content-Disposition: inline +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset="ISO-8859-1" +MIME-Version: 1.0 +X-Mailer: MIME::Lite 5022 (F2.73; T1.15; A1.64; B3.05; Q3.03) +References: <20060215090446.2F3AC1B819F@mx1.hub.org> + <1140018387.43f34cd36a076@imp2-g19.free.fr> + <1140018967.43f34f1761803@imp2-g19.free.fr> +Subject: Reliability recommendations +In-Reply-To: <1140018967.43f34f1761803@imp2-g19.free.fr> +Date: Wed, 15 Feb 2006 11:21:30 -0500 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.359 required=5 tests=[AWL=-0.120, + DNS_FROM_RFC_ABUSE=0.479] +X-Spam-Score: 0.359 +X-Spam-Level: +X-Archive-Number: 200602/200 +X-Sequence-Number: 17186 + +We are a small company looking to put together the most cost effective +solution for our production database environment. Currently in +production Postgres 8.1 is running on this machine: + +Dell 2850 +2 x 3.0 Ghz Xeon 800Mhz FSB 2MB Cache +4 GB DDR2 400 Mhz +2 x 73 GB 10K SCSI RAID 1 (for xlog and OS) +4 x 146 GB 10K SCSI RAID 10 (for postgres data) +Perc4ei controller + +The above is a standard Dell box with nothing added or modified beyond +the options available directly through Dell. We had a bad processor last +week that effectively put us down for an entire weekend. Though it was +the web server that failed, the experience has caused us to step back +and spend time coming up with a more reliable/fail-safe solution that +can reduce downtime. + +Our load won't be substantial so extreme performance and load balancing +are not huge concerns. We are looking for good performance, at a good +price, configured in the most redundant, high availability manner +possible. Availability is the biggest priority. + +I sent our scenario to our sales team at Dell and they came back with +all manner of SAN, DAS, and configuration costing as much as $50k. + +We have the budget to purchase 2-3 additional machines along the lines +of the one listed above. As a startup with a limited budget, what would +this list suggest as options for clustering/replication or setting our +database up well in general? + +From pgsql-performance-owner@postgresql.org Wed Feb 15 12:45:24 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 0FC5F9DCA52 + for ; + Wed, 15 Feb 2006 12:45:24 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 58875-08 + for ; + Wed, 15 Feb 2006 12:45:22 -0400 (AST) +X-Greylist: whitelisted by SQLgrey- +Received: from smtp6-g19.free.fr (smtp6-g19.free.fr [212.27.42.36]) + by postgresql.org (Postfix) with ESMTP id DF4B19DCA09 + for ; + Wed, 15 Feb 2006 12:45:21 -0400 (AST) +Received: from imp2-g19.free.fr (imp2-g19.free.fr [212.27.42.2]) + by smtp6-g19.free.fr (Postfix) with ESMTP id 9D77F1820B; + Wed, 15 Feb 2006 17:45:20 +0100 (CET) +Received: by imp2-g19.free.fr (Postfix, from userid 33) + id 683ED7AE33; Wed, 15 Feb 2006 17:45:20 +0100 (MET) +Received: from wormhole.x-echo.com (wormhole.x-echo.com [193.252.148.11]) + by imp2-g19.free.fr (IMP) with HTTP + for ; Wed, 15 Feb 2006 17:45:20 +0100 +Message-ID: <1140021920.43f35aa026fea@imp2-g19.free.fr> +Date: Wed, 15 Feb 2006 17:45:20 +0100 +From: martial.bizel@free.fr +To: Scott Marlowe +Cc: Tom Lane , pgsql-performance@postgresql.org +Subject: Re: out of memory +References: <1139930651.43f1f61b04773@imp2-g19.free.fr> + <15115.1139931169@sss.pgh.pa.us> + <1139933018.43f1ff5a5e542@imp6-g19.free.fr> + <1139933201.22740.179.camel@state.g2switchworks.com> + <1139933720.43f20218cfe3a@imp6-g19.free.fr> + <19747.1139938612@sss.pgh.pa.us> + <1139939253.22740.193.camel@state.g2switchworks.com> +In-Reply-To: <1139939253.22740.193.camel@state.g2switchworks.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 8bit +User-Agent: Internet Messaging Program (IMP) 3.2.5 +X-Originating-IP: 193.252.148.11 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.655 required=5 tests=[AWL=0.105, NO_REAL_NAME=0.55] +X-Spam-Score: 0.655 +X-Spam-Level: +X-Archive-Number: 200602/201 +X-Sequence-Number: 17187 + +You're right, release is 7.4.7. + +there's twenty millions records "query" + +> On Tue, 2006-02-14 at 11:36, Tom Lane wrote: +> > martial.bizel@free.fr writes: +> > > Yes, I've launched ANALYZE command before sending request. +> > > I precise that's postgres version is 7.3.4 +> > +> > Can't possibly be 7.3.4, that version didn't have HashAggregate. +> > +> > How many distinct values of "query" actually exist in the table? +> +> I thought that looked odd. +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 5: don't forget to increase your free space map settings +> + + + +From pgsql-performance-owner@postgresql.org Wed Feb 15 12:51:04 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 2625E9DCC19 + for ; + Wed, 15 Feb 2006 12:51:04 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 59861-10-2 + for ; + Wed, 15 Feb 2006 12:51:02 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id F39929DCC0D + for ; + Wed, 15 Feb 2006 12:50:58 -0400 (AST) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Wed, 15 Feb 2006 16:50:57 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 15 Feb 2006 10:50:57 -0600 +Subject: Re: out of memory +From: Scott Marlowe +To: martial.bizel@free.fr +Cc: pgsql-performance@postgresql.org +In-Reply-To: <1140018930.43f34ef260de0@imp2-g19.free.fr> +References: <1140018930.43f34ef260de0@imp2-g19.free.fr> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1140022257.22740.225.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Wed, 15 Feb 2006 10:50:57 -0600 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.162 required=5 tests=[AWL=0.161, + UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 0.162 +X-Spam-Level: +X-Archive-Number: 200602/202 +X-Sequence-Number: 17188 + +On Wed, 2006-02-15 at 09:55, martial.bizel@free.fr wrote: +> Good morning, +> +> +> +> +> I've increased sort_mem until 2Go !! +> and the error "out of memory" appears again. +> +> Here the request I try to pass with her explain plan, +> +> Nested Loop (cost=2451676.23..2454714.73 rows=1001 width=34) +> -> Subquery Scan "day" (cost=2451676.23..2451688.73 rows=1000 width=16) +> -> Limit (cost=2451676.23..2451678.73 rows=1000 width=12) +> -> Sort (cost=2451676.23..2451684.63 rows=3357 width=12) +> Sort Key: sum(occurence) +> -> HashAggregate (cost=2451471.24..2451479.63 rows=3357 +> width=12) +> -> Index Scan using test_date on +> queries_detail_statistics (cost=0.00..2449570.55 rows=380138 width=12) +> Index Cond: ((date >= '2006-01-01'::date) AND +> (date <= '2006-01-30'::date)) +> Filter: (((portal)::text = '1'::text) OR +> ((portal)::text = '2'::text)) +> -> Index Scan using query_string_pkey on query_string (cost=0.00..3.01 +> rows=1 width=34) +> Index Cond: ("outer".query = query_string.id) +> (11 rows) + +OK, so it looks like something is horrible wrong here. Try running the +explain analyze query after running the following: + + set enable_hashagg=off; + +and see what you get then. + +From pgsql-performance-owner@postgresql.org Wed Feb 15 13:18:26 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 999B69DCC2B + for ; + Wed, 15 Feb 2006 13:18:25 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 68441-02 + for ; + Wed, 15 Feb 2006 13:18:23 -0400 (AST) +X-Greylist: whitelisted by SQLgrey- +Received: from smtp1-g19.free.fr (smtp1-g19.free.fr [212.27.42.27]) + by postgresql.org (Postfix) with ESMTP id D14C19DCC27 + for ; + Wed, 15 Feb 2006 13:18:21 -0400 (AST) +Received: from imp2-g19.free.fr (imp2-g19.free.fr [212.27.42.2]) + by smtp1-g19.free.fr (Postfix) with ESMTP id D2FC36E4D6; + Wed, 15 Feb 2006 18:18:21 +0100 (CET) +Received: by imp2-g19.free.fr (Postfix, from userid 33) + id A445C7AE6A; Wed, 15 Feb 2006 18:18:21 +0100 (MET) +Received: from wormhole.x-echo.com (wormhole.x-echo.com [193.252.148.11]) + by imp2-g19.free.fr (IMP) with HTTP + for ; Wed, 15 Feb 2006 18:18:21 +0100 +Message-ID: <1140023901.43f3625d51661@imp2-g19.free.fr> +Date: Wed, 15 Feb 2006 18:18:21 +0100 +From: martial.bizel@free.fr +To: Scott Marlowe +Cc: pgsql-performance@postgresql.org +Subject: Re: out of memory +References: <1140018930.43f34ef260de0@imp2-g19.free.fr> + <1140022257.22740.225.camel@state.g2switchworks.com> +In-Reply-To: <1140022257.22740.225.camel@state.g2switchworks.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 8bit +User-Agent: Internet Messaging Program (IMP) 3.2.5 +X-Originating-IP: 193.252.148.11 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.657 required=5 tests=[AWL=0.107, NO_REAL_NAME=0.55] +X-Spam-Score: 0.657 +X-Spam-Level: +X-Archive-Number: 200602/203 +X-Sequence-Number: 17189 + +Here the result with hashAgg to false : + Nested Loop (cost=2487858.08..2490896.58 rows=1001 width=34) (actual +time=1028044.781..1030251.260 rows=1000 loops=1) + -> Subquery Scan "day" (cost=2487858.08..2487870.58 rows=1000 width=16) +(actual time=1027996.748..1028000.969 rows=1000 loops=1) + -> Limit (cost=2487858.08..2487860.58 rows=1000 width=12) (actual +time=1027996.737..1027999.199 rows=1000 loops=1) + -> Sort (cost=2487858.08..2487866.47 rows=3357 width=12) +(actual time=1027996.731..1027998.066 rows=1000 loops=1) + Sort Key: sum(occurence) + -> GroupAggregate (cost=2484802.05..2487661.48 rows=3357 +width=12) (actual time=810623.035..914550.262 rows=19422774 loops=1) + -> Sort (cost=2484802.05..2485752.39 rows=380138 +width=12) (actual time=810612.248..845427.013 rows=36724340 loops=1) + Sort Key: query + -> Index Scan using test_date on +queries_detail_statistics (cost=0.00..2449570.55 rows=380138 width=12) (actual +time=25.393..182029.205 rows=36724340 loops=1) + Index Cond: ((date >= '2006-01-01'::date) +AND (date <= '2006-01-30'::date)) + Filter: (((portal)::text = '1'::text) OR +((portal)::text = '2'::text)) + -> Index Scan using query_string_pkey on query_string (cost=0.00..3.01 +rows=1 width=34) (actual time=2.244..2.246 rows=1 loops=1000) + Index Cond: ("outer".query = query_string.id) + Total runtime: 1034357.390 ms +(14 rows) + + +thanks + +table daily has 250 millions records +and field query (bigint) 2 millions, occurence is int. + +request with HashAggregate is OK when date is restricted about 15 days like : + + SELECT query_string, DAY.ocu from search_data.query_string, + (SELECT SUM(occurence) as ocu, query +FROM daily.queries_detail_statistics + WHERE date >= '2006-01-01' AND date <= '2006-01-15' + AND portal IN (1,2) + GROUP BY query + ORDER BY ocu DESC + LIMIT 1000) as DAY + WHERE DAY.query=id; + +> On Wed, 2006-02-15 at 09:55, martial.bizel@free.fr wrote: +> > Good morning, +> > +> > +> > +> > +> > I've increased sort_mem until 2Go !! +> > and the error "out of memory" appears again. +> > +> > Here the request I try to pass with her explain plan, +> > +> > Nested Loop (cost=2451676.23..2454714.73 rows=1001 width=34) +> > -> Subquery Scan "day" (cost=2451676.23..2451688.73 rows=1000 +> width=16) +> > -> Limit (cost=2451676.23..2451678.73 rows=1000 width=12) +> > -> Sort (cost=2451676.23..2451684.63 rows=3357 width=12) +> > Sort Key: sum(occurence) +> > -> HashAggregate (cost=2451471.24..2451479.63 +> rows=3357 +> > width=12) +> > -> Index Scan using test_date on +> > queries_detail_statistics (cost=0.00..2449570.55 rows=380138 width=12) +> > Index Cond: ((date >= '2006-01-01'::date) +> AND +> > (date <= '2006-01-30'::date)) +> > Filter: (((portal)::text = '1'::text) OR +> > ((portal)::text = '2'::text)) +> > -> Index Scan using query_string_pkey on query_string (cost=0.00..3.01 +> > rows=1 width=34) +> > Index Cond: ("outer".query = query_string.id) +> > (11 rows) +> +> OK, so it looks like something is horrible wrong here. Try running the +> explain analyze query after running the following: +> +> set enable_hashagg=off; +> +> and see what you get then. +> +> ---------------------------(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 Wed Feb 15 13:24:18 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 6FB359DCA52 + for ; + Wed, 15 Feb 2006 13:24:18 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 69242-04 + for ; + Wed, 15 Feb 2006 13:24:17 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from moonunit2.moonview.localnet (wsip-68-15-5-150.sd.sd.cox.net + [68.15.5.150]) by postgresql.org (Postfix) with ESMTP id 2046D9DCA09 + for ; + Wed, 15 Feb 2006 13:24:15 -0400 (AST) +Received: from [192.168.0.3] (moonunit3.moonview.localnet [192.168.0.3]) + by moonunit2.moonview.localnet (8.13.1/8.13.1) with ESMTP id + k1FGS6Un012721; Wed, 15 Feb 2006 08:28:07 -0800 +Message-ID: <43F36288.3010302@modgraph-usa.com> +Date: Wed, 15 Feb 2006 09:19:04 -0800 +From: "Craig A. James" +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Jeremy Haile +CC: pgsql-performance@postgresql.org +Subject: Re: Reliability recommendations +References: <20060215090446.2F3AC1B819F@mx1.hub.org> + <1140018387.43f34cd36a076@imp2-g19.free.fr> + <1140018967.43f34f1761803@imp2-g19.free.fr> + <1140020490.9369.254450363@webmail.messagingengine.com> +In-Reply-To: <1140020490.9369.254450363@webmail.messagingengine.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, score=0.095 required=5 tests=[AWL=0.095] +X-Spam-Score: 0.095 +X-Spam-Level: +X-Archive-Number: 200602/204 +X-Sequence-Number: 17190 + +Jeremy Haile wrote: +> We are a small company looking to put together the most cost effective +> solution for our production database environment. Currently in +> production Postgres 8.1 is running on this machine: +> +> Dell 2850 +> 2 x 3.0 Ghz Xeon 800Mhz FSB 2MB Cache +> 4 GB DDR2 400 Mhz +> 2 x 73 GB 10K SCSI RAID 1 (for xlog and OS) +> 4 x 146 GB 10K SCSI RAID 10 (for postgres data) +> Perc4ei controller +> +> ... I sent our scenario to our sales team at Dell and they came back with +> all manner of SAN, DAS, and configuration costing as much as $50k. + +Given what you've told us, a $50K machine is not appropriate. + +Instead, think about a simple system with several clones of the database and a load-balancing web server, even if one machine could handle your load. If a machine goes down, the load balancer automatically switches to the other. + +Look at the MTBF figures of two hypothetical machines: + + Machine 1: Costs $2,000, MTBF of 2 years, takes two days to fix on average. + Machine 2: Costs $50,000, MTBF of 100 years (!), takes one hour to fix on average. + +Now go out and buy three of the $2,000 machines. Use a load-balancer front end web server that can send requests round-robin fashion to a "server farm". Clone your database. In fact, clone the load-balancer too so that all three machines have all software and databases installed. Call these A, B, and C machines. + +At any given time, your Machine A is your web front end, serving requests to databases on A, B and C. If B or C goes down, no problem - the system keeps running. If A goes down, you switch the IP address of B or C and make it your web front end, and you're back in business in a few minutes. + +Now compare the reliability -- in order for this system to be disabled, you'd have to have ALL THREE computers fail at the same time. With the MTBF and repair time of two days, each machine has a 99.726% uptime. The "MTBF", that is, the expected time until all three machines will fail simultaneously, is well over 100,000 years! Of course, this is silly, machines don't last that long, but it illustrates the point: Redundancy is beats reliability (which is why RAID is so useful). + +All for $6,000. + +Craig + +From pgsql-performance-owner@postgresql.org Wed Feb 15 13:32:21 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 679B59DC835 + for ; + Wed, 15 Feb 2006 13:32:21 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 69242-07 + for ; + Wed, 15 Feb 2006 13:32:19 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mir3-fs.mir3.com (mail.mir3.com [65.208.188.100]) + by postgresql.org (Postfix) with ESMTP id 9FBDE9DC821 + for ; + Wed, 15 Feb 2006 13:32:18 -0400 (AST) +Received: mir3-fs.mir3.com 172.16.1.11 from 172.16.2.68 172.16.2.68 via HTTP + with MS-WebStorage 6.0.6249 +Received: from archimedes.mirlogic.com by mir3-fs.mir3.com; + 15 Feb 2006 09:32:17 -0800 +Subject: Re: Reliability recommendations +From: Mark Lewis +To: "Craig A. James" +Cc: Jeremy Haile , pgsql-performance@postgresql.org +In-Reply-To: <43F36288.3010302@modgraph-usa.com> +References: <20060215090446.2F3AC1B819F@mx1.hub.org> + <1140018387.43f34cd36a076@imp2-g19.free.fr> + <1140018967.43f34f1761803@imp2-g19.free.fr> + <1140020490.9369.254450363@webmail.messagingengine.com> + <43F36288.3010302@modgraph-usa.com> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Organization: MIR3, Inc. +Date: Wed, 15 Feb 2006 09:32:16 -0800 +Message-Id: <1140024736.9076.167.camel@archimedes> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-22) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.121 required=5 tests=[AWL=0.120, + UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 0.121 +X-Spam-Level: +X-Archive-Number: 200602/205 +X-Sequence-Number: 17191 + +Machine 1: $2000 +Machine 2: $2000 +Machine 3: $2000 + +Knowing how to rig them together and maintain them in a fully fault- +tolerant way: priceless. + + +(Sorry for the off-topic post, I couldn't resist). + +-- Mark Lewis + +On Wed, 2006-02-15 at 09:19 -0800, Craig A. James wrote: +> Jeremy Haile wrote: +> > We are a small company looking to put together the most cost effective +> > solution for our production database environment. Currently in +> > production Postgres 8.1 is running on this machine: +> > +> > Dell 2850 +> > 2 x 3.0 Ghz Xeon 800Mhz FSB 2MB Cache +> > 4 GB DDR2 400 Mhz +> > 2 x 73 GB 10K SCSI RAID 1 (for xlog and OS) +> > 4 x 146 GB 10K SCSI RAID 10 (for postgres data) +> > Perc4ei controller +> > +> > ... I sent our scenario to our sales team at Dell and they came back with +> > all manner of SAN, DAS, and configuration costing as much as $50k. +> +> Given what you've told us, a $50K machine is not appropriate. +> +> Instead, think about a simple system with several clones of the database and a load-balancing web server, even if one machine could handle your load. If a machine goes down, the load balancer automatically switches to the other. +> +> Look at the MTBF figures of two hypothetical machines: +> +> Machine 1: Costs $2,000, MTBF of 2 years, takes two days to fix on average. +> Machine 2: Costs $50,000, MTBF of 100 years (!), takes one hour to fix on average. +> +> Now go out and buy three of the $2,000 machines. Use a load-balancer front end web server that can send requests round-robin fashion to a "server farm". Clone your database. In fact, clone the load-balancer too so that all three machines have all software and databases installed. Call these A, B, and C machines. +> +> At any given time, your Machine A is your web front end, serving requests to databases on A, B and C. If B or C goes down, no problem - the system keeps running. If A goes down, you switch the IP address of B or C and make it your web front end, and you're back in business in a few minutes. +> +> Now compare the reliability -- in order for this system to be disabled, you'd have to have ALL THREE computers fail at the same time. With the MTBF and repair time of two days, each machine has a 99.726% uptime. The "MTBF", that is, the expected time until all three machines will fail simultaneously, is well over 100,000 years! Of course, this is silly, machines don't last that long, but it illustrates the point: Redundancy is beats reliability (which is why RAID is so useful). +> +> All for $6,000. +> +> Craig +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 5: don't forget to increase your free space map settings + +From pgsql-performance-owner@postgresql.org Wed Feb 15 13:38:22 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 70FD29DC835 + for ; + Wed, 15 Feb 2006 13:38:22 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 73689-01 + for ; + Wed, 15 Feb 2006 13:38:21 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id 243D39DCC19 + for ; + Wed, 15 Feb 2006 13:38:18 -0400 (AST) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Wed, 15 Feb 2006 17:38:17 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 15 Feb 2006 11:38:17 -0600 +Subject: Re: out of memory +From: Scott Marlowe +To: martial.bizel@free.fr +Cc: pgsql-performance@postgresql.org +In-Reply-To: <1140023901.43f3625d51661@imp2-g19.free.fr> +References: <1140018930.43f34ef260de0@imp2-g19.free.fr> + <1140022257.22740.225.camel@state.g2switchworks.com> + <1140023901.43f3625d51661@imp2-g19.free.fr> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1140025097.22740.229.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Wed, 15 Feb 2006 11:38:17 -0600 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.161 required=5 tests=[AWL=0.160, + UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 0.161 +X-Spam-Level: +X-Archive-Number: 200602/206 +X-Sequence-Number: 17192 + +On Wed, 2006-02-15 at 11:18, martial.bizel@free.fr wrote: +> Here the result with hashAgg to false : +> Nested Loop (cost=2487858.08..2490896.58 rows=1001 width=34) (actual +> time=1028044.781..1030251.260 rows=1000 loops=1) +> -> Subquery Scan "day" (cost=2487858.08..2487870.58 rows=1000 width=16) +> (actual time=1027996.748..1028000.969 rows=1000 loops=1) +> -> Limit (cost=2487858.08..2487860.58 rows=1000 width=12) (actual +> time=1027996.737..1027999.199 rows=1000 loops=1) +> -> Sort (cost=2487858.08..2487866.47 rows=3357 width=12) +> (actual time=1027996.731..1027998.066 rows=1000 loops=1) +> Sort Key: sum(occurence) +> -> GroupAggregate (cost=2484802.05..2487661.48 rows=3357 +> width=12) (actual time=810623.035..914550.262 rows=19422774 loops=1) +> -> Sort (cost=2484802.05..2485752.39 rows=380138 +> width=12) (actual time=810612.248..845427.013 rows=36724340 loops=1) +> Sort Key: query +> -> Index Scan using test_date on +> queries_detail_statistics (cost=0.00..2449570.55 rows=380138 width=12) (actual +> time=25.393..182029.205 rows=36724340 loops=1) +> Index Cond: ((date >= '2006-01-01'::date) +> AND (date <= '2006-01-30'::date)) +> Filter: (((portal)::text = '1'::text) OR +> ((portal)::text = '2'::text)) +> -> Index Scan using query_string_pkey on query_string (cost=0.00..3.01 +> rows=1 width=34) (actual time=2.244..2.246 rows=1 loops=1000) +> Index Cond: ("outer".query = query_string.id) +> Total runtime: 1034357.390 ms + +OK, in the index scan using test_date, you get 36724340 when the planner +expects 380138. That's off by a factor of about 10, so I'm guessing +that your statistics aren't reflecting what's really in your db. You +said before you'd run analyze, so I'd try increasing the stats target on +that column and rerun analyze to see if things get any better. + + +From pgsql-performance-owner@postgresql.org Wed Feb 15 14:01:36 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id A45EB9DC897 + for ; + Wed, 15 Feb 2006 14:01:35 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81557-02 + for ; + Wed, 15 Feb 2006 14:01:34 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from hosting.commandprompt.com (128.commandprompt.com + [207.173.200.128]) + by postgresql.org (Postfix) with ESMTP id 544F19DC835 + for ; + Wed, 15 Feb 2006 14:01:32 -0400 (AST) +Received: from [192.168.1.100] (or-67-76-146-141.sta.sprint-hsd.net + [67.76.146.141]) (authenticated bits=0) + by hosting.commandprompt.com (8.13.4/8.13.4) with ESMTP id + k1FHoCfi017797; Wed, 15 Feb 2006 09:50:14 -0800 +Message-ID: <43F36D51.5090502@commandprompt.com> +Date: Wed, 15 Feb 2006 10:05:05 -0800 +From: "Joshua D. Drake" +User-Agent: Thunderbird 1.5 (X11/20051201) +MIME-Version: 1.0 +To: Jeremy Haile +CC: pgsql-performance@postgresql.org +Subject: Re: Reliability recommendations +References: <20060215090446.2F3AC1B819F@mx1.hub.org> + <1140018387.43f34cd36a076@imp2-g19.free.fr> + <1140018967.43f34f1761803@imp2-g19.free.fr> + <1140020490.9369.254450363@webmail.messagingengine.com> +In-Reply-To: <1140020490.9369.254450363@webmail.messagingengine.com> +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]); + Wed, 15 Feb 2006 09:50:14 -0800 (PST) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.086 required=5 tests=[AWL=0.086] +X-Spam-Score: 0.086 +X-Spam-Level: +X-Archive-Number: 200602/207 +X-Sequence-Number: 17193 + +Jeremy Haile wrote: +> We are a small company looking to put together the most cost effective +> solution for our production database environment. Currently in +> production Postgres 8.1 is running on this machine: +> +> Dell 2850 +> 2 x 3.0 Ghz Xeon 800Mhz FSB 2MB Cache +> 4 GB DDR2 400 Mhz +> 2 x 73 GB 10K SCSI RAID 1 (for xlog and OS) +> 4 x 146 GB 10K SCSI RAID 10 (for postgres data) +> Perc4ei controller +> +> The above is a standard Dell box with nothing added or modified beyond +> the options available directly through Dell. +You should probably review the archives for PostgreSQL user +experience with Dell's before you purchase one. + +> I sent our scenario to our sales team at Dell and they came back with +> all manner of SAN, DAS, and configuration costing as much as $50k. +> +HAHAHAHAHA.... Don't do that. Dell is making the assumption +you won't do your homework. Make sure you cross quote with IBM, +Compaq and Penguin Computing... + +Sincerely, + +Joshua D. Drake + +-- +The PostgreSQL Company - Command Prompt, Inc. 1.503.667.4564 +PostgreSQL Replication, Consulting, Custom Development, 24x7 support +Managed Services, Shared and Dedicated Hosting +Co-Authors: PLphp, PLperl - http://www.commandprompt.com/ + + +From pgsql-performance-owner@postgresql.org Wed Feb 15 14:17:49 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 739019DC89F + for ; + Wed, 15 Feb 2006 14:17:48 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81943-08 + for ; + Wed, 15 Feb 2006 14:17:47 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) + by postgresql.org (Postfix) with ESMTP id 38C629DC897 + for ; + Wed, 15 Feb 2006 14:17:45 -0400 (AST) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1F9RDb-0002Tv-00; Wed, 15 Feb 2006 13:17:35 -0500 +To: "Joshua D. Drake" +Cc: Jeremy Haile , pgsql-performance@postgresql.org +Subject: Re: Reliability recommendations +References: <20060215090446.2F3AC1B819F@mx1.hub.org> + <1140018387.43f34cd36a076@imp2-g19.free.fr> + <1140018967.43f34f1761803@imp2-g19.free.fr> + <1140020490.9369.254450363@webmail.messagingengine.com> + <43F36D51.5090502@commandprompt.com> +In-Reply-To: <43F36D51.5090502@commandprompt.com> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 15 Feb 2006 13:17:35 -0500 +Message-ID: <878xsc4hc0.fsf@stark.xeocode.com> +Lines: 33 +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, score=0.13 required=5 tests=[AWL=0.130] +X-Spam-Score: 0.13 +X-Spam-Level: +X-Archive-Number: 200602/208 +X-Sequence-Number: 17194 + + +"Joshua D. Drake" writes: + +> Jeremy Haile wrote: +> > We are a small company looking to put together the most cost effective +> > solution for our production database environment. Currently in +> > production Postgres 8.1 is running on this machine: +> > +> > Dell 2850 +> > 2 x 3.0 Ghz Xeon 800Mhz FSB 2MB Cache +> > 4 GB DDR2 400 Mhz +> > 2 x 73 GB 10K SCSI RAID 1 (for xlog and OS) +> > 4 x 146 GB 10K SCSI RAID 10 (for postgres data) +> > Perc4ei controller + +You don't say how this box is performing. There's no way to give +recommendations in a vacuum. Some users really need $50k boxes and others +(most) don't. This looks like a pretty good setup for Postgres and you would +have to be pushing things pretty hard to need much more. + +That said some users have reported problems with Dell's raid controllers even +when the same brand's regular controllers worked well. That's what Joshua is +referring to. + +> > The above is a standard Dell box with nothing added or modified beyond +> > the options available directly through Dell. +> +> You should probably review the archives for PostgreSQL user +> experience with Dell's before you purchase one. + + +-- +greg + + +From pgsql-performance-owner@postgresql.org Wed Feb 15 15:03:03 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 882679DCA61 + for ; + Wed, 15 Feb 2006 15:03:02 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 92947-09 + for ; + Wed, 15 Feb 2006 15:03:02 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id C83109DCA4C + for ; + Wed, 15 Feb 2006 15:02:59 -0400 (AST) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 0D68E3093C; Wed, 15 Feb 2006 20:03:00 +0100 (MET) +From: Christopher Browne +X-Newsgroups: pgsql.performance +Subject: Re: Reliability recommendations +Date: Wed, 15 Feb 2006 13:44:27 -0500 +Organization: cbbrowne Computing Inc +Lines: 50 +Message-ID: <87r764wjg4.fsf@wolfe.cbbrowne.com> +References: <20060215090446.2F3AC1B819F@mx1.hub.org> + <1140018387.43f34cd36a076@imp2-g19.free.fr> + <1140018967.43f34f1761803@imp2-g19.free.fr> + <1140020490.9369.254450363@webmail.messagingengine.com> + <43F36D51.5090502@commandprompt.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@news.hub.org +X-message-flag: Outlook is rather hackable, isn't it? +X-Home-Page: http://www.cbbrowne.com/info/ +X-Affero: http://svcs.affero.net/rm.php?r=cbbrowne +User-Agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4.19 (linux) +Cancel-Lock: sha1:Ajl2h/8oxknAlyMzwXyIAoRR6FU= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.67 required=5 tests=[AWL=-0.143, INFO_TLD=0.813] +X-Spam-Score: 0.67 +X-Spam-Level: +X-Archive-Number: 200602/209 +X-Sequence-Number: 17195 + +After takin a swig o' Arrakan spice grog, jd@commandprompt.com ("Joshua D. Drake") belched out: +> Jeremy Haile wrote: +>> We are a small company looking to put together the most cost effective +>> solution for our production database environment. Currently in +>> production Postgres 8.1 is running on this machine: +>> +>> Dell 2850 +>> 2 x 3.0 Ghz Xeon 800Mhz FSB 2MB Cache +>> 4 GB DDR2 400 Mhz +>> 2 x 73 GB 10K SCSI RAID 1 (for xlog and OS) +>> 4 x 146 GB 10K SCSI RAID 10 (for postgres data) +>> Perc4ei controller +>> +>> The above is a standard Dell box with nothing added or modified beyond +>> the options available directly through Dell. + +> You should probably review the archives for PostgreSQL user +> experience with Dell's before you purchase one. + +Hear, hear! We found Dell servers were big-time underperformers. + +Generic hardware put together with generally the same brand names of +components (e.g. - for SCSI controllers and such) would generally play +much better. + +For the cheapo desktop boxes they obviously have to buy the "cheapest +hardware available this week;" it sure seems as though they engage in +the same sort of thing with the "server class" hardware. + +I don't think anyone has been able to forcibly point out any +completely precise shortcoming; just that they underperform what the +specs suggest they ought to be able to provide. + +>> I sent our scenario to our sales team at Dell and they came back +>> with all manner of SAN, DAS, and configuration costing as much as +>> $50k. + +> HAHAHAHAHA.... Don't do that. Dell is making the assumption you +> won't do your homework. Make sure you cross quote with IBM, Compaq +> and Penguin Computing... + +Indeed. +-- +(format nil "~S@~S" "cbbrowne" "gmail.com") +http://linuxdatabases.info/info/rdbms.html +Rules of the Evil Overlord #141. "As an alternative to not having +children, I will have _lots_ of children. My sons will be too busy +jockeying for position to ever be a real threat, and the daughters +will all sabotage each other's attempts to win the hero." + + +From pgsql-performance-owner@postgresql.org Wed Feb 15 15:11:24 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id A27FF9DCC0B + for ; + Wed, 15 Feb 2006 15:11:23 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 96342-01 + for ; + Wed, 15 Feb 2006 15:11:23 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id B4FE89DCBDF + for ; + Wed, 15 Feb 2006 15:11:19 -0400 (AST) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Wed, 15 Feb 2006 19:11:20 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 15 Feb 2006 13:11:20 -0600 +Subject: Re: Reliability recommendations +From: Scott Marlowe +To: Christopher Browne +Cc: pgsql-performance@postgresql.org +In-Reply-To: <87r764wjg4.fsf@wolfe.cbbrowne.com> +References: <20060215090446.2F3AC1B819F@mx1.hub.org> + <1140018387.43f34cd36a076@imp2-g19.free.fr> + <1140018967.43f34f1761803@imp2-g19.free.fr> + <1140020490.9369.254450363@webmail.messagingengine.com> + <43F36D51.5090502@commandprompt.com> + <87r764wjg4.fsf@wolfe.cbbrowne.com> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1140030680.22740.235.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Wed, 15 Feb 2006 13:11:20 -0600 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.161 required=5 tests=[AWL=0.160, + UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 0.161 +X-Spam-Level: +X-Archive-Number: 200602/210 +X-Sequence-Number: 17196 + +On Wed, 2006-02-15 at 12:44, Christopher Browne wrote: +> After takin a swig o' Arrakan spice grog, jd@commandprompt.com ("Joshua D. Drake") belched out: + +> > You should probably review the archives for PostgreSQL user +> > experience with Dell's before you purchase one. +> +> Hear, hear! We found Dell servers were big-time underperformers. +> +> Generic hardware put together with generally the same brand names of +> components (e.g. - for SCSI controllers and such) would generally play +> much better. + +My experience has been that: + +A: Their rebranded LSI and Adaptec RAID controllers underperform. +B: Their BIOS updates for said cards and the mobos for the 26xx series +comes in a format that requires you to have a friggin bootable DOS +floppy. What is this, 1987??? +C: They use poorly performing mobo chipsets. + +We had a dual P-III-750 with a REAL LSI RAID card and an intel mobo, and +replaced it with a dual P-IV 2800 Dell 2600 with twice the RAM. As a +database server the P-III-750 was easily a match for the new dell, and +in some ways (i/o) outran it. + +We also had a dual 2400 PIV Intel generic box, and it spanked the Dell +handily at everything, was easier to work on, the parts cost less, and +it used bog standard RAID cards and such. I would highly recommend the +Intel Generic hardware over Dell any day. + +From pgsql-performance-owner@postgresql.org Wed Feb 15 15:53:37 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 9BA8E9DC85A + for ; + Wed, 15 Feb 2006 15:53:36 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 05487-03 + for ; + Wed, 15 Feb 2006 15:53:36 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from elasmtp-mealy.atl.sa.earthlink.net + (elasmtp-mealy.atl.sa.earthlink.net [209.86.89.69]) + by postgresql.org (Postfix) with ESMTP id E1C919DC818 + for ; + Wed, 15 Feb 2006 15:53:33 -0400 (AST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=UwIbMRR7LAJ1m1pLXM11shdTyntL0KZgjtMXVybI+HJRQtO+ANoHzpKUXr04OMp3; + 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 [71.243.43.186] (helo=ron-6d52adff2a6.earthlink.net) + by elasmtp-mealy.atl.sa.earthlink.net with asmtp (Exim 4.34) + id 1F9SiU-0005cc-Ga; Wed, 15 Feb 2006 14:53:34 -0500 +Message-Id: <7.0.1.0.2.20060215142631.03bbaf90@earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 7.0.1.0 +Date: Wed, 15 Feb 2006 14:53:28 -0500 +To: "Jeremy Haile" ,pgsql-performance@postgresql.org +From: Ron +Subject: Re: Reliability recommendations +In-Reply-To: <1140020490.9369.254450363@webmail.messagingengine.com> +References: <20060215090446.2F3AC1B819F@mx1.hub.org> + <1140018387.43f34cd36a076@imp2-g19.free.fr> + <1140018967.43f34f1761803@imp2-g19.free.fr> + <1140020490.9369.254450363@webmail.messagingengine.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bc20c450af6685939055117bf3311ace1a350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 71.243.43.186 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.479 required=5 tests=[AWL=0.000, + DNS_FROM_RFC_ABUSE=0.479] +X-Spam-Score: 0.479 +X-Spam-Level: +X-Archive-Number: 200602/211 +X-Sequence-Number: 17197 + +At 11:21 AM 2/15/2006, Jeremy Haile wrote: +>We are a small company looking to put together the most cost effective +>solution for our production database environment. Currently in +>production Postgres 8.1 is running on this machine: +> +>Dell 2850 +>2 x 3.0 Ghz Xeon 800Mhz FSB 2MB Cache +>4 GB DDR2 400 Mhz +>2 x 73 GB 10K SCSI RAID 1 (for xlog and OS) +>4 x 146 GB 10K SCSI RAID 10 (for postgres data) +>Perc4ei controller +> +>The above is a standard Dell box with nothing added or modified beyond +>the options available directly through Dell. We had a bad processor last +>week that effectively put us down for an entire weekend. Though it was +>the web server that failed, the experience has caused us to step back +>and spend time coming up with a more reliable/fail-safe solution that +>can reduce downtime. +> +>Our load won't be substantial so extreme performance and load balancing +>are not huge concerns. We are looking for good performance, at a good +>price, configured in the most redundant, high availability manner +>possible. Availability is the biggest priority. +> +>I sent our scenario to our sales team at Dell and they came back with +>all manner of SAN, DAS, and configuration costing as much as $50k. +> +>We have the budget to purchase 2-3 additional machines along the lines +>of the one listed above. As a startup with a limited budget, what would +>this list suggest as options for clustering/replication or setting our +>database up well in general? + +1= Tell Dell "Thanks but no thanks." and do not buy any more +equipment from them. Their value per $$ is less than other options +available to you. + +2= The current best bang for the buck HW (and in many cases, best +performing as well) for pg: + a= AMD K8 and K9 (dual core) CPUs. Particularly the A64 X2 3800+ +when getting the most for your $$ matters a lot + pg gets a nice performance boost from running in 64b. + b= Decent Kx server boards are available from Gigabyte, IWill, +MSI, Supermicro, and Tyan to name a few. + IWill has a 2P 16 DIMM slot board that is particularly nice +for a server that needs lots of RAM. + c= Don't bother with SCSI or FC HD's unless you are doing the most +demanding kind of OLTP. SATA II HD's provide better value. + d= HW RAID controllers are only worth it in certain +scenarios. Using RAID 5 almost always means you should use a HW RAID +controller. + e= The only HW RAID controllers worth the $$ for you are 3ware +Escalade 9550SX's and Areca ARC-11xx or ARC-12xx's. + *For the vast majority of throughput situations, the ARC-1xxx's +with >= 1GB of battery backed WB cache are the best value* + f= 1GB RAM sticks are cheap enough and provide enough value that +you should max out any system you get with them. + g= for +high+ speed fail over, Chelsio and others are now making +PCI-X and PCI-E 10GbE NICs at reasonable prices. +The above should serve as a good "pick list" for the components of +any servers you need. + +3= The most economically sound HW and SW architecture that best suits +your performance and reliability needs is context dependent to your +specific circumstances. + + +Where are you located? +Ron + + + + +From pgsql-performance-owner@postgresql.org Wed Feb 15 16:02:59 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id B3CD29DCA17 + for ; + Wed, 15 Feb 2006 16:02:57 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 06571-04 + for ; + Wed, 15 Feb 2006 16:02:57 -0400 (AST) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 202D09DCA09 + for ; + Wed, 15 Feb 2006 16:02:55 -0400 (AST) +Received: from server.gpdnet.co.uk (gpdnet.plus.com [212.56.100.243]) + by svr4.postgresql.org (Postfix) with ESMTP id E28845AF0AF + for ; + Wed, 15 Feb 2006 20:02:53 +0000 (GMT) +Received: from [192.168.1.2] (unknown [192.168.1.2]) + by server.gpdnet.co.uk (Postfix) with ESMTP id 928113AAB28 + for ; + Wed, 15 Feb 2006 20:13:22 +0000 (GMT) +Message-ID: <43F38867.6010701@gpdnet.co.uk> +Date: Wed, 15 Feb 2006 20:00:39 +0000 +From: Gary Doades +User-Agent: Thunderbird 1.5 (Windows/20051201) +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Strange Create Index behaviour +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, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200602/212 +X-Sequence-Number: 17198 + +Platform: FreeBSD 6.0, Postgresql 8.1.2 compiled from the ports collection. + +Not sure if this belongs in performance or bugs.. + +A pg_restore of my 2.5GB database was taking up to 2 hours to complete +instead of the expected 10-15 minutes. Checking the server it was mostly +CPU bound. Testing further I discovered that is was spending huge +amounts of CPU time creating some indexes. + +It took a while to find out, but basically it boils down to this: + +If the column that is having the index created has a certain +distribution of values then create index takes a very long time. If the +data values (integer in this case) a fairly evenly distributed then +create index is very quick, if the data values are all the same it is +very quick. I discovered that in the slow cases the column had +approximately half the values as zero and the rest fairly spread out. +One column started off with around 400,000 zeros and the rest of the +following rows spread between values of 1 to 500,000. + +I have put together a test case that demonstrates the problem (see +below). I create a simple table, as close in structure to one of my +problem tables and populate an integer column with 100,000 zeros follow +by 100,000 random integers between 0 and 100,000. Then create an index +on this column. I then drop the table and repeat. The create index +should take around 1-2 seconds. A fair proportion of the time it takes +50 seconds!!! + +If I fill the same row with all random data the create index always +takes a second or two. If I fill the column with all zeros everything is +still OK. + +When my tables that I am trying to restore are over 2 million rows the +creating one index can take an hour!! (almost all CPU time). + +All other areas of performance, once the dump is restored and analysed +seem to be OK, even large hash/merge joins and sorts + +This is entirely repeatable in FreeBSD in that around half the time +create index will be incredibly slow. + +All postgresql.conf settings are at the defaults for the test initially +(fresh install) + +The final interesting thing is that as I increase shared buffers to 2000 +or 3000 the problem gets *worse* + +The following text is output from the test script.. + +select version(); + version + +------------------------------------------------------------------------------------------------ + PostgreSQL 8.1.2 on i386-portbld-freebsd6.0, compiled by GCC cc (GCC) +3.4.4 [FreeBSD] 20050518 +(1 row) + +\timing +Timing is on. + +----- Many slow cases, note the 50+ seconds cases + +create table atest(i int4, r int4,d1 timestamp, d2 timestamp); +CREATE TABLE +Time: 81.859 ms +insert into atest (i,r,d1,d2) select +generate_series(1,100000),0,now(),now(); +INSERT 0 100000 +Time: 1482.141 ms +insert into atest (i,r,d1,d2) select +generate_series(1,100000),random()*100000,now(),now(); +INSERT 0 100000 +Time: 1543.508 ms +create index idx on atest(r); +CREATE INDEX +Time: 56685.230 ms + +drop table atest; +DROP TABLE +Time: 4.616 ms +create table atest(i int4, r int4,d1 timestamp, d2 timestamp); +CREATE TABLE +Time: 6.889 ms +insert into atest (i,r,d1,d2) select +generate_series(1,100000),0,now(),now(); +INSERT 0 100000 +Time: 2009.787 ms +insert into atest (i,r,d1,d2) select +generate_series(1,100000),random()*100000,now(),now(); +INSERT 0 100000 +Time: 1828.663 ms +create index idx on atest(r); +CREATE INDEX +Time: 3991.257 ms + +drop table atest; +DROP TABLE +Time: 3.796 ms +create table atest(i int4, r int4,d1 timestamp, d2 timestamp); +CREATE TABLE +Time: 19.965 ms +insert into atest (i,r,d1,d2) select +generate_series(1,100000),0,now(),now(); +INSERT 0 100000 +Time: 1625.059 ms +insert into atest (i,r,d1,d2) select +generate_series(1,100000),random()*100000,now(),now(); +INSERT 0 100000 +Time: 2622.827 ms +create index idx on atest(r); +CREATE INDEX +Time: 1082.799 ms + +drop table atest; +DROP TABLE +Time: 4.627 ms +create table atest(i int4, r int4,d1 timestamp, d2 timestamp); +CREATE TABLE +Time: 2.953 ms +insert into atest (i,r,d1,d2) select +generate_series(1,100000),0,now(),now(); +INSERT 0 100000 +Time: 2068.744 ms +insert into atest (i,r,d1,d2) select +generate_series(1,100000),random()*100000,now(),now(); +INSERT 0 100000 +Time: 2671.420 ms +create index idx on atest(r); +CREATE INDEX +Time: 8047.660 ms + +drop table atest; +DROP TABLE +Time: 3.675 ms +create table atest(i int4, r int4,d1 timestamp, d2 timestamp); +CREATE TABLE +Time: 2.582 ms +insert into atest (i,r,d1,d2) select +generate_series(1,100000),0,now(),now(); +INSERT 0 100000 +Time: 1723.987 ms +insert into atest (i,r,d1,d2) select +generate_series(1,100000),random()*100000,now(),now(); +INSERT 0 100000 +Time: 2263.131 ms +create index idx on atest(r); +CREATE INDEX +Time: 50050.308 ms + +drop table atest; +DROP TABLE +Time: 52.744 ms +create table atest(i int4, r int4,d1 timestamp, d2 timestamp); +CREATE TABLE +Time: 25.370 ms +insert into atest (i,r,d1,d2) select +generate_series(1,100000),0,now(),now(); +INSERT 0 100000 +Time: 2052.733 ms +insert into atest (i,r,d1,d2) select +generate_series(1,100000),random()*100000,now(),now(); +INSERT 0 100000 +Time: 2631.317 ms +create index idx on atest(r); +CREATE INDEX +Time: 61440.897 ms + +drop table atest; +DROP TABLE +Time: 26.137 ms +create table atest(i int4, r int4,d1 timestamp, d2 timestamp); +CREATE TABLE +Time: 24.794 ms +insert into atest (i,r,d1,d2) select +generate_series(1,100000),0,now(),now(); +INSERT 0 100000 +Time: 2851.977 ms +insert into atest (i,r,d1,d2) select +generate_series(1,100000),random()*100000,now(),now(); +INSERT 0 100000 +Time: 1553.046 ms +create index idx on atest(r); +CREATE INDEX +Time: 1774.920 ms + + +---- Fast (Normal?) cases + +drop table atest; +DROP TABLE +Time: 4.422 ms +create table atest(i int4, r int4,d1 timestamp, d2 timestamp); +CREATE TABLE +Time: 2.543 ms +insert into atest (i,r,d1,d2) select +generate_series(1,100000),random()*100000,now(),now(); +INSERT 0 100000 +Time: 1516.246 ms +insert into atest (i,r,d1,d2) select +generate_series(1,100000),random()*100000,now(),now(); +INSERT 0 100000 +Time: 1407.400 ms +create index idx on atest(r); +CREATE INDEX +Time: 903.503 ms + +drop table atest; +DROP TABLE +Time: 3.820 ms +create table atest(i int4, r int4,d1 timestamp, d2 timestamp); +CREATE TABLE +Time: 22.861 ms +insert into atest (i,r,d1,d2) select +generate_series(1,100000),random()*100000,now(),now(); +INSERT 0 100000 +Time: 1455.556 ms +insert into atest (i,r,d1,d2) select +generate_series(1,100000),random()*100000,now(),now(); +INSERT 0 100000 +Time: 2037.996 ms +create index idx on atest(r); +CREATE INDEX +Time: 718.286 ms + +drop table atest; +DROP TABLE +Time: 4.503 ms +create table atest(i int4, r int4,d1 timestamp, d2 timestamp); +CREATE TABLE +Time: 3.448 ms +insert into atest (i,r,d1,d2) select +generate_series(1,100000),random()*100000,now(),now(); +INSERT 0 100000 +Time: 1523.540 ms +insert into atest (i,r,d1,d2) select +generate_series(1,100000),random()*100000,now(),now(); +INSERT 0 100000 +Time: 1261.473 ms +create index idx on atest(r); +CREATE INDEX +Time: 727.707 ms + +drop table atest; +DROP TABLE +Time: 3.564 ms +create table atest(i int4, r int4,d1 timestamp, d2 timestamp); +CREATE TABLE +Time: 2.897 ms +insert into atest (i,r,d1,d2) select +generate_series(1,100000),random()*100000,now(),now(); +INSERT 0 100000 +Time: 1447.504 ms +insert into atest (i,r,d1,d2) select +generate_series(1,100000),random()*100000,now(),now(); +INSERT 0 100000 +Time: 1403.525 ms +create index idx on atest(r); +CREATE INDEX +Time: 754.577 ms + +drop table atest; +DROP TABLE +Time: 4.633 ms +create table atest(i int4, r int4,d1 timestamp, d2 timestamp); +CREATE TABLE +Time: 3.196 ms +insert into atest (i,r,d1,d2) select +generate_series(1,100000),random()*100000,now(),now(); +INSERT 0 100000 +Time: 1618.544 ms +insert into atest (i,r,d1,d2) select +generate_series(1,100000),random()*100000,now(),now(); +INSERT 0 100000 +Time: 1530.450 ms +create index idx on atest(r); +CREATE INDEX +Time: 802.980 ms +drop table atest; +DROP TABLE +Time: 4.707 ms +mserver# + +Regards, +Gary. + +From pgsql-performance-owner@postgresql.org Wed Feb 15 16:56:35 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id E82B79DCA54 + for ; + Wed, 15 Feb 2006 16:56:34 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18612-05 + for ; + Wed, 15 Feb 2006 16:56:35 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id BCB989DC808 + for ; + Wed, 15 Feb 2006 16:56:31 -0400 (AST) +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 k1FKu8GL019511; + Wed, 15 Feb 2006 15:56:08 -0500 (EST) +To: Gary Doades +cc: pgsql-performance@postgresql.org +Subject: Re: Strange Create Index behaviour +In-reply-to: <43F38867.6010701@gpdnet.co.uk> +References: <43F38867.6010701@gpdnet.co.uk> +Comments: In-reply-to Gary Doades + message dated "Wed, 15 Feb 2006 20:00:39 +0000" +Date: Wed, 15 Feb 2006 15:56:08 -0500 +Message-ID: <19510.1140036968@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.11 required=5 tests=[AWL=0.110] +X-Spam-Score: 0.11 +X-Spam-Level: +X-Archive-Number: 200602/213 +X-Sequence-Number: 17199 + +Gary Doades writes: +> Platform: FreeBSD 6.0, Postgresql 8.1.2 compiled from the ports collection. + +> If the column that is having the index created has a certain +> distribution of values then create index takes a very long time. If the +> data values (integer in this case) a fairly evenly distributed then +> create index is very quick, if the data values are all the same it is +> very quick. I discovered that in the slow cases the column had +> approximately half the values as zero and the rest fairly spread out. + +Interesting. I tried your test script and got fairly close times +for all the cases on two different machines: + old HPUX machine: shortest 5800 msec, longest 7960 msec + new Fedora 4 machine: shortest 461 msec, longest 608 msec +(the HPUX machine was doing other stuff at the same time, so some +of its variation is probably only noise). + +So what this looks like to me is a corner case that FreeBSD's qsort +fails to handle well. + +You might try forcing Postgres to use our private copy of qsort, as we +do on Solaris for similar reasons. (The easy way to do this by hand +is to configure as normal, then alter the LIBOBJS setting in +src/Makefile.global to add "qsort.o", then proceed with normal build.) +However, I think that our private copy is descended from *BSD sources, +so it might have the same failure mode. It'd be worth finding out. + +> The final interesting thing is that as I increase shared buffers to 2000 +> or 3000 the problem gets *worse* + +shared_buffers is unlikely to impact index build time noticeably in +recent PG releases. maintenance_work_mem would affect it a lot, though. +What setting were you using for that? + +Can anyone else try these test cases on other platforms? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Feb 15 16:58:01 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 6370E9DC808 + for ; + Wed, 15 Feb 2006 16:58:00 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18303-05 + for ; + Wed, 15 Feb 2006 16:58:01 -0400 (AST) +X-Greylist: delayed 04:36:21.971555 by SQLgrey- +Received: from out4.smtp.messagingengine.com (out4.smtp.messagingengine.com + [66.111.4.28]) by postgresql.org (Postfix) with ESMTP id 27BF89DC843 + for ; + Wed, 15 Feb 2006 16:57:57 -0400 (AST) +Received: from frontend1.internal (mysql-sessions.internal [10.202.2.149]) + by frontend1.messagingengine.com (Postfix) with ESMTP id B023FD3477A; + Wed, 15 Feb 2006 15:57:58 -0500 (EST) +Received: from web2.messagingengine.com ([10.202.2.211]) + by frontend1.internal (MEProxy); Wed, 15 Feb 2006 15:57:58 -0500 +Received: by web2.messagingengine.com (Postfix, from userid 99) + id 076A711BAE; Wed, 15 Feb 2006 15:57:51 -0500 (EST) +Message-Id: <1140037070.13854.254475604@webmail.messagingengine.com> +X-Sasl-Enc: ShWw9jhev+ynRUEbJY0yHLkqrZb+46h9QLIAb2w3yQiD 1140037070 +From: "Jeremy Haile" +To: "Ron" , pgsql-performance@postgresql.org +Content-Disposition: inline +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset="ISO-8859-1" +MIME-Version: 1.0 +X-Mailer: MIME::Lite 5022 (F2.73; T1.15; A1.64; B3.05; Q3.03) +References: <20060215090446.2F3AC1B819F@mx1.hub.org> + <1140018387.43f34cd36a076@imp2-g19.free.fr> + <1140018967.43f34f1761803@imp2-g19.free.fr> + <1140020490.9369.254450363@webmail.messagingengine.com> + <7.0.1.0.2.20060215142631.03bbaf90@earthlink.net> +Subject: Re: Reliability recommendations +In-Reply-To: <7.0.1.0.2.20060215142631.03bbaf90@earthlink.net> +Date: Wed, 15 Feb 2006 15:57:50 -0500 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.419 required=5 tests=[AWL=-0.060, + DNS_FROM_RFC_ABUSE=0.479] +X-Spam-Score: 0.419 +X-Spam-Level: +X-Archive-Number: 200602/214 +X-Sequence-Number: 17200 + +Thanks for everyone's feedback. I will definitely take the hardware +comments into consideration when purchasing future hardware. I am +located in Atlanta, GA. If Dell has such a bad reputation with this +list, does anyone have good vendor recommendations? + +Although most of the responses were hardware-oriented (which was +probably my fault for not clearly stating my question), I am mostly +interested in replication/clustering ways of solving the issue. My +example of Dell quoting us $50k for a SAN was meant to sound ridiculous +and is definitely not something we are considering. + +What we are really after is a good clustering or replication solution +where we can run PostgreSQL on a small set of servers and have failover +capabilities. While RAID is great, our last failure was a CPU failure +so a multi-server approach is something we want. Does anyone have any +recommendations as far as a clustering/replication solutions, regardless +of hardware? I know there are several open-source and commercial +postgres replication solutions - any good or bad experiences? Also, any +opinions on shared storage and clustering vs separate internal storage. + +Since performance is not our current bottleneck, I would imagine +Master->Slave replication would be sufficient, although performance +gains are always welcome. I don't have much experience with setting +PostgreSQL in a replicated or clustered manner, so anything to point me +in the right direction both hardware and software wise would be +appreciated! + +Thanks for all of the responses! + +On Wed, 15 Feb 2006 14:53:28 -0500, "Ron" said: +> At 11:21 AM 2/15/2006, Jeremy Haile wrote: +> >We are a small company looking to put together the most cost effective +> >solution for our production database environment. Currently in +> >production Postgres 8.1 is running on this machine: +> > +> >Dell 2850 +> >2 x 3.0 Ghz Xeon 800Mhz FSB 2MB Cache +> >4 GB DDR2 400 Mhz +> >2 x 73 GB 10K SCSI RAID 1 (for xlog and OS) +> >4 x 146 GB 10K SCSI RAID 10 (for postgres data) +> >Perc4ei controller +> > +> >The above is a standard Dell box with nothing added or modified beyond +> >the options available directly through Dell. We had a bad processor last +> >week that effectively put us down for an entire weekend. Though it was +> >the web server that failed, the experience has caused us to step back +> >and spend time coming up with a more reliable/fail-safe solution that +> >can reduce downtime. +> > +> >Our load won't be substantial so extreme performance and load balancing +> >are not huge concerns. We are looking for good performance, at a good +> >price, configured in the most redundant, high availability manner +> >possible. Availability is the biggest priority. +> > +> >I sent our scenario to our sales team at Dell and they came back with +> >all manner of SAN, DAS, and configuration costing as much as $50k. +> > +> >We have the budget to purchase 2-3 additional machines along the lines +> >of the one listed above. As a startup with a limited budget, what would +> >this list suggest as options for clustering/replication or setting our +> >database up well in general? +> +> 1= Tell Dell "Thanks but no thanks." and do not buy any more +> equipment from them. Their value per $$ is less than other options +> available to you. +> +> 2= The current best bang for the buck HW (and in many cases, best +> performing as well) for pg: +> a= AMD K8 and K9 (dual core) CPUs. Particularly the A64 X2 3800+ +> when getting the most for your $$ matters a lot +> pg gets a nice performance boost from running in 64b. +> b= Decent Kx server boards are available from Gigabyte, IWill, +> MSI, Supermicro, and Tyan to name a few. +> IWill has a 2P 16 DIMM slot board that is particularly nice +> for a server that needs lots of RAM. +> c= Don't bother with SCSI or FC HD's unless you are doing the most +> demanding kind of OLTP. SATA II HD's provide better value. +> d= HW RAID controllers are only worth it in certain +> scenarios. Using RAID 5 almost always means you should use a HW RAID +> controller. +> e= The only HW RAID controllers worth the $$ for you are 3ware +> Escalade 9550SX's and Areca ARC-11xx or ARC-12xx's. +> *For the vast majority of throughput situations, the ARC-1xxx's +> with >= 1GB of battery backed WB cache are the best value* +> f= 1GB RAM sticks are cheap enough and provide enough value that +> you should max out any system you get with them. +> g= for +high+ speed fail over, Chelsio and others are now making +> PCI-X and PCI-E 10GbE NICs at reasonable prices. +> The above should serve as a good "pick list" for the components of +> any servers you need. +> +> 3= The most economically sound HW and SW architecture that best suits +> your performance and reliability needs is context dependent to your +> specific circumstances. +> +> +> Where are you located? +> Ron +> +> +> + +From pgsql-performance-owner@postgresql.org Wed Feb 15 17:08:59 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id C72FA9DCC4F + for ; + Wed, 15 Feb 2006 17:08:58 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 21320-03 + for ; + Wed, 15 Feb 2006 17:08:59 -0400 (AST) +X-Greylist: delayed 01:06:09.142117 by SQLgrey- +Received: from server.gpdnet.co.uk (gpdnet.plus.com [212.56.100.243]) + by postgresql.org (Postfix) with ESMTP id 7AD029DCB9E + for ; + Wed, 15 Feb 2006 17:08:54 -0400 (AST) +Received: from [192.168.1.2] (unknown [192.168.1.2]) + by server.gpdnet.co.uk (Postfix) with ESMTP id 2C8C63AAB28; + Wed, 15 Feb 2006 21:19:34 +0000 (GMT) +Message-ID: <43F397EB.30608@gpdnet.co.uk> +Date: Wed, 15 Feb 2006 21:06:51 +0000 +From: Gary Doades +User-Agent: Thunderbird 1.5 (Windows/20051201) +MIME-Version: 1.0 +To: Tom Lane +CC: pgsql-performance@postgresql.org +Subject: Re: Strange Create Index behaviour +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> +In-Reply-To: <19510.1140036968@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, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200602/215 +X-Sequence-Number: 17201 + +Tom Lane wrote: +> Interesting. I tried your test script and got fairly close times +> for all the cases on two different machines: +> old HPUX machine: shortest 5800 msec, longest 7960 msec +> new Fedora 4 machine: shortest 461 msec, longest 608 msec +> (the HPUX machine was doing other stuff at the same time, so some +> of its variation is probably only noise). +> +> So what this looks like to me is a corner case that FreeBSD's qsort +> fails to handle well. +> +> You might try forcing Postgres to use our private copy of qsort, as we +> do on Solaris for similar reasons. (The easy way to do this by hand +> is to configure as normal, then alter the LIBOBJS setting in +> src/Makefile.global to add "qsort.o", then proceed with normal build.) +> However, I think that our private copy is descended from *BSD sources, +> so it might have the same failure mode. It'd be worth finding out. +> +>> The final interesting thing is that as I increase shared buffers to 2000 +>> or 3000 the problem gets *worse* +> +> shared_buffers is unlikely to impact index build time noticeably in +> recent PG releases. maintenance_work_mem would affect it a lot, though. +> What setting were you using for that? +> +> Can anyone else try these test cases on other platforms? +> + +Thanks for that. + +I've since tried it on Windows (pg 8.1.2) and the times were all +similar, around 1200ms so it might just be BSD. + +I'll have to wait until tomorrow to get back to my BSD box. FreeBSD +ports makes it easy to install, so I'll have to figure out how to get in +and change things manually. I guess the appropriate files are still left +around after the ports make command finishes, so I just edit the file +and make again? + +If it can't be fixed though I guess we may have a problem using BSD. I'm +surprised this hasn't been brought up before, the case doesn't seem +*that* rare. Maybe not that many using FreeBSD? + +I'd certainly be interested if anyone else can repro it on FreeBSD though. + +Regards, +Gary. + + +From pgsql-performance-owner@postgresql.org Wed Feb 15 17:13:23 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 886EF9DC803 + for ; + Wed, 15 Feb 2006 17:13:22 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 21894-02 + for ; + Wed, 15 Feb 2006 17:13:23 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from server.gpdnet.co.uk (gpdnet.plus.com [212.56.100.243]) + by postgresql.org (Postfix) with ESMTP id 2E77C9DC843 + for ; + Wed, 15 Feb 2006 17:13:19 -0400 (AST) +Received: from [192.168.1.2] (unknown [192.168.1.2]) + by server.gpdnet.co.uk (Postfix) with ESMTP id 2AB753AAB28; + Wed, 15 Feb 2006 21:23:59 +0000 (GMT) +Message-ID: <43F398F3.30105@gpdnet.co.uk> +Date: Wed, 15 Feb 2006 21:11:15 +0000 +From: Gary Doades +User-Agent: Thunderbird 1.5 (Windows/20051201) +MIME-Version: 1.0 +To: Tom Lane +CC: pgsql-performance@postgresql.org +Subject: Re: Strange Create Index behaviour +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> +In-Reply-To: <19510.1140036968@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, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200602/216 +X-Sequence-Number: 17202 + +Tom Lane wrote: +> shared_buffers is unlikely to impact index build time noticeably in +> recent PG releases. maintenance_work_mem would affect it a lot, though. +> What setting were you using for that? +> + +Also, i tried upping maintenance_work_mem to 65536 and it didn't make +much difference (maybe 10% faster for the "normal" cases). Upping the +shared_buffers *definitely* makes the bad cases worse though, but I +agree I don't see why... + +Regards, +Gary. + +From pgsql-performance-owner@postgresql.org Wed Feb 15 17:50:30 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 4F64F9DC805 + for ; + Wed, 15 Feb 2006 17:50:30 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25455-08 + for ; + Wed, 15 Feb 2006 17:50:31 -0400 (AST) +X-Greylist: delayed 00:30:01.194233 by SQLgrey- +Received: from mail.sonalysts.com (sentry.sonalysts.com [198.6.208.103]) + by postgresql.org (Postfix) with ESMTP id EF4959DC803 + for ; + Wed, 15 Feb 2006 17:50:27 -0400 (AST) +Received: from [198.6.213.78] ([198.6.213.78]) + (authenticated user rovero@sonalysts.com) by mail.sonalysts.com + (using TLSv1/SSLv3 with cipher AES256-SHA (256 bits)) + for pgsql-performance@postgresql.org; Wed, 15 Feb 2006 16:20:27 -0500 +Message-ID: <43F39B17.9020800@sonalysts.com> +Date: Wed, 15 Feb 2006 16:20:23 -0500 +From: Josh Rovero +Organization: Sonalysts, Inc. +User-Agent: Thunderbird 1.5 (X11/20051201) +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Reliability recommendations +References: <20060215090446.2F3AC1B819F@mx1.hub.org> + <1140018387.43f34cd36a076@imp2-g19.free.fr> + <1140018967.43f34f1761803@imp2-g19.free.fr> + <1140020490.9369.254450363@webmail.messagingengine.com> + <7.0.1.0.2.20060215142631.03bbaf90@earthlink.net> + <1140037070.13854.254475604@webmail.messagingengine.com> +In-Reply-To: <1140037070.13854.254475604@webmail.messagingengine.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, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200602/223 +X-Sequence-Number: 17209 + +Jeremy Haile wrote: +> Thanks for everyone's feedback. I will definitely take the hardware +> comments into consideration when purchasing future hardware. I am +> located in Atlanta, GA. If Dell has such a bad reputation with this +> list, does anyone have good vendor recommendations? +> +I can recommend Penguin Computing (even our windows weenies like them), +ASA, and HP Proliant. AMD Opteron *is* the way to go. + + + +From pgsql-performance-owner@postgresql.org Wed Feb 15 17:27:50 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id C6EEB9DCA57 + for ; + Wed, 15 Feb 2006 17:27:49 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 22055-06 + for ; + Wed, 15 Feb 2006 17:27:51 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smtp.nildram.co.uk (smtp.nildram.co.uk [195.112.4.54]) + by postgresql.org (Postfix) with ESMTP id BCC1F9DC803 + for ; + Wed, 15 Feb 2006 17:27:46 -0400 (AST) +Received: from [192.168.0.5] (unknown [84.12.26.47]) + by smtp.nildram.co.uk (Postfix) with ESMTP + id 4D5D4254027; Wed, 15 Feb 2006 21:27:33 +0000 (GMT) +Subject: Re: Strange Create Index behaviour +From: Simon Riggs +To: Gary Doades +Cc: pgsql-performance@postgresql.org +In-Reply-To: <43F38867.6010701@gpdnet.co.uk> +References: <43F38867.6010701@gpdnet.co.uk> +Content-Type: text/plain +Date: Wed, 15 Feb 2006 21:27:27 +0000 +Message-Id: <1140038847.12131.155.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.3 (2.2.3-2.fc4) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.086 required=5 tests=[AWL=0.086] +X-Spam-Score: 0.086 +X-Spam-Level: +X-Archive-Number: 200602/217 +X-Sequence-Number: 17203 + +On Wed, 2006-02-15 at 20:00 +0000, Gary Doades wrote: + +> I have put together a test case + +Please enable trace_sort=on and then repeat tests and post the +accompanying log file. + +I think this is simply the sort taking longer depending upon the data +distribution, but I'd like to know for sure. + +Thanks, + +Best Regards, Simon Riggs + + +From pgsql-performance-owner@postgresql.org Wed Feb 15 17:27:58 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id BB0AB9DCB9E + for ; + Wed, 15 Feb 2006 17:27:56 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 22055-07 + for ; + Wed, 15 Feb 2006 17:27:57 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id F385E9DCB98 + for ; + Wed, 15 Feb 2006 17:27:53 -0400 (AST) +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 k1FLRsqd019780; + Wed, 15 Feb 2006 16:27:54 -0500 (EST) +To: Gary Doades +cc: pgsql-performance@postgresql.org +Subject: Re: Strange Create Index behaviour +In-reply-to: <19510.1140036968@sss.pgh.pa.us> +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> +Comments: In-reply-to Tom Lane + message dated "Wed, 15 Feb 2006 15:56:08 -0500" +Date: Wed, 15 Feb 2006 16:27:54 -0500 +Message-ID: <19779.1140038874@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.11 required=5 tests=[AWL=0.110] +X-Spam-Score: 0.11 +X-Spam-Level: +X-Archive-Number: 200602/218 +X-Sequence-Number: 17204 + +I wrote: +> Interesting. I tried your test script and got fairly close times +> for all the cases on two different machines: +> old HPUX machine: shortest 5800 msec, longest 7960 msec +> new Fedora 4 machine: shortest 461 msec, longest 608 msec + +> So what this looks like to me is a corner case that FreeBSD's qsort +> fails to handle well. + +I tried forcing PG to use src/port/qsort.c on the Fedora machine, +and lo and behold: + new Fedora 4 machine: shortest 434 msec, longest 8530 msec + +So it sure looks like this script does expose a problem on BSD-derived +qsorts. Curiously, the case that's much the worst for me is the third +in the script, while the shortest time is the first case, which was slow +for Gary. So I'd venture that the *BSD code has been tweaked somewhere +along the way, in a manner that moves the problem around without really +fixing it. (Anyone want to compare the actual FreeBSD source to what +we have?) + +This is pretty relevant stuff, because there was a thread recently +advocating that we stop using the platform qsort on all platforms: +http://archives.postgresql.org/pgsql-hackers/2005-12/msg00610.php + +It's really interesting to see a case where port/qsort is radically +worse than other qsorts ... unless we figure that out and fix it, +I think the idea of using port/qsort everywhere has just taken a +major hit. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Feb 15 17:29:55 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id ACF2B9DC805 + for ; + Wed, 15 Feb 2006 17:29:54 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 23385-07 + for ; + Wed, 15 Feb 2006 17:29:55 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from timberline.ca (unknown [66.244.194.163]) + by postgresql.org (Postfix) with ESMTP id AE0F49DC803 + for ; + Wed, 15 Feb 2006 17:29:51 -0400 (AST) +Received: from tfic21 ([172.16.10.21]) + by timberline.ca (8.12.9/8.12.9) with ESMTP id k1FLTpiO008671 + for ; + Wed, 15 Feb 2006 13:29:51 -0800 (PST) +Message-Id: <200602152129.k1FLTpiO008671@timberline.ca> +From: "Jay Greenfield" +To: +Subject: Re: Postgres slower than MS ACCESS +Date: Wed, 15 Feb 2006 13:29:51 -0800 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Mailer: Microsoft Office Outlook, Build 11.0.6353 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 +Thread-Index: AcYyO2oHDK0P9LqwQsCIzVv3ZfSeLwAKmD6g +In-reply-to: <24B89C42-C597-4571-8BD1-A89073C3C035@torgo.978.org> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.09 required=5 tests=[AWL=0.090] +X-Spam-Score: 0.09 +X-Spam-Level: +X-Archive-Number: 200602/219 +X-Sequence-Number: 17205 + + +I've been vacuuming between each test run. + +Not vacuuming results in times all the way up to 121 minutes. For a direct +comparison with Access, the vacuuming time with Postgres should really be +included as this is not required with Access. + +By removing all of the indexes I have been able to get the Postgres time +down to 4.35 minutes with default setting for all except the following: +fsync: off +work_mem: 1024000 +shared_buffers: 10000 + +I did a run with checkpoint_segments @ 30 (from 3 in 4.35 min run) and +posted a time of 6.78 minutes. Any idea why this would increase the time? + +Thanks, + +Jay. + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Jeff Trout +Sent: Wednesday, February 15, 2006 6:23 AM +To: Jay Greenfield +Cc: 'Tom Lane'; 'Stephen Frost'; pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Postgres slower than MS ACCESS + + +On Feb 14, 2006, at 3:56 PM, Jay Greenfield wrote: + +>> How do you get 4,000+ lines of explain analyze for one update +>> query in a +>> database with only one table? Something a bit fishy there. +>> Perhaps you +>> mean explain verbose, though I don't really see how that'd be so long +>> either, but it'd be closer. Could you provide some more sane +>> information? +> +> My mistake - there was 4,000 lines in the EXPLAIN ANALYZE VERBOSE +> output. +> Here is the output of EXPLAIN ANALYZE: +> +> QUERY PLAN +> "Seq Scan on ntdn (cost=0.00..3471884.39 rows=1221391 width=1592) +> (actual +> time=57292.580..1531300.003 rows=1221391 loops=1)" +> "Total runtime: 4472646.988 ms" +> + +Have you been vacuuming or running autovacuum? +If you keep running queries like this you're certianly going to have +a ton of dead tuples, which would def explain these times too. + +-- +Jeff Trout +http://www.jefftrout.com/ +http://www.stuarthamm.net/ + + + +---------------------------(end of broadcast)--------------------------- +TIP 3: Have you checked our extensive FAQ? + + http://www.postgresql.org/docs/faq + + +From pgsql-performance-owner@postgresql.org Wed Feb 15 17:36:15 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id A90FD9DC803 + for ; + Wed, 15 Feb 2006 17:36:14 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 26110-04 + for ; + Wed, 15 Feb 2006 17:36:16 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from server.gpdnet.co.uk (gpdnet.plus.com [212.56.100.243]) + by postgresql.org (Postfix) with ESMTP id 5F1959DC843 + for ; + Wed, 15 Feb 2006 17:36:12 -0400 (AST) +Received: from [192.168.1.2] (unknown [192.168.1.2]) + by server.gpdnet.co.uk (Postfix) with ESMTP id D0FC33AAB28; + Wed, 15 Feb 2006 21:46:53 +0000 (GMT) +Message-ID: <43F39E53.1020009@gpdnet.co.uk> +Date: Wed, 15 Feb 2006 21:34:11 +0000 +From: Gary Doades +User-Agent: Thunderbird 1.5 (Windows/20051201) +MIME-Version: 1.0 +To: Tom Lane +CC: pgsql-performance@postgresql.org +Subject: Re: Strange Create Index behaviour +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> +In-Reply-To: <19779.1140038874@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, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200602/220 +X-Sequence-Number: 17206 + +Tom Lane wrote: + > I tried forcing PG to use src/port/qsort.c on the Fedora machine, +> and lo and behold: +> new Fedora 4 machine: shortest 434 msec, longest 8530 msec +> +> So it sure looks like this script does expose a problem on BSD-derived +> qsorts. Curiously, the case that's much the worst for me is the third +> in the script, while the shortest time is the first case, which was slow +> for Gary. So I'd venture that the *BSD code has been tweaked somewhere +> along the way, in a manner that moves the problem around without really +> fixing it. (Anyone want to compare the actual FreeBSD source to what +> we have?) +> + +If I run the script again, it is not always the first case that is slow, +it varies from run to run, which is why I repeated it quite a few times +for the test. + +Interestingly, if I don't delete the table after a run, but just drop +and re-create the index repeatedly it stays a pretty consistent time, +either repeatedly good or repeatedly bad! + +Regards, +Gary. + +From pgsql-performance-owner@postgresql.org Wed Feb 15 17:36:52 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 69AD39DCB9E + for ; + Wed, 15 Feb 2006 17:36:52 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 26303-03 + for ; + Wed, 15 Feb 2006 17:36:53 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 2F6729DCB6E + for ; + Wed, 15 Feb 2006 17:36:49 -0400 (AST) +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 k1FLap7Q019882; + Wed, 15 Feb 2006 16:36:51 -0500 (EST) +To: "Jay Greenfield" +cc: pgsql-performance@postgresql.org +Subject: Re: Postgres slower than MS ACCESS +In-reply-to: <200602152129.k1FLTpiO008671@timberline.ca> +References: <200602152129.k1FLTpiO008671@timberline.ca> +Comments: In-reply-to "Jay Greenfield" + message dated "Wed, 15 Feb 2006 13:29:51 -0800" +Date: Wed, 15 Feb 2006 16:36:51 -0500 +Message-ID: <19881.1140039411@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.11 required=5 tests=[AWL=0.110] +X-Spam-Score: 0.11 +X-Spam-Level: +X-Archive-Number: 200602/221 +X-Sequence-Number: 17207 + +"Jay Greenfield" writes: +> I did a run with checkpoint_segments @ 30 (from 3 in 4.35 min run) and +> posted a time of 6.78 minutes. Any idea why this would increase the time? + +The first time through might take longer while the machine creates empty +xlog segment files (though I'd not have expected a hit that big). Once +it's fully populated pg_xlog it'll just recycle the files, so you might +find that a second try is faster. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Feb 15 18:08:55 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 1DC7F9DC85A + for ; + Wed, 15 Feb 2006 18:08:55 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 32391-05 + for ; + Wed, 15 Feb 2006 18:08:56 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from server.gpdnet.co.uk (gpdnet.plus.com [212.56.100.243]) + by postgresql.org (Postfix) with ESMTP id E355D9DC803 + for ; + Wed, 15 Feb 2006 18:08:52 -0400 (AST) +Received: from [192.168.1.2] (unknown [192.168.1.2]) + by server.gpdnet.co.uk (Postfix) with ESMTP id A96353AAB69; + Wed, 15 Feb 2006 22:00:30 +0000 (GMT) +Message-ID: <43F3A182.4010608@gpdnet.co.uk> +Date: Wed, 15 Feb 2006 21:47:46 +0000 +From: Gary Doades +User-Agent: Thunderbird 1.5 (Windows/20051201) +MIME-Version: 1.0 +To: Tom Lane +CC: pgsql-performance@postgresql.org +Subject: Re: Strange Create Index behaviour +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> +In-Reply-To: <19779.1140038874@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, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200602/225 +X-Sequence-Number: 17211 + +Tom Lane wrote: +> +> So it sure looks like this script does expose a problem on BSD-derived +> qsorts. Curiously, the case that's much the worst for me is the third +> in the script, while the shortest time is the first case, which was slow +> for Gary. So I'd venture that the *BSD code has been tweaked somewhere +> along the way, in a manner that moves the problem around without really +> fixing it. (Anyone want to compare the actual FreeBSD source to what +> we have?) +> +> It's really interesting to see a case where port/qsort is radically +> worse than other qsorts ... unless we figure that out and fix it, +> I think the idea of using port/qsort everywhere has just taken a +> major hit. +> + +More specifically to BSD, is there any way I can use a non-BSD qsort for +building Postresql server? + +Regards, +Gary. + +From pgsql-performance-owner@postgresql.org Wed Feb 15 17:49:02 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 170629DCC61 + for ; + Wed, 15 Feb 2006 17:49:02 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28510-02 + for ; + Wed, 15 Feb 2006 17:49:03 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 821B09DCC2D + for ; + Wed, 15 Feb 2006 17:48:59 -0400 (AST) +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 k1FLmumk019976; + Wed, 15 Feb 2006 16:48:56 -0500 (EST) +To: Simon Riggs +cc: Gary Doades , pgsql-performance@postgresql.org +Subject: Re: Strange Create Index behaviour +In-reply-to: <1140038847.12131.155.camel@localhost.localdomain> +References: <43F38867.6010701@gpdnet.co.uk> + <1140038847.12131.155.camel@localhost.localdomain> +Comments: In-reply-to Simon Riggs + message dated "Wed, 15 Feb 2006 21:27:27 +0000" +Date: Wed, 15 Feb 2006 16:48:56 -0500 +Message-ID: <19975.1140040136@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.11 required=5 tests=[AWL=0.110] +X-Spam-Score: 0.11 +X-Spam-Level: +X-Archive-Number: 200602/222 +X-Sequence-Number: 17208 + +Simon Riggs writes: +> Please enable trace_sort=on and then repeat tests and post the +> accompanying log file. + +I did this on my Fedora machine with port/qsort.c, and got the results +attached. Curiously, this run has the spikes in completely different +places than the prior one did. So the random component of the test data +is affecting the results quite a lot. There seems absolutely no doubt +that we are looking at data-dependent qsort misbehavior, though. The +CPU time eaten by performsort accounts for all but about 100 msec of the +elapsed time reported on the psql side. + + regards, tom lane + + +LOG: begin index sort: unique = f, workMem = 16384, randomAccess = f +LOG: performsort starting: CPU 0.00s/0.15u sec elapsed 0.15 sec +LOG: performsort done: CPU 0.00s/12.43u sec elapsed 12.44 sec +LOG: internal sort ended, 9861 KB used: CPU 0.01s/12.51u sec elapsed 12.52 sec +LOG: begin index sort: unique = f, workMem = 16384, randomAccess = f +LOG: performsort starting: CPU 0.00s/0.14u sec elapsed 0.15 sec +LOG: performsort done: CPU 0.00s/0.78u sec elapsed 0.78 sec +LOG: internal sort ended, 9861 KB used: CPU 0.02s/0.85u sec elapsed 0.87 sec +LOG: begin index sort: unique = f, workMem = 16384, randomAccess = f +LOG: performsort starting: CPU 0.01s/0.14u sec elapsed 0.15 sec +LOG: performsort done: CPU 0.01s/0.96u sec elapsed 0.97 sec +LOG: internal sort ended, 9861 KB used: CPU 0.02s/1.03u sec elapsed 1.06 sec +LOG: begin index sort: unique = f, workMem = 16384, randomAccess = f +LOG: performsort starting: CPU 0.00s/0.14u sec elapsed 0.15 sec +LOG: performsort done: CPU 0.00s/0.31u sec elapsed 0.32 sec +LOG: internal sort ended, 9861 KB used: CPU 0.02s/0.38u sec elapsed 0.40 sec +LOG: begin index sort: unique = f, workMem = 16384, randomAccess = f +LOG: performsort starting: CPU 0.00s/0.14u sec elapsed 0.15 sec +LOG: performsort done: CPU 0.00s/7.91u sec elapsed 7.92 sec +LOG: internal sort ended, 9861 KB used: CPU 0.02s/7.99u sec elapsed 8.01 sec +LOG: begin index sort: unique = f, workMem = 16384, randomAccess = f +LOG: performsort starting: CPU 0.01s/0.13u sec elapsed 0.15 sec +LOG: performsort done: CPU 0.01s/0.61u sec elapsed 0.63 sec +LOG: internal sort ended, 9861 KB used: CPU 0.04s/0.67u sec elapsed 0.71 sec +LOG: begin index sort: unique = f, workMem = 16384, randomAccess = f +LOG: performsort starting: CPU 0.01s/0.13u sec elapsed 0.15 sec +LOG: performsort done: CPU 0.01s/11.52u sec elapsed 11.54 sec +LOG: internal sort ended, 9861 KB used: CPU 0.03s/11.59u sec elapsed 11.62 sec +LOG: begin index sort: unique = f, workMem = 16384, randomAccess = f +LOG: performsort starting: CPU 0.00s/0.14u sec elapsed 0.15 sec +LOG: performsort done: CPU 0.00s/0.45u sec elapsed 0.46 sec +LOG: internal sort ended, 9861 KB used: CPU 0.02s/0.55u sec elapsed 0.57 sec +LOG: begin index sort: unique = f, workMem = 16384, randomAccess = f +LOG: performsort starting: CPU 0.00s/0.14u sec elapsed 0.15 sec +LOG: performsort done: CPU 0.00s/0.45u sec elapsed 0.46 sec +LOG: internal sort ended, 9861 KB used: CPU 0.04s/0.54u sec elapsed 0.57 sec +LOG: begin index sort: unique = f, workMem = 16384, randomAccess = f +LOG: performsort starting: CPU 0.02s/0.12u sec elapsed 0.15 sec +LOG: performsort done: CPU 0.02s/0.44u sec elapsed 0.46 sec +LOG: internal sort ended, 9861 KB used: CPU 0.03s/0.55u sec elapsed 0.58 sec +LOG: begin index sort: unique = f, workMem = 16384, randomAccess = f +LOG: performsort starting: CPU 0.02s/0.13u sec elapsed 0.15 sec +LOG: performsort done: CPU 0.02s/0.44u sec elapsed 0.46 sec +LOG: internal sort ended, 9861 KB used: CPU 0.03s/0.54u sec elapsed 0.58 sec +LOG: begin index sort: unique = f, workMem = 16384, randomAccess = f +LOG: performsort starting: CPU 0.02s/0.13u sec elapsed 0.15 sec +LOG: performsort done: CPU 0.02s/0.44u sec elapsed 0.46 sec +LOG: internal sort ended, 9861 KB used: CPU 0.04s/0.54u sec elapsed 0.59 sec + +From pgsql-performance-owner@postgresql.org Wed Feb 15 17:51:45 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id DFB189DC803 + for ; + Wed, 15 Feb 2006 17:51:44 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25310-10 + for ; + Wed, 15 Feb 2006 17:51:46 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 5A6599DCB98 + for ; + Wed, 15 Feb 2006 17:51:42 -0400 (AST) +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 k1FLpNXS020006; + Wed, 15 Feb 2006 16:51:23 -0500 (EST) +To: Gary Doades +cc: pgsql-performance@postgresql.org +Subject: Re: Strange Create Index behaviour +In-reply-to: <43F39E53.1020009@gpdnet.co.uk> +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> +Comments: In-reply-to Gary Doades + message dated "Wed, 15 Feb 2006 21:34:11 +0000" +Date: Wed, 15 Feb 2006 16:51:23 -0500 +Message-ID: <20005.1140040283@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.11 required=5 tests=[AWL=0.110] +X-Spam-Score: 0.11 +X-Spam-Level: +X-Archive-Number: 200602/224 +X-Sequence-Number: 17210 + +Gary Doades writes: +> Interestingly, if I don't delete the table after a run, but just drop +> and re-create the index repeatedly it stays a pretty consistent time, +> either repeatedly good or repeatedly bad! + +This is consistent with the theory of a data-dependent performance +problem in qsort. If you don't generate a fresh set of random test +data, then you get repeatable runtimes. With a new set of test data, +you might or might not hit the not-so-sweet-spot that we seem to have +detected. + + regards, tom lane + +From pgsql-hackers-owner@postgresql.org Wed Feb 15 19:28:31 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 7C3D49DC803; + Wed, 15 Feb 2006 19:28:30 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 47149-10; Wed, 15 Feb 2006 19:28:32 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id C56AD9DC843; + Wed, 15 Feb 2006 19:28:27 -0400 (AST) +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 k1FNSTkm020782; + Wed, 15 Feb 2006 18:28:29 -0500 (EST) +To: Gary Doades +cc: pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Subject: qsort again (was Re: [PERFORM] Strange Create Index behaviour) +In-reply-to: <43F39E53.1020009@gpdnet.co.uk> +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> +Comments: In-reply-to Gary Doades + message dated "Wed, 15 Feb 2006 21:34:11 +0000" +Date: Wed, 15 Feb 2006 18:28:29 -0500 +Message-ID: <20781.1140046109@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.11 required=5 tests=[AWL=0.110] +X-Spam-Score: 0.11 +X-Spam-Level: +X-Archive-Number: 200602/589 +X-Sequence-Number: 79727 + +Gary Doades writes: +> If I run the script again, it is not always the first case that is slow, +> it varies from run to run, which is why I repeated it quite a few times +> for the test. + +For some reason I hadn't immediately twigged to the fact that your test +script is just N repetitions of the exact same structure with random data. +So it's not so surprising that you get random variations in behavior +with different test data sets. + +I did some experimentation comparing the qsort from Fedora Core 4 +(glibc-2.3.5-10.3) with our src/port/qsort.c. For those who weren't +following the pgsql-performance thread, the test case is just this +repeated a lot of times: + +create table atest(i int4, r int4); +insert into atest (i,r) select generate_series(1,100000), 0; +insert into atest (i,r) select generate_series(1,100000), random()*100000; +\timing +create index idx on atest(r); +\timing +drop table atest; + +I did this 100 times and sorted the reported runtimes. (Investigation +with trace_sort = on confirms that the runtime is almost entirely spent +in qsort() called from our performsort --- the Postgres overhead is +about 100msec on this machine.) Results are below. + +It seems clear that our qsort.c is doing a pretty awful job of picking +qsort pivots, while glibc is mostly managing not to make that mistake. +I haven't looked at the glibc code yet to see what they are doing +differently. + +I'd say this puts a considerable damper on my enthusiasm for using our +qsort all the time, as was recently debated in this thread: +http://archives.postgresql.org/pgsql-hackers/2005-12/msg00610.php +We need to fix our qsort.c before pushing ahead with that idea. + + regards, tom lane + + +100 runtimes for glibc qsort, sorted ascending: + +Time: 459.860 ms +Time: 460.209 ms +Time: 460.704 ms +Time: 461.317 ms +Time: 461.538 ms +Time: 461.652 ms +Time: 461.988 ms +Time: 462.573 ms +Time: 462.638 ms +Time: 462.716 ms +Time: 462.917 ms +Time: 463.219 ms +Time: 463.455 ms +Time: 463.650 ms +Time: 463.723 ms +Time: 463.737 ms +Time: 463.750 ms +Time: 463.852 ms +Time: 463.964 ms +Time: 463.988 ms +Time: 464.003 ms +Time: 464.135 ms +Time: 464.372 ms +Time: 464.458 ms +Time: 464.496 ms +Time: 464.551 ms +Time: 464.599 ms +Time: 464.655 ms +Time: 464.656 ms +Time: 464.722 ms +Time: 464.814 ms +Time: 464.827 ms +Time: 464.878 ms +Time: 464.899 ms +Time: 464.905 ms +Time: 464.987 ms +Time: 465.055 ms +Time: 465.138 ms +Time: 465.159 ms +Time: 465.194 ms +Time: 465.310 ms +Time: 465.316 ms +Time: 465.375 ms +Time: 465.450 ms +Time: 465.535 ms +Time: 465.595 ms +Time: 465.680 ms +Time: 465.769 ms +Time: 465.865 ms +Time: 465.892 ms +Time: 465.903 ms +Time: 466.003 ms +Time: 466.154 ms +Time: 466.164 ms +Time: 466.203 ms +Time: 466.305 ms +Time: 466.344 ms +Time: 466.364 ms +Time: 466.388 ms +Time: 466.502 ms +Time: 466.593 ms +Time: 466.725 ms +Time: 466.794 ms +Time: 466.798 ms +Time: 466.904 ms +Time: 466.971 ms +Time: 466.997 ms +Time: 467.122 ms +Time: 467.146 ms +Time: 467.221 ms +Time: 467.224 ms +Time: 467.244 ms +Time: 467.277 ms +Time: 467.587 ms +Time: 468.142 ms +Time: 468.207 ms +Time: 468.237 ms +Time: 468.471 ms +Time: 468.663 ms +Time: 468.700 ms +Time: 469.235 ms +Time: 469.840 ms +Time: 470.472 ms +Time: 471.140 ms +Time: 472.811 ms +Time: 472.959 ms +Time: 474.858 ms +Time: 477.210 ms +Time: 479.571 ms +Time: 479.671 ms +Time: 482.797 ms +Time: 488.852 ms +Time: 514.639 ms +Time: 529.287 ms +Time: 612.185 ms +Time: 660.748 ms +Time: 742.227 ms +Time: 866.814 ms +Time: 1234.848 ms +Time: 1267.398 ms + + +100 runtimes for port/qsort.c, sorted ascending: + +Time: 418.905 ms +Time: 420.611 ms +Time: 420.764 ms +Time: 420.904 ms +Time: 421.706 ms +Time: 422.466 ms +Time: 422.627 ms +Time: 423.189 ms +Time: 423.302 ms +Time: 425.096 ms +Time: 425.731 ms +Time: 425.851 ms +Time: 427.253 ms +Time: 430.113 ms +Time: 432.756 ms +Time: 432.963 ms +Time: 440.502 ms +Time: 440.640 ms +Time: 450.452 ms +Time: 458.143 ms +Time: 459.212 ms +Time: 467.706 ms +Time: 468.006 ms +Time: 468.574 ms +Time: 470.003 ms +Time: 472.313 ms +Time: 483.622 ms +Time: 492.395 ms +Time: 509.564 ms +Time: 531.037 ms +Time: 533.366 ms +Time: 535.610 ms +Time: 575.523 ms +Time: 582.688 ms +Time: 593.545 ms +Time: 647.364 ms +Time: 660.612 ms +Time: 677.312 ms +Time: 680.288 ms +Time: 697.626 ms +Time: 833.066 ms +Time: 834.511 ms +Time: 851.819 ms +Time: 920.443 ms +Time: 926.731 ms +Time: 954.289 ms +Time: 1045.214 ms +Time: 1059.200 ms +Time: 1062.328 ms +Time: 1136.018 ms +Time: 1260.091 ms +Time: 1276.883 ms +Time: 1319.351 ms +Time: 1438.854 ms +Time: 1475.457 ms +Time: 1538.211 ms +Time: 1549.004 ms +Time: 1744.642 ms +Time: 1771.258 ms +Time: 1959.530 ms +Time: 2300.140 ms +Time: 2589.641 ms +Time: 2612.780 ms +Time: 3100.024 ms +Time: 3284.125 ms +Time: 3379.792 ms +Time: 3750.278 ms +Time: 4302.278 ms +Time: 4780.624 ms +Time: 5000.056 ms +Time: 5092.604 ms +Time: 5168.722 ms +Time: 5292.941 ms +Time: 5895.964 ms +Time: 7003.164 ms +Time: 7099.449 ms +Time: 7115.083 ms +Time: 7384.940 ms +Time: 8214.010 ms +Time: 8700.771 ms +Time: 9331.225 ms +Time: 10503.360 ms +Time: 12496.026 ms +Time: 12982.474 ms +Time: 15192.390 ms +Time: 15392.161 ms +Time: 15958.295 ms +Time: 18375.693 ms +Time: 18617.706 ms +Time: 18927.515 ms +Time: 19898.018 ms +Time: 20865.979 ms +Time: 21000.907 ms +Time: 21297.585 ms +Time: 21714.518 ms +Time: 25423.235 ms +Time: 27543.052 ms +Time: 28314.182 ms +Time: 29400.278 ms +Time: 34142.534 ms + +From pgsql-performance-owner@postgresql.org Wed Feb 15 19:51:30 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 5A1A49DC803 + for ; + Wed, 15 Feb 2006 19:51:29 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 55613-10 + for ; + Wed, 15 Feb 2006 19:51:31 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smtp.nildram.co.uk (smtp.nildram.co.uk [195.112.4.54]) + by postgresql.org (Postfix) with ESMTP id 494759DC800 + for ; + Wed, 15 Feb 2006 19:51:27 -0400 (AST) +Received: from [192.168.0.5] (unknown [84.12.26.47]) + by smtp.nildram.co.uk (Postfix) with ESMTP + id 03DD5253B4D; Wed, 15 Feb 2006 23:51:26 +0000 (GMT) +Subject: Re: Strange Create Index behaviour +From: Simon Riggs +To: Tom Lane +Cc: Gary Doades , pgsql-performance@postgresql.org +In-Reply-To: <20005.1140040283@sss.pgh.pa.us> +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20005.1140040283@sss.pgh.pa.us> +Content-Type: text/plain +Date: Wed, 15 Feb 2006 23:51:21 +0000 +Message-Id: <1140047481.12131.205.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.3 (2.2.3-2.fc4) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.086 required=5 tests=[AWL=0.086] +X-Spam-Score: 0.086 +X-Spam-Level: +X-Archive-Number: 200602/227 +X-Sequence-Number: 17213 + +On Wed, 2006-02-15 at 16:51 -0500, Tom Lane wrote: +> Gary Doades writes: +> > Interestingly, if I don't delete the table after a run, but just drop +> > and re-create the index repeatedly it stays a pretty consistent time, +> > either repeatedly good or repeatedly bad! +> +> This is consistent with the theory of a data-dependent performance +> problem in qsort. If you don't generate a fresh set of random test +> data, then you get repeatable runtimes. With a new set of test data, +> you might or might not hit the not-so-sweet-spot that we seem to have +> detected. + +Agreed. Good analysis... + +Best Regards, Simon Riggs + + +From pgsql-hackers-owner@postgresql.org Wed Feb 15 19:57:33 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id D29BD9DC89F; + Wed, 15 Feb 2006 19:57:32 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 58307-02; Wed, 15 Feb 2006 19:57:35 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from server.gpdnet.co.uk (gpdnet.plus.com [212.56.100.243]) + by postgresql.org (Postfix) with ESMTP id 937819DC800; + Wed, 15 Feb 2006 19:57:30 -0400 (AST) +Received: from [192.168.1.2] (unknown [192.168.1.2]) + by server.gpdnet.co.uk (Postfix) with ESMTP id 6E4A33AAB50; + Thu, 16 Feb 2006 00:08:14 +0000 (GMT) +Message-ID: <43F3BF72.6000202@gpdnet.co.uk> +Date: Wed, 15 Feb 2006 23:55:30 +0000 +From: Gary Doades +User-Agent: Thunderbird 1.5 (Windows/20051201) +MIME-Version: 1.0 +To: Tom Lane +CC: pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Subject: Re: qsort again (was Re: [PERFORM] Strange Create Index behaviour) +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> +In-Reply-To: <20781.1140046109@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, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200602/590 +X-Sequence-Number: 79728 + +Tom Lane wrote: +> For some reason I hadn't immediately twigged to the fact that your test +> script is just N repetitions of the exact same structure with random data. +> So it's not so surprising that you get random variations in behavior +> with different test data sets. +> + > It seems clear that our qsort.c is doing a pretty awful job of picking +> qsort pivots, while glibc is mostly managing not to make that mistake. +> I haven't looked at the glibc code yet to see what they are doing +> differently. +> +> I'd say this puts a considerable damper on my enthusiasm for using our +> qsort all the time, as was recently debated in this thread: +> http://archives.postgresql.org/pgsql-hackers/2005-12/msg00610.php +> We need to fix our qsort.c before pushing ahead with that idea. + +[snip] + +> Time: 28314.182 ms +> Time: 29400.278 ms +> Time: 34142.534 ms + +Ouch! That confirms my problem. I generated the random test case because +it was easier than including the dump of my tables, but you can +appreciate that tables 20 times the size are basically crippled when it +comes to creating an index on them. + +Examining the dump and the associated times during restore it looks like +I have 7 tables with this approximate distribution, thus the +ridiculously long restore time. Better not re-index soon! + +Is this likely to hit me in a random fashion during normal operation, +joins, sorts, order by for example? + +So the options are: +1) Fix the included qsort.c code and use that +2) Get FreeBSD to fix their qsort code +3) Both + +I guess that 1 is the real solution in case anyone else's qsort is +broken in the same way. Then at least you *could* use it all the time :) + +Regards, +Gary. + + + + +From pgsql-hackers-owner@postgresql.org Wed Feb 15 20:04:48 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id DADCE9DC86D; + Wed, 15 Feb 2006 20:04:46 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 58297-08; Wed, 15 Feb 2006 20:04:49 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id C53789DC800; + Wed, 15 Feb 2006 20:04:44 -0400 (AST) +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 k1G04kGj021060; + Wed, 15 Feb 2006 19:04:46 -0500 (EST) +To: Gary Doades +cc: pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Subject: Re: qsort again (was Re: [PERFORM] Strange Create Index behaviour) +In-reply-to: <43F3BF72.6000202@gpdnet.co.uk> +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> <43F3BF72.6000202@gpdnet.co.uk> +Comments: In-reply-to Gary Doades + message dated "Wed, 15 Feb 2006 23:55:30 +0000" +Date: Wed, 15 Feb 2006 19:04:46 -0500 +Message-ID: <21059.1140048286@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.11 required=5 tests=[AWL=0.110] +X-Spam-Score: 0.11 +X-Spam-Level: +X-Archive-Number: 200602/591 +X-Sequence-Number: 79729 + +Gary Doades writes: +> Is this likely to hit me in a random fashion during normal operation, +> joins, sorts, order by for example? + +Yup, anytime you're passing data with that kind of distribution +through a sort. + +> So the options are: +> 1) Fix the included qsort.c code and use that +> 2) Get FreeBSD to fix their qsort code +> 3) Both + +> I guess that 1 is the real solution in case anyone else's qsort is +> broken in the same way. Then at least you *could* use it all the time :) + +It's reasonable to assume that most of the *BSDen have basically the +same qsort code. Ours claims to have come from NetBSD sources, but +I don't doubt that they all trace back to a common ancestor. + + regards, tom lane + +From pgsql-hackers-owner@postgresql.org Wed Feb 15 20:17:01 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id BDE8F9DCBBB; + Wed, 15 Feb 2006 20:17:00 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 62497-09; Wed, 15 Feb 2006 20:17:03 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 5A69D9DCB9E; + Wed, 15 Feb 2006 20:16:58 -0400 (AST) +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 k1G0H0ZX021153; + Wed, 15 Feb 2006 19:17:00 -0500 (EST) +To: Gary Doades +cc: pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Subject: Re: qsort again (was Re: [PERFORM] Strange Create Index behaviour) +In-reply-to: <43F3BF72.6000202@gpdnet.co.uk> +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> <43F3BF72.6000202@gpdnet.co.uk> +Comments: In-reply-to Gary Doades + message dated "Wed, 15 Feb 2006 23:55:30 +0000" +Date: Wed, 15 Feb 2006 19:17:00 -0500 +Message-ID: <21152.1140049020@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.11 required=5 tests=[AWL=0.110] +X-Spam-Score: 0.11 +X-Spam-Level: +X-Archive-Number: 200602/592 +X-Sequence-Number: 79730 + +Gary Doades writes: +> Ouch! That confirms my problem. I generated the random test case because +> it was easier than including the dump of my tables, but you can +> appreciate that tables 20 times the size are basically crippled when it +> comes to creating an index on them. + +Actually... we only use qsort when we have a sorting problem that fits +within the allowed sort memory. The external-sort logic doesn't go +through that code at all. So all the analysis we just did on your test +case doesn't necessarily apply to sort problems that are too large for +the sort_mem setting. + +The test case would be sorting 200000 index entries, which'd probably +occupy at least 24 bytes apiece of sort memory, so probably about 5 meg. +A problem 20 times that size would definitely not fit in the default +16MB maintenance_work_mem. Were you using a large value of +maintenance_work_mem for your restore? + + regards, tom lane + +From pgsql-hackers-owner@postgresql.org Wed Feb 15 20:57:58 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 82D4C9DC80D; + Wed, 15 Feb 2006 20:57:57 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 69490-08; Wed, 15 Feb 2006 20:58:00 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smtpauth08.mail.atl.earthlink.net + (smtpauth08.mail.atl.earthlink.net [209.86.89.68]) + by postgresql.org (Postfix) with ESMTP id 199F09DC800; + Wed, 15 Feb 2006 20:57:54 -0400 (AST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=ijyeM0kd7hL45wvx8YeI15Sk2zC1Bax3p0B1w2OYbs7KYln2KiuLXJ5Zv73gipDB; + 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 [71.243.43.186] (helo=ron-6d52adff2a6.earthlink.net) + by smtpauth08.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1F9XT3-0001m2-VF; Wed, 15 Feb 2006 19:57:58 -0500 +Message-Id: <7.0.1.0.2.20060215194635.03b55da0@earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 7.0.1.0 +Date: Wed, 15 Feb 2006 19:57:51 -0500 +To: Tom Lane ,pgsql-performance@postgresql.org, + pgsql-hackers@postgresql.org +From: Ron +Subject: Re: qsort again (was Re: [PERFORM] Strange Create Index +In-Reply-To: <20781.1140046109@sss.pgh.pa.us> +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bc07a0c4aa1cad9e1c345d3d6675ce820e350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 71.243.43.186 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.479 required=5 tests=[DNS_FROM_RFC_ABUSE=0.479] +X-Spam-Score: 0.479 +X-Spam-Level: +X-Archive-Number: 200602/593 +X-Sequence-Number: 79731 + +This behavior is consistent with the pivot choosing algorithm +assuming certain distribution(s) for the data. For instance, +median-of-three partitioning is known to be pessimal when the data is +geometrically or hyper-geometrically distributed. Also, care must be +taken that sometimes is not when there are many equal values in the +data. Even pseudo random number generator based pivot choosing +algorithms are not immune if the PRNG is flawed in some way. + +How are we choosing our pivots? + + +At 06:28 PM 2/15/2006, Tom Lane wrote: + +>I did some experimentation comparing the qsort from Fedora Core 4 +>(glibc-2.3.5-10.3) with our src/port/qsort.c. For those who weren't +>following the pgsql-performance thread, the test case is just this +>repeated a lot of times: +> +>create table atest(i int4, r int4); +>insert into atest (i,r) select generate_series(1,100000), 0; +>insert into atest (i,r) select generate_series(1,100000), random()*100000; +>\timing +>create index idx on atest(r); +>\timing +>drop table atest; +> +>I did this 100 times and sorted the reported runtimes. (Investigation +>with trace_sort = on confirms that the runtime is almost entirely spent +>in qsort() called from our performsort --- the Postgres overhead is +>about 100msec on this machine.) Results are below. +> +>It seems clear that our qsort.c is doing a pretty awful job of picking +>qsort pivots, while glibc is mostly managing not to make that mistake. +>I haven't looked at the glibc code yet to see what they are doing +>differently. +> +>I'd say this puts a considerable damper on my enthusiasm for using our +>qsort all the time, as was recently debated in this thread: +>http://archives.postgresql.org/pgsql-hackers/2005-12/msg00610.php +>We need to fix our qsort.c before pushing ahead with that idea. +> +> regards, tom lane +> +> +>100 runtimes for glibc qsort, sorted ascending: +> +>Time: 459.860 ms +> +>Time: 488.852 ms +>Time: 514.639 ms +>Time: 529.287 ms +>Time: 612.185 ms +>Time: 660.748 ms +>Time: 742.227 ms +>Time: 866.814 ms +>Time: 1234.848 ms +>Time: 1267.398 ms +> +> +>100 runtimes for port/qsort.c, sorted ascending: +> +>Time: 418.905 ms +> +>Time: 20865.979 ms +>Time: 21000.907 ms +>Time: 21297.585 ms +>Time: 21714.518 ms +>Time: 25423.235 ms +>Time: 27543.052 ms +>Time: 28314.182 ms +>Time: 29400.278 ms +>Time: 34142.534 ms + + + +From pgsql-hackers-owner@postgresql.org Wed Feb 15 20:59:46 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id E67AE9DCC10; + Wed, 15 Feb 2006 20:59:45 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 72204-02; Wed, 15 Feb 2006 20:59:48 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 5CCEB9DCC4F; + Wed, 15 Feb 2006 20:59:41 -0400 (AST) +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 k1G0xiiT021456; + Wed, 15 Feb 2006 19:59:44 -0500 (EST) +To: Gary Doades +cc: pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Subject: Re: qsort again (was Re: [PERFORM] Strange Create Index behaviour) +In-reply-to: <21152.1140049020@sss.pgh.pa.us> +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> <43F3BF72.6000202@gpdnet.co.uk> + <21152.1140049020@sss.pgh.pa.us> +Comments: In-reply-to Tom Lane + message dated "Wed, 15 Feb 2006 19:17:00 -0500" +Date: Wed, 15 Feb 2006 19:59:44 -0500 +Message-ID: <21455.1140051584@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.11 required=5 tests=[AWL=0.110] +X-Spam-Score: 0.11 +X-Spam-Level: +X-Archive-Number: 200602/594 +X-Sequence-Number: 79732 + +I wrote: +> Gary Doades writes: +>> Ouch! That confirms my problem. I generated the random test case because +>> it was easier than including the dump of my tables, but you can +>> appreciate that tables 20 times the size are basically crippled when it +>> comes to creating an index on them. + +> Actually... we only use qsort when we have a sorting problem that fits +> within the allowed sort memory. The external-sort logic doesn't go +> through that code at all. So all the analysis we just did on your test +> case doesn't necessarily apply to sort problems that are too large for +> the sort_mem setting. + +I increased the size of the test case by 10x (basically s/100000/1000000/) +which is enough to push it into the external-sort regime. I get +amazingly stable runtimes now --- I didn't have the patience to run 100 +trials, but in 30 trials I have slowest 11538 msec and fastest 11144 msec. +So this code path is definitely not very sensitive to this data +distribution. + +While these numbers aren't glittering in comparison to the best-case +qsort times (~450 msec to sort 10% as much data), they are sure a lot +better than the worst-case times. So maybe a workaround for you is +to decrease maintenance_work_mem, counterintuitive though that be. +(Now, if you *weren't* using maintenance_work_mem of 100MB or more +for your problem restore, then I'm not sure I know what's going on...) + +We still ought to try to fix qsort of course. + + regards, tom lane + +From pgsql-hackers-owner@postgresql.org Wed Feb 15 21:21:36 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 3DAA69DCACE; + Wed, 15 Feb 2006 21:21:34 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 76351-01; Wed, 15 Feb 2006 21:21:36 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 2FBB59DCA3F; + Wed, 15 Feb 2006 21:21:31 -0400 (AST) +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 k1G1LXXi021616; + Wed, 15 Feb 2006 20:21:33 -0500 (EST) +To: Ron +cc: pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Subject: Re: qsort again (was Re: [PERFORM] Strange Create Index behaviour) +In-reply-to: <7.0.1.0.2.20060215194635.03b55da0@earthlink.net> +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> + <7.0.1.0.2.20060215194635.03b55da0@earthlink.net> +Comments: In-reply-to Ron + message dated "Wed, 15 Feb 2006 19:57:51 -0500" +Date: Wed, 15 Feb 2006 20:21:33 -0500 +Message-ID: <21615.1140052893@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.11 required=5 tests=[AWL=0.110] +X-Spam-Score: 0.11 +X-Spam-Level: +X-Archive-Number: 200602/595 +X-Sequence-Number: 79733 + +Ron writes: +> How are we choosing our pivots? + +See qsort.c: it looks like median of nine equally spaced inputs (ie, +the 1/8th points of the initial input array, plus the end points), +implemented as two rounds of median-of-three choices. With half of the +data inputs zero, it's not too improbable for two out of the three +samples to be zeroes in which case I think the med3 result will be zero +--- so choosing a pivot of zero is much more probable than one would +like, and doing so in many levels of recursion causes the problem. + +I think. I'm not too sure if the code isn't just being sloppy about the +case where many data values are equal to the pivot --- there's a special +case there to switch to insertion sort, and maybe that's getting invoked +too soon. It'd be useful to get a line-level profile of the behavior of +this code in the slow cases... + + regards, tom lane + +From pgsql-hackers-owner@postgresql.org Wed Feb 15 21:37:58 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 7BB8A9DCC4F; + Wed, 15 Feb 2006 21:37:57 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 79365-02; Wed, 15 Feb 2006 21:38:00 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from postal.corporate.connx.com (postal.corporate.connx.com + [65.212.159.187]) + by postgresql.org (Postfix) with ESMTP id 33BEA9DCACE; + Wed, 15 Feb 2006 21:37:54 -0400 (AST) +X-MimeOLE: Produced By Microsoft Exchange V6.5 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: qsort again (was Re: [PERFORM] Strange Create Index behaviour) +Date: Wed, 15 Feb 2006 17:37:58 -0800 +Message-ID: + +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [HACKERS] qsort again (was Re: [PERFORM] Strange Create Index + behaviour) +Thread-Index: AcYyl2fPgxfNXHIRRyOEN4ZGeHtA3wAAEaNQ +From: "Dann Corbit" +To: "Tom Lane" , + "Ron" +Cc: , + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.075 required=5 tests=[AWL=0.075] +X-Spam-Score: 0.075 +X-Spam-Level: +X-Archive-Number: 200602/597 +X-Sequence-Number: 79735 + + + +> -----Original Message----- +> From: pgsql-hackers-owner@postgresql.org [mailto:pgsql-hackers- +> owner@postgresql.org] On Behalf Of Tom Lane +> Sent: Wednesday, February 15, 2006 5:22 PM +> To: Ron +> Cc: pgsql-performance@postgresql.org; pgsql-hackers@postgresql.org +> Subject: Re: [HACKERS] qsort again (was Re: [PERFORM] Strange Create +Index +> behaviour) +>=20 +> Ron writes: +> > How are we choosing our pivots? +>=20 +> See qsort.c: it looks like median of nine equally spaced inputs (ie, +> the 1/8th points of the initial input array, plus the end points), +> implemented as two rounds of median-of-three choices. With half of +the +> data inputs zero, it's not too improbable for two out of the three +> samples to be zeroes in which case I think the med3 result will be +zero +> --- so choosing a pivot of zero is much more probable than one would +> like, and doing so in many levels of recursion causes the problem. + +Adding some randomness to the selection of the pivot is a known +technique to fix the oddball partitions problem. However, Bentley and +Sedgewick proved that every quick sort algorithm has some input set that +makes it go quadratic (hence the recent popularity of introspective +sort, which switches to heapsort if quadratic behavior is detected. The +C++ template I submitted was an example of introspective sort, but +PostgreSQL does not use C++ so it was not helpful). + +> I think. I'm not too sure if the code isn't just being sloppy about +the +> case where many data values are equal to the pivot --- there's a +special +> case there to switch to insertion sort, and maybe that's getting +invoked +> too soon. =20 + +Here are some cases known to make qsort go quadratic: +1. Data already sorted +2. Data reverse sorted +3. Data organ-pipe sorted or ramp +4. Almost all data of the same value + +There are probably other cases. Randomizing the pivot helps some, as +does check for in-order or reverse order partitions. + +Imagine if 1/3 of the partitions fall into a category that causes +quadratic behavior (have one of the above formats and have more than +CUTOFF elements in them). + +It is doubtful that the switch to insertion sort is causing any sort of +problems. It is only going to be invoked on tiny sets, for which it has +a fixed cost that is probably less that qsort() function calls on sets +of the same size. + +>It'd be useful to get a line-level profile of the behavior of +> this code in the slow cases... + +I guess that my in-order or presorted tests [which often arise when +there are very few distinct values] may solve the bad partition +problems. Don't forget that the algorithm is called recursively. + +> regards, tom lane +>=20 +> ---------------------------(end of +broadcast)--------------------------- +> TIP 3: Have you checked our extensive FAQ? +>=20 +> http://www.postgresql.org/docs/faq + +From pgsql-performance-owner@postgresql.org Wed Feb 15 21:53:02 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 2E6D29DC89F + for ; + Wed, 15 Feb 2006 21:53:02 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 82844-01 + for ; + Wed, 15 Feb 2006 21:53:05 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smtp.nildram.co.uk (smtp.nildram.co.uk [195.112.4.54]) + by postgresql.org (Postfix) with ESMTP id 52E269DCC8D + for ; + Wed, 15 Feb 2006 21:52:59 -0400 (AST) +Received: from [192.168.0.5] (unknown [84.12.26.47]) + by smtp.nildram.co.uk (Postfix) with ESMTP + id BE51E2520EF; Thu, 16 Feb 2006 01:52:17 +0000 (GMT) +Subject: Re: Strange Create Index behaviour +From: Simon Riggs +To: Gary Doades +Cc: pgsql-performance@postgresql.org +In-Reply-To: <43F38867.6010701@gpdnet.co.uk> +References: <43F38867.6010701@gpdnet.co.uk> +Content-Type: text/plain +Date: Thu, 16 Feb 2006 01:52:09 +0000 +Message-Id: <1140054729.12131.225.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.3 (2.2.3-2.fc4) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.086 required=5 tests=[AWL=0.086] +X-Spam-Score: 0.086 +X-Spam-Level: +X-Archive-Number: 200602/235 +X-Sequence-Number: 17221 + +On Wed, 2006-02-15 at 20:00 +0000, Gary Doades wrote: + +> I have put together a test case that demonstrates the problem (see +> below). I create a simple table, as close in structure to one of my +> problem tables and populate an integer column with 100,000 zeros follow +> by 100,000 random integers between 0 and 100,000. Then create an index +> on this column. I then drop the table and repeat. The create index +> should take around 1-2 seconds. A fair proportion of the time it takes +> 50 seconds!!! +> +> If I fill the same row with all random data the create index always +> takes a second or two. If I fill the column with all zeros everything is +> still OK. + +Aside from the importance of investigating sort behaviour, have you +tried to build a partial index WHERE col > 0 ? That way you wouldn't +even be indexing the zeros. + +Best Regards, Simon Riggs + + + + +From pgsql-hackers-owner@postgresql.org Wed Feb 15 21:50:53 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 6877C9DCCA8; + Wed, 15 Feb 2006 21:50:51 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 77787-10; Wed, 15 Feb 2006 21:50:55 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from houston.familyhealth.com.au (houston.au.fhnetwork.com + [203.22.197.21]) + by postgresql.org (Postfix) with ESMTP id 991AD9DCC99; + Wed, 15 Feb 2006 21:50:48 -0400 (AST) +Received: from houston.familyhealth.com.au (localhost [127.0.0.1]) + by houston.familyhealth.com.au (Postfix) with ESMTP id DA4242508A; + Thu, 16 Feb 2006 09:50:49 +0800 (WST) +Received: from [127.0.0.1] (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (Postfix) with ESMTP id 09A612506B; + Thu, 16 Feb 2006 09:50:46 +0800 (WST) +Message-ID: <43F3DAEE.30002@familyhealth.com.au> +Date: Thu, 16 Feb 2006 09:52:46 +0800 +From: Christopher Kings-Lynne +User-Agent: Thunderbird 1.5 (Windows/20051201) +MIME-Version: 1.0 +To: Gary Doades +Cc: Tom Lane , pgsql-performance@postgresql.org, + pgsql-hackers@postgresql.org +Subject: Re: qsort again (was Re: [PERFORM] Strange Create Index behaviour) +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> <43F3BF72.6000202@gpdnet.co.uk> +In-Reply-To: <43F3BF72.6000202@gpdnet.co.uk> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-familyhealth-MailScanner-Information: Please contact the ISP for more + information +X-familyhealth-MailScanner: Found to be clean +X-familyhealth-MailScanner-From: chriskl@familyhealth.com.au +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.093 required=5 tests=[AWL=0.093] +X-Spam-Score: 0.093 +X-Spam-Level: +X-Archive-Number: 200602/599 +X-Sequence-Number: 79737 + +> Ouch! That confirms my problem. I generated the random test case because +> it was easier than including the dump of my tables, but you can +> appreciate that tables 20 times the size are basically crippled when it +> comes to creating an index on them. + + +I have to say that I restored a few gigabyte dump on freebsd the other +day, and most of the restore time was in index creation - I didn't think +too much of it though at the time. FreeBSD 4.x. + +Chris + + +From pgsql-hackers-owner@postgresql.org Wed Feb 15 21:57:04 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id CE38D9DCC96; + Wed, 15 Feb 2006 21:57:03 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81626-07; Wed, 15 Feb 2006 21:57:07 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smtp.nildram.co.uk (smtp.nildram.co.uk [195.112.4.54]) + by postgresql.org (Postfix) with ESMTP id B87879DCC68; + Wed, 15 Feb 2006 21:57:01 -0400 (AST) +Received: from [192.168.0.5] (unknown [84.12.26.47]) + by smtp.nildram.co.uk (Postfix) with ESMTP + id 54D912526A2; Thu, 16 Feb 2006 01:57:05 +0000 (GMT) +Subject: Re: qsort again (was Re: [PERFORM] Strange Create Index +From: Simon Riggs +To: Tom Lane +Cc: Gary Doades , pgsql-performance@postgresql.org, + pgsql-hackers@postgresql.org +In-Reply-To: <21455.1140051584@sss.pgh.pa.us> +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> <43F3BF72.6000202@gpdnet.co.uk> + <21152.1140049020@sss.pgh.pa.us> <21455.1140051584@sss.pgh.pa.us> +Content-Type: text/plain; charset=utf-8 +Date: Thu, 16 Feb 2006 01:56:55 +0000 +Message-Id: <1140055015.12131.232.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.3 (2.2.3-2.fc4) +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.086 required=5 tests=[AWL=0.086] +X-Spam-Score: 0.086 +X-Spam-Level: +X-Archive-Number: 200602/600 +X-Sequence-Number: 79738 + +On Wed, 2006-02-15 at 19:59 -0500, Tom Lane wrote: + +> I get +> amazingly stable runtimes now --- I didn't have the patience to run 100 +> trials, but in 30 trials I have slowest 11538 msec and fastest 11144 msec. +> So this code path is definitely not very sensitive to this data +> distribution. + +"The worst-case behavior of replacement-selection is very close to its +average behavior, while the worst-case behavior of QuickSort is terrible +(N2) – a strong argument in favor of replacement-selection. Despite this +risk, QuickSort is widely used because, in practice, it has superior +performance." p.8, "AlphaSort: A Cache-Sensitive Parallel External +Sort", Nyberg et al, VLDB Journal 4(4): 603-627 (1995) + +I think your other comment about flipping to insertion sort too early +(and not returning...) is a plausible cause for the poor pg qsort +behaviour, but the overall spread of values seems as expected. + +Some test results I've seen seem consistent with the view that +increasing memory also increases run-time for larger settings of +work_mem/maintenance_work_mem. Certainly, as I observed a while back, +having a large memory settings doesn't help you at all when you are +doing final run merging on the external sort. Whatever we do, we should +look at the value high memory settings bring to each phase of a sort +separately from the other phases. + +There is work underway on improving external sorts, so I hear (not me). +Plus my WIP on randomAccess requirements. + +Best Regards, Simon Riggs + + + + +From pgsql-hackers-owner@postgresql.org Wed Feb 15 22:12:17 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id C56ED9DCB67; + Wed, 15 Feb 2006 22:12:15 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 83875-09; Wed, 15 Feb 2006 22:12:19 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mailbox.samurai.com (mailbox.samurai.com [205.207.28.82]) + by postgresql.org (Postfix) with ESMTP id 929CC9DC940; + Wed, 15 Feb 2006 22:12:13 -0400 (AST) +Received: from localhost (mailbox.samurai.com [205.207.28.82]) + by mailbox.samurai.com (Postfix) with ESMTP id 88AAB2394F3; + Wed, 15 Feb 2006 21:12:17 -0500 (EST) +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 10882-01-7; Wed, 15 Feb 2006 21:12:16 -0500 (EST) +Received: from [192.168.1.102] (d226-82-205.home.cgocable.net [24.226.82.205]) + by mailbox.samurai.com (Postfix) with ESMTP id ECD952394B0; + Wed, 15 Feb 2006 21:12:15 -0500 (EST) +Subject: Re: qsort again (was Re: [PERFORM] Strange Create Index +From: Neil Conway +To: Tom Lane +Cc: Gary Doades , pgsql-performance@postgresql.org, + pgsql-hackers@postgresql.org +In-Reply-To: <20781.1140046109@sss.pgh.pa.us> +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> +Content-Type: text/plain +Date: Wed, 15 Feb 2006 21:12:52 -0500 +Message-Id: <1140055972.31672.42.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.4.1 +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, score=0.061 required=5 tests=[AWL=0.061] +X-Spam-Score: 0.061 +X-Spam-Level: +X-Archive-Number: 200602/601 +X-Sequence-Number: 79739 + +On Wed, 2006-02-15 at 18:28 -0500, Tom Lane wrote: +> It seems clear that our qsort.c is doing a pretty awful job of picking +> qsort pivots, while glibc is mostly managing not to make that mistake. +> I haven't looked at the glibc code yet to see what they are doing +> differently. + +glibc qsort is actually merge sort, so I'm not surprised it avoids this +problem. + +-Neil + + + +From pgsql-hackers-owner@postgresql.org Wed Feb 15 23:31:53 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 610139DCB10 + for ; + Wed, 15 Feb 2006 23:31:52 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 99167-08 + for ; + Wed, 15 Feb 2006 23:31:56 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id DDF079DC940 + for ; + Wed, 15 Feb 2006 23:31:49 -0400 (AST) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 9CBBF3093D; Thu, 16 Feb 2006 04:31:54 +0100 (MET) +From: "Qingqing Zhou" +X-Newsgroups: pgsql.hackers +Subject: Re: qsort again (was Re: [PERFORM] Strange Create Index behaviour) +Date: Thu, 16 Feb 2006 11:28:37 +0800 +Organization: Hub.Org Networking Services +Lines: 89 +Message-ID: +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> +X-Complaints-To: usenet@news.hub.org +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2800.1506 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506 +To: pgsql-hackers@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.162 required=5 tests=[AWL=0.162] +X-Spam-Score: 0.162 +X-Spam-Level: +X-Archive-Number: 200602/602 +X-Sequence-Number: 79740 + + +"Tom Lane" wrote +> +> I did this 100 times and sorted the reported runtimes. +> +> I'd say this puts a considerable damper on my enthusiasm for using our +> qsort all the time, as was recently debated in this thread: +> http://archives.postgresql.org/pgsql-hackers/2005-12/msg00610.php +> +> 100 runtimes for glibc qsort, sorted ascending: +> +> Time: 866.814 ms +> Time: 1234.848 ms +> Time: 1267.398 ms +> +> 100 runtimes for port/qsort.c, sorted ascending: +> +> Time: 28314.182 ms +> Time: 29400.278 ms +> Time: 34142.534 ms +> + +By "did this 100 times" do you mean generate a sequence of at most +200000*100 numbers, and for every 200000 numbers, the first half are all +zeros and the other half are uniform random numbers? I tried to confirm it +by patching the program mentioned in the link, but seems BSDqsort is still a +little bit leading. + +Regards, +Qingqing + +--- +Result + +sort#./sort +[3] [glibc qsort]: nelem(20000000), range(4294901760) distr(halfhalf) +ccost(2) : 18887.285000 ms +[3] [BSD qsort]: nelem(20000000), range(4294901760) distr(halfhalf) ccost(2) +: 18801.018000 ms +[3] [qsortG]: nelem(20000000), range(4294901760) distr(halfhalf) ccost(2) : +22997.004000 ms + +--- +Patch to sort.c + +sort#diff -c sort.c sort1.c +*** sort.c Thu Dec 15 12:18:59 2005 +--- sort1.c Wed Feb 15 22:21:15 2006 +*************** +*** 35,43 **** + {"BSD qsort", qsortB}, + {"qsortG", qsortG} + }; +! static const size_t d_nelem[] = {1000, 10000, 100000, 1000000, 5000000}; +! static const size_t d_range[] = {2, 32, 1024, 0xFFFF0000L}; +! static const char *d_distr[] = {"uniform", "gaussian", "95sorted", +"95reversed"}; + static const size_t d_ccost[] = {2}; + + /* factor index */ +--- 35,43 ---- + {"BSD qsort", qsortB}, + {"qsortG", qsortG} + }; +! static const size_t d_nelem[] = {5000000, 10000000, 20000000}; +! static const size_t d_range[] = {0xFFFF0000L}; +! static const char *d_distr[] = {"halfhalf"}; + static const size_t d_ccost[] = {2}; + + /* factor index */ +*************** +*** 180,185 **** +--- 180,192 ---- + swap(karray[i], karray[nelem-i-1]); + } + } ++ else if (!strcmp(distr, "halfhalf")) ++ { ++ int j; ++ for (i = 0; i < nelem/200000; i++) ++ for (j = 0; j < 100000; j++) ++ karray[i*200000 + j] = 0; ++ } + + return array; + } + + + + +From pgsql-hackers-owner@postgresql.org Thu Feb 16 00:31:04 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id E4D7A9DCCA2; + Thu, 16 Feb 2006 00:31:03 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 10324-09; Thu, 16 Feb 2006 00:31:01 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from elasmtp-mealy.atl.sa.earthlink.net + (elasmtp-mealy.atl.sa.earthlink.net [209.86.89.69]) + by postgresql.org (Postfix) with ESMTP id 3BA029DCC96; + Thu, 16 Feb 2006 00:31:01 -0400 (AST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=oL0d4S1ZzNMAlCfnB1LTFgtlDtAfr/OAnYQjN3EEB1STiNUBi+fdmjmVpUavYTYF; + 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 [71.243.43.186] (helo=ron-6d52adff2a6.earthlink.net) + by elasmtp-mealy.atl.sa.earthlink.net with asmtp (Exim 4.34) + id 1F9anD-0001N0-Ie; Wed, 15 Feb 2006 23:30:59 -0500 +Message-Id: <7.0.1.0.2.20060215223710.03a7c618@earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 7.0.1.0 +Date: Wed, 15 Feb 2006 23:30:54 -0500 +To: Tom Lane ,pgsql-performance@postgresql.org, + pgsql-hackers@postgresql.org +From: Ron +Subject: Re: qsort again (was Re: [PERFORM] Strange Create Index +In-Reply-To: <21615.1140052893@sss.pgh.pa.us> +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> + <7.0.1.0.2.20060215194635.03b55da0@earthlink.net> + <21615.1140052893@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bca6f44825382ee1f33278a6f9053419f7350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 71.243.43.186 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.479 required=5 tests=[AWL=0.000, + DNS_FROM_RFC_ABUSE=0.479] +X-Spam-Score: 0.479 +X-Spam-Level: +X-Archive-Number: 200602/603 +X-Sequence-Number: 79741 + +At 08:21 PM 2/15/2006, Tom Lane wrote: +>Ron writes: +> > How are we choosing our pivots? +> +>See qsort.c: it looks like median of nine equally spaced inputs (ie, +>the 1/8th points of the initial input array, plus the end points), +>implemented as two rounds of median-of-three choices. + +OK, this is a bad way to do median-of-n partitioning for a few +reasons. See Sedgewick's PhD thesis for details. + +Basically, if one is using median-of-n partitioning to choose a +pivot, one should do it in =one= pass, and n for that pass should be +<= the numbers of registers in the CPU. Since the x86 ISA has 8 +GPR's, n should be <= 8. 7 for instance. + +Special purposing the median-of-n code so that the minimal number of +comparisons and moves is used to sort the sample and then +"partitioning in place" is the best way to do it. In addition, care +must be taken to deal with the possibility that many of the keys may be equal. + +The (pseudo) code looks something like this: + +qs(a[],L,R){ +if((R-L) > SAMPLE_SIZE){ // Not worth using qs for too few elements + SortSample(SAMPLE_SIZE,a[],L,R); + // Sorts SAMPLE_SIZE= n elements and does median-of-n +partitioning for small n + // using the minimal number of comparisons and moves. + // In the process it ends up partitioning the first n/2 and last +n/2 elements + // SAMPLE_SIZE is a constant chosen to work best for a given CPU. + // #GPRs - 1 is a good initial guess. + // For the x86 ISA, #GPRs - 1 = 7. For native x86-64, it's 15. + // For most RISC CPUs it's 31 or 63. For Itanium, it's 127 (!) + pivot= a[(L+R)>>1]; i= L+(SAMPLE_SIZE>>1); j= R-(SAMPLE_SIZE>>1); + for(;;){ + while(a[++i] < pivot); + while(a[--j] > pivot); + if(i >= j) break; + if(a[i] > a[j]) swap(a[i],a[j]); + } + if((i-R) >= (j-L)){qs(a,L,i-1);} + else{qs(a,i,R);} +else{OofN^2_Sort(a,L,R);} +// SelectSort may be better than InsertSort if KeySize in bits << +RecordSize in bits +} // End of qs + +Given that the most common CPU ISA in existence has 8 GPRs, +SAMPLE_SIZE= 7 is probably optimal: +t= (L+R); +the set would be {L; t/8; t/4; t/2; 3*t/4; 7*t/8; R;} +==> {L; t>>3; t>>2; t>>1; (3*t)>>2; (7*t)>>3; R} as the locations. +Even better (and more easily scaled as the number of GPR's in the CPU +changes) is to use +the set {L; L+1; L+2; t>>1; R-2; R-1; R} +This means that instead of 7 random memory accesses, we have 3; two +of which result in a +burst access for three elements each. +That's much faster; _and_ using a sample of 9, 15, 31, 63, etc (to +max of ~GPRs -1) elements is more easily done. + +It also means that the work we do sorting the sample can be taken +advantage of when starting +inner loop of quicksort: items L..L+2, t, and R-2..R are already +partitioned by SortSample(). + +Insuring that the minimum number of comparisons and moves is done in +SortSample can be down by using a code generator to create a +comparison tree that identifies which permutation(s) of n we are +dealing with and then moving them into place with the minimal number of moves. + +SIDE NOTE: IIRC glibc's qsort is actually merge sort. Merge sort +performance is insensitive to all inputs, and there are way to +optimize it as well. + +I'll leave the actual coding to someone who knows the pg source +better than I do. +Ron + + + +From pgsql-hackers-owner@postgresql.org Thu Feb 16 00:40:28 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 144699DCCB8 + for ; + Thu, 16 Feb 2006 00:40:28 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 12942-07 + for ; + Thu, 16 Feb 2006 00:40:26 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id CF9979DCC90 + for ; + Thu, 16 Feb 2006 00:40:24 -0400 (AST) +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 k1G4eKig023108; + Wed, 15 Feb 2006 23:40:20 -0500 (EST) +To: "Qingqing Zhou" +cc: pgsql-hackers@postgresql.org +Subject: Re: qsort again (was Re: [PERFORM] Strange Create Index behaviour) +In-reply-to: +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> +Comments: In-reply-to "Qingqing Zhou" + message dated "Thu, 16 Feb 2006 11:28:37 +0800" +Date: Wed, 15 Feb 2006 23:40:20 -0500 +Message-ID: <23107.1140064820@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.11 required=5 tests=[AWL=0.110] +X-Spam-Score: 0.11 +X-Spam-Level: +X-Archive-Number: 200602/604 +X-Sequence-Number: 79742 + +"Qingqing Zhou" writes: +> By "did this 100 times" do you mean generate a sequence of at most +> 200000*100 numbers, and for every 200000 numbers, the first half are all +> zeros and the other half are uniform random numbers? + +No, I mean I ran the bit of SQL script I gave 100 separate times. + + regards, tom lane + +From pgsql-hackers-owner@postgresql.org Thu Feb 16 00:51:13 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 8BA409DCCC4 + for ; + Thu, 16 Feb 2006 00:51:12 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 16577-04 + for ; + Thu, 16 Feb 2006 00:51:11 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id 41EC69DCCC3 + for ; + Thu, 16 Feb 2006 00:51:10 -0400 (AST) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 874BF3093C; Thu, 16 Feb 2006 05:51:08 +0100 (MET) +From: "Qingqing Zhou" +X-Newsgroups: pgsql.hackers +Subject: Re: qsort again (was Re: [PERFORM] Strange Create Index behaviour) +Date: Thu, 16 Feb 2006 12:47:50 +0800 +Organization: Hub.Org Networking Services +Lines: 17 +Message-ID: +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> + <23107.1140064820@sss.pgh.pa.us> +X-Complaints-To: usenet@news.hub.org +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2800.1506 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506 +To: pgsql-hackers@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.161 required=5 tests=[AWL=0.161] +X-Spam-Score: 0.161 +X-Spam-Level: +X-Archive-Number: 200602/605 +X-Sequence-Number: 79743 + + +"Tom Lane" wrote +> "Qingqing Zhou" writes: +> > By "did this 100 times" do you mean generate a sequence of at most +> > 200000*100 numbers, and for every 200000 numbers, the first half are all +> > zeros and the other half are uniform random numbers? +> +> No, I mean I ran the bit of SQL script I gave 100 separate times. +> + +I must misunderstand something here -- I can't figure out that why the cost +of the same procedure keep climbing? + +Regards, +Qingqing + + + +From pgsql-hackers-owner@postgresql.org Thu Feb 16 00:54:53 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id CDFC89DC98D + for ; + Thu, 16 Feb 2006 00:54:52 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 15793-09 + for ; + Thu, 16 Feb 2006 00:54:51 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id A24119DC890 + for ; + Thu, 16 Feb 2006 00:54:50 -0400 (AST) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 2A13C3093C; Thu, 16 Feb 2006 05:54:50 +0100 (MET) +From: "Qingqing Zhou" +X-Newsgroups: pgsql.hackers +Subject: Re: qsort again (was Re: [PERFORM] Strange Create Index behaviour) +Date: Thu, 16 Feb 2006 12:51:32 +0800 +Organization: Hub.Org Networking Services +Lines: 14 +Message-ID: +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> + <23107.1140064820@sss.pgh.pa.us> +X-Complaints-To: usenet@news.hub.org +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2800.1506 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506 +To: pgsql-hackers@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.161 required=5 tests=[AWL=0.161] +X-Spam-Score: 0.161 +X-Spam-Level: +X-Archive-Number: 200602/606 +X-Sequence-Number: 79744 + + +"Qingqing Zhou" wrote +> +> I must misunderstand something here -- I can't figure out that why the +cost +> of the same procedure keep climbing? +> + +Ooops, I mis-intepret the sentence -- you sorted the results ... + +Regards, +Qingqing + + + +From pgsql-hackers-owner@postgresql.org Thu Feb 16 00:54:59 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 577299DC9F6 + for ; + Thu, 16 Feb 2006 00:54:58 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 19571-01 + for ; + Thu, 16 Feb 2006 00:54:57 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 1903D9DC9CC + for ; + Thu, 16 Feb 2006 00:54:55 -0400 (AST) +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 k1G4ss3c023298; + Wed, 15 Feb 2006 23:54:54 -0500 (EST) +To: "Qingqing Zhou" +cc: pgsql-hackers@postgresql.org +Subject: Re: qsort again (was Re: [PERFORM] Strange Create Index behaviour) +In-reply-to: +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> + <23107.1140064820@sss.pgh.pa.us> +Comments: In-reply-to "Qingqing Zhou" + message dated "Thu, 16 Feb 2006 12:47:50 +0800" +Date: Wed, 15 Feb 2006 23:54:54 -0500 +Message-ID: <23297.1140065694@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.11 required=5 tests=[AWL=0.110] +X-Spam-Score: 0.11 +X-Spam-Level: +X-Archive-Number: 200602/607 +X-Sequence-Number: 79745 + +"Qingqing Zhou" writes: +> "Tom Lane" wrote +>> No, I mean I ran the bit of SQL script I gave 100 separate times. + +> I must misunderstand something here -- I can't figure out that why the cost +> of the same procedure keep climbing? + +No, the run cost varies randomly depending on the random data supplied +by the test script. The reason the numbers are increasing is that I +sorted them for ease of inspection. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Feb 16 06:55:53 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 8BDDA9DC813 + for ; + Thu, 16 Feb 2006 06:55:52 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 55463-06 + for ; + Thu, 16 Feb 2006 06:55:53 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from server.gpdnet.co.uk (gpdnet.plus.com [212.56.100.243]) + by postgresql.org (Postfix) with ESMTP id B66319DC819 + for ; + Thu, 16 Feb 2006 06:55:47 -0400 (AST) +Received: from www.gpdnet.co.uk (server.gpdnet.co.uk [127.0.0.1]) + by server.gpdnet.co.uk (Postfix) with ESMTP id BF4233AAB6B; + Thu, 16 Feb 2006 11:06:32 +0000 (GMT) +Received: from 84.92.210.49 (SquirrelMail authenticated user gpd) + by www.gpdnet.co.uk with HTTP; Thu, 16 Feb 2006 11:06:32 -0000 (GMT) +Message-ID: <2417.84.92.210.49.1140087992.squirrel@www.gpdnet.co.uk> +In-Reply-To: <21455.1140051584@sss.pgh.pa.us> +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> <43F3BF72.6000202@gpdnet.co.uk> + <21152.1140049020@sss.pgh.pa.us> <21455.1140051584@sss.pgh.pa.us> +Date: Thu, 16 Feb 2006 11:06:32 -0000 (GMT) +Subject: Re: [HACKERS] qsort again (was Re: Strange Create Index +From: "Gary Doades" +To: "Tom Lane" +Cc: pgsql-performance@postgresql.org +Reply-To: gpd@gpdnet.co.uk +User-Agent: SquirrelMail/1.4.6 [CVS]-0.cvs20050812.1.fc4 +MIME-Version: 1.0 +Content-Type: text/plain;charset=iso-8859-15 +Content-Transfer-Encoding: 8bit +X-Priority: 3 (Normal) +Importance: Normal +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.111 required=5 tests=[AWL=0.111] +X-Spam-Score: 0.111 +X-Spam-Level: +X-Archive-Number: 200602/239 +X-Sequence-Number: 17225 + +Tom Lane wrote: +> I increased the size of the test case by 10x (basically s/100000/1000000/) +> which is enough to push it into the external-sort regime. I get +> amazingly stable runtimes now --- I didn't have the patience to run 100 +> trials, but in 30 trials I have slowest 11538 msec and fastest 11144 msec. +> So this code path is definitely not very sensitive to this data +> distribution. +> +> While these numbers aren't glittering in comparison to the best-case +> qsort times (~450 msec to sort 10% as much data), they are sure a lot +> better than the worst-case times. So maybe a workaround for you is +> to decrease maintenance_work_mem, counterintuitive though that be. +> (Now, if you *weren't* using maintenance_work_mem of 100MB or more +> for your problem restore, then I'm not sure I know what's going on...) +> + +Good call. I basically reversed your test by keeping the number of rows +the same (200000), but reducing maintenance_work_mem. Reducing to 8192 +made no real difference. Reducing to 4096 flattened out all the times +nicely. Slower overall, but at least predictable. Hopefully only a +temporary solution until qsort is fixed. + +My restore now takes 22 minutes :) + +I think the reason I wasn't seeing performance issues with normal sort +operations is because they use work_mem not maintenance_work_mem which was +only set to 2048 anyway. Does that sound right? + +Regards, +Gary. + + + +From pgsql-performance-owner@postgresql.org Thu Feb 16 07:35:21 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id BD2CF9DC813 + for ; + Thu, 16 Feb 2006 07:35:20 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 63485-10 + for ; + Thu, 16 Feb 2006 07:35:22 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from cassarossa.samfundet.no (cassarossa.samfundet.no + [129.241.93.19]) + by postgresql.org (Postfix) with ESMTP id BAA4D9DC80D + for ; + Thu, 16 Feb 2006 07:35:17 -0400 (AST) +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 1F9hPq-00047b-ON + for pgsql-performance@postgresql.org; Thu, 16 Feb 2006 12:35:19 +0100 +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1F9hPu-0000vG-00 + for ; Thu, 16 Feb 2006 12:35:22 +0100 +Date: Thu, 16 Feb 2006 12:35:22 +0100 +From: "Steinar H. Gunderson" +To: pgsql-performance@postgresql.org +Subject: Re: qsort again (was Re: Strange Create Index +Message-ID: <20060216113522.GA3461@uio.no> +Mail-Followup-To: pgsql-performance@postgresql.org +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> + <7.0.1.0.2.20060215194635.03b55da0@earthlink.net> + <21615.1140052893@sss.pgh.pa.us> + <7.0.1.0.2.20060215223710.03a7c618@earthlink.net> +MIME-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Disposition: inline +In-Reply-To: <7.0.1.0.2.20060215223710.03a7c618@earthlink.net> +X-Operating-System: Linux 2.6.14.3 on a x86_64 +X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ +User-Agent: Mutt/1.5.11+cvs20060126 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.078 required=5 tests=[AWL=0.078] +X-Spam-Score: 0.078 +X-Spam-Level: +X-Archive-Number: 200602/240 +X-Sequence-Number: 17226 + +On Wed, Feb 15, 2006 at 11:30:54PM -0500, Ron wrote: +> Even better (and more easily scaled as the number of GPR's in the CPU +> changes) is to use +> the set {L; L+1; L+2; t>>1; R-2; R-1; R} +> This means that instead of 7 random memory accesses, we have 3; two +> of which result in a +> burst access for three elements each. + +Isn't that improvement going to disappear competely if you choose a bad +pivot? + +> SIDE NOTE: IIRC glibc's qsort is actually merge sort. Merge sort +> performance is insensitive to all inputs, and there are way to +> optimize it as well. + +glibc-2.3.5/stdlib/qsort.c: + + /* Order size using quicksort. This implementation incorporates + four optimizations discussed in Sedgewick: + +I can't see any references to merge sort in there at all. + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-hackers-owner@postgresql.org Thu Feb 16 08:11:03 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id B6EFC9DCACD; + Thu, 16 Feb 2006 08:11:01 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 73062-03; Thu, 16 Feb 2006 08:11:04 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.enyo.de (mail.enyo.de [212.9.189.167]) + by postgresql.org (Postfix) with ESMTP id 7A5A79DC9F1; + Thu, 16 Feb 2006 08:10:59 -0400 (AST) +Received: from deneb.vpn.enyo.de ([212.9.189.177] helo=deneb.enyo.de) + by mail.enyo.de with esmtp id 1F9hyG-00073L-J4; + Thu, 16 Feb 2006 13:10:52 +0100 +Received: from fw by deneb.enyo.de with local (Exim 4.60) + (envelope-from ) + id 1F9hyC-0001SK-Mq; Thu, 16 Feb 2006 13:10:48 +0100 +From: Florian Weimer +To: Neil Conway +Cc: Tom Lane , Gary Doades , + pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Subject: Re: qsort again +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> + <1140055972.31672.42.camel@localhost.localdomain> +Date: Thu, 16 Feb 2006 13:10:48 +0100 +In-Reply-To: <1140055972.31672.42.camel@localhost.localdomain> (Neil Conway's + message of "Wed, 15 Feb 2006 21:12:52 -0500") +Message-ID: <873bijsdvb.fsf@mid.deneb.enyo.de> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.101 required=5 tests=[AWL=0.101] +X-Spam-Score: 0.101 +X-Spam-Level: +X-Archive-Number: 200602/614 +X-Sequence-Number: 79752 + +* Neil Conway: + +> On Wed, 2006-02-15 at 18:28 -0500, Tom Lane wrote: +>> It seems clear that our qsort.c is doing a pretty awful job of picking +>> qsort pivots, while glibc is mostly managing not to make that mistake. +>> I haven't looked at the glibc code yet to see what they are doing +>> differently. +> +> glibc qsort is actually merge sort, so I'm not surprised it avoids this +> problem. + +qsort also performs twice as many key comparisons as the theoretical +minimum. If key comparison is not very cheap, other schemes (like +heapsort, for example) are more attractive. + +From pgsql-hackers-owner@postgresql.org Thu Feb 16 08:49:42 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id D6AA09DC9A7; + Thu, 16 Feb 2006 08:49:41 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 80506-09; Thu, 16 Feb 2006 08:49:45 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from svana.org (svana.org [125.62.94.225]) + by postgresql.org (Postfix) with ESMTP id 8315F9DC86A; + Thu, 16 Feb 2006 08:49:39 -0400 (AST) +Received: from kleptog by svana.org with local (Exim 4.50) + id 1F9iZS-0007Y9-5X; Thu, 16 Feb 2006 23:49:18 +1100 +Date: Thu, 16 Feb 2006 13:49:18 +0100 +From: Martijn van Oosterhout +To: Florian Weimer +Cc: Neil Conway , Tom Lane , + Gary Doades , pgsql-performance@postgresql.org, + pgsql-hackers@postgresql.org +Subject: Re: qsort again +Message-ID: <20060216124918.GE26127@svana.org> +Reply-To: Martijn van Oosterhout +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> + <1140055972.31672.42.camel@localhost.localdomain> + <873bijsdvb.fsf@mid.deneb.enyo.de> +Mime-Version: 1.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; boundary="VUDLurXRWRKrGuMn" +Content-Disposition: inline +In-Reply-To: <873bijsdvb.fsf@mid.deneb.enyo.de> +X-PGP-Key-ID: Length=1024; ID=0x0DC67BE6 +X-PGP-Key-Fingerprint: 295F A899 A81A 156D B522 48A7 6394 F08A 0DC6 7BE6 +X-PGP-Key-URL: +User-Agent: Mutt/1.5.9i +X-SA-Exim-Connect-IP: +X-SA-Exim-Mail-From: kleptog@svana.org +X-SA-Exim-Scanned: No (on svana.org); SAEximRunCond expanded to false +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.121 required=5 tests=[AWL=0.121] +X-Spam-Score: 0.121 +X-Spam-Level: +X-Archive-Number: 200602/617 +X-Sequence-Number: 79755 + + +--VUDLurXRWRKrGuMn +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +Content-Transfer-Encoding: quoted-printable + +On Thu, Feb 16, 2006 at 01:10:48PM +0100, Florian Weimer wrote: +> * Neil Conway: +>=20 +> > On Wed, 2006-02-15 at 18:28 -0500, Tom Lane wrote: +> >> It seems clear that our qsort.c is doing a pretty awful job of picking +> >> qsort pivots, while glibc is mostly managing not to make that mistake. +> >> I haven't looked at the glibc code yet to see what they are doing +> >> differently. +> > +> > glibc qsort is actually merge sort, so I'm not surprised it avoids this +> > problem. +>=20 +> qsort also performs twice as many key comparisons as the theoretical +> minimum. If key comparison is not very cheap, other schemes (like +> heapsort, for example) are more attractive. + +Last time around there were a number of different algorithms tested. +Did anyone run those tests while getting it to count the number of +actual comparisons (which could easily swamp the time taken to do the +actual sort in some cases)? + +Have a nice day, +--=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. + +--VUDLurXRWRKrGuMn +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) + +iD8DBQFD9HTOIB7bNG8LQkwRAlzeAJ9Vf2SSm2YzPK9xMWxkf3bVLz5P7ACfReyV +447sapSOkSO6/NtDqjGuV20= +=Fpm+ +-----END PGP SIGNATURE----- + +--VUDLurXRWRKrGuMn-- + +From pgsql-hackers-owner@postgresql.org Thu Feb 16 09:08:49 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 28EBC9DC95D; + Thu, 16 Feb 2006 09:08:48 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 86594-08; Thu, 16 Feb 2006 09:08:51 -0400 (AST) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 27E5D9DC8AF; + Thu, 16 Feb 2006 09:08:46 -0400 (AST) +Received: from mail.aeccom.com (port-83-236-156-26.static.qsc.de + [83.236.156.26]) + by svr4.postgresql.org (Postfix) with ESMTP id 703B15AF085; + Thu, 16 Feb 2006 13:08:49 +0000 (GMT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mail.aeccom.com (Postfix) with ESMTP id AEF431C16A; + Thu, 16 Feb 2006 14:08:43 +0100 (CET) +Received: from mail.aeccom.com ([127.0.0.1]) + by localhost (gate6.aeccom.com [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 21212-01; Thu, 16 Feb 2006 14:08:42 +0100 (CET) +Received: from [192.168.2.14] (andes.core.aeccom.com [192.168.2.14]) + by mail.aeccom.com (Postfix) with ESMTP id C1A8C1C0AB; + Thu, 16 Feb 2006 14:08:42 +0100 (CET) +Message-ID: <43F47958.8000605@aeccom.com> +Date: Thu, 16 Feb 2006 14:08:40 +0100 +From: Sven Geisler +Organization: AEC/communications GmbH +User-Agent: Thunderbird 1.5 (Windows/20051201) +MIME-Version: 1.0 +To: Martijn van Oosterhout +Cc: Florian Weimer , + Neil Conway , Tom Lane , + Gary Doades , pgsql-performance@postgresql.org, + pgsql-hackers@postgresql.org +Subject: Re: [PERFORM] qsort again +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> + <1140055972.31672.42.camel@localhost.localdomain> + <873bijsdvb.fsf@mid.deneb.enyo.de> + <20060216124918.GE26127@svana.org> +In-Reply-To: <20060216124918.GE26127@svana.org> +Content-Type: text/plain; charset=ISO-8859-15; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: amavisd-new at aeccom.com +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200602/618 +X-Sequence-Number: 79756 + +Martijn van Oosterhout schrieb: +> +> Last time around there were a number of different algorithms tested. +> Did anyone run those tests while getting it to count the number of +> actual comparisons (which could easily swamp the time taken to do the +> actual sort in some cases)? +> + +The last time I did such tests is almost 10 years ago. I had used +MetroWerks CodeWarrior C/C++, which had Quicksort as algorithm in the Lib C. +Anyhow, I tested a few algorithms including merge sort and heapsort. I +end up with heapsort because it was the fastest algorithm for our issue. +We joined two arrays where each array was sorted and run qsort to sort +the new array. + +Sven. + +From pgsql-hackers-owner@postgresql.org Thu Feb 16 09:23:03 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 3A36E9DC9C7; + Thu, 16 Feb 2006 09:23:03 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 94811-01; Thu, 16 Feb 2006 09:23:06 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smtpauth08.mail.atl.earthlink.net + (smtpauth08.mail.atl.earthlink.net [209.86.89.68]) + by postgresql.org (Postfix) with ESMTP id 83F799DC9A7; + Thu, 16 Feb 2006 09:23:00 -0400 (AST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=Tdsc/NRb+FrTtFqmC7uOif5cxNyRMxHt5dKmjJDMfh9HY/CAEAtP2Hk79nryKkhf; + 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 [71.243.43.186] (helo=ron-6d52adff2a6.earthlink.net) + by smtpauth08.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1F9j67-00064e-Ef; Thu, 16 Feb 2006 08:23:03 -0500 +Message-Id: <7.0.1.0.2.20060216071053.0385a1a8@earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 7.0.1.0 +Date: Thu, 16 Feb 2006 08:22:55 -0500 +To: "Steinar H. Gunderson" , + pgsql-performance@postgresql.org,pgsql-hackers@postgresql.org +From: Ron +Subject: Re: qsort again (was Re: [PERFORM] Strange Create Index +In-Reply-To: <20060216113522.GA3461@uio.no> +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> + <7.0.1.0.2.20060215194635.03b55da0@earthlink.net> + <21615.1140052893@sss.pgh.pa.us> + <7.0.1.0.2.20060215223710.03a7c618@earthlink.net> + <20060216113522.GA3461@uio.no> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bcb92bd7dcb45eb30eeacd97ef0c260d9d350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 71.243.43.186 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.239 required=5 tests=[AWL=0.239] +X-Spam-Score: 0.239 +X-Spam-Level: +X-Archive-Number: 200602/619 +X-Sequence-Number: 79757 + +At 06:35 AM 2/16/2006, Steinar H. Gunderson wrote: +>On Wed, Feb 15, 2006 at 11:30:54PM -0500, Ron wrote: +> > Even better (and more easily scaled as the number of GPR's in the CPU +> > changes) is to use +> > the set {L; L+1; L+2; t>>1; R-2; R-1; R} +> > This means that instead of 7 random memory accesses, we have 3; two +> > of which result in a burst access for three elements each. +> +>Isn't that improvement going to disappear competely if you choose a bad +>pivot? +Only if you _consistently_ (read: "the vast majority of the time": +quicksort is actually darn robust) choose a _pessimal_, not just +"bad", pivot quicksort will degenerate to the O(N^2) behavior +everyone worries about. See Corman & Rivest for a proof on this. + +Even then, doing things as above has benefits: +1= The worst case is less bad since the guaranteed O(lgs!) pivot +choosing algorithm puts s elements into final position. +Worst case becomes better than O(N^2/(s-1)). + +2= The overhead of pivot choosing can overshadow the benefits using +more traditional methods for even moderate values of s. See +discussions on the quicksort variant known as "samplesort" and +Sedgewick's PhD thesis for details. Using a pivot choosing algorithm +that actually does some of the partitioning (and does it more +efficiently than the "usual" partitioning algorithm does) plus using +partition-in-place (rather then Lomuto's method) reduces overhead +very effectively (at the "cost" of more complicated / delicate to get +right partitioning code). The above reduces the number of moves used +in a quicksort pass considerably regardless of the number of compares used. + +3= Especially in modern systems where the gap between internal CPU +bandwidth and memory bandwidth is so great, the overhead of memory +accesses for comparisons and moves is the majority of the overhead +for both the pivot choosing and the partitioning algorithms within +quicksort. Particularly random memory accesses. The reason (#GPRs - +1) is a magic constant is that it's the most you can compare and move +using only register-to-register operations. + +In addition, replacing as many of the memory accesses you must do +with sequential rather than random memory accesses is a big deal: +sequential memory access is measured in 10's of CPU cycles while +random memory access is measured in hundreds of CPU cycles. It's no +accident that the advances in Grey's sorting contest have involved +algorithms that are both register and cache friendly, minimizing +overall memory access and using sequential memory access as much as +possible when said access can not be avoided. As caches grow larger +and memory accesses more expensive, it's often worth it to use a +BucketSort+QuickSort hybrid rather than just QuickSort. + +...and of course if you know enough about the data to be sorted so as +to constrain it appropriately, one should use a non comparison based +O(N) sorting algorithm rather than any of the general comparison +based O(NlgN) methods. + + +> > SIDE NOTE: IIRC glibc's qsort is actually merge sort. Merge sort +> > performance is insensitive to all inputs, and there are way to +> > optimize it as well. +> +>glibc-2.3.5/stdlib/qsort.c: +> +> /* Order size using quicksort. This implementation incorporates +> four optimizations discussed in Sedgewick: +> +>I can't see any references to merge sort in there at all. +Well, then I'm not the only person on the lists whose memory is faulty ;-) + +The up side of MergeSort is that its performance is always O(NlgN). +The down sides are that it is far more memory hungry than QuickSort and slower. + + +Ron + + + +From pgsql-performance-owner@postgresql.org Thu Feb 16 09:32:35 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 761689DC83D + for ; + Thu, 16 Feb 2006 09:32:34 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 90740-09 + for ; + Thu, 16 Feb 2006 09:32:37 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.198]) + by postgresql.org (Postfix) with ESMTP id 3374D9DC82A + for ; + Thu, 16 Feb 2006 09:32:31 -0400 (AST) +Received: by zproxy.gmail.com with SMTP id v1so170591nzb + for ; + Thu, 16 Feb 2006 05:32:35 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; + b=a4AROPv1cshXKE6wgKzSrWywEj8K3OZxTAs8+D48gh5qlbM4JwKzDdyRmSPfzN3mgM0TM7Ih5DVLxUr4Vs/Sk5JVUvDC3W4XivO4xE+hLDT/wSOheGBEZ6WVq5KdLPgVBXXM8eBLHRt1wlcw5PSZEBBel5QHOMaXDLdFRx9NTyI= +Received: by 10.65.230.4 with SMTP id h4mr716516qbr; + Thu, 16 Feb 2006 05:32:34 -0800 (PST) +Received: by 10.64.233.17 with HTTP; Thu, 16 Feb 2006 05:32:34 -0800 (PST) +Message-ID: +Date: Thu, 16 Feb 2006 13:32:34 +0000 +From: Peter Childs +To: Jay Greenfield +Subject: Re: Postgres slower than MS ACCESS +Cc: pgsql-performance@postgresql.org +In-Reply-To: <200602152129.k1FLTpiO008671@timberline.ca> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_18495_29586099.1140096754733" +References: <24B89C42-C597-4571-8BD1-A89073C3C035@torgo.978.org> + <200602152129.k1FLTpiO008671@timberline.ca> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.768 required=5 tests=[AWL=0.767, + HTML_MESSAGE=0.001] +X-Spam-Score: 0.768 +X-Spam-Level: +X-Archive-Number: 200602/245 +X-Sequence-Number: 17231 + +------=_Part_18495_29586099.1140096754733 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +On 15/02/06, Jay Greenfield wrote: +> +> +> I've been vacuuming between each test run. +> +> Not vacuuming results in times all the way up to 121 minutes. For a +> direct +> comparison with Access, the vacuuming time with Postgres should really be +> included as this is not required with Access. + + + +Hmm but then you would have to include Access Vacuum too I'll think you wil= +l +find "Tools -> Database Utils -> Compact Database" preforms a simular +purpose and is just as important as I've seen many Access Databases bloat i= +n +my time. + +Peter Childs + +------=_Part_18495_29586099.1140096754733 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +

On 15/02/06, Jay Greenfield <jag@ti= +mberline.ca> wrote:
+
I've been vacuuming between each test run.

Not vacuuming results= + in times all the way up to 121 minutes.  For a direct
compari= +son with Access, the vacuuming time with Postgres should really be
inclu= +ded as this is not required with Access. +

+
+Hmm but then you would have to include Access Vacuum too I'll think you +will find "Tools -> Database Utils -> Compact Database" pre= +forms +a simular purpose and is just as important as I've seen many Access +Databases bloat in my time.
+
+Peter Childs
+

+ +------=_Part_18495_29586099.1140096754733-- + +From pgsql-hackers-owner@postgresql.org Thu Feb 16 09:38:51 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 7B23B9DC83D; + Thu, 16 Feb 2006 09:38:50 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 92236-10; Thu, 16 Feb 2006 09:38:53 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smtpauth08.mail.atl.earthlink.net + (smtpauth08.mail.atl.earthlink.net [209.86.89.68]) + by postgresql.org (Postfix) with ESMTP id 62F1A9DC82A; + Thu, 16 Feb 2006 09:38:48 -0400 (AST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=RSTQxNw+GEjxmft7HywTnPolmWCqxdiO2P8+CmeDIlnF9J8JX1qhJB4hdrNKZ/IM; + 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 [71.243.43.186] (helo=ron-6d52adff2a6.earthlink.net) + by smtpauth08.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1F9jLP-0000mN-NJ; Thu, 16 Feb 2006 08:38:51 -0500 +Message-Id: <7.0.1.0.2.20060216082618.03ad7e48@earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 7.0.1.0 +Date: Thu, 16 Feb 2006 08:38:45 -0500 +To: Florian Weimer ,pgsql-performance@postgresql.org, + pgsql-hackers@postgresql.org +From: Ron +Subject: Re: [PERFORM] qsort again +In-Reply-To: <873bijsdvb.fsf@mid.deneb.enyo.de> +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> + <1140055972.31672.42.camel@localhost.localdomain> + <873bijsdvb.fsf@mid.deneb.enyo.de> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bc480b186c8c60dfc7dcbc075b2a287ed5350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 71.243.43.186 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.465 required=5 tests=[AWL=-0.014, + DNS_FROM_RFC_ABUSE=0.479] +X-Spam-Score: 0.465 +X-Spam-Level: +X-Archive-Number: 200602/620 +X-Sequence-Number: 79758 + +At 07:10 AM 2/16/2006, Florian Weimer wrote: +>* Neil Conway: +> +> > On Wed, 2006-02-15 at 18:28 -0500, Tom Lane wrote: +> >> It seems clear that our qsort.c is doing a pretty awful job of picking +> >> qsort pivots, while glibc is mostly managing not to make that mistake. +> >> I haven't looked at the glibc code yet to see what they are doing +> >> differently. +> > +> > glibc qsort is actually merge sort, so I'm not surprised it avoids this +> > problem. +> +>qsort also performs twice as many key comparisons as the theoretical +>minimum. + +The theoretical minimum number of comparisons for a general purpose +comparison based sort is O(lgN!). +QuickSort uses 2NlnN ~= 1.38NlgN or ~1.38x the optimum without tuning +(see Knuth, Sedgewick, Corman, ... etc) +OTOH, QuickSort uses ~2x as many =moves= as the theoretical minimum +unless tuned, and moves are more expensive than compares in modern systems. + +See my other posts for QuickSort tuning methods that attempt to +directly address both issues. + + +Ron + + + +From pgsql-hackers-owner@postgresql.org Thu Feb 16 09:44:46 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 7D52E9DCCBC; + Thu, 16 Feb 2006 09:44:45 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 98305-01; Thu, 16 Feb 2006 09:44:46 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.logix-tt.com (serval.logix-tt.com [213.239.221.42]) + by postgresql.org (Postfix) with ESMTP id 9A7449DC83D; + Thu, 16 Feb 2006 09:44:40 -0400 (AST) +Received: from kingfisher.intern.logix-tt.com (Me829.m.pppool.de + [89.49.232.41]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logix-tt.com (Postfix) with ESMTP id 3AEFB244080; + Thu, 16 Feb 2006 14:44:49 +0100 (CET) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id 6DEBE18189F93; + Thu, 16 Feb 2006 14:44:46 +0100 (CET) +Message-ID: <43F481CD.2010509@logix-tt.com> +Date: Thu, 16 Feb 2006 14:44:45 +0100 +From: Markus Schaber +Organization: Logical Tracking and Tracing International AG, Switzerland +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Subject: Re: qsort again (was Re: [PERFORM] Strange Create Index +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> + <7.0.1.0.2.20060215194635.03b55da0@earthlink.net> + <21615.1140052893@sss.pgh.pa.us> + <7.0.1.0.2.20060215223710.03a7c618@earthlink.net> + <20060216113522.GA3461@uio.no> + <7.0.1.0.2.20060216071053.0385a1a8@earthlink.net> +In-Reply-To: <7.0.1.0.2.20060216071053.0385a1a8@earthlink.net> +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.121 required=5 tests=[AWL=0.121] +X-Spam-Score: 0.121 +X-Spam-Level: +X-Archive-Number: 200602/622 +X-Sequence-Number: 79760 + +Hi, Ron, + +Ron wrote: + +> ...and of course if you know enough about the data to be sorted so as to +> constrain it appropriately, one should use a non comparison based O(N) +> sorting algorithm rather than any of the general comparison based +> O(NlgN) methods. + +Sounds interesting, could you give us some pointers (names, URLs, +papers) to such algorithms? + +Thanks a lot, +Markus + + + +-- +Markus Schaber | Logical Tracking&Tracing International AG +Dipl. Inf. | Software Development GIS + +Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org + +From pgsql-hackers-owner@postgresql.org Thu Feb 16 10:19:44 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 70BA69DCA02 + for ; + Thu, 16 Feb 2006 10:19:43 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 05143-02 + for ; + Thu, 16 Feb 2006 10:19:46 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from nproxy.gmail.com (nproxy.gmail.com [64.233.182.193]) + by postgresql.org (Postfix) with ESMTP id A34F89DC9CD + for ; + Thu, 16 Feb 2006 10:19:40 -0400 (AST) +Received: by nproxy.gmail.com with SMTP id a27so107718nfc + for ; + Thu, 16 Feb 2006 06:19:44 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; + b=LiZtTXX6BxR2gmpb5zWyTWgmkaPF67oTmQf8//DZIO9oMsKdeWZNCDFgr6rLbC4aGHUA6m/dO4sd/+oJBqhoClwqCc6KoSCcsgl9U04L1I3shOSe/v1tuz6K/XtoqIx59J3jwycPZc/SRY0CqzKKV85287LtYWgJPvHeEXEnlOo= +Received: by 10.49.51.13 with SMTP id d13mr172400nfk; + Thu, 16 Feb 2006 06:19:44 -0800 (PST) +Received: by 10.48.219.16 with HTTP; Thu, 16 Feb 2006 06:19:44 -0800 (PST) +Message-ID: <36e682920602160619n1f3752e4mb7a83c9dc9b045cf@mail.gmail.com> +Date: Thu, 16 Feb 2006 09:19:44 -0500 +From: "Jonah H. Harris" +To: Markus Schaber +Subject: Re: qsort again (was Re: [PERFORM] Strange Create Index +Cc: pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +In-Reply-To: <43F481CD.2010509@logix-tt.com> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_253_7557059.1140099584155" +References: <43F38867.6010701@gpdnet.co.uk> <19779.1140038874@sss.pgh.pa.us> + <43F39E53.1020009@gpdnet.co.uk> <20781.1140046109@sss.pgh.pa.us> + <7.0.1.0.2.20060215194635.03b55da0@earthlink.net> + <21615.1140052893@sss.pgh.pa.us> + <7.0.1.0.2.20060215223710.03a7c618@earthlink.net> + <20060216113522.GA3461@uio.no> + <7.0.1.0.2.20060216071053.0385a1a8@earthlink.net> + <43F481CD.2010509@logix-tt.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.215 required=5 tests=[AWL=0.214, + HTML_MESSAGE=0.001] +X-Spam-Score: 0.215 +X-Spam-Level: +X-Archive-Number: 200602/623 +X-Sequence-Number: 79761 + +------=_Part_253_7557059.1140099584155 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Last night I implemented a non-recursive introsort in C... let me test it a +bit more and then I'll post it here for everyone else to try out. + +On 2/16/06, Markus Schaber wrote: +> +> Hi, Ron, +> +> Ron wrote: +> +> > ...and of course if you know enough about the data to be sorted so as t= +o +> > constrain it appropriately, one should use a non comparison based O(N) +> > sorting algorithm rather than any of the general comparison based +> > O(NlgN) methods. +> +> Sounds interesting, could you give us some pointers (names, URLs, +> papers) to such algorithms? +> +> Thanks a lot, +> Markus +> +> +> +> -- +> Markus Schaber | Logical Tracking&Tracing International AG +> Dipl. Inf. | Software Development GIS +> +> Fight against software patents in EU! www.ffii.org +> www.nosoftwarepatents.org +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 4: Have you searched our list archives? +> +> http://archives.postgresql.org +> + + + +-- +Jonah H. Harris, Database Internals Architect +EnterpriseDB Corporation +732.331.1324 + +------=_Part_253_7557059.1140099584155 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Last night I implemented a non-recursive introsort in C... let me test it a= + bit more and then I'll post it here for everyone else to try out.

<= +div>On 2/16/06, M= +arkus Schaber + <schabi@logix-tt.com>= + wrote:
Hi,= + Ron, +

Ron wrote:

> ...and of course if you know enough about th= +e data to be sorted so as to
> constrain it appropriately, one should= + use a non comparison based O(N)
> sorting algorithm rather than any = +of the general comparison based +
> O(NlgN) methods.

Sounds interesting, could you give us some= + pointers (names, URLs,
papers) to such algorithms?

Thanks a lot,= +
Markus



--
Markus Schaber | Logical Tracking&Traci= +ng International AG +
Dipl. Inf.     | Software Development GIS

Fi= +ght against software patents in EU! www.ffi= +i.org www.nosoftwarepatent= +s.org

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

   &n= +bsp;           http://archives.postgresql.org



--
Jonah H. Harris, Database I= +nternals Architect +
EnterpriseDB Corporation
732.331.1324
+ +------=_Part_253_7557059.1140099584155-- + +From pgsql-performance-owner@postgresql.org Thu Feb 16 10:42:39 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 5368B9DCC4F + for ; + Thu, 16 Feb 2006 10:42:39 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 07651-04 + for ; + Thu, 16 Feb 2006 10:42:43 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 05EF69DCBB4 + for ; + Thu, 16 Feb 2006 10:42:36 -0400 (AST) +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 k1GEgewi027899; + Thu, 16 Feb 2006 09:42:40 -0500 (EST) +To: gpd@gpdnet.co.uk +cc: pgsql-performance@postgresql.org +Subject: Re: [HACKERS] qsort again (was Re: Strange Create Index behaviour) +In-reply-to: <2417.84.92.210.49.1140087992.squirrel@www.gpdnet.co.uk> +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> <43F3BF72.6000202@gpdnet.co.uk> + <21152.1140049020@sss.pgh.pa.us> <21455.1140051584@sss.pgh.pa.us> + <2417.84.92.210.49.1140087992.squirrel@www.gpdnet.co.uk> +Comments: In-reply-to "Gary Doades" + message dated "Thu, 16 Feb 2006 11:06:32 +0000" +Date: Thu, 16 Feb 2006 09:42:40 -0500 +Message-ID: <27898.1140100960@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.11 required=5 tests=[AWL=0.110] +X-Spam-Score: 0.11 +X-Spam-Level: +X-Archive-Number: 200602/248 +X-Sequence-Number: 17234 + +"Gary Doades" writes: +> I think the reason I wasn't seeing performance issues with normal sort +> operations is because they use work_mem not maintenance_work_mem which was +> only set to 2048 anyway. Does that sound right? + +Very probable. Do you want to test the theory by jacking that up? ;-) + + regards, tom lane + +From pgsql-hackers-owner@postgresql.org Thu Feb 16 10:48:47 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 938179DCCEB; + Thu, 16 Feb 2006 10:48:45 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 06777-08; Thu, 16 Feb 2006 10:48:47 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from svana.org (svana.org [125.62.94.225]) + by postgresql.org (Postfix) with ESMTP id D52529DCCE6; + Thu, 16 Feb 2006 10:48:39 -0400 (AST) +Received: from kleptog by svana.org with local (Exim 4.50) + id 1F9kQr-0007o5-Vu; Fri, 17 Feb 2006 01:48:33 +1100 +Date: Thu, 16 Feb 2006 15:48:33 +0100 +From: Martijn van Oosterhout +To: Ron +Cc: "Steinar H. Gunderson" , + pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Subject: Re: qsort again (was Re: [PERFORM] Strange Create Index +Message-ID: <20060216144833.GG26127@svana.org> +Reply-To: Martijn van Oosterhout +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> + <7.0.1.0.2.20060215194635.03b55da0@earthlink.net> + <21615.1140052893@sss.pgh.pa.us> + <7.0.1.0.2.20060215223710.03a7c618@earthlink.net> + <20060216113522.GA3461@uio.no> + <7.0.1.0.2.20060216071053.0385a1a8@earthlink.net> +Mime-Version: 1.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; boundary="Z0mFw3+mXTC5ycVe" +Content-Disposition: inline +In-Reply-To: <7.0.1.0.2.20060216071053.0385a1a8@earthlink.net> +X-PGP-Key-ID: Length=1024; ID=0x0DC67BE6 +X-PGP-Key-Fingerprint: 295F A899 A81A 156D B522 48A7 6394 F08A 0DC6 7BE6 +X-PGP-Key-URL: +User-Agent: Mutt/1.5.9i +X-SA-Exim-Connect-IP: +X-SA-Exim-Mail-From: kleptog@svana.org +X-SA-Exim-Scanned: No (on svana.org); SAEximRunCond expanded to false +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.122 required=5 tests=[AWL=0.122] +X-Spam-Score: 0.122 +X-Spam-Level: +X-Archive-Number: 200602/625 +X-Sequence-Number: 79763 + + +--Z0mFw3+mXTC5ycVe +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +Content-Transfer-Encoding: quoted-printable + +On Thu, Feb 16, 2006 at 08:22:55AM -0500, Ron wrote: +> 3=3D Especially in modern systems where the gap between internal CPU=20 +> bandwidth and memory bandwidth is so great, the overhead of memory=20 +> accesses for comparisons and moves is the majority of the overhead=20 +> for both the pivot choosing and the partitioning algorithms within=20 +> quicksort. Particularly random memory accesses. The reason (#GPRs -=20 +> 1) is a magic constant is that it's the most you can compare and move=20 +> using only register-to-register operations. + +But how much of this applies to us? We're not sorting arrays of +integers, we're sorting pointers to tuples. So while moves cost very +little, a comparison costs hundreds, maybe thousands of cycles. A tuple +can easily be two or three cachelines and you're probably going to +access all of it, not to mention the Fmgr structures and the Datums +themselves. + +None of this is cache friendly. The actual tuples themselves could be +spread all over memory (I don't think any particular effort is expended +trying to minimize fragmentation). + +Do these algorithms discuss the case where a comparison is more than +1000 times the cost of a move? + +Where this does become interesting is where we can convert a datum to +an integer such that if f(A) > f(B) then A > B. Then we can sort on +f(X) first with just integer comparisons and then do a full tuple +comparison only if f(A) =3D f(B). This would be much more cache-coherent +and make these algorithms much more applicable in my mind. + +Have a nice day, +--=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. + +--Z0mFw3+mXTC5ycVe +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) + +iD8DBQFD9JDBIB7bNG8LQkwRAoF+AJ0SGLPLBKiNPEEbXMzhGymCPBJ2YACfWO+A +bAIJWTN03tsUmzEMmCZLYc0= +=HJhH +-----END PGP SIGNATURE----- + +--Z0mFw3+mXTC5ycVe-- + +From pgsql-performance-owner@postgresql.org Thu Feb 16 11:31:49 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id A58449DCBA3 + for ; + Thu, 16 Feb 2006 11:31:48 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 19367-05 + for ; + Thu, 16 Feb 2006 11:31:52 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from server.gpdnet.co.uk (gpdnet.plus.com [212.56.100.243]) + by postgresql.org (Postfix) with ESMTP id EE8D19DCB83 + for ; + Thu, 16 Feb 2006 11:31:45 -0400 (AST) +Received: from www.gpdnet.co.uk (server.gpdnet.co.uk [127.0.0.1]) + by server.gpdnet.co.uk (Postfix) with ESMTP id 59F473AAB50; + Thu, 16 Feb 2006 15:42:36 +0000 (GMT) +Received: from 84.92.210.49 (SquirrelMail authenticated user gpd) + by www.gpdnet.co.uk with HTTP; Thu, 16 Feb 2006 15:42:36 -0000 (GMT) +Message-ID: <4383.84.92.210.49.1140104556.squirrel@www.gpdnet.co.uk> +In-Reply-To: <27898.1140100960@sss.pgh.pa.us> +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> <43F3BF72.6000202@gpdnet.co.uk> + <21152.1140049020@sss.pgh.pa.us> <21455.1140051584@sss.pgh.pa.us> + <2417.84.92.210.49.1140087992.squirrel@www.gpdnet.co.uk> + <27898.1140100960@sss.pgh.pa.us> +Date: Thu, 16 Feb 2006 15:42:36 -0000 (GMT) +Subject: Re: [HACKERS] qsort again (was Re: Strange Create Index +From: "Gary Doades" +To: "Tom Lane" +Cc: pgsql-performance@postgresql.org +Reply-To: gpd@gpdnet.co.uk +User-Agent: SquirrelMail/1.4.6 [CVS]-0.cvs20050812.1.fc4 +MIME-Version: 1.0 +Content-Type: text/plain;charset=iso-8859-15 +Content-Transfer-Encoding: 8bit +X-Priority: 3 (Normal) +Importance: Normal +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.112 required=5 tests=[AWL=0.112] +X-Spam-Score: 0.112 +X-Spam-Level: +X-Archive-Number: 200602/250 +X-Sequence-Number: 17236 + +> "Gary Doades" writes: +>> I think the reason I wasn't seeing performance issues with normal sort +>> operations is because they use work_mem not maintenance_work_mem which +>> was +>> only set to 2048 anyway. Does that sound right? +> +> Very probable. Do you want to test the theory by jacking that up? ;-) + +Hmm, played around a bit. I have managed to get it to do a sort on one of +the "bad" columns using a select of two whole tables that results in a +sequntial scan, sort and merge join. I also tried a simple select column +order by column for a bad column. + +I tried varying maintenance_work_mem and work_mem up and down between 2048 +and 65536 but I always get similar results. The sort phase always takes 4 +to 5 seconds which seems about right for 900,000 rows. + +This was on a colunm that took 12 minutes to create an index on. + +I've no idea why it should behave this way, but probably explains why I +(and others) may not have noticed it before. + +Regards, +Gary. + + + +From pgsql-hackers-owner@postgresql.org Thu Feb 16 11:53:00 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id AA2B89DCB83; + Thu, 16 Feb 2006 11:52:59 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 21299-09; Thu, 16 Feb 2006 11:53:01 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from elasmtp-junco.atl.sa.earthlink.net + (elasmtp-junco.atl.sa.earthlink.net [209.86.89.63]) + by postgresql.org (Postfix) with ESMTP id 8691B9DCA02; + Thu, 16 Feb 2006 11:52:53 -0400 (AST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=ExrRMilcLt+UTczQLEn/fQSKLP5rcKXclrG/+2+pcZ8xUpOCwP6yC39uEU8L5FgA; + 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.34.169.163] (helo=ron-6d52adff2a6.earthlink.net) + by elasmtp-junco.atl.sa.earthlink.net with asmtp (Exim 4.34) + id 1F9lR8-0000ue-Hd; Thu, 16 Feb 2006 10:52:54 -0500 +Message-Id: <7.0.1.0.2.20060216100954.035b5ee0@earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 7.0.1.0 +Date: Thu, 16 Feb 2006 10:52:48 -0500 +To: Martijn van Oosterhout , + pgsql-performance@postgresql.org,pgsql-hackers@postgresql.org +From: Ron +Subject: Re: qsort again (was Re: [PERFORM] Strange Create +In-Reply-To: <20060216144833.GG26127@svana.org> +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> + <7.0.1.0.2.20060215194635.03b55da0@earthlink.net> + <21615.1140052893@sss.pgh.pa.us> + <7.0.1.0.2.20060215223710.03a7c618@earthlink.net> + <20060216113522.GA3461@uio.no> + <7.0.1.0.2.20060216071053.0385a1a8@earthlink.net> + <20060216144833.GG26127@svana.org> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bcfbc3286cf58ce871daecdd77463b6951350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 24.34.169.163 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.479 required=5 tests=[AWL=0.000, + DNS_FROM_RFC_ABUSE=0.479] +X-Spam-Score: 0.479 +X-Spam-Level: +X-Archive-Number: 200602/627 +X-Sequence-Number: 79765 + +At 09:48 AM 2/16/2006, Martijn van Oosterhout wrote: +>On Thu, Feb 16, 2006 at 08:22:55AM -0500, Ron wrote: +> > 3= Especially in modern systems where the gap between internal CPU +> > bandwidth and memory bandwidth is so great, the overhead of memory +> > accesses for comparisons and moves is the majority of the overhead +> > for both the pivot choosing and the partitioning algorithms within +> > quicksort. Particularly random memory accesses. The reason (#GPRs - +> > 1) is a magic constant is that it's the most you can compare and move +> > using only register-to-register operations. +> +>But how much of this applies to us? We're not sorting arrays of +>integers, we're sorting pointers to tuples. So while moves cost very +>little, a comparison costs hundreds, maybe thousands of cycles. A tuple +>can easily be two or three cachelines and you're probably going to +>access all of it, not to mention the Fmgr structures and the Datums +>themselves. +Pointers are simply fixed size 32b or 64b quantities. They are +essentially integers. Comparing and moving pointers or fixed size +keys to those pointers is exactly the same problem as comparing and +moving integers. + +Comparing =or= moving the actual data structures is a much more +expensive and variable cost proposition. I'm sure that pg's sort +functionality is written intelligently enough that the only real data +moves are done in a final pass after the exact desired order has been +found using pointer compares and (re)assignments during the sorting +process. That's a standard technique for sorting data whose "key" or +pointer is much smaller than a datum. + +Your cost comment basically agrees with mine regarding the cost of +random memory accesses. The good news is that the number of datums +to be examined during the pivot choosing process is small enough that +the datums can fit into CPU cache while the pointers to them can be +assigned to registers: making pivot choosing +very+ fast when done correctly. + +As you've noted, actual partitioning is going to be more expensive +since it involves accessing enough actual datums that they can't all +fit into CPU cache. The good news is that QuickSort has a very +sequential access pattern within its inner loop. So while we must go +to memory for compares, we are at least keeping the cost for it down +it a minimum. In addition, said access is nice enough to be very +prefetch and CPU cache hierarchy friendly. + + +>None of this is cache friendly. The actual tuples themselves could be +>spread all over memory (I don't think any particular effort is expended +>trying to minimize fragmentation). +It probably would be worth it to spend some effort on memory layout +just as we do for HD layout. + + +>Do these algorithms discuss the case where a comparison is more than +>1000 times the cost of a move? +A move is always more expensive than a compare when the datum is +larger than its pointer or key. A move is always more expensive than +a compare when it involves memory to memory movement rather than CPU +location to CPU location movement. A move is especially more +expensive than a compare when it involves both factors. Most moves +do involve both. + +What I suspect you meant is that a key comparison that involves +accessing the data in memory is more expensive than reassigning the +pointers associated with those keys. That is certainly true. + +Yes. The problem has been extensively studied. ;-) + + +>Where this does become interesting is where we can convert a datum to +>an integer such that if f(A) > f(B) then A > B. Then we can sort on +>f(X) first with just integer comparisons and then do a full tuple +>comparison only if f(A) = f(B). This would be much more cache-coherent +>and make these algorithms much more applicable in my mind. +In fact we can do better. +Using hash codes or what-not to map datums to keys and then sorting +just the keys and the pointers to those datums followed by an +optional final pass where we do the actual data movement is also a +standard technique for handling large data structures. + + +Regardless of what tweaks beyond the basic algorithms we use, the +algorithms themselves have been well studied and their performance +well established. QuickSort is the best performing of the O(nlgn) +comparison based sorts and it uses less resources than HeapSort or MergeSort. + +Ron + + + +From pgsql-hackers-owner@postgresql.org Thu Feb 16 12:20:30 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 66C9B9DCCC8 + for ; + Thu, 16 Feb 2006 12:20:28 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28596-02 + for ; + Thu, 16 Feb 2006 12:20:26 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 2A1CD9DCC71 + for ; + Thu, 16 Feb 2006 12:20:26 -0400 (AST) +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 k1GGKNap028769; + Thu, 16 Feb 2006 11:20:23 -0500 (EST) +To: Ron +cc: Martijn van Oosterhout , + pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Subject: Re: qsort again (was Re: [PERFORM] Strange Create +In-reply-to: <7.0.1.0.2.20060216100954.035b5ee0@earthlink.net> +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> + <7.0.1.0.2.20060215194635.03b55da0@earthlink.net> + <21615.1140052893@sss.pgh.pa.us> + <7.0.1.0.2.20060215223710.03a7c618@earthlink.net> + <20060216113522.GA3461@uio.no> + <7.0.1.0.2.20060216071053.0385a1a8@earthlink.net> + <20060216144833.GG26127@svana.org> + <7.0.1.0.2.20060216100954.035b5ee0@earthlink.net> +Comments: In-reply-to Ron + message dated "Thu, 16 Feb 2006 10:52:48 -0500" +Date: Thu, 16 Feb 2006 11:20:23 -0500 +Message-ID: <28768.1140106823@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.11 required=5 tests=[AWL=0.110] +X-Spam-Score: 0.11 +X-Spam-Level: +X-Archive-Number: 200602/628 +X-Sequence-Number: 79766 + +Ron writes: +> Your cost comment basically agrees with mine regarding the cost of +> random memory accesses. The good news is that the number of datums +> to be examined during the pivot choosing process is small enough that +> the datums can fit into CPU cache while the pointers to them can be +> assigned to registers: making pivot choosing +very+ fast when done correctly. + +This is more or less irrelevant given that comparing the pointers is not +the operation we need to do. + + regards, tom lane + +From pgsql-hackers-owner@postgresql.org Thu Feb 16 12:32:25 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 68B829DCC4F; + Thu, 16 Feb 2006 12:32:24 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 29631-04; Thu, 16 Feb 2006 12:32:20 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from moonunit2.moonview.localnet (wsip-68-15-5-150.sd.sd.cox.net + [68.15.5.150]) by postgresql.org (Postfix) with ESMTP id 6D8609DCC71; + Thu, 16 Feb 2006 12:32:19 -0400 (AST) +Received: from [192.168.0.3] (moonunit3.moonview.localnet [192.168.0.3]) + by moonunit2.moonview.localnet (8.13.1/8.13.1) with ESMTP id + k1GHYUg9025336; Thu, 16 Feb 2006 09:34:30 -0800 +Message-ID: <43F4A7D8.4050907@modgraph-usa.com> +Date: Thu, 16 Feb 2006 08:27:04 -0800 +From: "Craig A. James" +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Markus Schaber +CC: pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Subject: Re: qsort again (was Re: [PERFORM] Strange Create Index +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> + <7.0.1.0.2.20060215194635.03b55da0@earthlink.net> + <21615.1140052893@sss.pgh.pa.us> + <7.0.1.0.2.20060215223710.03a7c618@earthlink.net> + <20060216113522.GA3461@uio.no> + <7.0.1.0.2.20060216071053.0385a1a8@earthlink.net> + <43F481CD.2010509@logix-tt.com> +In-Reply-To: <43F481CD.2010509@logix-tt.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, score=0.096 required=5 tests=[AWL=0.096] +X-Spam-Score: 0.096 +X-Spam-Level: +X-Archive-Number: 200602/629 +X-Sequence-Number: 79767 + +Markus Schaber wrote: +> Ron wrote: +>>...and of course if you know enough about the data to be sorted so as to +>>constrain it appropriately, one should use a non comparison based O(N) +>>sorting algorithm rather than any of the general comparison based +>>O(NlgN) methods. +> +> Sounds interesting, could you give us some pointers (names, URLs, +> papers) to such algorithms? + +Most of these techniques boil down to good ol' "bucket sort". A simple example: suppose you have a column of integer percentages, range zero to 100. You know there are only 101 distinct values. So create 101 "buckets" (e.g. linked lists), make a single pass through your data and drop each row's ID into the right bucket, then make a second pass through the buckets, and write the row ID's out in bucket order. This is an O(N) sort technique. + +Any time you have a restricted data range, you can do this. Say you have 100 million rows of scientific results known to be good to only three digits -- it can have at most 1,000 distinct values (regardless of the magnitude of the values), so you can do this with 1,000 buckets and just two passes through the data. + +You can also use this trick when the optimizer is asked for "fastest first result." Say you have a cursor on a column of numbers with good distribution. If you do a bucket sort on the first two or three digits only, you know the first "page" of results will be in the first bucket. So you only need to apply qsort to that first bucket (which is very fast, since it's small), and you can deliver the first page of data to the application. This can be particularly effective in interactive situations, where the user typically looks at a few pages of data and then abandons the search. + +I doubt this is very relevant to Postgres. A relational database has to be general purpose, and it's hard to give it "hints" that would tell it when to use this particular optimization. + +Craig + +From pgsql-hackers-owner@postgresql.org Thu Feb 16 12:33:37 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 521989DC847; + Thu, 16 Feb 2006 12:33:36 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 30818-06; Thu, 16 Feb 2006 12:33:24 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smtpauth01.mail.atl.earthlink.net + (smtpauth01.mail.atl.earthlink.net [209.86.89.61]) + by postgresql.org (Postfix) with ESMTP id 993A69DCD12; + Thu, 16 Feb 2006 12:33:23 -0400 (AST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=fr18u0hmtZS71avPDyLbCdjC/CzsWcC65mrkQXAjnnmefMQDBHc1pB5yyy/7hBU/; + 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.34.169.163] (helo=ron-6d52adff2a6.earthlink.net) + by smtpauth01.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1F9m4F-0002dy-Cd; Thu, 16 Feb 2006 11:33:19 -0500 +Message-Id: <7.0.1.0.2.20060216110249.0395d2b0@earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 7.0.1.0 +Date: Thu, 16 Feb 2006 11:32:55 -0500 +To: Martijn van Oosterhout , + pgsql-performance@postgresql.org,pgsql-hackers@postgresql.org +From: Ron +Subject: Re: qsort again (was Re: [PERFORM] Strange Create +In-Reply-To: <7.0.1.0.2.20060216100954.035b5ee0@earthlink.net> +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> + <7.0.1.0.2.20060215194635.03b55da0@earthlink.net> + <21615.1140052893@sss.pgh.pa.us> + <7.0.1.0.2.20060215223710.03a7c618@earthlink.net> + <20060216113522.GA3461@uio.no> + <7.0.1.0.2.20060216071053.0385a1a8@earthlink.net> + <20060216144833.GG26127@svana.org> + <7.0.1.0.2.20060216100954.035b5ee0@earthlink.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bce0597794fc79c05ed81de0f7c21374cc350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 24.34.169.163 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.439 required=5 tests=[AWL=-0.040, + DNS_FROM_RFC_ABUSE=0.479] +X-Spam-Score: 0.439 +X-Spam-Level: +X-Archive-Number: 200602/630 +X-Sequence-Number: 79768 + +At 10:52 AM 2/16/2006, Ron wrote: +>At 09:48 AM 2/16/2006, Martijn van Oosterhout wrote: +> +>>Where this does become interesting is where we can convert a datum to +>>an integer such that if f(A) > f(B) then A > B. Then we can sort on +>>f(X) first with just integer comparisons and then do a full tuple +>>comparison only if f(A) = f(B). This would be much more cache-coherent +>>and make these algorithms much more applicable in my mind. +>In fact we can do better. +>Using hash codes or what-not to map datums to keys and then sorting +>just the keys and the pointers to those datums followed by an +>optional final pass where we do the actual data movement is also a +>standard technique for handling large data structures. +I thought some follow up might be in order here. + +Let's pretend that we have the typical DB table where rows are ~2-4KB +apiece. 1TB of storage will let us have 256M-512M rows in such a table. + +A 32b hash code can be assigned to each row value such that only +exactly equal rows will have the same hash code. +A 32b pointer can locate any of the 256M-512M rows. + +Now instead of sorting 1TB of data we can sort 2^28 to 2^29 32b+32b= +64b*(2^28 to 2^29)= 2-4GB of pointers+keys followed by an optional +pass to rearrange the actual rows if we so wish. + +We get the same result while only examining and manipulating 1/50 to +1/25 as much data during the sort. + +If we want to spend more CPU time in order to save more space, we can +compress the key+pointer representation. That usually reduces the +amount of data to be manipulated to ~1/4 the original key+pointer +representation, reducing things to ~512M-1GB worth of compressed +pointers+keys. Or ~1/200 - ~1/100 the original amount of data we +were discussing. + +Either representation is small enough to fit within RAM rather than +requiring HD IO, so we solve the HD IO bottleneck in the best +possible way: we avoid ever doing it. + +Ron + + + +From pgsql-performance-owner@postgresql.org Thu Feb 16 13:01:43 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id D3D7B9DC847 + for ; + Thu, 16 Feb 2006 13:01:42 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 36930-01 + for ; + Thu, 16 Feb 2006 13:01:40 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from hotmail.com (bay106-dav19.bay106.hotmail.com [65.54.161.91]) + by postgresql.org (Postfix) with ESMTP id 935B79DC83D + for ; + Thu, 16 Feb 2006 13:01:39 -0400 (AST) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Thu, 16 Feb 2006 09:01:38 -0800 +Message-ID: +Received: from 85.105.24.123 by BAY106-DAV19.phx.gbl with DAV; + Thu, 16 Feb 2006 17:01:38 +0000 +X-Originating-IP: [85.105.24.123] +X-Originating-Email: [a_dursun@hotmail.com] +X-Sender: a_dursun@hotmail.com +From: "Adnan DURSUN" +To: +Subject: Why does not perform index combination +Date: Thu, 16 Feb 2006 18:56:20 +0200 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0007_01C6332A.ACC82A40" +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-OriginalArrivalTime: 16 Feb 2006 17:01:38.0882 (UTC) + FILETIME=[A6E4DA20:01C6331A] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=2.789 required=5 tests=[AWL=-0.331, + DNS_FROM_RFC_ABUSE=0.479, DNS_FROM_RFC_POST=1.44, HTML_MESSAGE=0.001, + MSGID_FROM_MTA_HEADER=0, WEIRD_QUOTING=1.2] +X-Spam-Score: 2.789 +X-Spam-Level: ** +X-Archive-Number: 200602/256 +X-Sequence-Number: 17242 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0007_01C6332A.ACC82A40 +Content-Type: text/plain; + charset="iso-8859-9" +Content-Transfer-Encoding: quoted-printable + +HI ALL, + + I have query for a report. Explain analyze result is below. The = +execution plan tells that it would use "t_koltuk_islem_pkey" index on = +table "t_koltuk_islem" to scan. However, there is another index on table = +"t_koltuk_islem" on column "islem_tarihi" that can be combined on plan. = +Why doesn't optimizer choice that ? It prefer to perform a filter on = +column "islem_tarihi" ... Why ? + +QUERY PLAN +-------------------------------------------------------------------------= +------------------------------------------------- +"Nested Loop (cost=3D0.00..2411.48 rows=3D14 width=3D797) (actual = +time=3D117.427..4059.351 rows=3D55885 loops=3D1)" +" -> Nested Loop (cost=3D0.00..35.69 rows=3D1 width=3D168) (actual = +time=3D0.124..8.714 rows=3D94 loops=3D1)" +" Join Filter: ((""outer"".sefer_tip_kod =3D ""inner"".kod) AND = +((""outer"".firma_no)::text =3D (""inner"".firma_no)::text))" +" -> Nested Loop (cost=3D0.00..34.64 rows=3D1 width=3D154) = +(actual time=3D0.114..7.555 rows=3D94 loops=3D1)" +" -> Nested Loop (cost=3D0.00..30.18 rows=3D1 = +width=3D144) (actual time=3D0.106..6.654 rows=3D94 loops=3D1)" +" -> Nested Loop (cost=3D0.00..25.71 rows=3D1 = +width=3D134) (actual time=3D0.089..5.445 rows=3D94 loops=3D1)" +" Join Filter: (((""inner"".""no"")::text =3D = +(""outer"".hat_no)::text) AND ((""inner"".firma_no)::text =3D = +(""outer"".firma_no)::text))" +" -> Nested Loop (cost=3D0.00..24.21 rows=3D1 = +width=3D116) (actual time=3D0.063..1.632 rows=3D94 loops=3D1)" +" Join Filter: ((""outer"".kod)::text =3D = +(""inner"".durumu)::text)" +" -> Seq Scan on t_domains d2 = +(cost=3D0.00..2.21 rows=3D2 width=3D18) (actual time=3D0.029..0.056 = +rows=3D2 loops=3D1)" +" Filter: ((name)::text =3D = +'SFR_DURUMU'::text)" +" -> Nested Loop (cost=3D0.00..10.91 = +rows=3D7 width=3D103) (actual time=3D0.028..0.649 rows=3D94 loops=3D2)" +" Join Filter: = +((""outer"".kod)::text =3D (""inner"".ek_dev)::text)" +" -> Seq Scan on t_domains d1 = +(cost=3D0.00..2.21 rows=3D2 width=3D18) (actual time=3D0.017..0.046 = +rows=3D2 loops=3D2)" +" Filter: ((name)::text =3D = +'EKDEV'::text)" +" -> Seq Scan on t_seferler s = +(cost=3D0.00..3.17 rows=3D94 width=3D90) (actual time=3D0.003..0.160 = +rows=3D94 loops=3D4)" +" Filter: ((iptal)::text =3D = +'H'::text)" +" -> Seq Scan on t_hatlar h = +(cost=3D0.00..1.20 rows=3D20 width=3D18) (actual time=3D0.002..0.020 = +rows=3D20 loops=3D94)" +" -> Index Scan using t_yer_pkey on t_yer y2 = +(cost=3D0.00..4.45 rows=3D1 width=3D14) (actual time=3D0.008..0.009 = +rows=3D1 loops=3D94)" +" Index Cond: (""outer"".varis_yer_kod =3D = +y2.kod)" +" Filter: ((iptal)::text =3D 'H'::text)" +" -> Index Scan using t_yer_pkey on t_yer y1 = +(cost=3D0.00..4.45 rows=3D1 width=3D14) (actual time=3D0.004..0.006 = +rows=3D1 loops=3D94)" +" Index Cond: (""outer"".kalkis_yer_kod =3D y1.kod)" +" Filter: ((iptal)::text =3D 'H'::text)" +" -> Seq Scan on t_sefer_tip t (cost=3D0.00..1.02 rows=3D2 = +width=3D18) (actual time=3D0.002..0.006 rows=3D2 loops=3D94)" +" Filter: ((iptal)::text =3D 'H'::text)" +" -> Index Scan using t_koltuk_islem_pkey on t_koltuk_islem i = +(cost=3D0.00..2375.10 rows=3D39 width=3D644) (actual = +time=3D38.151..41.881 rows=3D595 loops=3D94)" +" Index Cond: (((""outer"".firma_no)::text =3D = +(i.firma_no)::text) AND ((""outer"".hat_no)::text =3D (i.hat_no)::text) = +AND (""outer"".kod =3D i.sefer_kod))" +" Filter: ((islem_tarihi >=3D '2006-01-17'::date) AND = +(islem_tarihi <=3D '2006-02-16'::date))" +"Total runtime: 4091.242 ms" + +Best Regards + +Adnan DURSUN +ASRIN Bili=FEim Ltd.=DEti +Ankara / TURKEY +------=_NextPart_000_0007_01C6332A.ACC82A40 +Content-Type: text/html; + charset="iso-8859-9" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
HI ALL,
+
 
+
  I have query for a report. = +Explain analyze=20 +result is below. The execution plan tells that it would use=20 +"t_koltuk_islem_pkey" index on table "t_koltuk_islem" to = +scan. However,=20 +there is another index on table "t_koltuk_islem" on column = +"islem_tarihi"=20 +that can be combined on plan. Why doesn't optimizer choice that ? = +It prefer=20 +to perform a filter on column "islem_tarihi" ...=20 +Why ?
+
 
+
QUERY=20 +PLAN
-----------------------------------------------------------------= +---------------------------------------------------------
"Nested=20 +Loop  (cost=3D0.00..2411.48 rows=3D14 width=3D797) (actual = +time=3D117.427..4059.351=20 +rows=3D55885 loops=3D1)"
"  ->  Nested Loop  = +(cost=3D0.00..35.69=20 +rows=3D1 width=3D168) (actual time=3D0.124..8.714 rows=3D94=20 +loops=3D1)"
"        Join Filter:=20 +((""outer"".sefer_tip_kod =3D ""inner"".kod) AND = +((""outer"".firma_no)::text =3D=20 +(""inner"".firma_no)::text))"
"      &nb= +sp;=20 +->  Nested Loop  (cost=3D0.00..34.64 rows=3D1 width=3D154) = +(actual=20 +time=3D0.114..7.555 rows=3D94=20 +loops=3D1)"
"         &nb= +sp;   =20 +->  Nested Loop  (cost=3D0.00..30.18 rows=3D1 width=3D144) = +(actual=20 +time=3D0.106..6.654 rows=3D94=20 +loops=3D1)"
"         &nb= +sp;         =20 +->  Nested Loop  (cost=3D0.00..25.71 rows=3D1 width=3D134) = +(actual=20 +time=3D0.089..5.445 rows=3D94=20 +loops=3D1)"
"         &nb= +sp;           &nbs= +p;   =20 +Join Filter: (((""inner"".""no"")::text =3D (""outer"".hat_no)::text) = +AND=20 +((""inner"".firma_no)::text =3D=20 +(""outer"".firma_no)::text))"
"      &nb= +sp;           &nbs= +p;      =20 +->  Nested Loop  (cost=3D0.00..24.21 rows=3D1 width=3D116) = +(actual=20 +time=3D0.063..1.632 rows=3D94=20 +loops=3D1)"
"         &nb= +sp;           &nbs= +p;         =20 +Join Filter: ((""outer"".kod)::text =3D=20 +(""inner"".durumu)::text)"
"       = +            &= +nbsp;           =20 +->  Seq Scan on t_domains d2  (cost=3D0.00..2.21 rows=3D2 = +width=3D18)=20 +(actual time=3D0.029..0.056 rows=3D2=20 +loops=3D1)"
"         &nb= +sp;           &nbs= +p;            = +;   =20 +Filter: ((name)::text =3D=20 +'SFR_DURUMU'::text)"
"        = +            &= +nbsp;          =20 +->  Nested Loop  (cost=3D0.00..10.91 rows=3D7 width=3D103) = +(actual=20 +time=3D0.028..0.649 rows=3D94=20 +loops=3D2)"
"         &nb= +sp;           &nbs= +p;            = +;   =20 +Join Filter: ((""outer"".kod)::text =3D=20 +(""inner"".ek_dev)::text)"
"       = +            &= +nbsp;           &n= +bsp;     =20 +->  Seq Scan on t_domains d1  (cost=3D0.00..2.21 rows=3D2 = +width=3D18)=20 +(actual time=3D0.017..0.046 rows=3D2=20 +loops=3D2)"
"         &nb= +sp;           &nbs= +p;            = +;         =20 +Filter: ((name)::text =3D=20 +'EKDEV'::text)"
"         = +;            = +            &= +nbsp;   =20 +->  Seq Scan on t_seferler s  (cost=3D0.00..3.17 rows=3D94 = +width=3D90)=20 +(actual time=3D0.003..0.160 rows=3D94=20 +loops=3D4)"
"         &nb= +sp;           &nbs= +p;            = +;         =20 +Filter: ((iptal)::text =3D=20 +'H'::text)"
"         &nb= +sp;           &nbs= +p;   =20 +->  Seq Scan on t_hatlar h  (cost=3D0.00..1.20 rows=3D20 = +width=3D18)=20 +(actual time=3D0.002..0.020 rows=3D20=20 +loops=3D94)"
"         &n= +bsp;         =20 +->  Index Scan using t_yer_pkey on t_yer y2  = +(cost=3D0.00..4.45=20 +rows=3D1 width=3D14) (actual time=3D0.008..0.009 rows=3D1=20 +loops=3D94)"
"         &n= +bsp;           &nb= +sp;   =20 +Index Cond: (""outer"".varis_yer_kod =3D=20 +y2.kod)"
"          = +            &= +nbsp;  =20 +Filter: ((iptal)::text =3D=20 +'H'::text)"
"         &nb= +sp;   =20 +->  Index Scan using t_yer_pkey on t_yer y1  = +(cost=3D0.00..4.45=20 +rows=3D1 width=3D14) (actual time=3D0.004..0.006 rows=3D1=20 +loops=3D94)"
"         &n= +bsp;         =20 +Index Cond: (""outer"".kalkis_yer_kod =3D=20 +y1.kod)"
"          = +         =20 +Filter: ((iptal)::text =3D=20 +'H'::text)"
"        ->  = +Seq Scan=20 +on t_sefer_tip t  (cost=3D0.00..1.02 rows=3D2 width=3D18) (actual=20 +time=3D0.002..0.006 rows=3D2=20 +loops=3D94)"
"         &n= +bsp;   =20 +Filter: ((iptal)::text =3D 'H'::text)"
"  ->  Index Scan = +using=20 +t_koltuk_islem_pkey on t_koltuk_islem i  (cost=3D0.00..2375.10 = +rows=3D39=20 +width=3D644) (actual time=3D38.151..41.881 rows=3D595=20 +loops=3D94)"
"        Index Cond:=20 +(((""outer"".firma_no)::text =3D (i.firma_no)::text) AND = +((""outer"".hat_no)::text=20 +=3D (i.hat_no)::text) AND (""outer"".kod =3D=20 +i.sefer_kod))"
"        Filter:=20 +((islem_tarihi >=3D '2006-01-17'::date) AND (islem_tarihi <=3D=20 +'2006-02-16'::date))"
"Total runtime: 4091.242 ms"
+
Best Regards
+
 
+
+
Adnan DURSUN
+
ASRIN Bili=FEim Ltd.=DEti
+
Ankara / TURKEY
+ +------=_NextPart_000_0007_01C6332A.ACC82A40-- + +From pgsql-hackers-owner@postgresql.org Thu Feb 16 13:00:06 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 16D719DCA02; + Thu, 16 Feb 2006 13:00:06 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 35612-03; Thu, 16 Feb 2006 13:00:04 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from svana.org (svana.org [125.62.94.225]) + by postgresql.org (Postfix) with ESMTP id 95AEF9DC9C5; + Thu, 16 Feb 2006 13:00:01 -0400 (AST) +Received: from kleptog by svana.org with local (Exim 4.50) + id 1F9mU3-000870-O8; Fri, 17 Feb 2006 03:59:59 +1100 +Date: Thu, 16 Feb 2006 17:59:59 +0100 +From: Martijn van Oosterhout +To: Ron +Cc: pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Subject: Re: qsort again (was Re: [PERFORM] Strange Create +Message-ID: <20060216165959.GH26127@svana.org> +Reply-To: Martijn van Oosterhout +References: <43F39E53.1020009@gpdnet.co.uk> <20781.1140046109@sss.pgh.pa.us> + <7.0.1.0.2.20060215194635.03b55da0@earthlink.net> + <21615.1140052893@sss.pgh.pa.us> + <7.0.1.0.2.20060215223710.03a7c618@earthlink.net> + <20060216113522.GA3461@uio.no> + <7.0.1.0.2.20060216071053.0385a1a8@earthlink.net> + <20060216144833.GG26127@svana.org> + <7.0.1.0.2.20060216100954.035b5ee0@earthlink.net> + <7.0.1.0.2.20060216110249.0395d2b0@earthlink.net> +Mime-Version: 1.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; boundary="7SAgGoIHugoKhRwh" +Content-Disposition: inline +In-Reply-To: <7.0.1.0.2.20060216110249.0395d2b0@earthlink.net> +X-PGP-Key-ID: Length=1024; ID=0x0DC67BE6 +X-PGP-Key-Fingerprint: 295F A899 A81A 156D B522 48A7 6394 F08A 0DC6 7BE6 +X-PGP-Key-URL: +User-Agent: Mutt/1.5.9i +X-SA-Exim-Connect-IP: +X-SA-Exim-Mail-From: kleptog@svana.org +X-SA-Exim-Scanned: No (on svana.org); SAEximRunCond expanded to false +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.122 required=5 tests=[AWL=0.122] +X-Spam-Score: 0.122 +X-Spam-Level: +X-Archive-Number: 200602/631 +X-Sequence-Number: 79769 + + +--7SAgGoIHugoKhRwh +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +Content-Transfer-Encoding: quoted-printable + +On Thu, Feb 16, 2006 at 11:32:55AM -0500, Ron wrote: +> At 10:52 AM 2/16/2006, Ron wrote: +> >In fact we can do better. +> >Using hash codes or what-not to map datums to keys and then sorting=20 +> >just the keys and the pointers to those datums followed by an=20 +> >optional final pass where we do the actual data movement is also a=20 +> >standard technique for handling large data structures. + +Or in fact required if the Datums are not all the same size, which is +the case in PostgreSQL. + +> I thought some follow up might be in order here. +>=20 +> Let's pretend that we have the typical DB table where rows are ~2-4KB=20 +> apiece. 1TB of storage will let us have 256M-512M rows in such a table. +>=20 +> A 32b hash code can be assigned to each row value such that only=20 +> exactly equal rows will have the same hash code. +> A 32b pointer can locate any of the 256M-512M rows. + +That hash code is impossible the way you state it, since the set of +strings is not mappable to a 32bit integer. You probably meant that a +hash code can be assigned such that equal rows have equal hashes (drop +the only). + +> Now instead of sorting 1TB of data we can sort 2^28 to 2^29 32b+32b=3D=20 +> 64b*(2^28 to 2^29)=3D 2-4GB of pointers+keys followed by an optional=20 +> pass to rearrange the actual rows if we so wish. +>=20 +> We get the same result while only examining and manipulating 1/50 to=20 +> 1/25 as much data during the sort. + +But this is what we do now. The tuples are loaded, we sort an array of +pointers, then we write the output. Except we don't have the hash, so +we require access to the 1TB of data to do the actual comparisons. Even +if we did have the hash, we'd *still* need access to the data to handle +tie-breaks. + +That's why your comment about moves always being more expensive than +compares makes no sense. A move can be acheived simply by swapping two +pointers in the array. A compare actually needs to call all sorts of +functions. If and only if we have functions for every data type to +produce an ordered hash, we can optimise sorts based on single +integers. + +For reference, look at comparetup_heap(). It's just 20 lines, but each +function call there expands to maybe a dozen lines of code. And it has +a loop. I don't think we're anywhere near the stage where locality of +reference makes much difference. + +We very rarely needs the tuples actualised in memory in the required +order, just the pointers are enough. + +Have a ncie day, +--=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. + +--7SAgGoIHugoKhRwh +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) + +iD8DBQFD9K+PIB7bNG8LQkwRAq+EAJ4x81C6zvXeTDvTKKBnhXMbKER3xQCfYmjX +BZff0HpisxYTcypFVyNhX/M= +=00/O +-----END PGP SIGNATURE----- + +--7SAgGoIHugoKhRwh-- + +From pgsql-performance-owner@postgresql.org Sat Feb 18 00:10:34 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 047019DC9FA + for ; + Thu, 16 Feb 2006 13:03:26 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 35612-06 + for ; + Thu, 16 Feb 2006 13:03:24 -0400 (AST) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 9C7F79DC9FD + for ; + Thu, 16 Feb 2006 13:03:23 -0400 (AST) +Received: from rally.nexus-ag.com (rally.nexus-ag.com [217.71.244.118]) + by svr4.postgresql.org (Postfix) with ESMTP id 560585AF0B0 + for ; + Thu, 16 Feb 2006 17:03:23 +0000 (GMT) +Received: from [192.168.48.122] (helo=nosferatu.nexus-ag.com) + by rally.nexus-ag.com with esmtp (Exim 3.35 #1 (Debian)) + id 1F9mXH-0001HL-00 + for ; Thu, 16 Feb 2006 18:03:19 +0100 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C6331A.E1E8329A" +Subject: Future of Table Partitioning +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Date: Thu, 16 Feb 2006 12:03:17 -0500 +Message-ID: +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: Future of Table Partitioning +Thread-Index: AcYzGuGxVmRh0LpNR6WkG4sf4q5FoQ== +From: "Patrick Carriere" +To: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.001 required=5 tests=[HTML_MESSAGE=0.001] +X-Spam-Score: 0.001 +X-Spam-Level: +X-Archive-Number: 200602/298 +X-Sequence-Number: 17284 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C6331A.E1E8329A +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: quoted-printable + +Hi, + +I was wondering what the plan is for the future of table partitioning in +PostgresQL. It is pretty hard for me to implement partitioning right now +with its current limitation, specifically the fact that unique +constraints cannot be enforced across partitions and that Constraint +Exclusion cannot be used on non-constant values like CURRENT_DATE. It is +also quite cumbersome to do all the maintenance work to create the new +child table, do the triggers, drop the old one, etc,etc using the table +inheritance every week since I would need to do weekly and monthly table +partitioning. + +So, my question in short, Is there any plan to at least do Global unique +check constraints (or at least a global unique index) and is there a +thread/documentation somewhere about what are the future planned changes +to table partitioning? + + +Thanks + +Patrick Carriere +Software Architect +Nexus Telecom (Americas) + + + + +------_=_NextPart_001_01C6331A.E1E8329A +Content-Type: text/html; + charset="US-ASCII" +Content-Transfer-Encoding: quoted-printable + + + + + + +Future of Table Partitioning + + + + +

Hi, +

+ +

I was wondering what the plan is for = +the future of table partitioning in PostgresQL. It is pretty hard for me = +to implement partitioning right now with its current limitation, = +specifically the fact that unique constraints cannot be enforced across = +partitions and that Constraint Exclusion cannot be used on non-constant = +values like CURRENT_DATE. It is also quite cumbersome to do all the = +maintenance work to create the new child table, do the triggers, drop = +the old one, etc,etc using the table inheritance every week since I = +would need to do weekly and monthly table partitioning.

+ +

So, my question in short, Is there any = +plan to at least do Global unique check constraints (or at least a = +global unique index) and is there a thread/documentation somewhere about = +what are the future planned changes to table partitioning?

+
+ +

Thanks +

+ +

Patrick Carriere + +
Software Architect + +
Nexus Telecom (Americas) +

+
+
+ + + +------_=_NextPart_001_01C6331A.E1E8329A-- + +From pgsql-performance-owner@postgresql.org Sat Feb 18 00:10:36 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 4E8039DCCED + for ; + Thu, 16 Feb 2006 13:03:36 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 36731-03 + for ; + Thu, 16 Feb 2006 13:03:34 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.194]) + by postgresql.org (Postfix) with ESMTP id CBAAE9DCCD5 + for ; + Thu, 16 Feb 2006 13:03:29 -0400 (AST) +Received: by wproxy.gmail.com with SMTP id i5so242404wra + for ; + Thu, 16 Feb 2006 09:03:29 -0800 (PST) +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=TLVzyqAmqUjpKYWpTnn/NcWs9zz+xqSgO1Uhz16QxALmY+4ijiA2Lo2KEBRzfhKaqGDFDlY3dvHI3w9wEIJVKzE+eTW0SUSbTUCWLmXL/wt+vVXbjjk/Jfi+RDfCfkNPB1IL0oPEQW2Jw9nSohZegmrSCrjR46LsfmcVg6PtWUo= +Received: by 10.64.220.13 with SMTP id s13mr341821qbg; + Thu, 16 Feb 2006 09:03:29 -0800 (PST) +Received: by 10.65.231.4 with HTTP; Thu, 16 Feb 2006 09:03:29 -0800 (PST) +Message-ID: +Date: Thu, 16 Feb 2006 13:03:29 -0400 +From: Adam Alkins +To: pgsql-performance@postgresql.org +Subject: Index Choice Problem +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, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200602/299 +X-Sequence-Number: 17285 + +Hi List, + +I would like some insight from the experts here as to how I can alter +which index PostgreSQL is choosing to run a query. + +First off, I'm running an active web forum (phpBB) with sometimes +hundreds of concurrent users. The query in question is one which pulls +the lists of topics in the forum. The table in question is here: + +-- + +forums=3D> \d phpbb_topics; + Table "public.phpbb_topics" + Column | Type | =20 +Modifiers +----------------------+-----------------------+----------------------------= +--------------------------- + topic_id | integer | not null default +nextval('phpbb_topics_id_seq'::text) + forum_id | integer | not null default 0 + topic_title | character varying(60) | not null default +''::character varying + topic_poster | integer | not null default 0 + topic_time | integer | not null default 0 + topic_views | integer | not null default 0 + topic_replies | integer | not null default 0 + topic_status | smallint | not null default (0)::small= +int + topic_vote | smallint | not null default (0)::small= +int + topic_type | smallint | not null default (0)::small= +int + topic_first_post_id | integer | not null default 0 + topic_last_post_id | integer | not null default 0 + topic_moved_id | integer | not null default 0 + topic_last_post_time | integer | not null default 0 +Indexes: + "forum_id_phpbb_topics_index" btree (forum_id) + "topic_id_phpbb_topics_index" btree (topic_id) + "topic_last_post_id_phpbb_topics_index" btree (topic_last_post_id) + "topic_last_post_time_phpbb_topics_index" btree (topic_last_post_time) + "topic_moved_id_phpbb_topics_index" btree (topic_moved_id) + +-- + +To layout the contents of the table, here are some relevant queries +showing the number of entries + +forums=3D# SELECT COUNT(*) FROM phpbb_topics; SELECT COUNT(*) FROM +phpbb_topics WHERE forum_id =3D 71; SELECT COUNT(*) FROM phpbb_topics +WHERE forum_id =3D 55; + count +-------- + 190588 +(1 row) + + count +------- + 1013 +(1 row) + + count +------- + 35035 +(1 row) + +-- + +Ok. Now, here's the problem. I run a query to pull the list of topics +for the forum. There pagination, so the first page query looks like +this: + +SELECT t.topic_id +=09=09=09FROM phpbb_topics AS t +=09=09=09=09WHERE t.forum_id =3D 71 +=09=09=09=09=09AND t.topic_id NOT IN (205026, 29046, 144569, 59780, 187424, +138635, 184973, 170551, 22419, 181690, 197254, 205130) +=09=09=09=09=09=09ORDER BY t.topic_last_post_time DESC +=09=09=09=09=09=09=09LIMIT 23 OFFSET 0 + + =20 + =20 + =20 + QUERY PLAN +---------------------------------------------------------------------------= +---------------------------------------------------------------------------= +--------------- + Limit (cost=3D3487.78..3487.87 rows=3D34 width=3D8) (actual +time=3D1112.921..1113.005 rows=3D34 loops=3D1) + -> Sort (cost=3D3486.15..3489.10 rows=3D1181 width=3D8) (actual +time=3D1112.087..1112.535 rows=3D687 loops=3D1) + Sort Key: topic_last_post_time + -> Index Scan using forum_id_phpbb_topics_index on +phpbb_topics t (cost=3D0.00..3425.89 rows=3D1181 width=3D8) (actual +time=3D54.650..1109.877 rows=3D1012 loops=3D1) + Index Cond: (forum_id =3D 71) + Filter: (topic_id <> 205026) + Total runtime: 1113.268 ms +(7 rows) + +-- + +This is the query on one of the lesser active forums (forum_id =3D 71) +which as list earlier only has 1013 rows. This query slow because +PostgreSQL is not using the index on the "forum_id" column, but +instead scanning through the topics via the topic_last_post_time and +filtering through the posts. This would be good for the forum_id =3D 55 +where the most recent topics would be quickly found. Now here's the +stranger part, going deeper into the results (ie selecting pages +further down), the planner does this: + +-- + +SELECT t.topic_id +=09=09=09FROM phpbb_topics AS t +=09=09=09=09WHERE t.forum_id =3D 71 +=09=09=09=09=09AND t.topic_id NOT IN (205026) +=09=09=09=09=09=09ORDER BY t.topic_last_post_time DESC +=09=09=09=09=09=09=09LIMIT 34 OFFSET 653 + + =20 + QUERY PLAN +---------------------------------------------------------------------------= +---------------------------------------------------------------------------= +----------- + Limit (cost=3D3487.78..3487.87 rows=3D34 width=3D8) (actual +time=3D6.140..6.202 rows=3D34 loops=3D1) + -> Sort (cost=3D3486.15..3489.10 rows=3D1181 width=3D8) (actual +time=3D5.306..5.753 rows=3D687 loops=3D1) + Sort Key: topic_last_post_time + -> Index Scan using forum_id_phpbb_topics_index on +phpbb_topics t (cost=3D0.00..3425.89 rows=3D1181 width=3D8) (actual +time=3D0.070..3.581 rows=3D1012 loops=3D1) + Index Cond: (forum_id =3D 71) + Filter: (topic_id <> 205026) + Total runtime: 6.343 ms +(7 rows) + +-- + +This is more like how it should be done IMO. Results are much faster +when the forum id index is used. Now, the output of the first query on +the forum_id =3D 55 looks like this + +-- + +SELECT t.topic_id +=09=09=09FROM phpbb_topics AS t +=09=09=09=09WHERE t.forum_id =3D 55 +=09=09=09=09=09AND t.topic_id NOT IN (159934, 168973, 79609, 179029, 61593, +184896, 190572) +=09=09=09=09=09=09ORDER BY t.topic_last_post_time DESC +=09=09=09=09=09=09=09LIMIT 28 OFFSET 0 + + =20 + QUERY PLAN +---------------------------------------------------------------------------= +---------------------------------------------------------------------------= +---------------------------------------------------------- + Limit (cost=3D0.00..50.50 rows=3D28 width=3D8) (actual time=3D0.060..0.71= +4 +rows=3D28 loops=3D1) + -> Index Scan Backward using +topic_last_post_time_phpbb_topics_index on phpbb_topics t=20 +(cost=3D0.00..63232.38 rows=3D35063 width=3D8) (actual time=3D0.057..0.675 +rows=3D28 loops=3D1) + Filter: ((forum_id =3D 55) AND (topic_id <> 159934) AND +(topic_id <> 168973) AND (topic_id <> 79609) AND (topic_id <> 179029) +AND (topic_id <> 61593) AND (topic_id <> 184896) AND (topic_id <> +190572)) + Total runtime: 0.794 ms + +-- + +This is acceptable usage when the forum_id is heavily populated. Next +now, here again puzzles me, pulling entries in the middle of forum_id +=3D 55 + +-- + +SELECT t.topic_id +=09=09=09FROM phpbb_topics AS t +=09=09=09=09WHERE t.forum_id =3D 55 +=09=09=09=09=09AND t.topic_id NOT IN (159934, 168973) +=09=09=09=09=09=09ORDER BY t.topic_last_post_time DESC +=09=09=09=09=09=09=09LIMIT 33 OFFSET 17458 + + QUERY PLAN +---------------------------------------------------------------------------= +------------------------------------------------------- + Limit (cost=3D29302.43..29302.51 rows=3D33 width=3D8) (actual +time=3D625.907..625.969 rows=3D33 loops=3D1) + -> Sort (cost=3D29258.78..29346.44 rows=3D35064 width=3D8) (actual +time=3D603.710..615.411 rows=3D17491 loops=3D1) + Sort Key: topic_last_post_time + -> Seq Scan on phpbb_topics t (cost=3D0.00..26611.85 +rows=3D35064 width=3D8) (actual time=3D0.067..528.271 rows=3D35034 loops=3D= +1) + Filter: ((forum_id =3D 55) AND (topic_id <> 159934) AND +(topic_id <> 168973)) + Total runtime: 632.444 ms +(6 rows) + +-- + +Why is it doing a sequential scan? :( + +My questions... is there a method for me to suggest which index to use +in the query. I'm think adding logic in my script depending on which +forum_id is used (since I can hard code in my scripts which are the +popular forums) and tell the planner to use a specific index first? + +Secondly, why in the last output did it opt to do a sequential scan +over using the forum_id index as it did earlier. + +Side note, a vacuum analayze was done just prior to running these tests. + +Thank you, +-- +Adam Alkins +http://www.rasadam.com +Mobile: 868-680-4612 + +From pgsql-hackers-owner@postgresql.org Thu Feb 16 13:15:17 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 46E8D9DC831; + Thu, 16 Feb 2006 13:15:14 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37805-05; Thu, 16 Feb 2006 13:15:13 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id E08159DC83D; + Thu, 16 Feb 2006 13:15:11 -0400 (AST) +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 k1GHF8cO029278; + Thu, 16 Feb 2006 12:15:08 -0500 (EST) +To: "Craig A. James" +cc: Markus Schaber , pgsql-performance@postgresql.org, + pgsql-hackers@postgresql.org +Subject: Re: qsort again (was Re: [PERFORM] Strange Create Index +In-reply-to: <43F4A7D8.4050907@modgraph-usa.com> +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> + <7.0.1.0.2.20060215194635.03b55da0@earthlink.net> + <21615.1140052893@sss.pgh.pa.us> + <7.0.1.0.2.20060215223710.03a7c618@earthlink.net> + <20060216113522.GA3461@uio.no> + <7.0.1.0.2.20060216071053.0385a1a8@earthlink.net> + <43F481CD.2010509@logix-tt.com> <43F4A7D8.4050907@modgraph-usa.com> +Comments: In-reply-to "Craig A. James" + message dated "Thu, 16 Feb 2006 08:27:04 -0800" +Date: Thu, 16 Feb 2006 12:15:08 -0500 +Message-ID: <29277.1140110108@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.11 required=5 tests=[AWL=0.110] +X-Spam-Score: 0.11 +X-Spam-Level: +X-Archive-Number: 200602/632 +X-Sequence-Number: 79770 + +"Craig A. James" writes: +> You can also use this trick when the optimizer is asked for "fastest first result." Say you have a cursor on a column of numbers with good distribution. If you do a bucket sort on the first two or three digits only, you know the first "page" of results will be in the first bucket. So you only need to apply qsort to that first bucket (which is very fast, since it's small), and you can deliver the first page of data to the application. This can be particularly effective in interactive situations, where the user typically looks at a few pages of data and then abandons the search. + +> I doubt this is very relevant to Postgres. A relational database has to be general purpose, and it's hard to give it "hints" that would tell it when to use this particular optimization. + +Actually, LIMIT does nicely for that hint; the PG planner has definitely +got a concept of preferring fast-start plans for limited queries. The +real problem in applying bucket-sort ideas is the lack of any +datatype-independent way of setting up the buckets. + +Once or twice we've kicked around the idea of having some +datatype-specific sorting code paths alongside the general-purpose one, +but I can't honestly see this as being workable from a code maintenance +standpoint. + + regards, tom lane + +From pgsql-hackers-owner@postgresql.org Thu Feb 16 13:49:57 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id F2A2D9DCD00; + Thu, 16 Feb 2006 13:49:55 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 46072-02; Thu, 16 Feb 2006 13:49:54 -0400 (AST) +X-Greylist: delayed 00:30:24.397906 by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from calvin.slamb.org (calvin.slamb.org [216.136.66.56]) + by postgresql.org (Postfix) with ESMTP id BB2B59DCCFF; + Thu, 16 Feb 2006 13:49:52 -0400 (AST) +Received: by calvin.slamb.org (Postfix, from userid 103) + id DC40D7BC9D; Thu, 16 Feb 2006 11:19:27 -0600 (CST) +Received: from [IPv6:::1] (localhost.slamb.org [127.0.0.1]) + by calvin.slamb.org (Postfix) with ESMTP + id B0CBB7BC5E; Thu, 16 Feb 2006 11:19:26 -0600 (CST) +In-Reply-To: <7.0.1.0.2.20060216110249.0395d2b0@earthlink.net> +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> + <7.0.1.0.2.20060215194635.03b55da0@earthlink.net> + <21615.1140052893@sss.pgh.pa.us> + <7.0.1.0.2.20060215223710.03a7c618@earthlink.net> + <20060216113522.GA3461@uio.no> + <7.0.1.0.2.20060216071053.0385a1a8@earthlink.net> + <20060216144833.GG26127@svana.org> + <7.0.1.0.2.20060216100954.035b5ee0@earthlink.net> + <7.0.1.0.2.20060216110249.0395d2b0@earthlink.net> +Mime-Version: 1.0 (Apple Message framework v746.2) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <87FA36B4-CD97-4CF5-B9B3-02FEEA25CC95@slamb.org> +Cc: Martijn van Oosterhout , + pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Content-Transfer-Encoding: 7bit +From: Scott Lamb +Subject: Re: qsort again (was Re: [PERFORM] Strange Create +Date: Thu, 16 Feb 2006 09:19:24 -0800 +To: Ron +X-Mailer: Apple Mail (2.746.2) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200602/633 +X-Sequence-Number: 79771 + +On Feb 16, 2006, at 8:32 AM, Ron wrote: +> Let's pretend that we have the typical DB table where rows are +> ~2-4KB apiece. 1TB of storage will let us have 256M-512M rows in +> such a table. +> +> A 32b hash code can be assigned to each row value such that only +> exactly equal rows will have the same hash code. +> A 32b pointer can locate any of the 256M-512M rows. +> +> Now instead of sorting 1TB of data we can sort 2^28 to 2^29 32b +> +32b= 64b*(2^28 to 2^29)= 2-4GB of pointers+keys followed by an +> optional pass to rearrange the actual rows if we so wish. + +I don't understand this. + +This is a true statement: (H(x) != H(y)) => (x != y) +This is not: (H(x) < H(y)) => (x < y) + +Hash keys can tell you there's an inequality, but they can't tell you +how the values compare. If you want 32-bit keys that compare in the +same order as the original values, here's how you have to get them: + +(1) sort the values into an array +(2) use each value's array index as its key + +It reduces to the problem you're trying to use it to solve. + + +-- +Scott Lamb + + + +From pgsql-performance-owner@postgresql.org Thu Feb 16 13:28:56 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 0EA4C9DCBA3 + for ; + Thu, 16 Feb 2006 13:28:56 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 42314-01 + for ; + Thu, 16 Feb 2006 13:28:54 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id B00D59DCB6A + for ; + Thu, 16 Feb 2006 13:28:53 -0400 (AST) +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 k1GHRaaL029368; + Thu, 16 Feb 2006 12:27:36 -0500 (EST) +To: "Adnan DURSUN" +cc: pgsql-performance@postgresql.org +Subject: Re: Why does not perform index combination +In-reply-to: +References: +Comments: In-reply-to "Adnan DURSUN" + message dated "Thu, 16 Feb 2006 18:56:20 +0200" +Date: Thu, 16 Feb 2006 12:27:36 -0500 +Message-ID: <29367.1140110856@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.11 required=5 tests=[AWL=0.110] +X-Spam-Score: 0.11 +X-Spam-Level: +X-Archive-Number: 200602/258 +X-Sequence-Number: 17244 + +"Adnan DURSUN" writes: +> I have query for a report. Explain analyze result is below. The = +> execution plan tells that it would use "t_koltuk_islem_pkey" index on = +> table "t_koltuk_islem" to scan. However, there is another index on table = +> "t_koltuk_islem" on column "islem_tarihi" that can be combined on plan. = +> Why doesn't optimizer choice that ? It prefer to perform a filter on = +> column "islem_tarihi" ... Why ? + +Probably thinks that the extra index doesn't add enough selectivity to +be worth scanning. It's probably right, too --- maybe with a narrower +date range the answer would be different. + +I think the main problem in this plan is the poor estimation of the size +of the d1/s join. Are your stats up to date on those tables? Maybe +boosting the statistics target for one or both would help. + + regards, tom lane + +From pgsql-hackers-owner@postgresql.org Thu Feb 16 14:39:49 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id C02869DC9FA; + Thu, 16 Feb 2006 14:39:48 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 56025-02; Thu, 16 Feb 2006 14:39:48 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from postal.corporate.connx.com (postal.corporate.connx.com + [65.212.159.187]) + by postgresql.org (Postfix) with ESMTP id 312C59DC82C; + Thu, 16 Feb 2006 14:39:45 -0400 (AST) +Content-class: urn:content-classes:message +Subject: Re: qsort again (was Re: [PERFORM] Strange Create Index +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Date: Thu, 16 Feb 2006 10:39:45 -0800 +X-MimeOLE: Produced By Microsoft Exchange V6.5 +Message-ID: + +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [HACKERS] qsort again (was Re: [PERFORM] Strange Create Index +Thread-Index: AcYy/z+jeIb5/aDsRcOmf1bPXXjiqwAJz1ig +From: "Dann Corbit" +To: "Markus Schaber" , + , + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.077 required=5 tests=[AWL=0.077] +X-Spam-Score: 0.077 +X-Spam-Level: +X-Archive-Number: 200602/634 +X-Sequence-Number: 79772 + +> -----Original Message----- +> From: pgsql-hackers-owner@postgresql.org [mailto:pgsql-hackers- +> owner@postgresql.org] On Behalf Of Markus Schaber +> Sent: Thursday, February 16, 2006 5:45 AM +> To: pgsql-performance@postgresql.org; pgsql-hackers@postgresql.org +> Subject: Re: [HACKERS] qsort again (was Re: [PERFORM] Strange Create +Index +>=20 +> Hi, Ron, +>=20 +> Ron wrote: +>=20 +> > ...and of course if you know enough about the data to be sorted so +as to +> > constrain it appropriately, one should use a non comparison based +O(N) +> > sorting algorithm rather than any of the general comparison based +> > O(NlgN) methods. +>=20 +> Sounds interesting, could you give us some pointers (names, URLs, +> papers) to such algorithms? + +He refers to counting sort and radix sort (which comes in most +significant digit and least significant digit format). These are also +called distribution (as opposed to comparison) sorts. + +These sorts are O(n) as a function of the data size, but really they are +O(M*n) where M is the average key length and n is the data set size. +(In the case of MSD radix sort M is the average length to completely +differentiate strings) + +So if you have an 80 character key, then 80*log(n) will only be faster +than n*log(n) when you have 2^80th elements -- in other words -- never. + +If you have short keys, on the other hand, distribution sorts will be +dramatically faster. On an unsigned integer, for instance, it requires +4 passes with 8 bit buckets and so 16 elements is the crossover to radix +is faster than an O(n*log(n)) sort. Of course, there is a fixed +constant of proportionality and so it will really be higher than that, +but for large data sets distribution sorting is the best thing that +there is for small keys. + +You could easily have an introspective MSD radix sort. The nice thing +about MSD radix sort is that you can retain the ordering that has +occurred so far and switch to another algorithm. + +An introspective MSD radix sort could call an introspective quick sort +algorithm once it processed a crossover point of buckets of key data. + +In order to have distribution sorts that will work with a database +system, for each and every data type you will need a function to return +the bucket of bits of significance for the kth bucket of bits. For a +character string, you could return key[bucket]. For an unsigned integer +it is the byte of the integer to return will be a function of the +endianness of the CPU. And for each other distinct data type a bucket +function would be needed or a sort could not be generated for that type +using the distribution method. + +From pgsql-hackers-owner@postgresql.org Thu Feb 16 14:47:23 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id C08A39DCBA3; + Thu, 16 Feb 2006 14:47:22 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 56890-03; Thu, 16 Feb 2006 14:47:22 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smtpauth01.mail.atl.earthlink.net + (smtpauth01.mail.atl.earthlink.net [209.86.89.61]) + by postgresql.org (Postfix) with ESMTP id AEE519DCB63; + Thu, 16 Feb 2006 14:47:19 -0400 (AST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=bALduVVYWIvQ5B+fiXuva5UlYKZn2mNUDAjxtvrkCkn7ZIlN8Az6wZilSO5WayJG; + 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.34.169.163] (helo=ron-6d52adff2a6.earthlink.net) + by smtpauth01.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1F9o9v-0004Mf-63; Thu, 16 Feb 2006 13:47:19 -0500 +Message-Id: <7.0.1.0.2.20060216133801.03a7ab50@earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 7.0.1.0 +Date: Thu, 16 Feb 2006 13:47:14 -0500 +To: Scott Lamb ,pgsql-performance@postgresql.org, + pgsql-hackers@postgresql.org +From: Ron +Subject: Re: qsort again (was Re: [PERFORM] Strange Create +In-Reply-To: <87FA36B4-CD97-4CF5-B9B3-02FEEA25CC95@slamb.org> +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> + <7.0.1.0.2.20060215194635.03b55da0@earthlink.net> + <21615.1140052893@sss.pgh.pa.us> + <7.0.1.0.2.20060215223710.03a7c618@earthlink.net> + <20060216113522.GA3461@uio.no> + <7.0.1.0.2.20060216071053.0385a1a8@earthlink.net> + <20060216144833.GG26127@svana.org> + <7.0.1.0.2.20060216100954.035b5ee0@earthlink.net> + <7.0.1.0.2.20060216110249.0395d2b0@earthlink.net> + <87FA36B4-CD97-4CF5-B9B3-02FEEA25CC95@slamb.org> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bc16fc814c666dc5d7a546f17257a8d2de350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 24.34.169.163 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.452 required=5 tests=[AWL=-0.027, + DNS_FROM_RFC_ABUSE=0.479] +X-Spam-Score: 0.452 +X-Spam-Level: +X-Archive-Number: 200602/635 +X-Sequence-Number: 79773 + +At 12:19 PM 2/16/2006, Scott Lamb wrote: +>On Feb 16, 2006, at 8:32 AM, Ron wrote: +>>Let's pretend that we have the typical DB table where rows are +>>~2-4KB apiece. 1TB of storage will let us have 256M-512M rows in +>>such a table. +>> +>>A 32b hash code can be assigned to each row value such that only +>>exactly equal rows will have the same hash code. +>>A 32b pointer can locate any of the 256M-512M rows. +>> +>>Now instead of sorting 1TB of data we can sort 2^28 to 2^29 32b +>>+32b= 64b*(2^28 to 2^29)= 2-4GB of pointers+keys followed by an +>>optional pass to rearrange the actual rows if we so wish. +> +>I don't understand this. +> +>This is a true statement: (H(x) != H(y)) => (x != y) +>This is not: (H(x) < H(y)) => (x < y) +> +>Hash keys can tell you there's an inequality, but they can't tell you +>how the values compare. If you want 32-bit keys that compare in the +>same order as the original values, here's how you have to get them: +For most hash codes, you are correct. There is a class of hash or +hash-like codes that maintains the mapping to support that second statement. + +More later when I can get more time. +Ron + + + +From pgsql-hackers-owner@postgresql.org Thu Feb 16 15:13:15 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id E987C9DC9B8; + Thu, 16 Feb 2006 15:13:14 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 59288-10; Thu, 16 Feb 2006 15:13:14 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mailbox.samurai.com (mailbox.samurai.com [205.207.28.82]) + by postgresql.org (Postfix) with ESMTP id 380F29DC83D; + Thu, 16 Feb 2006 15:13:11 -0400 (AST) +Received: from localhost (mailbox.samurai.com [205.207.28.82]) + by mailbox.samurai.com (Postfix) with ESMTP id D062E239461; + Thu, 16 Feb 2006 14:13:12 -0500 (EST) +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 71135-02-7; Thu, 16 Feb 2006 14:13:10 -0500 (EST) +Received: from [192.168.1.102] (d226-82-205.home.cgocable.net [24.226.82.205]) + by mailbox.samurai.com (Postfix) with ESMTP id 41A2B239456; + Thu, 16 Feb 2006 14:13:10 -0500 (EST) +Subject: Re: qsort again (was Re: [PERFORM] Strange Create Index +From: Neil Conway +To: "Steinar H. Gunderson" +Cc: pgsql-performance@postgresql.org, + PostgreSQL-development +In-Reply-To: <20060216113522.GA3461@uio.no> +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> + <7.0.1.0.2.20060215194635.03b55da0@earthlink.net> + <21615.1140052893@sss.pgh.pa.us> + <7.0.1.0.2.20060215223710.03a7c618@earthlink.net> + <20060216113522.GA3461@uio.no> +Content-Type: text/plain +Date: Thu, 16 Feb 2006 14:14:03 -0500 +Message-Id: <1140117243.31672.54.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.4.1 +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, score=0.067 required=5 tests=[AWL=0.067] +X-Spam-Score: 0.067 +X-Spam-Level: +X-Archive-Number: 200602/636 +X-Sequence-Number: 79774 + +On Thu, 2006-02-16 at 12:35 +0100, Steinar H. Gunderson wrote: +> glibc-2.3.5/stdlib/qsort.c: +> +> /* Order size using quicksort. This implementation incorporates +> four optimizations discussed in Sedgewick: +> +> I can't see any references to merge sort in there at all. + +stdlib/qsort.c defines _quicksort(), not qsort(), which is defined by +msort.c. On looking closer, it seems glibc actually tries to determine +the physical memory in the machine -- if it is sorting a single array +that exceeds 1/4 of the machine's physical memory, it uses quick sort, +otherwise it uses merge sort. + +-Neil + + + +From pgsql-performance-owner@postgresql.org Thu Feb 16 18:16:58 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 9776A9DC857 + for ; + Thu, 16 Feb 2006 18:16:57 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18684-07 + for ; + Thu, 16 Feb 2006 18:16:58 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from hotmail.com (bay106-dav18.bay106.hotmail.com [65.54.161.90]) + by postgresql.org (Postfix) with ESMTP id 87F5B9DC83B + for ; + Thu, 16 Feb 2006 18:16:54 -0400 (AST) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Thu, 16 Feb 2006 14:16:56 -0800 +Message-ID: +Received: from 85.105.24.123 by BAY106-DAV18.phx.gbl with DAV; + Thu, 16 Feb 2006 22:16:56 +0000 +X-Originating-IP: [85.105.24.123] +X-Originating-Email: [a_dursun@hotmail.com] +X-Sender: a_dursun@hotmail.com +From: "Adnan DURSUN" +To: +Subject: Re: Why does not perform index combination +Date: Fri, 17 Feb 2006 00:14:56 +0200 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0003_01C63357.2ECF59B0" +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-OriginalArrivalTime: 16 Feb 2006 22:16:56.0295 (UTC) + FILETIME=[B28CFF70:01C63346] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=2.187 required=5 tests=[AWL=0.267, + DNS_FROM_RFC_ABUSE=0.479, DNS_FROM_RFC_POST=1.44, HTML_MESSAGE=0.001, + MSGID_FROM_MTA_HEADER=0] +X-Spam-Score: 2.187 +X-Spam-Level: ** +X-Archive-Number: 200602/262 +X-Sequence-Number: 17248 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0003_01C63357.2ECF59B0 +Content-Type: text/plain; + charset="iso-8859-9" +Content-Transfer-Encoding: quoted-printable + +>From: Tom Lane +>Date: 02/16/06 19:29:21 +>To: Adnan DURSUN +>Cc: pgsql-performance@postgresql.org +>Subject: Re: [PERFORM] Why does not perform index combination + +>"Adnan DURSUN" writes: +>> I have query for a report. Explain analyze result is below. The =3D +>> execution plan tells that it would use "t_koltuk_islem_pkey" index on = +=3D +>> table "t_koltuk_islem" to scan. However, there is another index on = +table =3D +>> "t_koltuk_islem" on column "islem_tarihi" that can be combined on = +plan. =3D +>> Why doesn't optimizer choice that ? It prefer to perform a filter on = +=3D +>> column "islem_tarihi" ... Why ? + +>Probably thinks that the extra index doesn't add enough selectivity to +>be worth scanning. It's probably right, too --- maybe with a narrower +>date range the answer would be different. + + Yes, a narrower date range solves that.. Thanks for your = +suggestions... + +>I think the main problem in this plan is the poor estimation of the = +size +>of the d1/s join. Are your stats up to date on those tables? Maybe +>boosting the statistics target for one or both would help. + + Database was vacuumed and analyzed before got take the plan.. + +Regards +Adnan DURSUN + +------=_NextPart_000_0003_01C63357.2ECF59B0 +Content-Type: text/html; + charset="iso-8859-9" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
+
+
>From: Tom Lane
+
>Date: = +02/16/06=20 +19:29:21
+
>To: Adnan DURSUN
+
>Cc: pgsql-performance@postgr= +esql.org
+
>Subject: Re: = +[PERFORM]=20 +Why does not perform index combination
+
 
+
>"Adnan DURSUN" <a_dursun@hotmail.com> = +writes:
+
>>   I have query for a report. Explain analyze = +result is=20 +below. The =3D
+
>> execution plan tells that it would use = +"t_koltuk_islem_pkey" index=20 +on =3D
+
>> table "t_koltuk_islem" to scan. However, there is another = +index on=20 +table =3D
+
>> "t_koltuk_islem" on column "islem_tarihi" that can be = +combined on=20 +plan. =3D
+
>> Why doesn't optimizer choice that ? It prefer to perform a = +filter=20 +on =3D
+
>> column "islem_tarihi" ... Why ?
+
 
+
>Probably thinks that the extra index doesn't add enough = +selectivity=20 +to
+
>be worth scanning.  It's probably right, too --- = +maybe with a=20 +narrower
+
>date range the answer would be different.
+
 
+
    Yes, a narrower date range solves that.. Thanks = +for your=20 +suggestions...
+
 
+
>I think the main problem in this plan is the poor estimation of = +the=20 +size
+
>of the d1/s join.  Are your stats up to date on those = + +tables?  Maybe
+
>boosting the statistics target for one or both would = +help.
+
 
+
    Database was vacuumed and analyzed = +before got take=20 +the plan..
+
 
+
Regards
+
Adnan DURSUN
+
 
+ +------=_NextPart_000_0003_01C63357.2ECF59B0-- + +From pgsql-hackers-owner@postgresql.org Thu Feb 16 18:17:41 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 920929DC9B9; + Thu, 16 Feb 2006 18:17:40 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 26710-04; Thu, 16 Feb 2006 18:17:42 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mir3-fs.mir3.com (mail.mir3.com [65.208.188.100]) + by postgresql.org (Postfix) with ESMTP id 5C3E29DC9BF; + Thu, 16 Feb 2006 18:17:35 -0400 (AST) +Received: mir3-fs.mir3.com 172.16.1.11 from 172.16.2.68 172.16.2.68 via HTTP + with MS-WebStorage 6.0.6249 +Received: from archimedes.mirlogic.com by mir3-fs.mir3.com; + 16 Feb 2006 14:17:36 -0800 +Subject: Re: qsort again (was Re: [PERFORM] Strange Create Index +From: Mark Lewis +To: Tom Lane +Cc: "Craig A. James" , + Markus Schaber , + pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +In-Reply-To: <29277.1140110108@sss.pgh.pa.us> +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> + <7.0.1.0.2.20060215194635.03b55da0@earthlink.net> + <21615.1140052893@sss.pgh.pa.us> + <7.0.1.0.2.20060215223710.03a7c618@earthlink.net> + <20060216113522.GA3461@uio.no> + <7.0.1.0.2.20060216071053.0385a1a8@earthlink.net> + <43F481CD.2010509@logix-tt.com> <43F4A7D8.4050907@modgraph-usa.com> + <29277.1140110108@sss.pgh.pa.us> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Organization: MIR3, Inc. +Date: Thu, 16 Feb 2006 14:17:36 -0800 +Message-Id: <1140128256.9076.254.camel@archimedes> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-22) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.121 required=5 tests=[AWL=0.120, + UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 0.121 +X-Spam-Level: +X-Archive-Number: 200602/642 +X-Sequence-Number: 79780 + +On Thu, 2006-02-16 at 12:15 -0500, Tom Lane wrote: +> Once or twice we've kicked around the idea of having some +> datatype-specific sorting code paths alongside the general-purpose one, +> but I can't honestly see this as being workable from a code maintenance +> standpoint. +> +> regards, tom lane + + +It seems that instead of maintaining a different sorting code path for +each data type, you could get away with one generic path and one +(hopefully faster) path if you allowed data types to optionally support +a 'sortKey' interface by providing a function f which maps inputs to 32- +bit int outputs, such that the following two properties hold: + +f(a)>=f(b) iff a>=b +if a==b then f(a)==f(b) + +So if a data type supports the sortKey interface you could perform the +sort on f(value) and only refer back to the actual element comparison +functions when two sortKeys have the same value. + +Data types which could probably provide a useful function for f would be +int2, int4, oid, and possibly int8 and text (at least for SQL_ASCII). + +Depending on the overhead, you might not even need to maintain 2 +independent search code paths, since you could always use f(x)=0 as the +default sortKey function which would degenerate to the exact same sort +behavior in use today. + +-- Mark Lewis + +From pgsql-hackers-owner@postgresql.org Thu Feb 16 18:33:53 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 883DF9DC9B9; + Thu, 16 Feb 2006 18:33:52 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34124-04; Thu, 16 Feb 2006 18:33:54 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from moutng.kundenserver.de (moutng.kundenserver.de + [212.227.126.188]) + by postgresql.org (Postfix) with ESMTP id 2B79E9DC873; + Thu, 16 Feb 2006 18:33:49 -0400 (AST) +Received: from [84.157.0.176] (helo=lunix.schabi.de) + by mrelayeu.kundenserver.de (node=mrelayeu3) with ESMTP (Nemesis), + id 0MKxQS-1F9rh90aNq-0000Ak; Thu, 16 Feb 2006 23:33:51 +0100 +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by lunix.schabi.de (Postfix) with ESMTP id 53A961CC8D2; + Thu, 16 Feb 2006 23:33:49 +0100 (CET) +Message-ID: <43F4FDCC.2000204@logix-tt.com> +Date: Thu, 16 Feb 2006 23:33:48 +0100 +From: Markus Schaber +User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: de-DE, de, en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +CC: pgsql-hackers@postgresql.org +Subject: Re: qsort again (was Re: [PERFORM] Strange Create Index +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> + <7.0.1.0.2.20060215194635.03b55da0@earthlink.net> + <21615.1140052893@sss.pgh.pa.us> + <7.0.1.0.2.20060215223710.03a7c618@earthlink.net> + <20060216113522.GA3461@uio.no> + <7.0.1.0.2.20060216071053.0385a1a8@earthlink.net> + <43F481CD.2010509@logix-tt.com> + <43F4A7D8.4050907@modgraph-usa.com> + <29277.1140110108@sss.pgh.pa.us> + <1140128256.9076.254.camel@archimedes> +In-Reply-To: <1140128256.9076.254.camel@archimedes> +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=ISO-8859-15 +Content-Transfer-Encoding: 7bit +X-Provags-ID: kundenserver.de abuse@kundenserver.de + login:a9554655f07a4e401310f2acfb43f5bf +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200602/643 +X-Sequence-Number: 79781 + +Hi, Mark, + +Mark Lewis schrieb: + +> It seems that instead of maintaining a different sorting code path for +> each data type, you could get away with one generic path and one +> (hopefully faster) path if you allowed data types to optionally support +> a 'sortKey' interface by providing a function f which maps inputs to 32- +> bit int outputs, such that the following two properties hold: +> +> f(a)>=f(b) iff a>=b +> if a==b then f(a)==f(b) + +Hmm, to remove redundancy, I'd change the <= to a < and define: + +if a==b then f(a)==f(b) +if a Data types which could probably provide a useful function for f would be +> int2, int4, oid, and possibly int8 and text (at least for SQL_ASCII). + +With int2 or some restricted ranges of oid and int4, we could even +implement a bucket sort. + +Markus + +From pgsql-hackers-owner@postgresql.org Thu Feb 16 18:40:35 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 6115C9DC973; + Thu, 16 Feb 2006 18:40:34 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34457-06; Thu, 16 Feb 2006 18:40:35 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from svana.org (svana.org [125.62.94.225]) + by postgresql.org (Postfix) with ESMTP id 7C8C29DC86B; + Thu, 16 Feb 2006 18:40:31 -0400 (AST) +Received: from kleptog by svana.org with local (Exim 4.50) + id 1F9rnC-0000jI-9z; Fri, 17 Feb 2006 09:40:06 +1100 +Date: Thu, 16 Feb 2006 23:40:06 +0100 +From: Martijn van Oosterhout +To: Mark Lewis +Cc: Tom Lane , "Craig A. James" , + Markus Schaber , + pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Subject: Re: qsort again (was Re: [PERFORM] Strange Create Index +Message-ID: <20060216224006.GK26127@svana.org> +Reply-To: Martijn van Oosterhout +References: <20781.1140046109@sss.pgh.pa.us> + <7.0.1.0.2.20060215194635.03b55da0@earthlink.net> + <21615.1140052893@sss.pgh.pa.us> + <7.0.1.0.2.20060215223710.03a7c618@earthlink.net> + <20060216113522.GA3461@uio.no> + <7.0.1.0.2.20060216071053.0385a1a8@earthlink.net> + <43F481CD.2010509@logix-tt.com> <43F4A7D8.4050907@modgraph-usa.com> + <29277.1140110108@sss.pgh.pa.us> + <1140128256.9076.254.camel@archimedes> +Mime-Version: 1.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; boundary="P7Tqkd/m/Jnohiaz" +Content-Disposition: inline +In-Reply-To: <1140128256.9076.254.camel@archimedes> +X-PGP-Key-ID: Length=1024; ID=0x0DC67BE6 +X-PGP-Key-Fingerprint: 295F A899 A81A 156D B522 48A7 6394 F08A 0DC6 7BE6 +X-PGP-Key-URL: +User-Agent: Mutt/1.5.9i +X-SA-Exim-Connect-IP: +X-SA-Exim-Mail-From: kleptog@svana.org +X-SA-Exim-Scanned: No (on svana.org); SAEximRunCond expanded to false +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.123 required=5 tests=[AWL=0.123] +X-Spam-Score: 0.123 +X-Spam-Level: +X-Archive-Number: 200602/644 +X-Sequence-Number: 79782 + + +--P7Tqkd/m/Jnohiaz +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +Content-Transfer-Encoding: quoted-printable + +On Thu, Feb 16, 2006 at 02:17:36PM -0800, Mark Lewis wrote: +> It seems that instead of maintaining a different sorting code path for +> each data type, you could get away with one generic path and one +> (hopefully faster) path if you allowed data types to optionally support +> a 'sortKey' interface by providing a function f which maps inputs to 32- +> bit int outputs, such that the following two properties hold: +>=20 +> f(a)>=3Df(b) iff a>=3Db +> if a=3D=3Db then f(a)=3D=3Df(b) + +Note this is a property of the collation, not the type. For example +strings can be sorted in many ways and the sortKey must reflect that. +So in postgres terms it's a property of the btree operator class. + +It's something I'd like to do if I get A Round Tuit. :) + +Have a nice day, +--=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. + +--P7Tqkd/m/Jnohiaz +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) + +iD8DBQFD9P9GIB7bNG8LQkwRAtB9AJwKlPgpniwDtbKSxJNNeNoPuXzU5gCdFYsD +diX9/Sk6Ua49glk4VApgnIw= +=IwiP +-----END PGP SIGNATURE----- + +--P7Tqkd/m/Jnohiaz-- + +From pgsql-hackers-owner@postgresql.org Thu Feb 16 18:51:11 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id BF5459DC9BF; + Thu, 16 Feb 2006 18:51:10 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 35506-10; Thu, 16 Feb 2006 18:51:12 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) + by postgresql.org (Postfix) with ESMTP id 18CAF9DC9E2; + Thu, 16 Feb 2006 18:51:05 -0400 (AST) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1F9rxn-0003xW-00; Thu, 16 Feb 2006 17:51:03 -0500 +To: Markus Schaber +Cc: pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Subject: Re: qsort again (was Re: [PERFORM] Strange Create Index +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> + <7.0.1.0.2.20060215194635.03b55da0@earthlink.net> + <21615.1140052893@sss.pgh.pa.us> + <7.0.1.0.2.20060215223710.03a7c618@earthlink.net> + <20060216113522.GA3461@uio.no> + <7.0.1.0.2.20060216071053.0385a1a8@earthlink.net> + <43F481CD.2010509@logix-tt.com> <43F4A7D8.4050907@modgraph-usa.com> + <29277.1140110108@sss.pgh.pa.us> + <1140128256.9076.254.camel@archimedes> <43F4FDCC.2000204@logix-tt.com> +In-Reply-To: <43F4FDCC.2000204@logix-tt.com> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 16 Feb 2006 17:51:02 -0500 +Message-ID: <871wy23okp.fsf@stark.xeocode.com> +Lines: 16 +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, score=0.13 required=5 tests=[AWL=0.130] +X-Spam-Score: 0.13 +X-Spam-Level: +X-Archive-Number: 200602/645 +X-Sequence-Number: 79783 + +Markus Schaber writes: + +> Hmm, to remove redundancy, I'd change the <= to a < and define: +> +> if a==b then f(a)==f(b) +> if a +> > Data types which could probably provide a useful function for f would be +> > int2, int4, oid, and possibly int8 and text (at least for SQL_ASCII). + +How exactly do you imagine doing this for text? + +I could see doing it for char(n)/varchar(n) where n<=4 in SQL_ASCII though. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Thu Feb 16 19:05:15 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 9BADF9DC86B + for ; + Thu, 16 Feb 2006 19:05:14 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 46083-07 + for ; + Thu, 16 Feb 2006 19:05:16 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from peufeu.com (unknown [82.67.9.10]) + by postgresql.org (Postfix) with ESMTP id E83FF9DC83B + for ; + Thu, 16 Feb 2006 19:05:10 -0400 (AST) +Received: (qmail 28176 invoked from network); 17 Feb 2006 00:05:24 +0100 +Received: from unknown (HELO apollo13) (82.67.9.10) + by boutiquenumerique.com with SMTP; 17 Feb 2006 00:05:24 +0100 +Date: Fri, 17 Feb 2006 00:05:23 +0100 +To: pgsql-performance@postgresql.org +Subject: Re: [HACKERS] qsort again (was Re: Strange Create Index +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> + <7.0.1.0.2.20060215194635.03b55da0@earthlink.net> + <21615.1140052893@sss.pgh.pa.us> + <7.0.1.0.2.20060215223710.03a7c618@earthlink.net> + <20060216113522.GA3461@uio.no> + <7.0.1.0.2.20060216071053.0385a1a8@earthlink.net> + <43F481CD.2010509@logix-tt.com> <43F4A7D8.4050907@modgraph-usa.com> + <29277.1140110108@sss.pgh.pa.us> + <1140128256.9076.254.camel@archimedes> +From: PFC +Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-ID: +In-Reply-To: <1140128256.9076.254.camel@archimedes> +User-Agent: Opera M2/8.51 (Linux, build 1462) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.093 required=5 tests=[AWL=0.093] +X-Spam-Score: 0.093 +X-Spam-Level: +X-Archive-Number: 200602/267 +X-Sequence-Number: 17253 + + + +> It seems that instead of maintaining a different sorting code path for +> each data type, you could get away with one generic path and one +> (hopefully faster) path if you allowed data types to optionally support +> a 'sortKey' interface by providing a function f which maps inputs to 32- +> bit int outputs, such that the following two properties hold: + + Looks like the decorate-sort-undecorate pattern, which works quite well. +Good idea. + I would have said a 64 bit int, but it's the same idea. However it won't +work for floats, which is a pity, because floats fit in 64 bits. Unless +more types creep in the code path (which would not necessarily make it +that slower). + As for text, the worst case is when all strings start with the same 8 +letters, but a good case pops up when a few-letter code is used as a key +in a table. Think about a zipcode, for instance. If a merge join needs to +sort on zipcodes, it might as well sort on 64-bits integers... + + By the way, I'd like to declare my zipcode columns as SQL_ASCII while the +rest of my database is in UNICODE, so they are faster to index and sort. +Come on, MySQL does it... + + Keep up ! + +From pgsql-hackers-owner@postgresql.org Thu Feb 16 19:23:10 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 255E69DC873; + Thu, 16 Feb 2006 19:23:09 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 58456-02; Thu, 16 Feb 2006 19:23:11 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mir3-fs.mir3.com (mail.mir3.com [65.208.188.100]) + by postgresql.org (Postfix) with ESMTP id DBA219DC83B; + Thu, 16 Feb 2006 19:23:06 -0400 (AST) +Received: mir3-fs.mir3.com 172.16.1.11 from 172.16.2.68 172.16.2.68 via HTTP + with MS-WebStorage 6.0.6249 +Received: from archimedes.mirlogic.com by mir3-fs.mir3.com; + 16 Feb 2006 15:23:09 -0800 +Subject: Re: qsort again (was Re: [PERFORM] Strange Create Index +From: Mark Lewis +To: Greg Stark +Cc: Markus Schaber , pgsql-performance@postgresql.org, + pgsql-hackers@postgresql.org +In-Reply-To: <871wy23okp.fsf@stark.xeocode.com> +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> + <7.0.1.0.2.20060215194635.03b55da0@earthlink.net> + <21615.1140052893@sss.pgh.pa.us> + <7.0.1.0.2.20060215223710.03a7c618@earthlink.net> + <20060216113522.GA3461@uio.no> + <7.0.1.0.2.20060216071053.0385a1a8@earthlink.net> + <43F481CD.2010509@logix-tt.com> <43F4A7D8.4050907@modgraph-usa.com> + <29277.1140110108@sss.pgh.pa.us> <1140128256.9076.254.camel@archimedes> + <43F4FDCC.2000204@logix-tt.com> <871wy23okp.fsf@stark.xeocode.com> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Organization: MIR3, Inc. +Date: Thu, 16 Feb 2006 15:23:09 -0800 +Message-Id: <1140132189.9076.261.camel@archimedes> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-22) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.126 required=5 tests=[AWL=0.125, + UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 0.126 +X-Spam-Level: +X-Archive-Number: 200602/646 +X-Sequence-Number: 79784 + +On Thu, 2006-02-16 at 17:51 -0500, Greg Stark wrote: +> > > Data types which could probably provide a useful function for f would be +> > > int2, int4, oid, and possibly int8 and text (at least for SQL_ASCII). +> +> How exactly do you imagine doing this for text? +> +> I could see doing it for char(n)/varchar(n) where n<=4 in SQL_ASCII though. + + +In SQL_ASCII, just take the first 4 characters (or 8, if using a 64-bit +sortKey as elsewhere suggested). The sorting key doesn't need to be a +one-to-one mapping. + +-- Mark Lewis + +From pgsql-performance-owner@postgresql.org Thu Feb 16 20:18:10 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id D603D9DC86B + for ; + Thu, 16 Feb 2006 20:18:09 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 66723-09 + for ; + Thu, 16 Feb 2006 20:18:12 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from moutng.kundenserver.de (moutng.kundenserver.de + [212.227.126.188]) + by postgresql.org (Postfix) with ESMTP id 66D579DC83D + for ; + Thu, 16 Feb 2006 20:18:07 -0400 (AST) +Received: from [84.157.0.176] (helo=lunix.schabi.de) + by mrelayeu.kundenserver.de (node=mrelayeu2) with ESMTP (Nemesis), + id 0MKwtQ-1F9tK40U5m-0000cW; Fri, 17 Feb 2006 01:18:10 +0100 +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by lunix.schabi.de (Postfix) with ESMTP id 448171CD32E; + Fri, 17 Feb 2006 01:18:06 +0100 (CET) +Message-ID: <43F5163E.2020108@logix-tt.com> +Date: Fri, 17 Feb 2006 01:18:06 +0100 +From: Markus Schaber +User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: de-DE, de, en-us, en +MIME-Version: 1.0 +To: PFC +CC: pgsql-performance@postgresql.org +Subject: Re: [HACKERS] qsort again (was Re: Strange Create Index +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> + <7.0.1.0.2.20060215194635.03b55da0@earthlink.net> + <21615.1140052893@sss.pgh.pa.us> + <7.0.1.0.2.20060215223710.03a7c618@earthlink.net> + <20060216113522.GA3461@uio.no> + <7.0.1.0.2.20060216071053.0385a1a8@earthlink.net> + <43F481CD.2010509@logix-tt.com> <43F4A7D8.4050907@modgraph-usa.com> + <29277.1140110108@sss.pgh.pa.us> + <1140128256.9076.254.camel@archimedes> +In-Reply-To: +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 7bit +X-Provags-ID: kundenserver.de abuse@kundenserver.de + login:a9554655f07a4e401310f2acfb43f5bf +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.126 required=5 tests=[AWL=0.126] +X-Spam-Score: 0.126 +X-Spam-Level: +X-Archive-Number: 200602/269 +X-Sequence-Number: 17255 + +Hi, PFC, + +PFC schrieb: + +> By the way, I'd like to declare my zipcode columns as SQL_ASCII +> while the rest of my database is in UNICODE, so they are faster to +> index and sort. Come on, MySQL does it... + +Another use case for parametric column definitions - charset definitions +- and the first one that cannot be emulated via constraints. + +Other use cases I remember were range definitions for numbers or PostGIS +dimension, subtype and SRID, but those cann all be emulated via checks / +constraints. + +Markus + +From pgsql-performance-owner@postgresql.org Thu Feb 16 22:02:19 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id AC9C09DCA0B + for ; + Thu, 16 Feb 2006 22:02:18 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 92587-07 + for ; + Thu, 16 Feb 2006 22:02:22 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from cassarossa.samfundet.no (cassarossa.samfundet.no + [129.241.93.19]) + by postgresql.org (Postfix) with ESMTP id 1E2629DC886 + for ; + Thu, 16 Feb 2006 22:02:15 -0400 (AST) +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 1F9uwq-00070k-VV + for pgsql-performance@postgresql.org; Fri, 17 Feb 2006 03:02:17 +0100 +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1F9uwt-0001Rg-00 + for ; Fri, 17 Feb 2006 03:02:19 +0100 +Date: Fri, 17 Feb 2006 03:02:19 +0100 +From: "Steinar H. Gunderson" +To: pgsql-performance@postgresql.org +Subject: Re: [HACKERS] qsort again (was Re: Strange Create Index +Message-ID: <20060217020219.GE5273@uio.no> +Mail-Followup-To: pgsql-performance@postgresql.org +References: <7.0.1.0.2.20060215194635.03b55da0@earthlink.net> + <21615.1140052893@sss.pgh.pa.us> + <7.0.1.0.2.20060215223710.03a7c618@earthlink.net> + <20060216113522.GA3461@uio.no> + <7.0.1.0.2.20060216071053.0385a1a8@earthlink.net> + <43F481CD.2010509@logix-tt.com> <43F4A7D8.4050907@modgraph-usa.com> + <29277.1140110108@sss.pgh.pa.us> + <1140128256.9076.254.camel@archimedes> +MIME-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Disposition: inline +In-Reply-To: +X-Operating-System: Linux 2.6.14.3 on a x86_64 +X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ +User-Agent: Mutt/1.5.11+cvs20060126 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.08 required=5 tests=[AWL=0.080] +X-Spam-Score: 0.08 +X-Spam-Level: +X-Archive-Number: 200602/270 +X-Sequence-Number: 17256 + +On Fri, Feb 17, 2006 at 12:05:23AM +0100, PFC wrote: +> I would have said a 64 bit int, but it's the same idea. However it +> won't work for floats, which is a pity, because floats fit in 64 bits. + +Actually, you can compare IEEE floats directly as ints, as long as they're +positive. (If they can be both positive and negative, you need to take +special care of the sign bit first, but it's still doable.) + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-hackers-owner@postgresql.org Fri Feb 17 01:41:03 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id EFBA09DCA59; + Fri, 17 Feb 2006 01:41:02 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34378-05; Fri, 17 Feb 2006 01:41:01 -0400 (AST) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 504319DC800; + Fri, 17 Feb 2006 01:41:00 -0400 (AST) +Received: from mail.invendra.net (sbx-01.invendra.net [66.139.76.16]) + by svr4.postgresql.org (Postfix) with ESMTP id 80AF65AF089; + Fri, 17 Feb 2006 05:40:48 +0000 (GMT) +Received: from david.lang.hm (dsl081-044-215.lax1.dsl.speakeasy.net + [64.81.44.215]) + by mail.invendra.net (Postfix) with ESMTP id DF7E31AC3E9; + Thu, 16 Feb 2006 21:35:38 -0800 (PST) +Date: Thu, 16 Feb 2006 21:33:16 -0800 (PST) +From: David Lang +X-X-Sender: dlang@david.lang.hm +To: Mark Lewis +Cc: Greg Stark , Markus Schaber , + pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Subject: Re: qsort again (was Re: [PERFORM] Strange Create Index +In-Reply-To: <1140132189.9076.261.camel@archimedes> +Message-ID: +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> + <7.0.1.0.2.20060215194635.03b55da0@earthlink.net> + <21615.1140052893@sss.pgh.pa.us> + <7.0.1.0.2.20060215223710.03a7c618@earthlink.net> + <20060216113522.GA3461@uio.no> + <7.0.1.0.2.20060216071053.0385a1a8@earthlink.net> + <43F481CD.2010509@logix-tt.com> <43F4A7D8.4050907@modgraph-usa.com> + <29277.1140110108@sss.pgh.pa.us> <1140128256.9076.254.camel@archimedes> + <43F4FDCC.2000204@logix-tt.com> <871wy23okp.fsf@stark.xeocode.com> + <1140132189.9076.261.camel@archimedes> +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, score=0.112 required=5 tests=[AWL=0.112] +X-Spam-Score: 0.112 +X-Spam-Level: +X-Archive-Number: 200602/648 +X-Sequence-Number: 79786 + +On Thu, 16 Feb 2006, Mark Lewis wrote: + +> On Thu, 2006-02-16 at 17:51 -0500, Greg Stark wrote: +>>>> Data types which could probably provide a useful function for f would be +>>>> int2, int4, oid, and possibly int8 and text (at least for SQL_ASCII). +>> +>> How exactly do you imagine doing this for text? +>> +>> I could see doing it for char(n)/varchar(n) where n<=4 in SQL_ASCII though. +> +> +> In SQL_ASCII, just take the first 4 characters (or 8, if using a 64-bit +> sortKey as elsewhere suggested). The sorting key doesn't need to be a +> one-to-one mapping. + +that would violate your second contraint ( f(a)==f(b) iff (a==b) ) + +if you could drop that constraint (the cost of which would be extra 'real' +compares within a bucket) then a helper function per datatype could work +as you are talking. + +David Lang + +From pgsql-hackers-owner@postgresql.org Fri Feb 17 02:21:09 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 35A2A9DCB97; + Fri, 17 Feb 2006 02:21:08 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 42094-06; Fri, 17 Feb 2006 02:21:06 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from elasmtp-kukur.atl.sa.earthlink.net + (elasmtp-kukur.atl.sa.earthlink.net [209.86.89.65]) + by postgresql.org (Postfix) with ESMTP id C74A99DCBD6; + Fri, 17 Feb 2006 02:21:04 -0400 (AST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=Au/7rupkHPTRyl1tCLCeSN5vgcx7z6pRfm8uS8T7Y1RDWVE/1MnM/3ai93+wE/ml; + 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 [71.243.43.186] (helo=ron-6d52adff2a6.earthlink.net) + by elasmtp-kukur.atl.sa.earthlink.net with asmtp (Exim 4.34) + id 1F9yzI-0004QJ-GJ; Fri, 17 Feb 2006 01:21:04 -0500 +Message-Id: <7.0.1.0.2.20060217004822.039d46a8@earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 7.0.1.0 +Date: Fri, 17 Feb 2006 01:20:58 -0500 +To: Scott Lamb ,pgsql-performance@postgresql.org, + pgsql-hackers@postgresql.org +From: Ron +Subject: Re: qsort again (was Re: [PERFORM] Strange Create +In-Reply-To: <7.0.1.0.2.20060216133801.03a7ab50@earthlink.net> +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> + <7.0.1.0.2.20060215194635.03b55da0@earthlink.net> + <21615.1140052893@sss.pgh.pa.us> + <7.0.1.0.2.20060215223710.03a7c618@earthlink.net> + <20060216113522.GA3461@uio.no> + <7.0.1.0.2.20060216071053.0385a1a8@earthlink.net> + <20060216144833.GG26127@svana.org> + <7.0.1.0.2.20060216100954.035b5ee0@earthlink.net> + <7.0.1.0.2.20060216110249.0395d2b0@earthlink.net> + <87FA36B4-CD97-4CF5-B9B3-02FEEA25CC95@slamb.org> + <7.0.1.0.2.20060216133801.03a7ab50@earthlink.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bc7f14af81f8298dbfb791d54798827018350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 71.243.43.186 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.467 required=5 tests=[AWL=-0.012, + DNS_FROM_RFC_ABUSE=0.479] +X-Spam-Score: 0.467 +X-Spam-Level: +X-Archive-Number: 200602/650 +X-Sequence-Number: 79788 + +At 01:47 PM 2/16/2006, Ron wrote: +>At 12:19 PM 2/16/2006, Scott Lamb wrote: +>>On Feb 16, 2006, at 8:32 AM, Ron wrote: +>>>Let's pretend that we have the typical DB table where rows are +>>>~2-4KB apiece. 1TB of storage will let us have 256M-512M rows in +>>>such a table. +>>> +>>>A 32b hash code can be assigned to each row value such that only +>>>exactly equal rows will have the same hash code. +>>>A 32b pointer can locate any of the 256M-512M rows. +>>> +>>>Now instead of sorting 1TB of data we can sort 2^28 to 2^29 32b +>>>+32b= 64b*(2^28 to 2^29)= 2-4GB of pointers+keys followed by an +>>>optional pass to rearrange the actual rows if we so wish. +>> +>>I don't understand this. +>> +>>This is a true statement: (H(x) != H(y)) => (x != y) +>>This is not: (H(x) < H(y)) => (x < y) +>> +>>Hash keys can tell you there's an inequality, but they can't tell you +>>how the values compare. If you want 32-bit keys that compare in the +>>same order as the original values, here's how you have to get them: +>For most hash codes, you are correct. There is a class of hash or +>hash-like codes that maintains the mapping to support that second statement. +> +>More later when I can get more time. +>Ron + +OK, so here's _a_ way (there are others) to obtain a mapping such that + if a < b then f(a) < f (b) and + if a == b then f(a) == f(b) + +Pretend each row is a integer of row size (so a 2KB row becomes a +16Kb integer; a 4KB row becomes a 32Kb integer; etc) +Since even a 1TB table made of such rows can only have 256M - 512M +possible values even if each row is unique, a 28b or 29b key is large +enough to represent each row's value and relative rank compared to +all of the others even if all row values are unique. + +By scanning the table once, we can map say 0000001h (Hex used to ease +typing) to the row with the minimum value and 1111111h to the row +with the maximum value as well as mapping everything in between to +their appropriate keys. That same scan can be used to assign a +pointer to each record's location. + +We can now sort the key+pointer pairs instead of the actual data and +use an optional final pass to rearrange the actual rows if we wish. + +That initial scan to set up the keys is expensive, but if we wish +that cost can be amortized over the life of the table so we don't +have to pay it all at once. In addition, once we have created those +keys, then can be saved for later searches and sorts. + +Further space savings can be obtained whenever there are duplicate +keys and/or when compression methods are used on the Key+pointer pairs. + +Ron + + + + + + + +From pgsql-performance-owner@postgresql.org Fri Feb 17 04:12:42 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 552A09DC9E8 + for ; + Fri, 17 Feb 2006 04:12:41 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 61640-08 + for ; + Fri, 17 Feb 2006 04:12:41 -0400 (AST) +X-Greylist: whitelisted by SQLgrey- +Received: from smtp6-g19.free.fr (smtp6-g19.free.fr [212.27.42.36]) + by postgresql.org (Postfix) with ESMTP id 2E9E69DC9DE + for ; + Fri, 17 Feb 2006 04:12:39 -0400 (AST) +Received: from imp2-g19.free.fr (imp2-g19.free.fr [212.27.42.2]) + by smtp6-g19.free.fr (Postfix) with ESMTP id 2567518197 + for ; + Fri, 17 Feb 2006 09:12:39 +0100 (CET) +Received: by imp2-g19.free.fr (Postfix, from userid 33) + id ADBF67ABB0; Fri, 17 Feb 2006 09:12:39 +0100 (MET) +Received: from wormhole.x-echo.com (wormhole.x-echo.com [193.252.148.11]) + by imp2-g19.free.fr (IMP) with HTTP + for ; Fri, 17 Feb 2006 09:12:39 +0100 +Message-ID: <1140163959.43f585777f2cc@imp2-g19.free.fr> +Date: Fri, 17 Feb 2006 09:12:39 +0100 +From: martial.bizel@free.fr +To: pgsql-performance@postgresql.org +Subject: split partitioned table across several postgres servers +References: <1140018930.43f34ef260de0@imp2-g19.free.fr> + <1140022257.22740.225.camel@state.g2switchworks.com> +In-Reply-To: <1140022257.22740.225.camel@state.g2switchworks.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 8bit +User-Agent: Internet Messaging Program (IMP) 3.2.5 +X-Originating-IP: 193.252.148.11 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.658 required=5 tests=[AWL=0.108, NO_REAL_NAME=0.55] +X-Spam-Score: 0.658 +X-Spam-Level: +X-Archive-Number: 200602/273 +X-Sequence-Number: 17259 + +Hello, + +I want to split table partitioned across two servers postgres (two hosts). +To query this remote object, I want to make view with union on two servers with +two dblink. + +But, How to be sure that optimizer plan on remote node is same than local node +(ie : optimizer scan only the selected partitions and not make full scan of +the remote object) ? + +example : server 1 (table test partionned on field number and 1 < number <10) + server 2 (table test partitioned on field number 10 15. + +optimizer made full scan of all partitions on all servers or +scan only partition 1 to partition 4 on server1 +and scan partiton 16 to partition 19 on server2 +and union ? + +In fact, I don't know how to have explain plan of remote node. + +Thanks a lot. + +MB + + + +From pgsql-hackers-owner@postgresql.org Fri Feb 17 04:18:48 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id A11289DC9DE + for ; + Fri, 17 Feb 2006 04:18:47 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 68361-01 + for ; + Fri, 17 Feb 2006 04:18:47 -0400 (AST) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 0F27A9DC88D + for ; + Fri, 17 Feb 2006 04:18:45 -0400 (AST) +Received: from smtp1.asco.de (smtp1.asco.de [217.13.70.154]) + by svr4.postgresql.org (Postfix) with ESMTP id 91E525AF08F + for ; + Fri, 17 Feb 2006 08:18:45 +0000 (GMT) +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 k1H8IdXB005847 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); + Fri, 17 Feb 2006 09:18:39 +0100 +Date: Fri, 17 Feb 2006 09:18:39 +0100 +From: Jens-Wolfhard Schicke +Reply-To: Jens-Wolfhard Schicke +To: Dann Corbit , pgsql-hackers@postgresql.org +Subject: Re: qsort again (was Re: [PERFORM] Strange Create Index +Message-ID: <97E2D852E73713354532B531@[192.168.1.72]> +In-Reply-To: + +References: +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, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200602/653 +X-Sequence-Number: 79791 + +--On Donnerstag, Februar 16, 2006 10:39:45 -0800 Dann Corbit=20 + wrote: + +> He refers to counting sort and radix sort (which comes in most +> significant digit and least significant digit format). These are also +> called distribution (as opposed to comparison) sorts. +> +> These sorts are O(n) as a function of the data size, but really they are +> O(M*n) where M is the average key length and n is the data set size. +> (In the case of MSD radix sort M is the average length to completely +> differentiate strings) +> +> So if you have an 80 character key, then 80*log(n) will only be faster +I suppose you meant 80 * n here? + +> than n*log(n) when you have 2^80th elements -- in other words -- never. +I think this is wrong. You can easily improve Radix sort by a constant if=20 +you don't take single bytes as the digits but rather k-byte values. At=20 +least 2 byte should be possible without problems. This would give you 40 *=20 +n time, not 80 * n. And you assume that the comparision of an 80-byte wide=20 +value only costs 1, which might (and in many cases will be imho) wrong.=20 +Actually it migh mean to compare 80 bytes as well, but I might be wrong. + +What I think as the biggest problem is the digit representation necessary=20 +for Radix-Sort in cases of locales which sort without looking at spaces. I=20 +assume that would be hard to implement. The same goes for the proposed=20 +mapping of string values onto 4/8-byte values. + +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-hackers-owner@postgresql.org Fri Feb 17 05:18:00 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 6F25B9DCB79 + for ; + Fri, 17 Feb 2006 05:17:59 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 77148-05 + for ; + Fri, 17 Feb 2006 05:18:00 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from svana.org (svana.org [125.62.94.225]) + by postgresql.org (Postfix) with ESMTP id D6A049DCAEE + for ; + Fri, 17 Feb 2006 05:17:56 -0400 (AST) +Received: from kleptog by svana.org with local (Exim 4.50) + id 1FA1kL-0002WN-NG; Fri, 17 Feb 2006 20:17:49 +1100 +Date: Fri, 17 Feb 2006 10:17:49 +0100 +From: Martijn van Oosterhout +To: Jens-Wolfhard Schicke +Cc: Dann Corbit , pgsql-hackers@postgresql.org +Subject: Re: qsort again (was Re: [PERFORM] Strange Create Index +Message-ID: <20060217091749.GA9254@svana.org> +Reply-To: Martijn van Oosterhout +References: + + <97E2D852E73713354532B531@[192.168.1.72]> +Mime-Version: 1.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; boundary="bg08WKrSYDhXBjb5" +Content-Disposition: inline +In-Reply-To: <97E2D852E73713354532B531@[192.168.1.72]> +X-PGP-Key-ID: Length=1024; ID=0x0DC67BE6 +X-PGP-Key-Fingerprint: 295F A899 A81A 156D B522 48A7 6394 F08A 0DC6 7BE6 +X-PGP-Key-URL: +User-Agent: Mutt/1.5.9i +X-SA-Exim-Connect-IP: +X-SA-Exim-Mail-From: kleptog@svana.org +X-SA-Exim-Scanned: No (on svana.org); SAEximRunCond expanded to false +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.123 required=5 tests=[AWL=0.123] +X-Spam-Score: 0.123 +X-Spam-Level: +X-Archive-Number: 200602/654 +X-Sequence-Number: 79792 + + +--bg08WKrSYDhXBjb5 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +Content-Transfer-Encoding: quoted-printable + +On Fri, Feb 17, 2006 at 09:18:39AM +0100, Jens-Wolfhard Schicke wrote: +> What I think as the biggest problem is the digit representation necessary= +=20 +> for Radix-Sort in cases of locales which sort without looking at spaces. = +I=20 +> assume that would be hard to implement. The same goes for the proposed=20 +> mapping of string values onto 4/8-byte values. + +Actually, this is easy. The standard C library provides strxfrm() and +other locale toolkits like ICU provide ucol_getSortKey(). Windows +provides LCMapString(). Just pass each string through this and take the +first four bytes of the result to form your integer key. + +Have a nice day, +--=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. + +--bg08WKrSYDhXBjb5 +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) + +iD8DBQFD9ZS9IB7bNG8LQkwRAlazAJ9EDy9ArrtWpDkv5ZjceLU0wfQs9gCffxWW +5nKKZj3XPYrJD5IY2t4pS1Q= +=EGOa +-----END PGP SIGNATURE----- + +--bg08WKrSYDhXBjb5-- + +From pgsql-performance-owner@postgresql.org Fri Feb 17 05:23:34 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 1626B9DCC5F + for ; + Fri, 17 Feb 2006 05:23:33 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 78936-03 + for ; + Fri, 17 Feb 2006 05:23:33 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx1.hive.is (scania.ipf.is [85.197.192.147]) + by postgresql.org (Postfix) with SMTP id 88D8A9DCA18 + for ; + Fri, 17 Feb 2006 05:23:29 -0400 (AST) +Received: (qmail 50420 invoked by uid 1010); 17 Feb 2006 09:23:34 -0000 +Received: from 85.197.216.186 by scania.ipf.is (envelope-from , + uid 1009) with qmail-scanner-1.25-st-qms + (clamdscan: 0.88/1283. spamassassin: 3.1.0. perlscan: 1.25-st-qms. + Clear:RC:1(85.197.216.186):SA:0(-4.1/4.0):. + Processed in 1.223345 secs); 17 Feb 2006 09:23:34 -0000 +X-Antivirus-HIVE-Mail-From: gnari@hive.is via scania.ipf.is +X-Antivirus-HIVE: 1.25-st-qms (Clear:RC:1(85.197.216.186):SA:0(-4.1/4.0):. + Processed in 1.223345 secs Process 50405) +Received: from dsl-216-186.hive.is (HELO ?192.168.1.34?) (85.197.216.186) + by mx1.hive.is with SMTP; 17 Feb 2006 09:23:32 -0000 +Subject: Re: [HACKERS] qsort again (was Re: Strange Create +From: Ragnar +To: Ron +Cc: pgsql-performance@postgresql.org +In-Reply-To: <7.0.1.0.2.20060217004822.039d46a8@earthlink.net> +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> + <7.0.1.0.2.20060215194635.03b55da0@earthlink.net> + <21615.1140052893@sss.pgh.pa.us> + <7.0.1.0.2.20060215223710.03a7c618@earthlink.net> + <20060216113522.GA3461@uio.no> + <7.0.1.0.2.20060216071053.0385a1a8@earthlink.net> + <20060216144833.GG26127@svana.org> + <7.0.1.0.2.20060216100954.035b5ee0@earthlink.net> + <7.0.1.0.2.20060216110249.0395d2b0@earthlink.net> + <87FA36B4-CD97-4CF5-B9B3-02FEEA25CC95@slamb.org> + <7.0.1.0.2.20060216133801.03a7ab50@earthlink.net> + <7.0.1.0.2.20060217004822.039d46a8@earthlink.net> +Content-Type: text/plain; charset=ISO-8859-1 +Date: Fri, 17 Feb 2006 09:24:21 +0000 +Message-Id: <1140168261.32324.70.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.4.1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.162 required=5 tests=[AWL=0.162] +X-Spam-Score: 0.162 +X-Spam-Level: +X-Archive-Number: 200602/274 +X-Sequence-Number: 17260 + +On f�s, 2006-02-17 at 01:20 -0500, Ron wrote: +> At 01:47 PM 2/16/2006, Ron wrote: +> >At 12:19 PM 2/16/2006, Scott Lamb wrote: +> >>On Feb 16, 2006, at 8:32 AM, Ron wrote: +> >>>Let's pretend that we have the typical DB table where rows are +> >>>~2-4KB apiece. 1TB of storage will let us have 256M-512M rows in +> >>>such a table. +> >>> +> >>>A 32b hash code can be assigned to each row value such that only +> >>>exactly equal rows will have the same hash code. +> >>>A 32b pointer can locate any of the 256M-512M rows. +> >>> +> >>>Now instead of sorting 1TB of data we can sort 2^28 to 2^29 32b +> >>>+32b= 64b*(2^28 to 2^29)= 2-4GB of pointers+keys followed by an +> >>>optional pass to rearrange the actual rows if we so wish. +> >> +> >>I don't understand this. +> >> +> >>This is a true statement: (H(x) != H(y)) => (x != y) +> >>This is not: (H(x) < H(y)) => (x < y) +> >> +> >>Hash keys can tell you there's an inequality, but they can't tell you +> >>how the values compare. If you want 32-bit keys that compare in the +> >>same order as the original values, here's how you have to get them: +> >For most hash codes, you are correct. There is a class of hash or +> >hash-like codes that maintains the mapping to support that second statement. +> > +> >More later when I can get more time. +> >Ron +> +> OK, so here's _a_ way (there are others) to obtain a mapping such that +> if a < b then f(a) < f (b) and +> if a == b then f(a) == f(b) + +> By scanning the table once, we can map say 0000001h (Hex used to ease +> typing) to the row with the minimum value and 1111111h to the row +> with the maximum value as well as mapping everything in between to +> their appropriate keys. That same scan can be used to assign a +> pointer to each record's location. + +This step is just as expensive as the original sort you +want to replace/improve. If you want to keep this mapping +saved as a sort of an index, or as part ot each row data, this will make +the cost of inserts and updates enormous. + +> +> We can now sort the key+pointer pairs instead of the actual data and +> use an optional final pass to rearrange the actual rows if we wish. + +How are you suggesting this mapping be accessed? If the +mapping is kept separate from the tuple data, as in an index, then how +will you look up the key? + +> That initial scan to set up the keys is expensive, but if we wish +> that cost can be amortized over the life of the table so we don't +> have to pay it all at once. In addition, once we have created those +> keys, then can be saved for later searches and sorts. + +What is the use case where this would work better than a +regular btree index ? + +gnari + + + +From pgsql-hackers-owner@postgresql.org Fri Feb 17 06:13:48 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 8D1769DC87E; + Fri, 17 Feb 2006 06:13:47 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 83976-09; Fri, 17 Feb 2006 06:13:49 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from moutng.kundenserver.de (moutng.kundenserver.de + [212.227.126.188]) + by postgresql.org (Postfix) with ESMTP id 544C89DC863; + Fri, 17 Feb 2006 06:13:44 -0400 (AST) +Received: from [84.157.11.200] (helo=lunix.schabi.de) + by mrelayeu.kundenserver.de (node=mrelayeu7) with ESMTP (Nemesis), + id 0ML2Dk-1FA2cR10aY-0000lN; Fri, 17 Feb 2006 11:13:46 +0100 +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by lunix.schabi.de (Postfix) with ESMTP id 6311A1495C8; + Fri, 17 Feb 2006 11:13:41 +0100 (CET) +Message-ID: <43F5A1D5.20903@logix-tt.com> +Date: Fri, 17 Feb 2006 11:13:41 +0100 +From: Markus Schaber +User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: de-DE, de, en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +CC: pgsql-hackers@postgresql.org +Subject: Re: qsort again (was Re: [PERFORM] Strange Create Index +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> + <7.0.1.0.2.20060215194635.03b55da0@earthlink.net> + <21615.1140052893@sss.pgh.pa.us> + <7.0.1.0.2.20060215223710.03a7c618@earthlink.net> + <20060216113522.GA3461@uio.no> + <7.0.1.0.2.20060216071053.0385a1a8@earthlink.net> + <43F481CD.2010509@logix-tt.com> <43F4A7D8.4050907@modgraph-usa.com> + <29277.1140110108@sss.pgh.pa.us> + <1140128256.9076.254.camel@archimedes> + <43F4FDCC.2000204@logix-tt.com> <871wy23okp.fsf@stark.xeocode.com> + <1140132189.9076.261.camel@archimedes> + +In-Reply-To: +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Provags-ID: kundenserver.de abuse@kundenserver.de + login:a9554655f07a4e401310f2acfb43f5bf +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.125 required=5 tests=[AWL=0.125] +X-Spam-Score: 0.125 +X-Spam-Level: +X-Archive-Number: 200602/655 +X-Sequence-Number: 79793 + +Hi, David, + +David Lang schrieb: + +>> In SQL_ASCII, just take the first 4 characters (or 8, if using a 64-bit +>> sortKey as elsewhere suggested). The sorting key doesn't need to be a +>> one-to-one mapping. + +> that would violate your second contraint ( f(a)==f(b) iff (a==b) ) + +no, it doesn't. + +When both strings are equal, then the first characters are equal, too. + +If they are not equal, the constraint condition does not match. + +The first characters of the strings may be equal as f(a) may be equal to +f(b) as to the other constraint. + +Markus + +From pgsql-hackers-owner@postgresql.org Fri Feb 17 06:19:53 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id CE8F09DC838; + Fri, 17 Feb 2006 06:19:52 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 87769-06; Fri, 17 Feb 2006 06:19:53 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from moutng.kundenserver.de (moutng.kundenserver.de + [212.227.126.187]) + by postgresql.org (Postfix) with ESMTP id 4651A9DCBA7; + Fri, 17 Feb 2006 06:19:49 -0400 (AST) +Received: from [84.157.11.200] (helo=lunix.schabi.de) + by mrelayeu.kundenserver.de (node=mrelayeu2) with ESMTP (Nemesis), + id 0MKwtQ-1FA2iI1QaI-0000Zp; Fri, 17 Feb 2006 11:19:46 +0100 +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by lunix.schabi.de (Postfix) with ESMTP id A57341495C8; + Fri, 17 Feb 2006 11:19:45 +0100 (CET) +Message-ID: <43F5A341.5090808@logix-tt.com> +Date: Fri, 17 Feb 2006 11:19:45 +0100 +From: Markus Schaber +User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: de-DE, de, en-us, en +MIME-Version: 1.0 +To: Ron +CC: Scott Lamb , pgsql-performance@postgresql.org, + pgsql-hackers@postgresql.org +Subject: Re: qsort again (was Re: [PERFORM] Strange Create +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> + <7.0.1.0.2.20060215194635.03b55da0@earthlink.net> + <21615.1140052893@sss.pgh.pa.us> + <7.0.1.0.2.20060215223710.03a7c618@earthlink.net> + <20060216113522.GA3461@uio.no> + <7.0.1.0.2.20060216071053.0385a1a8@earthlink.net> + <20060216144833.GG26127@svana.org> + <7.0.1.0.2.20060216100954.035b5ee0@earthlink.net> + <7.0.1.0.2.20060216110249.0395d2b0@earthlink.net> + <87FA36B4-CD97-4CF5-B9B3-02FEEA25CC95@slamb.org> + <7.0.1.0.2.20060216133801.03a7ab50@earthlink.net> + <7.0.1.0.2.20060217004822.039d46a8@earthlink.net> +In-Reply-To: <7.0.1.0.2.20060217004822.039d46a8@earthlink.net> +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Provags-ID: kundenserver.de abuse@kundenserver.de + login:a9554655f07a4e401310f2acfb43f5bf +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.13 required=5 tests=[AWL=0.130] +X-Spam-Score: 0.13 +X-Spam-Level: +X-Archive-Number: 200602/656 +X-Sequence-Number: 79794 + +Hi, Ron, + +Ron schrieb: + +> OK, so here's _a_ way (there are others) to obtain a mapping such that +> if a < b then f(a) < f (b) and +> if a == b then f(a) == f(b) +> +> Pretend each row is a integer of row size (so a 2KB row becomes a 16Kb +> integer; a 4KB row becomes a 32Kb integer; etc) +> Since even a 1TB table made of such rows can only have 256M - 512M +> possible values even if each row is unique, a 28b or 29b key is large +> enough to represent each row's value and relative rank compared to all +> of the others even if all row values are unique. +> +> By scanning the table once, we can map say 0000001h (Hex used to ease +> typing) to the row with the minimum value and 1111111h to the row with +> the maximum value as well as mapping everything in between to their +> appropriate keys. That same scan can be used to assign a pointer to +> each record's location. + +But with a single linear scan, this cannot be accomplished, as the table +contents are neither sorted nor distributed linearly between the minimum +and the maximum. + +For this mapping, you need a full table sort. + +> That initial scan to set up the keys is expensive, but if we wish that +> cost can be amortized over the life of the table so we don't have to pay +> it all at once. In addition, once we have created those keys, then can +> be saved for later searches and sorts. + +But for every update or insert, you have to resort the keys, which is +_very_ expensive as it basically needs to update a huge part of the table. + +Markus + +From pgsql-performance-owner@postgresql.org Fri Feb 17 06:55:13 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 819279DCB79 + for ; + Fri, 17 Feb 2006 06:55:12 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 96531-03-2 + for ; + Fri, 17 Feb 2006 06:55:14 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from peufeu.com (unknown [82.67.9.10]) + by postgresql.org (Postfix) with ESMTP id B96C39DCA42 + for ; + Fri, 17 Feb 2006 06:55:09 -0400 (AST) +Received: (qmail 445 invoked from network); 17 Feb 2006 11:55:35 +0100 +Received: from unknown (HELO apollo13) (82.67.9.10) + by boutiquenumerique.com with SMTP; 17 Feb 2006 11:55:35 +0100 +Date: Fri, 17 Feb 2006 11:55:34 +0100 +To: pgsql-performance@postgresql.org +Subject: Re: [HACKERS] qsort again (was Re: Strange Create +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> + <7.0.1.0.2.20060215194635.03b55da0@earthlink.net> + <21615.1140052893@sss.pgh.pa.us> + <7.0.1.0.2.20060215223710.03a7c618@earthlink.net> + <20060216113522.GA3461@uio.no> + <7.0.1.0.2.20060216071053.0385a1a8@earthlink.net> + <20060216144833.GG26127@svana.org> + <7.0.1.0.2.20060216100954.035b5ee0@earthlink.net> + <7.0.1.0.2.20060216110249.0395d2b0@earthlink.net> + <87FA36B4-CD97-4CF5-B9B3-02FEEA25CC95@slamb.org> + <7.0.1.0.2.20060216133801.03a7ab50@earthlink.net> + <7.0.1.0.2.20060217004822.039d46a8@earthlink.net> + <43F5A341.5090808@logix-tt.com> +From: PFC +Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-ID: +In-Reply-To: <43F5A341.5090808@logix-tt.com> +User-Agent: Opera M2/8.51 (Linux, build 1462) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.096 required=5 tests=[AWL=0.096] +X-Spam-Score: 0.096 +X-Spam-Level: +X-Archive-Number: 200602/277 +X-Sequence-Number: 17263 + + + Has anybody got some profiler data on the amount of time spent in +comparisons during a sort ? Say, the proposals here would give the most +gains on simple types like INTEGER ; so it would be interesting to know +how much time is now spent in comparisons for sorting a column of ints. If +it's like, 10% of the total time, well... + + More hand-waving : + + What are the usage case for sorts ? + + - potentially huge data sets : create index, big joins, reporting queries +etc. + - small data sets : typically, a query with an ORDER BY which will return +a small amount of rows (website stuff), or joins not small enough to use a +HashAggregate, but not big enough to create an index just for them. + + The cost of a comparison vs. moving stuff around and fetching stuff is +probably very different in these two cases. If it all neatly fits in +sort_mem, you can do fancy stuff (like sorting on SortKeys) which will +need to access the data in almost random order when time comes to hand the +sorted data back. So, I guess the SortKey idea would rather apply to the +latter case only, which is CPU limited. + + Anyway, I was wondering about queries with multipart keys, like ORDER BY +zipcode, client_name, date and the like. Using just an int64 as the key +isn't going to help a lot here. Why not use a binary string of limited +length ? I'd tend to think it would not be that slower than comparing +ints, and it would be faster than calling each comparison function for +each column. Each key part would get assigned to a byte range in the +string. + It would waste some memory, but for instance, using 2x the memory for +half the time would be a good tradeoff if the amount of memory involved is +in the order of megabytes. + Also, it would solve the problem of locales. Comparisons involving +locales are slow, but strings can be converted to a canonical form +(removing accents and stuff), and then binary sorted. + + Also I'll insert a plug for the idea that the Sort needs to know if there +will be a LIMIT afterwards ; this way it could reduce its working set by +simply discarding the rows which would have been discarded anyway by the +LIMIT. Say you want the 100 first rows out of a million ordered rows. If +the sort knows this, it can be performed in the amount of memory for a 100 +rows sort. + + +From pgsql-hackers-owner@postgresql.org Fri Feb 17 09:01:42 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 350D69DC891; + Fri, 17 Feb 2006 09:01:41 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 27669-09; Fri, 17 Feb 2006 09:01:43 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from elasmtp-junco.atl.sa.earthlink.net + (elasmtp-junco.atl.sa.earthlink.net [209.86.89.63]) + by postgresql.org (Postfix) with ESMTP id 6A96D9DC868; + Fri, 17 Feb 2006 09:01:38 -0400 (AST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=MPZNWZ8XkErpCssaHtA7I+SvjGnLokKEF5Z8SAzU1DKAh5rORh5NDMcgMqAR+wzl; + h=Received:Message-Id:X-Mailer:Date:To:From:Subject:In-Reply-To:References:Mime-Version:Content-Type:Content-Transfer-Encoding:X-ELNK-Trace:X-Originating-IP; +Received: from [71.243.43.186] (helo=ron-6d52adff2a6.earthlink.net) + by elasmtp-junco.atl.sa.earthlink.net with asmtp (Exim 4.34) + id 1FA5Ez-000756-92; Fri, 17 Feb 2006 08:01:41 -0500 +Message-Id: <7.0.1.0.2.20060217072626.039c5f20@earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 7.0.1.0 +Date: Fri, 17 Feb 2006 08:01:34 -0500 +To: Ragnar ,pgsql-performance@postgresql.org, + pgsql-hackers@postgresql.org +From: Ron +Subject: Re: qsort again (was Re: [PERFORM] Strange Create +In-Reply-To: <1140168261.32324.70.camel@localhost.localdomain> +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> + <7.0.1.0.2.20060215194635.03b55da0@earthlink.net> + <21615.1140052893@sss.pgh.pa.us> + <7.0.1.0.2.20060215223710.03a7c618@earthlink.net> + <20060216113522.GA3461@uio.no> + <7.0.1.0.2.20060216071053.0385a1a8@earthlink.net> + <20060216144833.GG26127@svana.org> + <7.0.1.0.2.20060216100954.035b5ee0@earthlink.net> + <7.0.1.0.2.20060216110249.0395d2b0@earthlink.net> + <87FA36B4-CD97-4CF5-B9B3-02FEEA25CC95@slamb.org> + <7.0.1.0.2.20060216133801.03a7ab50@earthlink.net> + <7.0.1.0.2.20060217004822.039d46a8@earthlink.net> + <1140168261.32324.70.camel@localhost.localdomain> +Mime-Version: 1.0 +Content-Type: text/plain; charset="iso-8859-1"; format=flowed +Content-Transfer-Encoding: quoted-printable +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bc98a3719bad45c719a78c5732130994cf350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 71.243.43.186 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.469 required=5 tests=[AWL=-0.010, + DNS_FROM_RFC_ABUSE=0.479] +X-Spam-Score: 0.469 +X-Spam-Level: +X-Archive-Number: 200602/657 +X-Sequence-Number: 79795 + +At 04:24 AM 2/17/2006, Ragnar wrote: +>On f=F6s, 2006-02-17 at 01:20 -0500, Ron wrote: +> > +> > OK, so here's _a_ way (there are others) to obtain a mapping such that +> > if a < b then f(a) < f (b) and +> > if a =3D=3D b then f(a) =3D=3D f(b) +> +> > By scanning the table once, we can map say 0000001h (Hex used to ease +> > typing) to the row with the minimum value and 1111111h to the row +> > with the maximum value as well as mapping everything in between to +> > their appropriate keys. That same scan can be used to assign a +> > pointer to each record's location. +> +>This step is just as expensive as the original=20 +>sort you want to replace/improve. + +Why do you think that? External sorts involve=20 +the equivalent of multiple scans of the table to=20 +be sorted, sometimes more than lgN (where N is=20 +the number of items in the table to be=20 +sorted). Since this is physical IO we are=20 +talking about, each scan is very expensive, and=20 +therefore 1 scan is going to take considerably=20 +less time than >=3D lgN scans will be. + + +>If you want to keep this mapping saved as a sort=20 +>of an index, or as part ot each row data, this=20 +>will make the cost of inserts and updates enormous. + +Not sure you've got this right either. Looks to=20 +me like we are adding a <=3D 32b quantity to each=20 +row. Once we know the mapping, incrementally=20 +updating it upon insert or update would seem to=20 +be simple matter of a fast search for the correct=20 +ranking [Interpolation search, which we have all=20 +the needed data for, is O(lglgN). Hash based=20 +search is O(1)]; plus an increment/decrement of=20 +the key values greater/less than the key value of=20 +the row being inserted / updated. Given than we=20 +are updating all the keys in a specific range=20 +within a tree structure, that update can be done=20 +in O(lgm) (where m is the number of records affected). + +> > We can now sort the key+pointer pairs instead of the actual data and +> > use an optional final pass to rearrange the actual rows if we wish. +> +>How are you suggesting this mapping be accessed?=20 +>If the mapping is kept separate from the tuple=20 +>data, as in an index, then how will you look up the key? +??? We've effectively created a data set where=20 +each record is a pointer to a DB row plus its=20 +key. We can now sort the data set by key and=20 +then do an optional final pass to rearrange the=20 +actual DB rows if we so wish. Since that final=20 +pass is very expensive, it is good that not all=20 +use scenarios will need that final pass. + +The amount of storage required to sort this=20 +representation of the table rather than the=20 +actual table is so much less that it turns an=20 +external sorting problem into a internal sorting=20 +problem with an optional final pass that is =3D1=3D=20 +scan (albeit one scan with a lot of seeks and=20 +data movement). This is a big win. It is a=20 +variation of a well known technique. See Sedgewick, Knuth, etc. + + +> > That initial scan to set up the keys is expensive, but if we wish +> > that cost can be amortized over the life of the table so we don't +> > have to pay it all at once. In addition, once we have created those +> > keys, then can be saved for later searches and sorts. +> +>What is the use case where this would work better than a +>regular btree index ? +Again, ??? btree indexes address different=20 +issues. They do not in any way help create a=20 +compact data representation of the original data=20 +that saves enough space so as to turn an external=20 +ranking or sorting problem into an internal one. + + +Ron=20 + + + +From pgsql-hackers-owner@postgresql.org Fri Feb 17 09:23:46 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 82AFF9DC868; + Fri, 17 Feb 2006 09:23:45 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34289-02; Fri, 17 Feb 2006 09:23:48 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from elasmtp-kukur.atl.sa.earthlink.net + (elasmtp-kukur.atl.sa.earthlink.net [209.86.89.65]) + by postgresql.org (Postfix) with ESMTP id 292B49DC808; + Fri, 17 Feb 2006 09:23:43 -0400 (AST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=c2ToPum2mWzi7ndOjvbuikgarK5vePo4rdfTOC+gnBHhSJRlcGVIv0Wca2Us1/rf; + 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 [71.243.43.186] (helo=ron-6d52adff2a6.earthlink.net) + by elasmtp-kukur.atl.sa.earthlink.net with asmtp (Exim 4.34) + id 1FA5aL-0004hz-Ox; Fri, 17 Feb 2006 08:23:45 -0500 +Message-Id: <7.0.1.0.2.20060217080226.03a11010@earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 7.0.1.0 +Date: Fri, 17 Feb 2006 08:23:40 -0500 +To: Markus Schaber ,pgsql-performance@postgresql.org, + pgsql-hackers@postgresql.org +From: Ron +Subject: Re: qsort again (was Re: [PERFORM] Strange Create +In-Reply-To: <43F5A341.5090808@logix-tt.com> +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> + <7.0.1.0.2.20060215194635.03b55da0@earthlink.net> + <21615.1140052893@sss.pgh.pa.us> + <7.0.1.0.2.20060215223710.03a7c618@earthlink.net> + <20060216113522.GA3461@uio.no> + <7.0.1.0.2.20060216071053.0385a1a8@earthlink.net> + <20060216144833.GG26127@svana.org> + <7.0.1.0.2.20060216100954.035b5ee0@earthlink.net> + <7.0.1.0.2.20060216110249.0395d2b0@earthlink.net> + <87FA36B4-CD97-4CF5-B9B3-02FEEA25CC95@slamb.org> + <7.0.1.0.2.20060216133801.03a7ab50@earthlink.net> + <7.0.1.0.2.20060217004822.039d46a8@earthlink.net> + <43F5A341.5090808@logix-tt.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bc099510ee8ea7e7662bed61755475f949350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 71.243.43.186 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.47 required=5 tests=[AWL=-0.009, + DNS_FROM_RFC_ABUSE=0.479] +X-Spam-Score: 0.47 +X-Spam-Level: +X-Archive-Number: 200602/658 +X-Sequence-Number: 79796 + +At 05:19 AM 2/17/2006, Markus Schaber wrote: +>Hi, Ron, +> +>Ron schrieb: +> +> > OK, so here's _a_ way (there are others) to obtain a mapping such that +> > if a < b then f(a) < f (b) and +> > if a == b then f(a) == f(b) +> > +> > Pretend each row is a integer of row size (so a 2KB row becomes a 16Kb +> > integer; a 4KB row becomes a 32Kb integer; etc) +> > Since even a 1TB table made of such rows can only have 256M - 512M +> > possible values even if each row is unique, a 28b or 29b key is large +> > enough to represent each row's value and relative rank compared to all +> > of the others even if all row values are unique. +> > +> > By scanning the table once, we can map say 0000001h (Hex used to ease +> > typing) to the row with the minimum value and 1111111h to the row with +> > the maximum value as well as mapping everything in between to their +> > appropriate keys. That same scan can be used to assign a pointer to +> > each record's location. +> +>But with a single linear scan, this cannot be accomplished, as the table +>contents are neither sorted nor distributed linearly between the minimum +>and the maximum. +So what? We are talking about key assignment here, not anything that +requires physically manipulating the actual DB rows. +One physical IO pass should be all that's needed. + + +>For this mapping, you need a full table sort. +One physical IO pass should be all that's needed. However, let's +pretend you are correct and that we do need to sort the table to get +the key mapping. Even so, we would only need to do it =once= and +then we would be able to use and incrementally update the results +forever afterward. Even under this assumption, one external sort to +save all subsequent such sorts seems well worth it. + +IOW, even if I'm wrong about the initial cost to do this; it is still +worth doing ;-) + + +> > That initial scan to set up the keys is expensive, but if we wish that +> > cost can be amortized over the life of the table so we don't have to pay +> > it all at once. In addition, once we have created those keys, then can +> > be saved for later searches and sorts. +> +>But for every update or insert, you have to resort the keys, which is +>_very_ expensive as it basically needs to update a huge part of the table. + +??? You do not need to resort already ordered data to insert a new +element into it such that the data stays ordered! Once we have done +the key ordering operation once, we should not ever need to do it +again on the original data. Else most sorting algorithms wouldn't work ;-) + + +Ron + + + +From pgsql-performance-owner@postgresql.org Fri Feb 17 10:49:05 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 123619DC84B + for ; + Fri, 17 Feb 2006 10:49:05 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 50203-03 + for ; + Fri, 17 Feb 2006 10:49:09 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id BD3DB9DC82F + for ; + Fri, 17 Feb 2006 10:49:02 -0400 (AST) +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 k1HEn5P4009164; + Fri, 17 Feb 2006 09:49:05 -0500 (EST) +To: martial.bizel@free.fr +cc: pgsql-performance@postgresql.org +Subject: Re: split partitioned table across several postgres servers +In-reply-to: <1140163959.43f585777f2cc@imp2-g19.free.fr> +References: <1140018930.43f34ef260de0@imp2-g19.free.fr> + <1140022257.22740.225.camel@state.g2switchworks.com> + <1140163959.43f585777f2cc@imp2-g19.free.fr> +Comments: In-reply-to martial.bizel@free.fr + message dated "Fri, 17 Feb 2006 09:12:39 +0100" +Date: Fri, 17 Feb 2006 09:49:05 -0500 +Message-ID: <9163.1140187745@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.11 required=5 tests=[AWL=0.110] +X-Spam-Score: 0.11 +X-Spam-Level: +X-Archive-Number: 200602/280 +X-Sequence-Number: 17266 + +martial.bizel@free.fr writes: +> In fact, I don't know how to have explain plan of remote node. + +You send it an EXPLAIN. + +You can *not* use a view defined as you suggest if you want decent +performance --- the dblink functions will fetch the entire table +contents and the filtering will be done locally. You'll need to +pass the WHERE conditions over to the remote servers, which more +or less means that you have to give them to the dblink functions +as text. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Feb 17 11:18:38 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 8E9369DC9C3 + for ; + Fri, 17 Feb 2006 11:18:37 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 56151-01 + for ; + Fri, 17 Feb 2006 11:18:41 -0400 (AST) +X-Greylist: whitelisted by SQLgrey- +Received: from smtp4-g19.free.fr (smtp4-g19.free.fr [212.27.42.30]) + by postgresql.org (Postfix) with ESMTP id 370C09DC82F + for ; + Fri, 17 Feb 2006 11:18:35 -0400 (AST) +Received: from imp2-g19.free.fr (imp2-g19.free.fr [212.27.42.2]) + by smtp4-g19.free.fr (Postfix) with ESMTP id CF9364F2D1; + Fri, 17 Feb 2006 16:18:39 +0100 (CET) +Received: by imp2-g19.free.fr (Postfix, from userid 33) + id 8649A7AE1E; Fri, 17 Feb 2006 16:18:39 +0100 (MET) +Received: from wormhole.x-echo.com (wormhole.x-echo.com [193.252.148.11]) + by imp2-g19.free.fr (IMP) with HTTP + for ; Fri, 17 Feb 2006 16:18:39 +0100 +Message-ID: <1140189519.43f5e94f69584@imp2-g19.free.fr> +Date: Fri, 17 Feb 2006 16:18:39 +0100 +From: martial.bizel@free.fr +To: pgsql-performance@postgresql.org +Cc: Tom Lane +Subject: Re: split partitioned table across several postgres servers +References: <1140018930.43f34ef260de0@imp2-g19.free.fr> + <1140022257.22740.225.camel@state.g2switchworks.com> + <1140163959.43f585777f2cc@imp2-g19.free.fr> + <9163.1140187745@sss.pgh.pa.us> +In-Reply-To: <9163.1140187745@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 8bit +User-Agent: Internet Messaging Program (IMP) 3.2.5 +X-Originating-IP: 193.252.148.11 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.659 required=5 tests=[AWL=0.109, NO_REAL_NAME=0.55] +X-Spam-Score: 0.659 +X-Spam-Level: +X-Archive-Number: 200602/281 +X-Sequence-Number: 17267 + +Selon Tom Lane : + +> martial.bizel@free.fr writes: +> > In fact, I don't know how to have explain plan of remote node. +> +> You send it an EXPLAIN. + + +Please, Could you send me what to put at end of request : + + select * from dblink('my_connexion', 'EXPLAIN select * from test where +number='1' ') as ........ + +I want to be sure that remote test is seen as partitioned object. + +thanks a lot. + + +> +> You can *not* use a view defined as you suggest if you want decent +> performance --- the dblink functions will fetch the entire table +> contents and the filtering will be done locally. You'll need to +> pass the WHERE conditions over to the remote servers, which more +> or less means that you have to give them to the dblink functions +> as text. +> +> regards, tom lane +> + +From pgsql-hackers-owner@postgresql.org Fri Feb 17 11:54:15 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id B5FD39DCAD7; + Fri, 17 Feb 2006 11:54:13 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 61431-07; Fri, 17 Feb 2006 11:54:18 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from svana.org (svana.org [125.62.94.225]) + by postgresql.org (Postfix) with ESMTP id CDEEE9DCA95; + Fri, 17 Feb 2006 11:54:10 -0400 (AST) +Received: from kleptog by svana.org with local (Exim 4.50) + id 1FA7vi-0003Kt-Ks; Sat, 18 Feb 2006 02:53:58 +1100 +Date: Fri, 17 Feb 2006 16:53:58 +0100 +From: Martijn van Oosterhout +To: Ron +Cc: Markus Schaber , pgsql-performance@postgresql.org, + pgsql-hackers@postgresql.org +Subject: Re: qsort again (was Re: [PERFORM] Strange Create +Message-ID: <20060217155358.GD9254@svana.org> +Reply-To: Martijn van Oosterhout +References: <20060216113522.GA3461@uio.no> + <7.0.1.0.2.20060216071053.0385a1a8@earthlink.net> + <20060216144833.GG26127@svana.org> + <7.0.1.0.2.20060216100954.035b5ee0@earthlink.net> + <7.0.1.0.2.20060216110249.0395d2b0@earthlink.net> + <87FA36B4-CD97-4CF5-B9B3-02FEEA25CC95@slamb.org> + <7.0.1.0.2.20060216133801.03a7ab50@earthlink.net> + <7.0.1.0.2.20060217004822.039d46a8@earthlink.net> + <43F5A341.5090808@logix-tt.com> + <7.0.1.0.2.20060217080226.03a11010@earthlink.net> +Mime-Version: 1.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; boundary="oj4kGyHlBMXGt3Le" +Content-Disposition: inline +In-Reply-To: <7.0.1.0.2.20060217080226.03a11010@earthlink.net> +X-PGP-Key-ID: Length=1024; ID=0x0DC67BE6 +X-PGP-Key-Fingerprint: 295F A899 A81A 156D B522 48A7 6394 F08A 0DC6 7BE6 +X-PGP-Key-URL: +User-Agent: Mutt/1.5.9i +X-SA-Exim-Connect-IP: +X-SA-Exim-Mail-From: kleptog@svana.org +X-SA-Exim-Scanned: No (on svana.org); SAEximRunCond expanded to false +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.123 required=5 tests=[AWL=0.123] +X-Spam-Score: 0.123 +X-Spam-Level: +X-Archive-Number: 200602/660 +X-Sequence-Number: 79798 + + +--oj4kGyHlBMXGt3Le +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +Content-Transfer-Encoding: quoted-printable + +On Fri, Feb 17, 2006 at 08:23:40AM -0500, Ron wrote: +> >For this mapping, you need a full table sort. +> One physical IO pass should be all that's needed. However, let's=20 +> pretend you are correct and that we do need to sort the table to get=20 +> the key mapping. Even so, we would only need to do it =3Donce=3D and=20 +> then we would be able to use and incrementally update the results=20 +> forever afterward. Even under this assumption, one external sort to=20 +> save all subsequent such sorts seems well worth it. +>=20 +> IOW, even if I'm wrong about the initial cost to do this; it is still=20 +> worth doing ;-) + +I think you're talking about something different here. You're thinking +of having the whole table sorted and when you add a new value you add +it in such a way to keep it sorted. The problem is, what do you sort it +by? If you've sorted the table by col1, then when the user does ORDER +BY col2 it's useless. + +Indeed, this is what btrees do, you store the order of the table +seperate from the data. And you can store multiple orders. But even +then, when someone does ORDER BY lower(col1), it's still useless. + +And you're right, we still need to do the single mass sort in the +beginning, which is precisely what we're trying to optimise here. + +> ??? You do not need to resort already ordered data to insert a new=20 +> element into it such that the data stays ordered! Once we have done=20 +> the key ordering operation once, we should not ever need to do it=20 +> again on the original data. Else most sorting algorithms wouldn't work ;= +-) + +We already do this with btree indexes. I'm not sure what you are +proposing that improves on that. + +Have a nice day, +--=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. + +--oj4kGyHlBMXGt3Le +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) + +iD8DBQFD9fGWIB7bNG8LQkwRAuEGAKCBmgneGkWhYa2RIkkjFcbs13VnywCgi78D +FDv+hOlXVbTw8evk84RBIak= +=bszz +-----END PGP SIGNATURE----- + +--oj4kGyHlBMXGt3Le-- + +From pgsql-hackers-owner@postgresql.org Fri Feb 17 12:18:58 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id E6E4B9DC9A0; + Fri, 17 Feb 2006 12:18:57 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 66015-10; Fri, 17 Feb 2006 12:18:55 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from calvin.slamb.org (calvin.slamb.org [216.136.66.56]) + by postgresql.org (Postfix) with ESMTP id BD2CC9DC99B; + Fri, 17 Feb 2006 12:18:54 -0400 (AST) +Received: by calvin.slamb.org (Postfix, from userid 103) + id 816057BD2E; Fri, 17 Feb 2006 10:18:52 -0600 (CST) +Received: from [192.168.1.105] (adsl-69-230-8-158.dsl.pltn13.pacbell.net + [69.230.8.158]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by calvin.slamb.org (Postfix) with ESMTP + id 323477BD2A; Fri, 17 Feb 2006 10:18:50 -0600 (CST) +In-Reply-To: <1140128256.9076.254.camel@archimedes> +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> + <7.0.1.0.2.20060215194635.03b55da0@earthlink.net> + <21615.1140052893@sss.pgh.pa.us> + <7.0.1.0.2.20060215223710.03a7c618@earthlink.net> + <20060216113522.GA3461@uio.no> + <7.0.1.0.2.20060216071053.0385a1a8@earthlink.net> + <43F481CD.2010509@logix-tt.com> <43F4A7D8.4050907@modgraph-usa.com> + <29277.1140110108@sss.pgh.pa.us> + <1140128256.9076.254.camel@archimedes> +Mime-Version: 1.0 (Apple Message framework v746.2) +Content-Type: multipart/alternative; boundary=Apple-Mail-1-824648008 +Message-Id: <8F91CB67-8459-4B65-ADDC-A47A135E0767@slamb.org> +Cc: Tom Lane , "Craig A. James" , + Markus Schaber , + pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +From: Scott Lamb +Subject: Re: qsort again (was Re: [PERFORM] Strange Create Index +Date: Fri, 17 Feb 2006 08:18:41 -0800 +To: Mark Lewis +X-Mailer: Apple Mail (2.746.2) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.001 required=5 tests=[HTML_MESSAGE=0.001] +X-Spam-Score: 0.001 +X-Spam-Level: +X-Archive-Number: 200602/661 +X-Sequence-Number: 79799 + + +--Apple-Mail-1-824648008 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset=US-ASCII; + delsp=yes; + format=flowed + +On Feb 16, 2006, at 2:17 PM, Mark Lewis wrote: +> Data types which could probably provide a useful function for f +> would be +> int2, int4, oid, and possibly int8 and text (at least for SQL_ASCII). + +...and with some work, floats (I think just the exponent would work, +if nothing else). bytea. Probably just about anything. + +Interesting. If you abandon the idea that collisions should be +impossible (they're not indexes) or extremely rare (they're not +hashes), it's pretty easy to come up with a decent hint to avoid a +lot of dereferences. + +-- +Scott Lamb + + + +--Apple-Mail-1-824648008 +Content-Transfer-Encoding: quoted-printable +Content-Type: text/html; + charset=US-ASCII + +
On Feb 16, 2006, at = +2:17 PM, Mark Lewis wrote:

Data types which could = +probably provide a useful function for f would be

int2, int4, oid, and = +possibly int8 and text (at least for SQL_ASCII).

= +

...and with some work, = +floats (I think just the exponent would work, if nothing else). bytea. = +Probably just about anything.

Interesting. If you abandon = +the idea that collisions should be impossible (they're not indexes) or = +extremely rare (they're not hashes), it's pretty easy to come up with a = +decent hint to avoid a lot of dereferences.

--


= + +--Apple-Mail-1-824648008-- + +From pgsql-hackers-owner@postgresql.org Fri Feb 17 12:31:47 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id F37A89DCA31; + Fri, 17 Feb 2006 12:31:45 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 67459-10; Fri, 17 Feb 2006 12:31:43 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from svana.org (svana.org [125.62.94.225]) + by postgresql.org (Postfix) with ESMTP id 027FE9DC84B; + Fri, 17 Feb 2006 12:31:41 -0400 (AST) +Received: from kleptog by svana.org with local (Exim 4.50) + id 1FA8Vv-0003Q1-Mi; Sat, 18 Feb 2006 03:31:23 +1100 +Date: Fri, 17 Feb 2006 17:31:23 +0100 +From: Martijn van Oosterhout +To: Scott Lamb +Cc: Mark Lewis , Tom Lane , + "Craig A. James" , + Markus Schaber , + pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Subject: Re: qsort again (was Re: [PERFORM] Strange Create Index +Message-ID: <20060217163123.GE9254@svana.org> +Reply-To: Martijn van Oosterhout +References: <7.0.1.0.2.20060215194635.03b55da0@earthlink.net> + <21615.1140052893@sss.pgh.pa.us> + <7.0.1.0.2.20060215223710.03a7c618@earthlink.net> + <20060216113522.GA3461@uio.no> + <7.0.1.0.2.20060216071053.0385a1a8@earthlink.net> + <43F481CD.2010509@logix-tt.com> <43F4A7D8.4050907@modgraph-usa.com> + <29277.1140110108@sss.pgh.pa.us> + <1140128256.9076.254.camel@archimedes> + <8F91CB67-8459-4B65-ADDC-A47A135E0767@slamb.org> +Mime-Version: 1.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; boundary="3O1VwFp74L81IIeR" +Content-Disposition: inline +In-Reply-To: <8F91CB67-8459-4B65-ADDC-A47A135E0767@slamb.org> +X-PGP-Key-ID: Length=1024; ID=0x0DC67BE6 +X-PGP-Key-Fingerprint: 295F A899 A81A 156D B522 48A7 6394 F08A 0DC6 7BE6 +X-PGP-Key-URL: +User-Agent: Mutt/1.5.9i +X-SA-Exim-Connect-IP: +X-SA-Exim-Mail-From: kleptog@svana.org +X-SA-Exim-Scanned: No (on svana.org); SAEximRunCond expanded to false +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.123 required=5 tests=[AWL=0.123] +X-Spam-Score: 0.123 +X-Spam-Level: +X-Archive-Number: 200602/662 +X-Sequence-Number: 79800 + + +--3O1VwFp74L81IIeR +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +Content-Transfer-Encoding: quoted-printable + +On Fri, Feb 17, 2006 at 08:18:41AM -0800, Scott Lamb wrote: +> On Feb 16, 2006, at 2:17 PM, Mark Lewis wrote: +> >Data types which could probably provide a useful function for f =20 +> >would be +> >int2, int4, oid, and possibly int8 and text (at least for SQL_ASCII). +>=20 +> ...and with some work, floats (I think just the exponent would work, =20 +> if nothing else). bytea. Probably just about anything. +>=20 +> Interesting. If you abandon the idea that collisions should be =20 +> impossible (they're not indexes) or extremely rare (they're not =20 +> hashes), it's pretty easy to come up with a decent hint to avoid a =20 +> lot of dereferences. + +Yep, pretty much for any datatype you create a mapping function to map +it to a signed int32. All you have to guarentee is that f(a) > f(b) +implies that a > b. Only if f(a) =3D=3D f(b) do you need to compare a and +b. + +You then change the sorting code to have an array of (Datum,int32) +(ouch, double the storage) where the int32 is the f(Datum). And in the +comparison routines you first check the int32. If they give an order +you're done. On match you do the full comparison. + +For integer types (int2,int4,int8,oid) the conversion is straight +forward. For float you'd use the exponent and the first few bits of the +mantissa. For strings you'd have to bail, or use a strxfrm equivalent. +NULL would be INT_MAX pr INT_MIN depending on where you want it. Thing +is, even if you don't have such a function and always return zero, the +results will still be right. + +Not a new idea, but it would be very nice to implement. If would +produce nice speedups for type where comparisons are expensive. And +more importantly, the bulk of the comparisons can be moved inline and +make the whole cache-friendlyness discussed here much more meaningful. + +Have a nice day, +--=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. + +--3O1VwFp74L81IIeR +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) + +iD8DBQFD9fpbIB7bNG8LQkwRAqGiAJ99zj5mcaHkYCccW87sug+nbloTGwCgjaNd +ND3PDJKC6kq3Adbfzzmqi0Y= +=i14/ +-----END PGP SIGNATURE----- + +--3O1VwFp74L81IIeR-- + +From pgsql-hackers-owner@postgresql.org Fri Feb 17 12:45:06 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 3A15D9DC84C; + Fri, 17 Feb 2006 12:45:04 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 72781-04; Fri, 17 Feb 2006 12:45:02 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smtpauth08.mail.atl.earthlink.net + (smtpauth08.mail.atl.earthlink.net [209.86.89.68]) + by postgresql.org (Postfix) with ESMTP id 8C0B19DC84B; + Fri, 17 Feb 2006 12:45:01 -0400 (AST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=kQts5CU3L7EWyfSghA1PveN4DyuCJ2BB9Fq6pcBhdYbhoCNrWpBIvC7m54ZHsaMd; + 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 [71.243.43.186] (helo=ron-6d52adff2a6.earthlink.net) + by smtpauth08.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1FA8j3-0006DS-0d; Fri, 17 Feb 2006 11:44:57 -0500 +Message-Id: <7.0.1.0.2.20060217111116.03a509e8@earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 7.0.1.0 +Date: Fri, 17 Feb 2006 11:44:51 -0500 +To: Martijn van Oosterhout , + pgsql-performance@postgresql.org,pgsql-hackers@postgresql.org +From: Ron +Subject: Re: qsort again (was Re: [PERFORM] Strange Create +In-Reply-To: <20060217155358.GD9254@svana.org> +References: <20060216113522.GA3461@uio.no> + <7.0.1.0.2.20060216071053.0385a1a8@earthlink.net> + <20060216144833.GG26127@svana.org> + <7.0.1.0.2.20060216100954.035b5ee0@earthlink.net> + <7.0.1.0.2.20060216110249.0395d2b0@earthlink.net> + <87FA36B4-CD97-4CF5-B9B3-02FEEA25CC95@slamb.org> + <7.0.1.0.2.20060216133801.03a7ab50@earthlink.net> + <7.0.1.0.2.20060217004822.039d46a8@earthlink.net> + <43F5A341.5090808@logix-tt.com> + <7.0.1.0.2.20060217080226.03a11010@earthlink.net> + <20060217155358.GD9254@svana.org> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bc04f64cf36a9fb0e6fab93930b1e54897350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 71.243.43.186 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.471 required=5 tests=[AWL=-0.008, + DNS_FROM_RFC_ABUSE=0.479] +X-Spam-Score: 0.471 +X-Spam-Level: +X-Archive-Number: 200602/664 +X-Sequence-Number: 79802 + +At 10:53 AM 2/17/2006, Martijn van Oosterhout wrote: +>On Fri, Feb 17, 2006 at 08:23:40AM -0500, Ron wrote: +> > >For this mapping, you need a full table sort. +> > One physical IO pass should be all that's needed. However, let's +> > pretend you are correct and that we do need to sort the table to get +> > the key mapping. Even so, we would only need to do it =once= and +> > then we would be able to use and incrementally update the results +> > forever afterward. Even under this assumption, one external sort to +> > save all subsequent such sorts seems well worth it. +> > +> > IOW, even if I'm wrong about the initial cost to do this; it is still +> > worth doing ;-) +> +>I think you're talking about something different here. You're thinking +>of having the whole table sorted and when you add a new value you add +>it in such a way to keep it sorted. The problem is, what do you sort it +>by? If you've sorted the table by col1, then when the user does ORDER +>BY col2 it's useless. +No, I'm thinking about how to represent DB row data in such a way that +a= we use a compact enough representation that we can sort internally +rather than externally. +b= we do the sort once and avoid most of the overhead upon subsequent +similar requests. + +I used the example of sorting on the entire row to show that the +approach works even when the original record being sorted by is very large. +All my previous comments on this topic hold for the case where we are +sorting on only part of a row as well. + +If all you are doing is sorting on a column or a few columns, what +I'm discussing is even easier since treating the columns actually +being used a sort criteria as integers rather than the whole row as +an atomic unit eats less resources during the key creation and +mapping process. If the row is 2-4KB in size, but we only care about +some combination of columns that only takes on <= 2^8 or <= 2^16 +different values, then what I've described will be even better than +the original example I gave. + +Basically, the range of a key is going to be restricted by how +a= big the field is that represents the key (columns and such are +usually kept narrow for performance reasons) or +b= big each row is (the more space each row takes, the fewer rows fit +into any given amount of storage) +c= many rows there are in the table +Between the conditions, the range of a key tends to be severely +restricted and therefore use much less space than sorting the actual +DB records would. ...and that gives us something we can take advantage of. + + +>Indeed, this is what btrees do, you store the order of the table +>seperate from the data. And you can store multiple orders. But even +>then, when someone does ORDER BY lower(col1), it's still useless. +> +>And you're right, we still need to do the single mass sort in the +>beginning, which is precisely what we're trying to optimise here. +Sigh. My points were: +1= we have information available to us that allows us to map the rows +in such a way as to turn most external sorts into internal sorts, +thereby avoiding the entire external sorting problem in those +cases. This is a huge performance improvement. + +2= that an external sort is =NOT= required for initial key +assignment, but even if it was it would be worth it. + +3= that this is a variation of a well known technique so I'm not +suggesting heresy here. + + +Ron + + + +From pgsql-hackers-owner@postgresql.org Fri Feb 17 12:51:35 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id BFAF99DC97F; + Fri, 17 Feb 2006 12:51:34 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 72917-05; Fri, 17 Feb 2006 12:51:33 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smtpauth08.mail.atl.earthlink.net + (smtpauth08.mail.atl.earthlink.net [209.86.89.68]) + by postgresql.org (Postfix) with ESMTP id A56989DC810; + Fri, 17 Feb 2006 12:51:31 -0400 (AST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=nSg9Di/V1cJCelWSSLmVTadwKJFBZtu142/6CkDgukstBKeAK2m+TXUb5KvW7TNX; + h=Received:Message-Id:X-Mailer:Date:To:From:Subject:Mime-Version:Content-Type:X-ELNK-Trace:X-Originating-IP; +Received: from [71.243.43.186] (helo=ron-6d52adff2a6.earthlink.net) + by smtpauth08.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1FA8pP-0003ve-1q; Fri, 17 Feb 2006 11:51:31 -0500 +Message-Id: <7.0.1.0.2.20060217114924.0390b890@earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 7.0.1.0 +Date: Fri, 17 Feb 2006 11:51:26 -0500 +To: pgsql-hackers@postgresql.org,pgsql-performance@postgresql.org +From: Ron +Subject: Need pointers to "standard" pg database(s) for testing +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bc7478143adefa7577bc3fd66f20d3c475350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 71.243.43.186 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.472 required=5 tests=[AWL=-0.007, + DNS_FROM_RFC_ABUSE=0.479] +X-Spam-Score: 0.472 +X-Spam-Level: +X-Archive-Number: 200602/665 +X-Sequence-Number: 79803 + +I assume we have such? + +Ron + + + +From pgsql-hackers-owner@postgresql.org Fri Feb 17 12:56:38 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 5F5DA9DC9A0; + Fri, 17 Feb 2006 12:56:37 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 73606-05; Fri, 17 Feb 2006 12:56:35 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) + by postgresql.org (Postfix) with ESMTP id 7032C9DC9AF; + Fri, 17 Feb 2006 12:56:32 -0400 (AST) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Fri, 17 Feb 2006 16:56:30 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 17 Feb 2006 10:56:30 -0600 +Subject: Re: [PERFORM] Need pointers to "standard" pg database(s) for +From: Scott Marlowe +To: Ron +Cc: pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org +In-Reply-To: <7.0.1.0.2.20060217114924.0390b890@earthlink.net> +References: <7.0.1.0.2.20060217114924.0390b890@earthlink.net> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1140195390.22740.288.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Fri, 17 Feb 2006 10:56:30 -0600 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.159 required=5 tests=[AWL=0.158, + UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 0.159 +X-Spam-Level: +X-Archive-Number: 200602/666 +X-Sequence-Number: 79804 + +On Fri, 2006-02-17 at 10:51, Ron wrote: +> I assume we have such? + +Depends on what you wanna do. +For transactional systems, look at some of the stuff OSDL has done. + +For large geospatial type stuff, the government is a good source, like +www.usgs.gov or the fcc transmitter database. + +There are other ones out there. Really depends on what you wanna test. + +From pgsql-hackers-owner@postgresql.org Fri Feb 17 13:09:59 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id CBE399DC9A0 + for ; + Fri, 17 Feb 2006 13:09:58 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 76497-04 + for ; + Fri, 17 Feb 2006 13:09:56 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.gmx.net (mail.gmx.de [213.165.64.20]) + by postgresql.org (Postfix) with SMTP id 6596D9DCA51 + for ; + Fri, 17 Feb 2006 13:09:54 -0400 (AST) +Received: (qmail invoked by alias); 17 Feb 2006 17:09:54 -0000 +Received: from 85-124-1-213.dynamic.xdsl-line.inode.at (EHLO zaphod) + [85.124.1.213] + by mail.gmx.net (mp018) with SMTP; 17 Feb 2006 18:09:54 +0100 +X-Authenticated: #1946847 +Message-ID: <00d401c633e4$f7cff940$0f01a8c0@zaphod> +From: "Michael Paesold" +To: , , + "Ron" +References: <7.0.1.0.2.20060217114924.0390b890@earthlink.net> +Subject: Re: Need pointers to "standard" pg database(s) for testing +Date: Fri, 17 Feb 2006 18:09:52 +0100 +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-Y-GMX-Trusted: 0 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.067 required=5 tests=[AWL=0.067] +X-Spam-Score: 0.067 +X-Spam-Level: +X-Archive-Number: 200602/667 +X-Sequence-Number: 79805 + +Ron wrote: +>I assume we have such? + +You could look at the Sample Databases project on pgfoundry: +http://pgfoundry.org/projects/dbsamples/ + +Best Regards, +Michael Paesold + + +From pgsql-hackers-owner@postgresql.org Fri Feb 17 13:30:46 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 5E3419DC810; + Fri, 17 Feb 2006 13:30:46 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 79497-10; Fri, 17 Feb 2006 13:30:45 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mir3-fs.mir3.com (mail.mir3.com [65.208.188.100]) + by postgresql.org (Postfix) with ESMTP id 732169DCA31; + Fri, 17 Feb 2006 13:30:42 -0400 (AST) +Received: mir3-fs.mir3.com 172.16.1.11 from 172.16.2.68 172.16.2.68 via HTTP + with MS-WebStorage 6.0.6249 +Received: from archimedes.mirlogic.com by mir3-fs.mir3.com; + 17 Feb 2006 09:30:37 -0800 +Subject: Re: qsort again (was Re: [PERFORM] Strange Create Index +From: Mark Lewis +To: David Lang +Cc: Greg Stark , Markus Schaber , + pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +In-Reply-To: +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> + <7.0.1.0.2.20060215194635.03b55da0@earthlink.net> + <21615.1140052893@sss.pgh.pa.us> + <7.0.1.0.2.20060215223710.03a7c618@earthlink.net> + <20060216113522.GA3461@uio.no> + <7.0.1.0.2.20060216071053.0385a1a8@earthlink.net> + <43F481CD.2010509@logix-tt.com> <43F4A7D8.4050907@modgraph-usa.com> + <29277.1140110108@sss.pgh.pa.us> <1140128256.9076.254.camel@archimedes> + <43F4FDCC.2000204@logix-tt.com> <871wy23okp.fsf@stark.xeocode.com> + <1140132189.9076.261.camel@archimedes> + +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Organization: MIR3, Inc. +Date: Fri, 17 Feb 2006 09:30:37 -0800 +Message-Id: <1140197437.9076.268.camel@archimedes> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-22) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.131 required=5 tests=[AWL=0.130, + UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 0.131 +X-Spam-Level: +X-Archive-Number: 200602/668 +X-Sequence-Number: 79806 + +On Thu, 2006-02-16 at 21:33 -0800, David Lang wrote: +> > In SQL_ASCII, just take the first 4 characters (or 8, if using a 64-bit +> > sortKey as elsewhere suggested). The sorting key doesn't need to be a +> > one-to-one mapping. +> +> that would violate your second contraint ( f(a)==f(b) iff (a==b) ) +> +> if you could drop that constraint (the cost of which would be extra 'real' +> compares within a bucket) then a helper function per datatype could work +> as you are talking. + +I think we're actually on the same page here; you're right that the +constraint above ( f(a)==f(b) iff a==b ) can't be extended to data types +with more than 32 bits of value space. But the constraint I listed was +actually: + +if a==b then f(a)==f(b) + +Which doesn't imply 'if and only if'. It's a similar constraint to +hashcodes; the same value will always have the same hash, but you're not +guaranteed that the hashcodes for two distinct values will be unique. + +-- Mark + +From pgsql-hackers-owner@postgresql.org Fri Feb 17 15:22:09 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 50B179DC83A + for ; + Fri, 17 Feb 2006 15:22:08 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 14346-02 + for ; + Fri, 17 Feb 2006 15:22:03 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx1.hive.is (scania.ipf.is [85.197.192.147]) + by postgresql.org (Postfix) with SMTP id CB5B79DCA00 + for ; + Fri, 17 Feb 2006 15:21:57 -0400 (AST) +Received: (qmail 39487 invoked by uid 1010); 17 Feb 2006 19:22:03 -0000 +Received: from 85.197.216.186 by scania.ipf.is (envelope-from , + uid 1009) with qmail-scanner-1.25-st-qms + (clamdscan: 0.88/1283. spamassassin: 3.1.0. perlscan: 1.25-st-qms. + Clear:RC:1(85.197.216.186):SA:0(-4.1/4.0):. + Processed in 6.437122 secs); 17 Feb 2006 19:22:03 -0000 +X-Antivirus-HIVE-Mail-From: gnari@hive.is via scania.ipf.is +X-Antivirus-HIVE: 1.25-st-qms (Clear:RC:1(85.197.216.186):SA:0(-4.1/4.0):. + Processed in 6.437122 secs Process 39443) +Received: from dsl-216-186.hive.is (HELO ?192.168.1.34?) (85.197.216.186) + by mx1.hive.is with SMTP; 17 Feb 2006 19:21:56 -0000 +Subject: Re: qsort again (was Re: [PERFORM] Strange Create +From: Ragnar +To: Ron +Cc: pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +In-Reply-To: <7.0.1.0.2.20060217072626.039c5f20@earthlink.net> +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> + <7.0.1.0.2.20060215194635.03b55da0@earthlink.net> + <21615.1140052893@sss.pgh.pa.us> + <7.0.1.0.2.20060215223710.03a7c618@earthlink.net> + <20060216113522.GA3461@uio.no> + <7.0.1.0.2.20060216071053.0385a1a8@earthlink.net> + <20060216144833.GG26127@svana.org> + <7.0.1.0.2.20060216100954.035b5ee0@earthlink.net> + <7.0.1.0.2.20060216110249.0395d2b0@earthlink.net> + <87FA36B4-CD97-4CF5-B9B3-02FEEA25CC95@slamb.org> + <7.0.1.0.2.20060216133801.03a7ab50@earthlink.net> + <7.0.1.0.2.20060217004822.039d46a8@earthlink.net> + <1140168261.32324.70.camel@localhost.localdomain> + <7.0.1.0.2.20060217072626.039c5f20@earthlink.net> +Content-Type: text/plain; charset=ISO-8859-1 +Date: Fri, 17 Feb 2006 19:22:49 +0000 +Message-Id: <1140204169.32324.108.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.4.1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.145 required=5 tests=[AWL=0.145] +X-Spam-Score: 0.145 +X-Spam-Level: +X-Archive-Number: 200602/669 +X-Sequence-Number: 79807 + +On f�s, 2006-02-17 at 08:01 -0500, Ron wrote: +> At 04:24 AM 2/17/2006, Ragnar wrote: +> >On f�s, 2006-02-17 at 01:20 -0500, Ron wrote: +> > > +> > > OK, so here's _a_ way (there are others) to obtain a mapping such that +> > > if a < b then f(a) < f (b) and +> > > if a == b then f(a) == f(b) +> > +> > > By scanning the table once, we can map say 0000001h (Hex used to ease +> > > typing) to the row with the minimum value and 1111111h to the row +> > > with the maximum value as well as mapping everything in between to +> > > their appropriate keys. That same scan can be used to assign a +> > > pointer to each record's location. +> > +> >This step is just as expensive as the original +> >sort you want to replace/improve. +> +> Why do you think that? External sorts involve +> the equivalent of multiple scans of the table to +> be sorted, sometimes more than lgN (where N is +> the number of items in the table to be +> sorted). Since this is physical IO we are +> talking about, each scan is very expensive, and +> therefore 1 scan is going to take considerably +> less time than >= lgN scans will be. + +Call me dim, but please explain exactly how you are going +to build this mapping in one scan. Are you assuming +the map will fit in memory? + +> +> +> >If you want to keep this mapping saved as a sort +> >of an index, or as part ot each row data, this +> >will make the cost of inserts and updates enormous. +> +> Not sure you've got this right either. Looks to +> me like we are adding a <= 32b quantity to each +> row. Once we know the mapping, incrementally +> updating it upon insert or update would seem to +> be simple matter of a fast search for the correct +> ranking [Interpolation search, which we have all +> the needed data for, is O(lglgN). Hash based +> search is O(1)]; plus an increment/decrement of +> the key values greater/less than the key value of +> the row being inserted / updated. Given than we +> are updating all the keys in a specific range +> within a tree structure, that update can be done +> in O(lgm) (where m is the number of records affected). + +Say again ? +Let us say you have 1 billion rows, where the +column in question contains strings like +baaaaaaaaaaaaaaa....aaa +baaaaaaaaaaaaaaa....aab +baaaaaaaaaaaaaaa....aac +... +not necessarily in this order on disc of course + +The minimum value would be keyed as 00000001h, +the next one as 00000002h and so on. + +Now insert new value 'aaaaa' + +Not only will you have to update 1 billion records, +but also all the values in your map. + +please explain + +gnari + + + +From pgsql-hackers-owner@postgresql.org Fri Feb 17 15:43:41 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 3F1AA9DCB61; + Fri, 17 Feb 2006 15:43:40 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 17365-08; Fri, 17 Feb 2006 15:43:39 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 2BB539DCB4D; + Fri, 17 Feb 2006 15:43:36 -0400 (AST) +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 k1HJh6R1011802; + Fri, 17 Feb 2006 14:43:07 -0500 (EST) +To: Mark Lewis +cc: David Lang , Greg Stark , + Markus Schaber , pgsql-performance@postgresql.org, + pgsql-hackers@postgresql.org +Subject: Re: qsort again (was Re: [PERFORM] Strange Create Index +In-reply-to: <1140197437.9076.268.camel@archimedes> +References: <43F38867.6010701@gpdnet.co.uk> <19510.1140036968@sss.pgh.pa.us> + <19779.1140038874@sss.pgh.pa.us> <43F39E53.1020009@gpdnet.co.uk> + <20781.1140046109@sss.pgh.pa.us> + <7.0.1.0.2.20060215194635.03b55da0@earthlink.net> + <21615.1140052893@sss.pgh.pa.us> + <7.0.1.0.2.20060215223710.03a7c618@earthlink.net> + <20060216113522.GA3461@uio.no> + <7.0.1.0.2.20060216071053.0385a1a8@earthlink.net> + <43F481CD.2010509@logix-tt.com> <43F4A7D8.4050907@modgraph-usa.com> + <29277.1140110108@sss.pgh.pa.us> + <1140128256.9076.254.camel@archimedes> + <43F4FDCC.2000204@logix-tt.com> <871wy23okp.fsf@stark.xeocode.com> + <1140132189.9076.261.camel@archimedes> + + <1140197437.9076.268.camel@archimedes> +Comments: In-reply-to Mark Lewis + message dated "Fri, 17 Feb 2006 09:30:37 -0800" +Date: Fri, 17 Feb 2006 14:43:06 -0500 +Message-ID: <11801.1140205386@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.11 required=5 tests=[AWL=0.110] +X-Spam-Score: 0.11 +X-Spam-Level: +X-Archive-Number: 200602/671 +X-Sequence-Number: 79809 + +Mark Lewis writes: +> I think we're actually on the same page here; you're right that the +> constraint above ( f(a)==f(b) iff a==b ) can't be extended to data types +> with more than 32 bits of value space. But the constraint I listed was +> actually: + +> if a==b then f(a)==f(b) + +I believe Martijn had it right: the important constraint is + + f(a) > f(b) implies a > b + +which implies by commutativity + + f(a) < f(b) implies a < b + +and these two together imply + + a == b implies f(a) == f(b) + +Now you can't do any sorting if you only have the equality rule, you +need the inequality rule. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sat Feb 18 00:10:54 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 354969DC836 + for ; + Fri, 17 Feb 2006 16:26:24 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 33479-02 + for ; + Fri, 17 Feb 2006 16:26:24 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from twmail.ESNCC.COM (static-66-173-159-28.t1.cavtel.net + [66.173.159.28]) by postgresql.org (Postfix) with SMTP id 247969DC82F + for ; + Fri, 17 Feb 2006 16:26:20 -0400 (AST) +Received: from spawar2i8uvlb9 ([150.125.117.63]) by twmail.ESNCC.COM with + Microsoft SMTPSVC(6.0.3790.1830); Fri, 17 Feb 2006 15:26:20 -0500 +From: "Lane Van Ingen" +To: +Subject: Measuring Lock Performance +Date: Fri, 17 Feb 2006 15:26:19 -0500 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.181 +Importance: Normal +X-OriginalArrivalTime: 17 Feb 2006 20:26:20.0598 (UTC) + FILETIME=[69C7BD60:01C63400] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.203 required=5 tests=[AWL=0.203] +X-Spam-Score: 0.203 +X-Spam-Level: +X-Archive-Number: 200602/301 +X-Sequence-Number: 17287 + +Does anybody know if it is possible to use the statistics collected by +PostgreSQL to do the following, and how? + +- view all locks held by a particular PostgreSQL session (including how to +determine + the session ID#) + +- determine effect of lock contention on overall database performance, as +well as the + extent to which contention varies with overall database traffic + +I am using version 8.0.2 on Windows 2003. + + + +From pgsql-hackers-owner@postgresql.org Fri Feb 17 18:36:12 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 0A3E19DC850 + for ; + Fri, 17 Feb 2006 18:36:11 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 77104-02 + for ; + Fri, 17 Feb 2006 18:36:12 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from nproxy.gmail.com (nproxy.gmail.com [64.233.182.197]) + by postgresql.org (Postfix) with ESMTP id CBCA89DC82F + for ; + Fri, 17 Feb 2006 18:36:08 -0400 (AST) +Received: by nproxy.gmail.com with SMTP id x30so340094nfb + for ; + Fri, 17 Feb 2006 14:36:10 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=SmO7qmCpUYkRicsud2ZLkVqffyKvVe5qRMXzDL4vugkJ5QlqSKp8yMPDd+7+ykrRYMNPZC3v9gwSnLwRCKEuedRDMsf2wzJTeuu1kvO30Q3p3n0BM9nzKPFSKFf5eim/NdwzMGzHp3n6bX+jvr4C9NPFxfh0ZUxMHiKqGFnUwsk= +Received: by 10.48.127.15 with SMTP id z15mr571162nfc; + Fri, 17 Feb 2006 14:36:10 -0800 (PST) +Received: by 10.48.143.7 with HTTP; Fri, 17 Feb 2006 14:36:10 -0800 (PST) +Message-ID: +Date: Fri, 17 Feb 2006 17:36:10 -0500 +From: "Gregory Maxwell" +To: Ragnar +Subject: Re: qsort again (was Re: [PERFORM] Strange Create +Cc: Ron , pgsql-performance@postgresql.org, + pgsql-hackers@postgresql.org +In-Reply-To: <1140204169.32324.108.camel@localhost.localdomain> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <43F38867.6010701@gpdnet.co.uk> <20060216144833.GG26127@svana.org> + <7.0.1.0.2.20060216100954.035b5ee0@earthlink.net> + <7.0.1.0.2.20060216110249.0395d2b0@earthlink.net> + <87FA36B4-CD97-4CF5-B9B3-02FEEA25CC95@slamb.org> + <7.0.1.0.2.20060216133801.03a7ab50@earthlink.net> + <7.0.1.0.2.20060217004822.039d46a8@earthlink.net> + <1140168261.32324.70.camel@localhost.localdomain> + <7.0.1.0.2.20060217072626.039c5f20@earthlink.net> + <1140204169.32324.108.camel@localhost.localdomain> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.044 required=5 tests=[AWL=0.044] +X-Spam-Score: 0.044 +X-Spam-Level: +X-Archive-Number: 200602/674 +X-Sequence-Number: 79812 + +On 2/17/06, Ragnar wrote: +> Say again ? +> Let us say you have 1 billion rows, where the +> column in question contains strings like +> baaaaaaaaaaaaaaa....aaa +> baaaaaaaaaaaaaaa....aab +> baaaaaaaaaaaaaaa....aac +> ... +> not necessarily in this order on disc of course +> +> The minimum value would be keyed as 00000001h, +> the next one as 00000002h and so on. +> +> Now insert new value 'aaaaa' +> +> Not only will you have to update 1 billion records, +> but also all the values in your map. +> +> please explain + +No comment on the usefulness of the idea overall.. but the solution +would be to insert with the colliding value of the existing one lesser +than it.. + +It will falsly claim equal, which you then must fix with a second +local sort which should be fast because you only need to sort the +duplicates/false dupes. If you insert too much then this obviously +becomes completely useless. + +From pgsql-performance-owner@postgresql.org Sat Feb 18 01:53:08 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id D4DB89DC981 + for ; + Sat, 18 Feb 2006 01:53:07 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 63977-08 + for ; + Sat, 18 Feb 2006 01:53:07 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 9ED8D9DC94C + for ; + Sat, 18 Feb 2006 01:53:05 -0400 (AST) +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 k1I5r49u015894; + Sat, 18 Feb 2006 00:53:04 -0500 (EST) +To: Adam Alkins +cc: pgsql-performance@postgresql.org +Subject: Re: Index Choice Problem +In-reply-to: +References: +Comments: In-reply-to Adam Alkins + message dated "Thu, 16 Feb 2006 13:03:29 -0400" +Date: Sat, 18 Feb 2006 00:53:04 -0500 +Message-ID: <15893.1140241984@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.11 required=5 tests=[AWL=0.110] +X-Spam-Score: 0.11 +X-Spam-Level: +X-Archive-Number: 200602/304 +X-Sequence-Number: 17290 + +Adam Alkins writes: +> SELECT t.topic_id +> FROM phpbb_topics AS t +> WHERE t.forum_id = 71 +> AND t.topic_id NOT IN (205026, 29046, 144569, 59780, 187424, +> 138635, 184973, 170551, 22419, 181690, 197254, 205130) +> ORDER BY t.topic_last_post_time DESC +> LIMIT 23 OFFSET 0 + +If you're using 8.1, you'd probably find that an index on (forum_id, +topic_last_post_time) would work nicely for this. You could use it +in prior versions too, but you'd have to spell the ORDER BY rather +strangely: + ORDER BY forum_id desc, topic_last_post_time desc +The reason for this trickery is to get the planner to realize that +the index order matches the ORDER BY ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sat Feb 18 03:29:07 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id C6B239DC896 + for ; + Sat, 18 Feb 2006 03:29:05 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 83205-03 + for ; + Sat, 18 Feb 2006 03:29:03 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.207]) + by postgresql.org (Postfix) with ESMTP id 8E6429DC88F + for ; + Sat, 18 Feb 2006 03:29:00 -0400 (AST) +Received: by wproxy.gmail.com with SMTP id i6so297972wra + for ; + Fri, 17 Feb 2006 23:29:01 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; + b=ZCEZsenJcUOTQPJ1FZ5TgPmWNJEmdz7MjP5bUB/nwCWEpy4xoyLXCGi4c1txQpNUmoaGGB4w9tRRMOr6fqXTDnsIQRL0Th86QbAex4ZvpCVCBok8kZot+da3o1uxzAMEdvLaf3BVt2x8rg0TpcZyu1nfJoDlRorvwoITBGWnPrc= +Received: by 10.65.141.7 with SMTP id t7mr141233qbn; + Fri, 17 Feb 2006 23:29:00 -0800 (PST) +Received: by 10.65.225.2 with HTTP; Fri, 17 Feb 2006 23:29:00 -0800 (PST) +Message-ID: +Date: Sat, 18 Feb 2006 03:29:00 -0400 +From: "Adam Alkins" +To: "Tom Lane" +Subject: Re: Index Choice Problem +Cc: pgsql-performance@postgresql.org +In-Reply-To: <15893.1140241984@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_4040_12034139.1140247740907" +References: + <15893.1140241984@sss.pgh.pa.us> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.14 required=5 tests=[AWL=0.139, HTML_MESSAGE=0.001] +X-Spam-Score: 0.14 +X-Spam-Level: +X-Archive-Number: 200602/305 +X-Sequence-Number: 17291 + +------=_Part_4040_12034139.1140247740907 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Unfortunately I'm using 8.0.4 and this is for a government website, I only +get so many maintenance windows. Is this the only workaround for this issue= +? + +I did make a test index as you described on my test box and tried the query +and it used the new index. However, ORDER BY forum_id then last_post_time i= +s +simply not the intended sorting order. (Though I'm considering just +SELECTing the topic_last_post_time field and resorting the results in the +script if this is the only workaround). + +- Adam + +On 2/18/06, Tom Lane wrote: +> +> Adam Alkins writes: +> > SELECT t.topic_id +> > FROM phpbb_topics AS t +> > WHERE t.forum_id =3D 71 +> > AND t.topic_id NOT IN (205026, +> 29046, 144569, 59780, 187424, +> > 138635, 184973, 170551, 22419, 181690, 197254, 205130) +> > ORDER BY +> t.topic_last_post_time DESC +> > LIMIT 23 OFFSET 0 +> +> If you're using 8.1, you'd probably find that an index on (forum_id, +> topic_last_post_time) would work nicely for this. You could use it +> in prior versions too, but you'd have to spell the ORDER BY rather +> strangely: +> ORDER BY forum_id desc, topic_last_post_time desc +> The reason for this trickery is to get the planner to realize that +> the index order matches the ORDER BY ... +> +> regards, tom lane +> + + + +-- +Adam Alkins +http://www.rasadam.com +Mobile: 868-680-4612 + +------=_Part_4040_12034139.1140247740907 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Unfortunately I'm using 8.0.4 and this is for a government website, I only = +get so many maintenance windows. Is this the only workaround for this issue= +?

I did make a test index as you described on my test box and tried = +the query and it used the new index. However, ORDER BY forum_id then last_p= +ost_time is simply not the intended sorting order. (Though I'm considering = +just SELECTing the topic_last_post_time field and resorting the results in = +the script if this is the only workaround). +

- Adam

On 2/18/06, Tom Lane <tgl@sss.pgh.pa.us> wrote:
+Adam Alkins <adam.alkins@gmail.= +com> writes:
> SELECT t.topic_id
>   &nbs= +p;            &= +nbsp;      FROM phpbb_topics AS t
> &nb= +sp;            = +            &nb= +sp;    WHERE t.forum_id + =3D 71
>          = +            &nb= +sp;            = +    AND t.topic_id NOT IN (205026, 29046, 144569, 59780, 187= +424,
> 138635, 184973, 170551, 22419, 181690, 197254, 205130)
>= +            &nb= +sp;            = +            &nb= +sp;         ORDER BY=20 +t.topic_last_post_time DESC
>      &nbs= +p;            &= +nbsp;           &nbs= +p;            &= +nbsp;          LIMIT 23 OFFSET= + 0

If you're using 8.1, you'd probably find that an index on (forum_= +id,
topic_last_post_time) would work nicely for this.  You cou= +ld use it +
in prior versions too, but you'd have to spell the ORDER BY rather
s= +trangely:
        ORDER BY forum= +_id desc, topic_last_post_time desc
The reason for this trickery is to g= +et the planner to realize that
the index order matches the ORDER BY ... +

           &= +nbsp;           &nbs= +p;regards, tom lane



--
= +Adam Alkins
http://www.rasadam.com
Mobile: 868-680-4612 + +------=_Part_4040_12034139.1140247740907-- + +From pgsql-performance-owner@postgresql.org Sat Feb 18 03:39:21 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id F1BFB9DC806 + for ; + Sat, 18 Feb 2006 03:39:20 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 88278-01 + for ; + Sat, 18 Feb 2006 03:39:21 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.207]) + by postgresql.org (Postfix) with ESMTP id 9CD339DCA46 + for ; + Sat, 18 Feb 2006 03:39:18 -0400 (AST) +Received: by zproxy.gmail.com with SMTP id m7so592515nzf + for ; + Fri, 17 Feb 2006 23:39:19 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; + b=QH159+zK8o/Ygs/RbN8rsDV3Ft8rlSNTnZh1KSuKRx20HTyL5iLG+OgKehy+gFsNuoqb/Y6YbO9XitZVWVJTyVZ+7CFSRW2eu0YMXaZ4RBmrNWZYDihI7PRFUTwMBli2SRLVwAcw80iD+L2MvYVMmrjGgQvorOm/4+W3sv75ipk= +Received: by 10.65.224.6 with SMTP id b6mr1509516qbr; + Fri, 17 Feb 2006 23:39:19 -0800 (PST) +Received: by 10.65.225.2 with HTTP; Fri, 17 Feb 2006 23:39:19 -0800 (PST) +Message-ID: +Date: Sat, 18 Feb 2006 03:39:19 -0400 +From: "Adam Alkins" +To: "Tom Lane" +Subject: Re: Index Choice Problem +Cc: pgsql-performance@postgresql.org +In-Reply-To: +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_4068_23512812.1140248359447" +References: + <15893.1140241984@sss.pgh.pa.us> + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.137 required=5 tests=[AWL=0.136, + HTML_MESSAGE=0.001] +X-Spam-Score: 0.137 +X-Spam-Level: +X-Archive-Number: 200602/306 +X-Sequence-Number: 17292 + +------=_Part_4068_23512812.1140248359447 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Nevermind the reply, blonde moment on the ordering... + +This works :) + +Thanks + +On 2/18/06, Adam Alkins wrote: +> +> Unfortunately I'm using 8.0.4 and this is for a government website, I onl= +y +> get so many maintenance windows. Is this the only workaround for this iss= +ue? +> +> I did make a test index as you described on my test box and tried the +> query and it used the new index. However, ORDER BY forum_id then +> last_post_time is simply not the intended sorting order. (Though I'm +> considering just SELECTing the topic_last_post_time field and resorting t= +he +> results in the script if this is the only workaround). +> +> - Adam +> +> On 2/18/06, Tom Lane wrote: +> > +> > Adam Alkins writes: +> > > SELECT t.topic_id +> > > FROM phpbb_topics AS t +> > > WHERE t.forum_id =3D 71 +> > > AND t.topic_id NOT IN (205026, +> > 29046, 144569, 59780, 187424, +> > > 138635, 184973, 170551, 22419, 181690, 197254, 205130) +> > > ORDER BY +> > t.topic_last_post_time DESC +> > > LIMIT 23 OFFSET +> > 0 +> > +> > If you're using 8.1, you'd probably find that an index on (forum_id, +> > topic_last_post_time) would work nicely for this. You could use it +> > in prior versions too, but you'd have to spell the ORDER BY rather +> > strangely: +> > ORDER BY forum_id desc, topic_last_post_time desc +> > The reason for this trickery is to get the planner to realize that +> > the index order matches the ORDER BY ... +> > +> > regards, tom lane +> > +> +> +> +> -- +> Adam Alkins +> http://www.rasadam.com +> Mobile: 868-680-4612 +> + + + +-- +Adam Alkins +http://www.rasadam.com +Mobile: 868-680-4612 + +------=_Part_4068_23512812.1140248359447 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Nevermind the reply, blonde moment on the ordering...

This works :)<= +br>
Thanks

On 2/18/06, Adam Alkins < +adam.alkins@gmail.com> wrote:
Unfortunately I'm using 8.0.4 and this is for a g= +overnment website, I only get so many maintenance windows. Is this the only= + workaround for this issue? +

I did make a test index as you described on my test box and tried t= +he query and it used the new index. However, ORDER BY forum_id then last_po= +st_time is simply not the intended sorting order. (Though I'm considering j= +ust SELECTing the topic_last_post_time field and resorting the results in t= +he script if this is the only workaround). +

- Adam


On 2/18/06, Tom Lane < +tgl@sss.pgh.pa.us> wrote:
+Adam Alkins <adam.alkins@gmail.= +com> writes:
> SELECT t.topic_id
>   &nbs= +p;            &= +nbsp;      FROM phpbb_topics AS t +
>           &= +nbsp;           &nbs= +p;       WHERE t.forum_id + =3D 71
>          = +            &nb= +sp;            = +    AND t.topic_id NOT IN (205026, 29046, 144569, 59780, 187= +424,
> 138635, 184973, 170551, 22419, 181690, 197254, 205130)
>= +            &nb= +sp;            = +            &nb= +sp;         ORDER BY=20 +t.topic_last_post_time DESC
>      &nbs= +p;            &= +nbsp;           &nbs= +p;            &= +nbsp;          LIMIT 23 OFFSET= + 0

If you're using 8.1, you'd probably find that an index on (forum_= +id,
topic_last_post_time) would work nicely for this.  You cou= +ld use it +
in prior versions too, but you'd have to spell the ORDER BY rather
s= +trangely:
        ORDER BY forum= +_id desc, topic_last_post_time desc
The reason for this trickery is to g= +et the planner to realize that
the index order matches the ORDER BY ... +

           &= +nbsp;           &nbs= +p;regards, tom lane



= +
--

Adam Alkins= +
+http://www.rasadam.com
Mobile: 868-680-4612 + +



--
Adam Alkin= +s
http://www.rasadam.com
Mobil= +e: 868-680-4612 + +------=_Part_4068_23512812.1140248359447-- + +From pgsql-performance-owner@postgresql.org Sat Feb 18 12:04:45 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id D3D3A9DC84A + for ; + Sat, 18 Feb 2006 12:04:44 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 85819-06 + for ; + Sat, 18 Feb 2006 12:04:42 -0400 (AST) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 529799DC813 + for ; + Sat, 18 Feb 2006 12:04:41 -0400 (AST) +Received: from localhost.localdomain (unknown [80.73.176.164]) + by svr4.postgresql.org (Postfix) with ESMTP id CC3905AF0A6 + for ; + Sat, 18 Feb 2006 16:04:40 +0000 (GMT) +Received: from localhost ([127.0.0.1] helo=[192.168.1.4]) + by localhost.localdomain with esmtp (Exim 4.50) id 1FAUXG-0005Mu-6c + for pgsql-performance@postgresql.org; Sat, 18 Feb 2006 17:02:14 +0100 +Message-ID: <43F74592.7010701@treyst.se> +Date: Sat, 18 Feb 2006 17:04:34 +0100 +From: Fredrik Olsson +User-Agent: Thunderbird 1.5 (Macintosh/20051201) +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Force another plan. +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, score=0.08 required=5 tests=[AWL=0.080] +X-Spam-Score: 0.08 +X-Spam-Level: +X-Archive-Number: 200602/307 +X-Sequence-Number: 17293 + +I have some quite huge queries, inside functions, so debugging is kind +of hard. But I have located the query that for some reason gets 4 times +as slow after an analyze. + +Before analyze the plan for the query is this: +Nested Loop (cost=16.80..34.33 rows=1 width=28) + Join Filter: (ischildof(2, "outer".calendar) OR (hashed subplan)) + -> Nested Loop (cost=0.00..11.66 rows=1 width=32) + -> Index Scan using t_events_eventype on t_events e +(cost=0.00..5.82 rows=1 width=28) + Index Cond: (eventtype = 1) + Filter: (rrfreq IS NOT NULL) + -> Index Scan using t_entities_pkey on t_entities te +(cost=0.00..5.83 rows=1 width=4) + Index Cond: (te."ID" = "outer".entity) + Filter: (partof = 'events'::name) + -> Index Scan using t_entities_pkey on t_entities (cost=0.00..5.85 +rows=1 width=4) + Index Cond: (t_entities."ID" = "outer".entity) + Filter: ((haveaccess(createdby, responsible, "class", false) OR +CASE WHEN (partof = 'contacts'::name) THEN ischildof(ancestorof(me()), +"ID") ELSE false END) AND (subplan)) + SubPlan + -> Function Scan on alleventoccurances (cost=0.00..12.50 +rows=1000 width=8) + SubPlan + -> Seq Scan on t_attendees (cost=0.00..16.38 rows=170 width=4) + Filter: ischildof(2, contact) + +In reality this takes approximately 1.0s in the general case. After an +analyze the plan becomes: + +Nested Loop (cost=2.09..4.82 rows=1 width=28) + Join Filter: ("inner"."ID" = "outer"."ID") + -> Hash Join (cost=2.09..3.59 rows=1 width=32) + Hash Cond: ("outer"."ID" = "inner".entity) + Join Filter: (ischildof(2, "inner".calendar) OR (hashed subplan)) + -> Seq Scan on t_entities (cost=0.00..1.46 rows=6 width=4) + Filter: ((haveaccess(createdby, responsible, "class", +false) OR CASE WHEN (partof = 'contacts'::name) THEN +ischildof(ancestorof(me()), "ID") ELSE false END) AND (subplan)) + SubPlan + -> Function Scan on alleventoccurances +(cost=0.00..12.50 rows=1000 width=8) + -> Hash (cost=1.06..1.06 rows=2 width=28) + -> Seq Scan on t_events e (cost=0.00..1.06 rows=2 width=28) + Filter: ((rrfreq IS NOT NULL) AND (eventtype = 1)) + SubPlan + -> Seq Scan on t_attendees (cost=0.00..1.02 rows=1 width=4) + Filter: ischildof(2, contact) + -> Seq Scan on t_entities te (cost=0.00..1.16 rows=5 width=4) + Filter: (partof = 'events'::name) + +This takes on approximately 4.5s. So obviously it has degraded. + +I count myself as a newbie here, so any hints on what goes on, why a +plan might be chosen, and how I can make is better is appreciated. +Naturally the I can provide scripts to set up all or parts of the +database if anyone like. + +regards + +-- +//Fredrik Olsson + Treyst AB + +46-(0)19-362182 + fredrik.olsson@treyst.se + + +From pgsql-hackers-owner@postgresql.org Sat Feb 18 13:01:22 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 04E049DCA1A; + Sat, 18 Feb 2006 13:01:21 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 95120-09; Sat, 18 Feb 2006 13:01:19 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smtpauth08.mail.atl.earthlink.net + (smtpauth08.mail.atl.earthlink.net [209.86.89.68]) + by postgresql.org (Postfix) with ESMTP id 0F2649DC84A; + Sat, 18 Feb 2006 13:01:17 -0400 (AST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=hTf+vH75Kot6Usr1eDoY9LSWpea7wh7iMc1Tz0kSBjOqZQYa2CvU2hAqzNZyz/9s; + 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 [71.243.43.186] (helo=ron-6d52adff2a6.earthlink.net) + by smtpauth08.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1FAVSO-0007Cw-HO; Sat, 18 Feb 2006 12:01:16 -0500 +Message-Id: <7.0.1.0.2.20060218112647.0397ce48@earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 7.0.1.0 +Date: Sat, 18 Feb 2006 12:01:10 -0500 +To: "Dann Corbit" ,, + +From: Ron +Subject: Re: qsort again (was Re: [PERFORM] Strange Create +In-Reply-To: +References: + +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bca6b7ceb2ca5ee59e611577ab5598d8b8350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 71.243.43.186 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.472 required=5 tests=[AWL=-0.007, + DNS_FROM_RFC_ABUSE=0.479] +X-Spam-Score: 0.472 +X-Spam-Level: +X-Archive-Number: 200602/702 +X-Sequence-Number: 79840 + +At 08:37 PM 2/15/2006, Dann Corbit wrote: + +>Adding some randomness to the selection of the pivot is a known +>technique to fix the oddball partitions problem. + +True, but it makes QuickSort slower than say MergeSort because of the +expense of the PRNG being called ~O(lgN) times during a sort. + + +>However, Bentley and Sedgewick proved that every quick sort +>algorithm has some input set that makes it go quadratic + +Yep. OTOH, that input set can be so specific and so unusual as to +require astronomically unlikely bad luck or hostile hacking in order +for it to actually occur. + + +> (hence the recent popularity of introspective sort, which switches +> to heapsort if quadratic behavior is detected. The C++ template I +> submitted was an example of introspective sort, but PostgreSQL does +> not use C++ so it was not helpful). +...and there are other QuickSort+Other hybrids that address the issue +as well. MergeSort, RadixExchangeSort, and BucketSort all come to +mind. See Gonnet and Baeza-Yates, etc. + + +>Here are some cases known to make qsort go quadratic: +>1. Data already sorted + +Only if one element is used to choose the pivot; _and_ only if the +pivot is the first or last element of each pass. +Even just always using the middle element as the pivot avoids this +problem. See Sedgewick or Knuth. + + +>2. Data reverse sorted + +Ditto above. + + +>3. Data organ-pipe sorted or ramp + +Not sure what this means? Regardless, median of n partitioning that +includes samples from each of the 1st 1/3, 2nd 1/3, and final 3rd of +the data is usually enough to guarantee O(NlgN) behavior unless the +_specific_ distribution known to be pessimal to that sampling +algorithm is encountered. The only times I've ever seen it ITRW was +as a result of hostile activity: purposely arranging the data in such +a manner is essentially a DoS attack. + + +>4. Almost all data of the same value + +Well known fixes to inner loop available to avoid this problem. + + +>There are probably other cases. Randomizing the pivot helps some, +>as does check for in-order or reverse order partitions. +Randomizing the choice of pivot essentially guarantees O(NlgN) +behavior no matter what the distribution of the data at the price of +increasing the cost of each pass by a constant factor (the generation +of a random number or numbers). + + +In sum, QuickSort gets all sorts of bad press that is far more FUD +than fact ITRW. +Ron. + + + +From pgsql-performance-owner@postgresql.org Sat Feb 18 14:36:54 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 028F39DC841 + for ; + Sat, 18 Feb 2006 14:36:53 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 86868-09 + for ; + Sat, 18 Feb 2006 14:36:53 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 5418E9DC99B + for ; + Sat, 18 Feb 2006 14:36:51 -0400 (AST) +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 k1IIaprc020491; + Sat, 18 Feb 2006 13:36:51 -0500 (EST) +To: Fredrik Olsson +cc: pgsql-performance@postgresql.org +Subject: Re: Force another plan. +In-reply-to: <43F74592.7010701@treyst.se> +References: <43F74592.7010701@treyst.se> +Comments: In-reply-to Fredrik Olsson + message dated "Sat, 18 Feb 2006 17:04:34 +0100" +Date: Sat, 18 Feb 2006 13:36:51 -0500 +Message-ID: <20490.1140287811@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.11 required=5 tests=[AWL=0.110] +X-Spam-Score: 0.11 +X-Spam-Level: +X-Archive-Number: 200602/309 +X-Sequence-Number: 17295 + +Fredrik Olsson writes: +> I have some quite huge queries, inside functions, so debugging is kind +> of hard. But I have located the query that for some reason gets 4 times +> as slow after an analyze. + +Could we see EXPLAIN ANALYZE output for these cases, not just EXPLAIN? +It seems a bit premature to be discussing ways to "force" a plan choice +when you don't even have a clear idea what's going wrong. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Feb 19 08:39:02 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id B27DB9DC817 + for ; + Sun, 19 Feb 2006 08:39:01 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 16738-09 + for ; + Sun, 19 Feb 2006 08:39:04 -0400 (AST) +X-Greylist: delayed 20:34:24.025661 by SQLgrey- +Received: from localhost.localdomain (unknown [80.73.176.164]) + by postgresql.org (Postfix) with ESMTP id 1F63D9DC812 + for ; + Sun, 19 Feb 2006 08:38:58 -0400 (AST) +Received: from localhost ([127.0.0.1] helo=[192.168.1.4]) + by localhost.localdomain with esmtp (Exim 4.50) id 1FAnnp-0001ez-Ju + for pgsql-performance@postgresql.org; Sun, 19 Feb 2006 13:36:37 +0100 +Message-ID: <43F866E2.20001@treyst.se> +Date: Sun, 19 Feb 2006 13:38:58 +0100 +From: Fredrik Olsson +User-Agent: Thunderbird 1.5 (Macintosh/20051201) +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Force another plan. +References: <43F74592.7010701@treyst.se> <20490.1140287811@sss.pgh.pa.us> +In-Reply-To: <20490.1140287811@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, score=0.096 required=5 tests=[AWL=0.096] +X-Spam-Score: 0.096 +X-Spam-Level: +X-Archive-Number: 200602/310 +X-Sequence-Number: 17296 + +Tom Lane skrev: +> Fredrik Olsson writes: +> +>> I have some quite huge queries, inside functions, so debugging is kind +>> of hard. But I have located the query that for some reason gets 4 times +>> as slow after an analyze. +>> +> +> Could we see EXPLAIN ANALYZE output for these cases, not just EXPLAIN? +> It seems a bit premature to be discussing ways to "force" a plan choice +> when you don't even have a clear idea what's going wrong. +> +Sorry about that, my fault. Here comes EXPLAIN ANALYZE: + +Before VACUUM ANALYZE: +=== +Nested Loop (cost=16.80..34.33 rows=1 width=28) (actual +time=54.197..98.598 rows=1 loops=1) + Join Filter: (ischildof(2, "outer".calendar) OR (hashed subplan)) + -> Nested Loop (cost=0.00..11.66 rows=1 width=32) (actual +time=0.307..0.458 rows=3 loops=1) + -> Index Scan using t_events_eventype on t_events e +(cost=0.00..5.82 rows=1 width=28) (actual time=0.241..0.307 rows=3 loops=1) + Index Cond: (eventtype = 1) + Filter: (rrfreq IS NOT NULL) + -> Index Scan using t_entities_pkey on t_entities te +(cost=0.00..5.83 rows=1 width=4) (actual time=0.035..0.039 rows=1 loops=3) + Index Cond: (te."ID" = "outer".entity) + Filter: (partof = 'events'::name) + -> Index Scan using t_entities_pkey on t_entities (cost=0.00..5.85 +rows=1 width=4) (actual time=28.445..28.447 rows=0 loops=3) + Index Cond: (t_entities."ID" = "outer".entity) + Filter: ((haveaccess(createdby, responsible, "class", false) OR +CASE WHEN (partof = 'contacts'::name) THEN ischildof(ancestorof(me()), +"ID") ELSE false END) AND (subplan)) + SubPlan + -> Function Scan on alleventoccurances (cost=0.00..12.50 +rows=1000 width=8) (actual time=19.745..19.745 rows=0 loops=3) + SubPlan + -> Seq Scan on t_attendees (cost=0.00..16.38 rows=170 width=4) +(actual time=0.422..0.447 rows=2 loops=1) + Filter: ischildof(2, contact) +Total runtime: 99.814 ms + +After VACUUM ANALYZE: +=== +Nested Loop (cost=2.11..4.92 rows=1 width=28) (actual +time=434.321..439.102 rows=1 loops=1) + Join Filter: ("inner"."ID" = "outer"."ID") + -> Hash Join (cost=2.11..3.67 rows=1 width=32) (actual +time=434.001..438.775 rows=1 loops=1) + Hash Cond: ("outer"."ID" = "inner".entity) + Join Filter: (ischildof(2, "inner".calendar) OR (hashed subplan)) + -> Seq Scan on t_entities (cost=0.00..1.49 rows=7 width=4) +(actual time=404.539..409.302 rows=2 loops=1) + Filter: ((haveaccess(createdby, responsible, "class", +false) OR CASE WHEN (partof = 'contacts'::name) THEN +ischildof(ancestorof(me()), "ID") ELSE false END) AND (subplan)) + SubPlan + -> Function Scan on alleventoccurances +(cost=0.00..12.50 rows=1000 width=8) (actual time=27.871..27.871 rows=0 +loops=14) + -> Hash (cost=1.07..1.07 rows=3 width=28) (actual +time=0.063..0.063 rows=3 loops=1) + -> Seq Scan on t_events e (cost=0.00..1.07 rows=3 +width=28) (actual time=0.023..0.034 rows=3 loops=1) + Filter: ((rrfreq IS NOT NULL) AND (eventtype = 1)) + SubPlan + -> Seq Scan on t_attendees (cost=0.00..1.02 rows=1 width=4) +(actual time=0.205..0.228 rows=2 loops=1) + Filter: ischildof(2, contact) + -> Seq Scan on t_entities te (cost=0.00..1.18 rows=6 width=4) +(actual time=0.029..0.045 rows=6 loops=1) + Filter: (partof = 'events'::name) +Total runtime: 440.385 ms + +As I read it, the villain is the sequential sqan on t_entities with the +huge filter; haveacces() ... +And that is understandable, doing haveaccess() on all rows is not good. +A much better solution in this case would be to first get the set that +conforms to (partof = 'events'::name), that would reduce the set to a +third. Secondly applying (eventtype=1) would reduce that to half. Then +it is time to do the (haveaccess() ...). + +Perhaps a small explanation of the tables, and their intent is in order. + +What I have is one "master table" with entities (t_entitites), and two +child tables t_contacts and t_events. In a perfect world rt_contacts and +t_events would have inherited from t_entities as they share muuch data, +but then I would not be able to have foreign key referencing just +events, or just contacts. So instead every row in events and contacts +have a corresponding one to one row in entities. The fourth table used +in this query is t_attendees, that links well attendees for an event to +contacts. Here goes a simplified example (SQL says more then 1000 words): + +CREATE TABLE t_entities ( + "ID" integer PRIMARY KEY, + "createdby" integer NOT NULL, + "class" integer NOT NULL, -- Defines visibility for entity and is +used by haveaccess() + "partof" name NOT NULL +); + +CREATE TABLE t_contacts ( + "entity" integer PRIMARY KEY REFERENCES t_entities ("ID"), + "undercontact" integer REFERENCES t_contacts ("entity"), -- Tree +structure, used by haveaccess() + "name" varchar(48) +); + +ALTER TABLE t_entities ADD FOREIGN KEY ("createdby") + REFERENCES t_contacts ("entity"); + +CREATE TABLE t_events ( + "entity" integer PRIMARY KEY REFERENCES t_entities ("ID"), + "calendar" integer NOT NULL REFERENCES t_entities ("ID"), + "eventtype" integer NOT NULL, + "start" timestamptz, + "end" timestamptz +); + +CREATE TABLE t_attendees ( + "event" integer NOT NULL REFERENCES t_events ("entity"), + "contact" integer NOT NULL REFERENCES t_contacts ("entity"), + PRIMARY KEY ("event", "contact") +); + +No user have privileges to select, update or delete in any of these +tables. They are instead accessed with views that are made updatable +using rules. These rules uses the function haveaccess() to sort out the +rows that each user is allowed to see. Users are also contacts in the +t_contacts table. + +Well the complete database, with a shell script for setting it up can as +I said be provided if wanted. + +-- +//Fredrik Olsson + Treyst AB + +46-(0)19-362182 + fredrik.olsson@treyst.se + + + +From pgsql-performance-owner@postgresql.org Sun Feb 19 10:05:00 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 2586B9DC87B + for ; + Sun, 19 Feb 2006 10:04:59 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 47164-04 + for ; + Sun, 19 Feb 2006 10:05:02 -0400 (AST) +X-Greylist: delayed 00:06:40.761083 by SQLgrey- +Received: from mail.baymountain.com (mail.baymountain.com [8.7.96.19]) + by postgresql.org (Postfix) with SMTP id 8CD879DC820 + for ; + Sun, 19 Feb 2006 10:04:55 -0400 (AST) +Received: (qmail 392 invoked by uid 504); 19 Feb 2006 13:58:18 -0000 +Received: from emil@baymountain.com by mail.baymountain.com by uid 501 with + qmail-scanner-1.16 (spamassassin: 2.53. Clear:SA:0(0.2/7.0):. + Processed in 0.355396 secs); 19 Feb 2006 13:58:18 -0000 +Received: from unknown (HELO briggspack.com) + (emil@briggspack.com@24.211.148.77) + by mail.baymountain.com with SMTP; 19 Feb 2006 13:58:18 -0000 +From: Emil Briggs +Reply-To: emil@baymountain.com +Organization: Baymountain, Inc. +To: pgsql-performance@postgresql.org +Subject: Question about query planner +Date: Sun, 19 Feb 2006 08:58:12 -0500 +User-Agent: KMail/1.7.1 +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +Message-Id: <200602190858.13081.emil@baymountain.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200602/311 +X-Sequence-Number: 17297 + + + +The following query runs much slower than I would have expected. I ran it +through EXPLAIN ANALYZE (results included after) and I don't understand why +the planner is doing what it is. All of the columns from the WHERE part of +the query are indexed and the indexes are being used. The number of rows +being reported is equal to the size of the table though so it's really no +better than just doing a sequential scan. This is running on Postgres 8.0.7 +and the system has been freshly vaccumed with the statistics target set to +800. Does any know why the query behaves like this? Does it have anything to +do with the OR statements in the where clause spanning two different tables? +I tried an experiment where I split this into queries two queries using UNION +and it ran in less than 1 ms. Which is a solution but I'm still curious why +the original was so slow. + + +SELECT DISTINCT a.account_id, l.username, a.status, a.company, a.fax_num, +a.primary_phone, a.responsible_first, a.responsible_last FROM + accounts a, logins l, supplemental_info i + WHERE l.account_id=a.account_id and + i.account_id=a.account_id and + ((a.primary_phone = 'xxx-xxx-xxxx') OR (a.alternate_phone = 'xxx-xxx-xxxx') +OR (i.contact_num = 'xxx-xxx-xxxx')) + ORDER BY a.status, a.primary_phone, a.account_id; + + +EXPLAIN ANALYZE results + + Unique (cost=47837.93..47838.02 rows=4 width=92) (actual +time=850.250..850.252 rows=1 loops=1) + -> Sort (cost=47837.93..47837.94 rows=4 width=92) (actual +time=850.248..850.248 rows=1 loops=1) + Sort Key: a.status, a.primary_phone, a.account_id, l.username, +a.company, a.fax_num, a.responsible_first, a.responsible_last + -> Nested Loop (cost=0.00..47837.89 rows=4 width=92) (actual +time=610.641..850.222 rows=1 loops=1) + -> Merge Join (cost=0.00..47818.70 rows=4 width=88) (actual +time=610.602..850.179 rows=1 loops=1) + Merge Cond: ("outer".account_id = "inner".account_id) + Join Filter: ((("outer".primary_phone)::text = +'xxx-xxx-xxxx'::text) OR (("outer".alternate_phone)::text = +'xxx-xxx-xxxx'::text) OR (("inner".contact_num)::text = +'xxx-xxx-xxxx'::text)) + -> Index Scan using accounts_pkey on accounts a +(cost=0.00..18423.73 rows=124781 width=95) (actual time=0.019..173.523 +rows=124783 loops=1) + -> Index Scan using supplemental_info_account_id_idx on +supplemental_info i (cost=0.00..15393.35 rows=124562 width=24) (actual +time=0.014..145.757 rows=124643 loops=1) + -> Index Scan using logins_account_id_idx on logins l +(cost=0.00..4.59 rows=2 width=20) (actual time=0.022..0.023rows=1 loops=1) + Index Cond: ("outer".account_id = l.account_id) + Total runtime: 850.429 ms + + +From pgsql-performance-owner@postgresql.org Sun Feb 19 13:31:21 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id E99849DCB53 + for ; + Sun, 19 Feb 2006 13:31:20 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 21240-04 + for ; + Sun, 19 Feb 2006 13:31:19 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id B5F0F9DCB69 + for ; + Sun, 19 Feb 2006 13:31:18 -0400 (AST) +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 k1JHVHTS011674; + Sun, 19 Feb 2006 12:31:18 -0500 (EST) +To: Fredrik Olsson +cc: pgsql-performance@postgresql.org +Subject: Re: Force another plan. +In-reply-to: <43F866E2.20001@treyst.se> +References: <43F74592.7010701@treyst.se> <20490.1140287811@sss.pgh.pa.us> + <43F866E2.20001@treyst.se> +Comments: In-reply-to Fredrik Olsson + message dated "Sun, 19 Feb 2006 13:38:58 +0100" +Date: Sun, 19 Feb 2006 12:31:17 -0500 +Message-ID: <11673.1140370277@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.11 required=5 tests=[AWL=0.110] +X-Spam-Score: 0.11 +X-Spam-Level: +X-Archive-Number: 200602/312 +X-Sequence-Number: 17298 + +Fredrik Olsson writes: +> -> Seq Scan on t_entities (cost=0.00..1.49 rows=7 width=4) +> (actual time=404.539..409.302 rows=2 loops=1) +> Filter: ((haveaccess(createdby, responsible, "class", +> false) OR CASE WHEN (partof = 'contacts'::name) THEN +> ischildof(ancestorof(me()), "ID") ELSE false END) AND (subplan)) +> SubPlan +> -> Function Scan on alleventoccurances +> (cost=0.00..12.50 rows=1000 width=8) (actual time=27.871..27.871 rows=0 +> loops=14) + +This seems to be your problem right here: evaluating that subplan for +each row of t_entities is pretty expensive, and yet the planner's +estimating a total cost of only 1.49 to run the scan. What PG version +is this? AFAICT we've accounted for subplan costs in scan quals for +a long time, certainly since 7.4. Can you put together a self-contained +test case for this? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Feb 19 14:15:13 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 8DE079DC814 + for ; + Sun, 19 Feb 2006 14:15:12 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34287-05 + for ; + Sun, 19 Feb 2006 14:15:11 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 2455B9DC842 + for ; + Sun, 19 Feb 2006 14:15:08 -0400 (AST) +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 k1JIF75W011960; + Sun, 19 Feb 2006 13:15:07 -0500 (EST) +To: emil@baymountain.com +cc: pgsql-performance@postgresql.org +Subject: Re: Question about query planner +In-reply-to: <200602190858.13081.emil@baymountain.com> +References: <200602190858.13081.emil@baymountain.com> +Comments: In-reply-to Emil Briggs + message dated "Sun, 19 Feb 2006 08:58:12 -0500" +Date: Sun, 19 Feb 2006 13:15:07 -0500 +Message-ID: <11959.1140372907@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.11 required=5 tests=[AWL=0.110] +X-Spam-Score: 0.11 +X-Spam-Level: +X-Archive-Number: 200602/313 +X-Sequence-Number: 17299 + +Emil Briggs writes: +> Does any know why the query behaves like this? Does it have anything to +> do with the OR statements in the where clause spanning two different tables? + +Exactly. + +> SELECT DISTINCT a.account_id, l.username, a.status, a.company, a.fax_num, +> a.primary_phone, a.responsible_first, a.responsible_last FROM +> accounts a, logins l, supplemental_info i +> WHERE l.account_id=a.account_id and +> i.account_id=a.account_id and +> ((a.primary_phone = 'xxx-xxx-xxxx') OR (a.alternate_phone = 'xxx-xxx-xxxx') +> OR (i.contact_num = 'xxx-xxx-xxxx')) +> ORDER BY a.status, a.primary_phone, a.account_id; + +The system has to fetch all the rows of a, because any of them might +join to a row of i matching the i.contact_num condition, and conversely +it has to fetch every row of i because any of them might join to a row +of a matching one of the phone conditions. It is therefore necessary +to effectively form the entire join of a and i; until you've done that +there is no way to eliminate any rows. + +I'm a bit surprised that it's using the indexes at all --- a hash join +with seqscan inputs would probably run faster. Try increasing work_mem +a bit. + + regards, tom lane + +From pgsql-hackers-owner@postgresql.org Sun Feb 19 22:02:27 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 7275D9DCA42; + Sun, 19 Feb 2006 22:02:26 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 51974-09; Sun, 19 Feb 2006 22:02:30 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from houston.familyhealth.com.au (houston.au.fhnetwork.com + [203.22.197.21]) + by postgresql.org (Postfix) with ESMTP id 1C1FE9DCA41; + Sun, 19 Feb 2006 22:02:23 -0400 (AST) +Received: from houston.familyhealth.com.au (localhost [127.0.0.1]) + by houston.familyhealth.com.au (Postfix) with ESMTP id 005BE25089; + Mon, 20 Feb 2006 10:02:26 +0800 (WST) +Received: from [127.0.0.1] (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (Postfix) with ESMTP id 682E825084; + Mon, 20 Feb 2006 10:02:24 +0800 (WST) +Message-ID: <43F9232F.4040005@familyhealth.com.au> +Date: Mon, 20 Feb 2006 10:02:23 +0800 +From: Christopher Kings-Lynne +User-Agent: Thunderbird 1.5 (Windows/20051201) +MIME-Version: 1.0 +To: Ron +Cc: pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Need pointers to "standard" pg database(s) for testing +References: <7.0.1.0.2.20060217114924.0390b890@earthlink.net> +In-Reply-To: <7.0.1.0.2.20060217114924.0390b890@earthlink.net> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-familyhealth-MailScanner-Information: Please contact the ISP for more + information +X-familyhealth-MailScanner: Found to be clean +X-familyhealth-MailScanner-From: chriskl@familyhealth.com.au +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.094 required=5 tests=[AWL=0.094] +X-Spam-Score: 0.094 +X-Spam-Level: +X-Archive-Number: 200602/806 +X-Sequence-Number: 79944 + +Not really, but you can check out the sample databases project: + +http://pgfoundry.org/projects/dbsamples/ + +Chris + +Ron wrote: +> I assume we have such? +> +> Ron +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 5: don't forget to increase your free space map settings + + +From pgsql-performance-owner@postgresql.org Mon Feb 20 00:06:20 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id E68B39DC951 + for ; + Mon, 20 Feb 2006 00:06:19 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 84466-03 + for ; + Mon, 20 Feb 2006 00:06:17 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from pillette.com (adsl-67-119-5-202.dsl.snfc21.pacbell.net + [67.119.5.202]) by postgresql.org (Postfix) with ESMTP id D86C99DC84A + for ; + Mon, 20 Feb 2006 00:06:16 -0400 (AST) +Received: (from andrew@localhost) + by pillette.com (8.11.6/8.11.6) id k1K46CB09448; + Sun, 19 Feb 2006 20:06:12 -0800 +Date: Sun, 19 Feb 2006 20:06:12 -0800 +From: andrew@pillette.com +Message-Id: <200602200406.k1K46CB09448@pillette.com> +Subject: How to optimize a JOIN with BETWEEN? +To: pgsql-performance@postgresql.org +Cc: +X-Originating-IP: 63.201.37.104 +X-Mailer: Webmin 0.940 +MIME-Version: 1.0 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.486 required=5 tests=[AWL=-0.064, + NO_REAL_NAME=0.55] +X-Spam-Score: 0.486 +X-Spam-Level: +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200602/315 +X-Sequence-Number: 17301 + +Here's a simplified version of the schema: + +Table A has an ID field, an observation date, and other stuff. There are about 20K IDs and 3K observations per ID. Table B has a matching ID field, minimum and maximum dates, a code, and other stuff, about 0-50 records per ID. For a given ID, the dates in B never overlap. On A, the PK is (id, obsdate). On B, the PK is (id, mindate). I want + +SELECT a.id, b.code, AVG(other stuff) FROM A LEFT JOIN B ON a.id=b.id AND a.obsdate BETWEEN b.mindate AND b.maxdate GROUP BY 1,2; + +Is there a way to smarten the query to take advantage of the fact at most one record of B matches A? Also, I have a choice between using a LEFT JOIN or inserting dummy records into B to fill in the gaps in the covered dates, which would make exactly one matching record. Would this make a difference? + +Thanks. + +From pgsql-hackers-owner@postgresql.org Mon Feb 20 00:47:46 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id CA0DA9DCAA9; + Mon, 20 Feb 2006 00:47:44 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91591-08; Mon, 20 Feb 2006 00:47:43 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from houston.familyhealth.com.au (houston.au.fhnetwork.com + [203.22.197.21]) + by postgresql.org (Postfix) with ESMTP id E14BA9DCAAF; + Mon, 20 Feb 2006 00:47:40 -0400 (AST) +Received: from houston.familyhealth.com.au (localhost [127.0.0.1]) + by houston.familyhealth.com.au (Postfix) with ESMTP id B1CCA25077; + Mon, 20 Feb 2006 12:47:39 +0800 (WST) +Received: from [127.0.0.1] (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (Postfix) with ESMTP id 092CB2506B; + Mon, 20 Feb 2006 12:47:38 +0800 (WST) +Message-ID: <43F949F4.8020607@familyhealth.com.au> +Date: Mon, 20 Feb 2006 12:47:48 +0800 +From: Christopher Kings-Lynne +User-Agent: Thunderbird 1.5 (Windows/20051201) +MIME-Version: 1.0 +To: Scott Marlowe +Cc: Ron , pgsql-hackers@postgresql.org, + pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Need pointers to "standard" pg database(s) for +References: <7.0.1.0.2.20060217114924.0390b890@earthlink.net> + <1140195390.22740.288.camel@state.g2switchworks.com> +In-Reply-To: <1140195390.22740.288.camel@state.g2switchworks.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-familyhealth-MailScanner-Information: Please contact the ISP for more + information +X-familyhealth-MailScanner: Found to be clean +X-familyhealth-MailScanner-From: chriskl@familyhealth.com.au +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.095 required=5 tests=[AWL=0.095] +X-Spam-Score: 0.095 +X-Spam-Level: +X-Archive-Number: 200602/815 +X-Sequence-Number: 79953 + +Relating to this. If anyone can find govt or other free db's and +convert them into pgsql format, I will host them on the dbsamples page. + The dbsamples are _really_ popular! + +Chris + +Scott Marlowe wrote: +> On Fri, 2006-02-17 at 10:51, Ron wrote: +>> I assume we have such? +> +> Depends on what you wanna do. +> For transactional systems, look at some of the stuff OSDL has done. +> +> For large geospatial type stuff, the government is a good source, like +> www.usgs.gov or the fcc transmitter database. +> +> There are other ones out there. Really depends on what you wanna test. +> +> ---------------------------(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 Mon Feb 20 02:42:42 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id DF1C59DCA2E + for ; + Mon, 20 Feb 2006 02:42:41 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 13954-05 + for ; + Mon, 20 Feb 2006 02:42:41 -0400 (AST) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 06AFF9DC99C + for ; + Mon, 20 Feb 2006 02:42:39 -0400 (AST) +Received: from mail.auptyma.com (64-60-124-12.cust.telepacific.net + [64.60.124.12]) + by svr4.postgresql.org (Postfix) with ESMTP id AAB975AF02D + for ; + Mon, 20 Feb 2006 06:42:39 +0000 (GMT) +Received: from demo1 (64-60-124-12.cust.telepacific.net [64.60.124.12]) + (authenticated bits=0) + by mail.auptyma.com (8.13.1/8.13.1) with ESMTP id k1K6Kl6Y012525 + (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO); + Sun, 19 Feb 2006 22:20:49 -0800 +Message-ID: <002c01c635e8$cfc225d0$3100000a@demo1> +From: "Virag Saksena" +To: "=?UTF-8?B?U3rFsWNzIEfDoWJvcg==?=" , + +References: <002b01c610e5$21cc7340$3100000a@demo1> + <43C28854.9000605@gmail.com> +Subject: Re: Avoiding cartesian product +Date: Sun, 19 Feb 2006 22:42:23 -0800 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0029_01C635A5.C01622F0" +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2600.0000 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 +X-Greylist: Sender succeded SMTP AUTH authentication, not delayed by + milter-greylist-1.7.5 (mail.auptyma.com [10.0.0.47]); + Sun, 19 Feb 2006 22:20:49 -0800 (PST) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.121 required=5 tests=[AWL=0.120, + HTML_MESSAGE=0.001] +X-Spam-Score: 0.121 +X-Spam-Level: +X-Archive-Number: 200602/317 +X-Sequence-Number: 17303 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0029_01C635A5.C01622F0 +Content-Type: text/plain; + charset="UTF-8" +Content-Transfer-Encoding: quoted-printable + +Sz=C5=B1cs, + Thanks for your suggestion, I guess there is more than one way to = +attack the problem. + +I ended up using a trick with limit to get the next row ... + +select (b.gc_minor- a.gc_minor), (b.gc_major- a.gc_major) +from jam_trace_sys a join jam_trace_sys b on +(b.seq_no =3D (select c.seq_no from jam_trace_sys c + where c.trace_id =3D a.trace_id and c.seq_no > a.seq_no + order by c.trace_id, c.seq_no limit 1) + and b.trace_id =3D a.trace_id), +jam_tracesnap s1, jam_tracesnap s2 +where s1.trace_id =3D a.trace_id +and s1.seq_no =3D a.seq_no +and s2.trace_id =3D b.trace_id +and s2.seq_no =3D b.seq_no +and a.trace_id =3D 22 +order by a.seq_no; + +This gave me a nice clean execution plan (there are some extra sources = +listed, but that is a bug in postgresql) ... + +QUERY PLAN +-------------------------------------------------------------------------= +-------------------------------------------------------------------------= +--------- +Sort (cost=3D11.24..11.25 rows=3D1 width=3D20) (actual = +time=3D0.040..0.040 rows=3D0 loops=3D1) + Sort Key: a.seq_no + ->Nested Loop (cost=3D0.00..11.23 rows=3D1 width=3D20) (actual = +time=3D0.028..0.028 rows=3D0 loops=3D1) + Join Filter: ("inner".seq_no =3D "outer".seq_no) + ->Nested Loop (cost=3D0.00..9.20 rows=3D1 width=3D32) (actual = +time=3D0.024..0.024 rows=3D0 loops=3D1) + Join Filter: ("inner".seq_no =3D "outer".seq_no) + ->Nested Loop (cost=3D0.00..7.17 rows=3D1 width=3D32) (actual = +time=3D0.020..0.020 rows=3D0 loops=3D1) + Join Filter: ("inner".seq_no =3D (subplan)) + ->Index Scan using jam_trace_sys_n1 on jam_trace_sys a = +(cost=3D0.00..3.41 rows=3D1 width=3D16) (actual time=3D0.016..0.016 = +rows=3D0 loops=3D1) + Index Cond: (trace_id =3D 22) + ->Index Scan using jam_trace_sys_n1 on jam_trace_sys b = +(cost=3D0.00..3.41 rows=3D1 width=3D16) (never executed) + Index Cond: (22 =3D trace_id) + SubPlan + ->Limit (cost=3D0.00..0.33 rows=3D1 width=3D8) (never = +executed) + ->Index Scan using jam_trace_sys_n1 on jam_trace_sys c = +(cost=3D0.00..6.36 rows=3D19 width=3D8) (never executed) + Index Cond: ((trace_id =3D $0) AND (seq_no > $1)) + ->Index Scan using jam_tracesnap_n1 on jam_tracesnap s1 = +(cost=3D0.00..2.01 rows=3D1 width=3D8) (never executed) + Index Cond: (22 =3D trace_id) + ->Index Scan using jam_tracesnap_n1 on jam_tracesnap s2 = +(cost=3D0.00..2.01 rows=3D1 width=3D8) (never executed) + Index Cond: (22 =3D trace_id) + +Regards, + +Virag + + +----- Original Message -----=20 +From: "Sz=C5=B1cs G=C3=A1bor" +To: +Sent: Monday, January 09, 2006 7:59 AM +Subject: Re: Avoiding cartesian product + + +> Dear Virag, +>=20 +> AFAIK aggregates aren't indexed in postgres (at least not before 8.1, = +which=20 +> indexes min and max, iirc). +>=20 +> Also, I don't think you need to exactly determine the trace_id. Try = +this one=20 +> (OTOH; might be wrong): +>=20 +> select DISTINCT ON (a.trace_id, a.seq_no) -- See below +> b.gc_minor - a.gc_minor, b.gc_major - a.gc_major +> from jam_trace_sys a, jam_trace_sys b +> where a.trace_id =3D 22 +> and b.trace_id =3D a.trace_id +> and b.seq_no > a.seq_no -- Simply ">" is enough +> order by a.trace_id, a.seq_no, b.seq_no; -- DISTINCT, see below +>=20 +> The trick is that DISTINCT takes the first one in each group (IIRC it = +is=20 +> granted, at least someone told me on one of these lists :) ) so if you = +order=20 +> by the DISTINCT attributes and then by b.seq_no, you'll get the = +smallest of=20 +> appropriate b.seq_no values for each DISTINCT values. +>=20 +> The idea of DISTINCTing by both columns is to make sure the planner = +finds=20 +> the index. (lately I had a similar problem: WHERE a=3D1 ORDER BY b = +LIMIT 1=20 +> used an index on b, instead of an (a,b) index. Using ORDER BY a,b = +solved it) +>=20 +> HTH, +>=20 +> -- +> G. +>=20 +>=20 +> On 2006.01.04. 5:12, Virag Saksena wrote: +> >=20 +> > I have a table which stores cumulative values +> > I would like to display/chart the deltas between successive data=20 +> > collections +> > =20 +> > If my primary key only increments by 1, I could write a simple query +> > =20 +> > select b.gc_minor - a.gc_minor, b.gc_major - a.gc_major +> > from jam_trace_sys a, jam_trace_sys b +> > where a.trace_id =3D 22 +> > and b.trace_id =3D a.trace_id +> > and b.seq_no =3D a.seq_no + 1 +> > order by a.seq_no; +> > =20 +> > However the difference in sequence number is variable. +> > So (in Oracle) I used to extract the next seq_no using a correlated=20 +> > sub-query +> > =20 +> > select b.gc_minor - a.gc_minor, b.gc_major - a.gc_major +> > from jam_trace_sys a, jam_trace_sys b +> > where a.trace_id =3D 22 +> > and (b.trace_id, b.seq_no) =3D +> > (select a.trace_id, min(c.seq_no) from jam_trace_sys c +> > where c.trace_id =3D a.trace_id and c.seq_no > a.seq_no) +> > order by a.seq_no; +> > =20 +> > For every row in A, The correlated sub-query from C will execute +> > With an appropriate index, it will just descend the index Btree +> > go one row to the right and return that row (min > :value) +> > and join to table B +> > =20 +> > SELECT STATEMENT +> > SORT ORDER BY +> > TABLE ACCESS BY INDEX ROWID JAM_TRACE_SYS B +> > NESTED LOOPS +> > TABLE ACCESS BY INDEX ROWID JAM_TRACE_SYS A +> > INDEX RANGE SCAN JAM_TRACE_SYS_N1 A +> > INDEX RANGE SCAN JAM_TRACE_SYS_N1 B +> > SORT AGGREGATE +> > INDEX RANGE SCAN JAM_TRACE_SYS_N1 C +> > =20 +> > In postgreSQL A and B are doing a cartesian product +> > then C gets executed for every row in this cartesian product +> > and most of the extra rows get thrown out. +> > Is there any way to force an execution plan like above where the=20 +> > correlated subquery runs before going to B. +> > The table is small right now, but it will grow to have millions of = +rows +> > QUERY PLAN +> > = +-------------------------------------------------------------------------= +---------------------------------------------------------- +> > Sort (cost=3D124911.81..124944.84 rows=3D13213 width=3D20) (actual = + +> > time=3D13096.754..13097.053 rows=3D149 loops=3D1) +> > Sort Key: a.seq_no +> > -> Nested Loop (cost=3D4.34..124007.40 rows=3D13213 width=3D20) = +(actual=20 +> > time=3D1948.300..13096.329 rows=3D149 loops=3D1) +> > Join Filter: (subplan) +> > -> Seq Scan on jam_trace_sys b (cost=3D0.00..3.75 = +rows=3D175=20 +> > width=3D16) (actual time=3D0.005..0.534 rows=3D175 loops=3D1) +> > -> Materialize (cost=3D4.34..5.85 rows=3D151 width=3D16) = +(actual=20 +> > time=3D0.002..0.324 rows=3D150 loops=3D175) +> > -> Seq Scan on jam_trace_sys a (cost=3D0.00..4.19=20 +> > rows=3D151 width=3D16) (actual time=3D0.022..0.687 rows=3D150 = +loops=3D1) +> > Filter: (trace_id =3D 22) +> > SubPlan +> > -> Aggregate (cost=3D4.67..4.67 rows=3D1 width=3D4) = +(actual=20 +> > time=3D0.486..0.488 rows=3D1 loops=3D26250) +> > -> Seq Scan on jam_trace_sys c (cost=3D0.00..4.62 = + +> > rows=3D15 width=3D4) (actual time=3D0.058..0.311 rows=3D74 = +loops=3D26250) +> > Filter: ((trace_id =3D $0) AND (seq_no > $1)) +> > Total runtime: 13097.557 ms +> > (13 rows) +> > =20 +> > pglnx01=3D> \d jam_trace_sys +> > Table "public.jam_trace_sys" +> > Column | Type | Modifiers +> > -----------------+---------+----------- +> > trace_id | integer | +> > seq_no | integer | +> > cpu_utilization | integer | +> > gc_minor | integer | +> > gc_major | integer | +> > heap_used | integer | +> > Indexes: +> > "jam_trace_sys_n1" btree (trace_id, seq_no) +> > =20 +> > pglnx01=3D> select count(*) from jam_trace_Sys ; +> > count +> > ------- +> > 175 +> > (1 row) +> > =20 +> > pglnx01=3D> select trace_id, count(*) from jam_trace_sys group by = +trace_id ; +> > trace_id | count +> > ----------+------- +> > 15 | 2 +> > 18 | 21 +> > 22 | 150 +> > 16 | 2 +> > (4 rows) +>=20 + +------=_NextPart_000_0029_01C635A5.C01622F0 +Content-Type: text/html; + charset="UTF-8" +Content-Transfer-Encoding: quoted-printable + +=EF=BB=BF + + + + + + +
Sz=C5=B1cs,
+
    Thanks for your = +suggestion, I=20 +guess there is more than one way to attack the problem.
+
 
+
I ended up using a trick with limit to = +get the next=20 +row ...
+
 
+
select (b.gc_minor- a.gc_minor), = +(b.gc_major-=20 +a.gc_major)
from jam_trace_sys a join jam_trace_sys b on
(b.seq_no = +=3D=20 +(select c.seq_no from jam_trace_sys c
 where c.trace_id =3D = +a.trace_id and=20 +c.seq_no > a.seq_no
 order by c.trace_id, c.seq_no limit=20 +1)
 and b.trace_id =3D a.trace_id),
jam_tracesnap s1, = +jam_tracesnap=20 +s2
where s1.trace_id =3D a.trace_id
and s1.seq_no =3D = +a.seq_no
and=20 +s2.trace_id =3D b.trace_id
and s2.seq_no =3D b.seq_no
and = +a.trace_id =3D=20 +22
order by a.seq_no;
+
 
+
This gave me a nice clean execution = +plan (there are=20 +some extra sources listed, but that is a bug in postgresql) = +...
+
 
+
QUERY=20 +PLAN
-----------------------------------------------------------------= +-------------------------------------------------------------------------= +-----------------
Sort =20 +(cost=3D11.24..11.25 rows=3D1 width=3D20) (actual time=3D0.040..0.040 = +rows=3D0=20 +loops=3D1)
 Sort Key: a.seq_no
 ->Nested Loop =20 +(cost=3D0.00..11.23 rows=3D1 width=3D20) (actual time=3D0.028..0.028 = +rows=3D0=20 +loops=3D1)
    Join Filter: ("inner".seq_no =3D=20 +"outer".seq_no)
    ->Nested Loop  = +(cost=3D0.00..9.20=20 +rows=3D1 width=3D32) (actual time=3D0.024..0.024 rows=3D0=20 +loops=3D1)
       Join Filter: = +("inner".seq_no =3D=20 +"outer".seq_no)
       ->Nested = +Loop =20 +(cost=3D0.00..7.17 rows=3D1 width=3D32) (actual time=3D0.020..0.020 = +rows=3D0=20 +loops=3D1)
          = +Join Filter:=20 +("inner".seq_no =3D=20 +(subplan))
          = +->Index=20 +Scan using jam_trace_sys_n1 on jam_trace_sys a  (cost=3D0.00..3.41 = +rows=3D1=20 +width=3D16) (actual time=3D0.016..0.016 rows=3D0=20 +loops=3D1)
          = +;  =20 +Index Cond: (trace_id =3D=20 +22)
          ->Index = +Scan=20 +using jam_trace_sys_n1 on jam_trace_sys b  (cost=3D0.00..3.41 = +rows=3D1=20 +width=3D16) (never=20 +executed)
          = +  =20 +Index Cond: (22 =3D=20 +trace_id)
         =20 +SubPlan
         =20 +->Limit  (cost=3D0.00..0.33 rows=3D1 width=3D8) (never=20 +executed)
          = + =20 +->Index Scan using jam_trace_sys_n1 on jam_trace_sys c  = +(cost=3D0.00..6.36=20 +rows=3D19 width=3D8) (never=20 +executed)
          = +    =20 +Index Cond: ((trace_id =3D $0) AND (seq_no >=20 +$1))
       ->Index Scan using=20 +jam_tracesnap_n1 on jam_tracesnap s1  (cost=3D0.00..2.01 rows=3D1 = +width=3D8)=20 +(never = +executed)
          = +Index=20 +Cond: (22 =3D trace_id)
    ->Index Scan using=20 +jam_tracesnap_n1 on jam_tracesnap s2  (cost=3D0.00..2.01 rows=3D1 = +width=3D8)=20 +(never executed)
       Index Cond: (22 = +=3D=20 +trace_id)
+
Regards,
+
 
+
Virag
+

+
----- Original Message ----- +
From: "Sz=C5=B1cs G=C3=A1bor" = +<surrano@gmail.com>
+
To: <pgsql-performance@postgresql.org>
+
Sent: Monday, January 09, 2006 7:59 = +AM
+
Subject: Re: Avoiding cartesian=20 +product
+

> Dear Virag,
>
> AFAIK aggregates aren't = +indexed in=20 +postgres (at least not before 8.1, which
> indexes min and max,=20 +iirc).
>
> Also, I don't think you need to exactly = +determine the=20 +trace_id. Try this one
> (OTOH; might be wrong):
>
> = +select=20 +DISTINCT ON (a.trace_id, a.seq_no) -- See below
>    = +b.gc_minor=20 +- a.gc_minor, b.gc_major - a.gc_major
> from jam_trace_sys a,=20 +jam_trace_sys b
> where a.trace_id =3D 22
>    and = + +b.trace_id =3D a.trace_id
>    and b.seq_no > = +a.seq_no --=20 +Simply ">" is enough
> order by a.trace_id, a.seq_no, b.seq_no; = +--=20 +DISTINCT, see below
>
> The trick is that DISTINCT takes = +the first=20 +one in each group (IIRC it is
> granted, at least someone told me = +on one=20 +of these lists :) ) so if you order
> by the DISTINCT attributes = +and then=20 +by b.seq_no, you'll get the smallest of
> appropriate b.seq_no = +values for=20 +each DISTINCT values.
>
> The idea of DISTINCTing by both = +columns=20 +is to make sure the planner finds
> the index. (lately I had a = +similar=20 +problem: WHERE a=3D1 ORDER BY b LIMIT 1
> used an index on b, = +instead of an=20 +(a,b) index. Using ORDER BY a,b solved it)
>
> HTH,
> = + +
> --
> G.
>
>
> On 2006.01.04. 5:12, = +Virag=20 +Saksena wrote:
> >
> > I have a table which stores = +cumulative=20 +values
> > I would like to display/chart the deltas between = +successive=20 +data
> > collections
> > 
> > If my = +primary=20 +key only increments by 1, I could write a simple query
> = +> =20 +
> > select b.gc_minor - a.gc_minor, b.gc_major - = +a.gc_major
>=20 +>   from jam_trace_sys a, jam_trace_sys b
> = +>  where=20 +a.trace_id =3D 22
> >    and b.trace_id =3D=20 +a.trace_id
> >    and b.seq_no =3D a.seq_no + = +1
>=20 +>  order by a.seq_no;
> > 
> > However = +the=20 +difference in sequence number is variable.
> > So (in Oracle) I = +used to=20 +extract the next seq_no using a correlated
> > = +sub-query
>=20 +> 
> > select b.gc_minor - a.gc_minor, b.gc_major -=20 +a.gc_major
> > from jam_trace_sys a, jam_trace_sys b
> = +> where=20 +a.trace_id =3D 22
> > and (b.trace_id, b.seq_no) =3D
> = +> (select=20 +a.trace_id, min(c.seq_no) from jam_trace_sys c
> > where = +c.trace_id =3D=20 +a.trace_id and c.seq_no > a.seq_no)
> >  order by=20 +a.seq_no;
> > 
> > For every row in A, The = +correlated=20 +sub-query from C will execute
> > With an appropriate index, it = +will=20 +just descend the index Btree
> > go one row to the right and = +return=20 +that row (min > :value)
> > and join to table B
> = +> =20 +
> > SELECT STATEMENT
> >   SORT ORDER = +BY
>=20 +>    TABLE ACCESS BY INDEX ROWID JAM_TRACE_SYS = +B
>=20 +>      NESTED LOOPS
>=20 +>        TABLE ACCESS BY INDEX = +ROWID=20 +JAM_TRACE_SYS  A
>=20 +>          INDEX RANGE = +SCAN=20 +JAM_TRACE_SYS_N1  A
> = +>       =20 +INDEX RANGE SCAN JAM_TRACE_SYS_N1 B
>=20 +>          SORT=20 +AGGREGATE
>=20 +>            = +INDEX=20 +RANGE SCAN JAM_TRACE_SYS_N1 C
> > 
> > In = +postgreSQL A=20 +and B are doing a cartesian product
> > then C gets executed = +for every=20 +row in this cartesian product
> > and most of the extra rows = +get thrown=20 +out.
> > Is there any way to force an execution plan like above = +where=20 +the
> > correlated subquery runs before going to B.
> = +> The=20 +table is small right now, but it will grow to have millions of = +rows
> >=20 +QUERY PLAN
> >=20 +-------------------------------------------------------------------------= +----------------------------------------------------------
>=20 +>  Sort  (cost=3D124911.81..124944.84 rows=3D13213 = +width=3D20) (actual=20 +
> > time=3D13096.754..13097.053 rows=3D149 loops=3D1)
>=20 +>    Sort Key: a.seq_no
> >    = + +->  Nested Loop  (cost=3D4.34..124007.40 rows=3D13213 = +width=3D20) (actual=20 +
> > time=3D1948.300..13096.329 rows=3D149 loops=3D1)
>=20 +>          Join Filter:=20 +(subplan)
> = +>         =20 +->  Seq Scan on jam_trace_sys b  (cost=3D0.00..3.75 = +rows=3D175
>=20 +> width=3D16) (actual time=3D0.005..0.534 rows=3D175 = +loops=3D1)
>=20 +>          -> =20 +Materialize  (cost=3D4.34..5.85 rows=3D151 width=3D16) (actual = +
> >=20 +time=3D0.002..0.324 rows=3D150 loops=3D175)
>=20 +>           &nb= +sp;   =20 +->  Seq Scan on jam_trace_sys a  (cost=3D0.00..4.19 = +
> >=20 +rows=3D151 width=3D16) (actual time=3D0.022..0.687 rows=3D150 = +loops=3D1)
>=20 +>           &nb= +sp;         =20 +Filter: (trace_id =3D 22)
>=20 +>          = +SubPlan
>=20 +>           =20 +->  Aggregate  (cost=3D4.67..4.67 rows=3D1 width=3D4) = +(actual
>=20 +> time=3D0.486..0.488 rows=3D1 loops=3D26250)
>=20 +>           &nb= +sp;     =20 +->  Seq Scan on jam_trace_sys c  (cost=3D0.00..4.62 = +
> >=20 +rows=3D15 width=3D4) (actual time=3D0.058..0.311 rows=3D74 = +loops=3D26250)
>=20 +>           &nb= +sp;           =20 +Filter: ((trace_id =3D $0) AND (seq_no > $1))
> >  = +Total runtime:=20 +13097.557 ms
> > (13 rows)
> > 
> >=20 +pglnx01=3D> \d jam_trace_sys
> = +>      Table=20 +"public.jam_trace_sys"
> >     =20 +Column      |  Type   |=20 +Modifiers
> > -----------------+---------+-----------
>=20 +>  trace_id        | integer=20 +|
> > =20 +seq_no          | integer = +|
>=20 +>  cpu_utilization | integer |
> > =20 +gc_minor        | integer |
>=20 +>  gc_major        | integer=20 +|
> >  heap_used       | = +integer=20 +|
> > Indexes:
> >     = +"jam_trace_sys_n1"=20 +btree (trace_id, seq_no)
> > 
> > pglnx01=3D> = +select=20 +count(*) from jam_trace_Sys ;
> >  count
> >=20 +-------
> >    175
> > (1 row)
>=20 +> 
> > pglnx01=3D> select trace_id, count(*) from=20 +jam_trace_sys group by trace_id ;
> >  trace_id | = +count
>=20 +> ----------+-------
> = +>       =20 +15 |     2
>=20 +>        18 |    = +21
>=20 +>        22 |   = +150
>=20 +>        16 = +|    =20 +2
> > (4 rows)
>
+ +------=_NextPart_000_0029_01C635A5.C01622F0-- + + +From pgsql-performance-owner@postgresql.org Mon Feb 20 05:58:46 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 236E99DC86A + for ; + Mon, 20 Feb 2006 05:58:45 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 53336-08 + for ; + Mon, 20 Feb 2006 05:58:46 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from localhost.localdomain (unknown [80.73.176.164]) + by postgresql.org (Postfix) with ESMTP id D226B9DC81C + for ; + Mon, 20 Feb 2006 05:58:41 -0400 (AST) +Received: from localhost ([127.0.0.1] helo=[192.168.1.4]) + by localhost.localdomain with esmtp (Exim 4.50) id 1FB7mE-0007il-In + for pgsql-performance@postgresql.org; Mon, 20 Feb 2006 10:56:18 +0100 +Message-ID: <43F992D1.6040308@treyst.se> +Date: Mon, 20 Feb 2006 10:58:41 +0100 +From: Fredrik Olsson +User-Agent: Thunderbird 1.5 (Macintosh/20051201) +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Force another plan. +References: <43F74592.7010701@treyst.se> <20490.1140287811@sss.pgh.pa.us> + <43F866E2.20001@treyst.se> <11673.1140370277@sss.pgh.pa.us> +In-Reply-To: <11673.1140370277@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, score=0.103 required=5 tests=[AWL=0.103] +X-Spam-Score: 0.103 +X-Spam-Level: +X-Archive-Number: 200602/318 +X-Sequence-Number: 17304 + +Tom Lane skrev: +> Fredrik Olsson writes: +> +>> -> Seq Scan on t_entities (cost=0.00..1.49 rows=7 width=4) +>> (actual time=404.539..409.302 rows=2 loops=1) +>> Filter: ((haveaccess(createdby, responsible, "class", +>> false) OR CASE WHEN (partof = 'contacts'::name) THEN +>> ischildof(ancestorof(me()), "ID") ELSE false END) AND (subplan)) +>> SubPlan +>> -> Function Scan on alleventoccurances +>> (cost=0.00..12.50 rows=1000 width=8) (actual time=27.871..27.871 rows=0 +>> loops=14) +>> +> +> This seems to be your problem right here: evaluating that subplan for +> each row of t_entities is pretty expensive, and yet the planner's +> estimating a total cost of only 1.49 to run the scan. What PG version +> is this? AFAICT we've accounted for subplan costs in scan quals for +> a long time, certainly since 7.4. Can you put together a self-contained +> test case for this? +> +> +I have found the real bottle-neck, looks like I trusted PG to do a bit +too much magic. Since all table accesses go through views, and the first +11 columns always look the same, I did a "proxy-view" to simplify my +"real-views" to: +SELECT pv.*, ... +The "proxy-view" fetches from t_entities, and so does the "real-views" +to do a filter on "partof". This resulted in two scans on t_entities +when only one is needed. Skipping the "proxy-view" allows PG to chose +the best plan for every case. I guess I stressed the optimizer a bit too +far :). + +Is a self contained test-case for the old way with the "proxy-view" is +still wanted? + +-- +//Fredrik Olsson + Treyst AB + +46-(0)19-362182 + fredrik.olsson@treyst.se + + +From pgsql-performance-owner@postgresql.org Mon Feb 20 08:57:36 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id BB5959DC851 + for ; + Mon, 20 Feb 2006 08:57:35 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 87671-05 + for ; + Mon, 20 Feb 2006 08:57:38 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) + by postgresql.org (Postfix) with SMTP id 293349DC83D + for ; + Mon, 20 Feb 2006 08:57:32 -0400 (AST) +Received: (qmail invoked by alias); 20 Feb 2006 12:57:34 -0000 +Received: from 201-25-163-211.ctame704.dsl.brasiltelecom.net.br (EHLO + servidor) [201.25.163.211] + by mail.gmx.net (mp018) with SMTP; 20 Feb 2006 13:57:34 +0100 +X-Authenticated: #15924888 +Subject: Creating a correct and real benchmark +From: Marcos +To: pgsql-performance@postgresql.org +Content-Type: text/plain +Date: Mon, 20 Feb 2006 10:50:36 +0000 +Message-Id: <1140432636.1170.6.camel@servidor> +Mime-Version: 1.0 +X-Mailer: Evolution 2.4.1 FreeBSD GNOME Team Port +Content-Transfer-Encoding: 7bit +X-Y-GMX-Trusted: 0 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200602/319 +X-Sequence-Number: 17305 + +Hi, + +I'm developing a search engine using the postgresql's databas. I've +already doing some tunnings looking increase the perform. + +Now, I'd like of do a realistic test of perfom with number X of queries +for know the performance with many queries. + +What the corret way to do this? + +Thanks. + + +From pgsql-performance-owner@postgresql.org Mon Feb 20 11:01:45 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 969C99DC815 + for ; + Mon, 20 Feb 2006 11:01:44 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 14214-04 + for ; + Mon, 20 Feb 2006 11:01:48 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 0D5F69DC806 + for ; + Mon, 20 Feb 2006 11:01:41 -0400 (AST) +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 k1KF1k0c025934; + Mon, 20 Feb 2006 10:01:46 -0500 (EST) +To: Fredrik Olsson +cc: pgsql-performance@postgresql.org +Subject: Re: Force another plan. +In-reply-to: <43F992D1.6040308@treyst.se> +References: <43F74592.7010701@treyst.se> <20490.1140287811@sss.pgh.pa.us> + <43F866E2.20001@treyst.se> <11673.1140370277@sss.pgh.pa.us> + <43F992D1.6040308@treyst.se> +Comments: In-reply-to Fredrik Olsson + message dated "Mon, 20 Feb 2006 10:58:41 +0100" +Date: Mon, 20 Feb 2006 10:01:46 -0500 +Message-ID: <25933.1140447706@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.11 required=5 tests=[AWL=0.110] +X-Spam-Score: 0.11 +X-Spam-Level: +X-Archive-Number: 200602/320 +X-Sequence-Number: 17306 + +Fredrik Olsson writes: +> Is a self contained test-case for the old way with the "proxy-view" is +> still wanted? + +Yes, something still seems funny there. And for that matter it wasn't +clear what was wrong with your proxy view, either. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Feb 20 20:13:50 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 31EFC9DC82D + for ; + Mon, 20 Feb 2006 20:13:50 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 11698-09 + for ; + Mon, 20 Feb 2006 20:13:52 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from peufeu.com (unknown [82.67.9.10]) + by postgresql.org (Postfix) with ESMTP id 9C3D99DC805 + for ; + Mon, 20 Feb 2006 20:13:46 -0400 (AST) +Received: (qmail 13442 invoked from network); 21 Feb 2006 01:14:28 +0100 +Received: from unknown (HELO apollo13) (82.67.9.10) + by boutiquenumerique.com with SMTP; 21 Feb 2006 01:14:28 +0100 +Date: Tue, 21 Feb 2006 01:14:27 +0100 +To: Marcos , pgsql-performance@postgresql.org +Subject: Re: Creating a correct and real benchmark +References: <1140432636.1170.6.camel@servidor> +From: PFC +Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-ID: +In-Reply-To: <1140432636.1170.6.camel@servidor> +User-Agent: Opera M2/8.51 (Linux, build 1462) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.098 required=5 tests=[AWL=0.098] +X-Spam-Score: 0.098 +X-Spam-Level: +X-Archive-Number: 200602/321 +X-Sequence-Number: 17307 + + +> I'm developing a search engine using the postgresql's databas. I've +> already doing some tunnings looking increase the perform. +> +> Now, I'd like of do a realistic test of perfom with number X of queries +> for know the performance with many queries. +> +> What the corret way to do this? + + + I guess the only way to know how it will perform with your own +application is to benchmark it with queries coming from your own +application. You can create a test suite with a number of typical queries +and use your favourite scripting language to spawn a number of threads and +hammer the database. I find it interesting to measure the responsiveness +of the server while torturing it, simply by measuring the time it takes to +respond to a simple query and graphing it. Also you should not have N +threads issue the exact same queries, because then you will hit a too +small dataset. Introduce some randomness in the testing, for instance. +Benchmarking from another machine makes sure the test client's CPU usage +is not a part of the problem. + +From pgsql-performance-owner@postgresql.org Mon Feb 20 20:21:51 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 491889DC82D + for ; + Mon, 20 Feb 2006 20:21:50 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 22971-01 + for ; + Mon, 20 Feb 2006 20:21:52 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.202]) + by postgresql.org (Postfix) with ESMTP id EFEF49DC805 + for ; + Mon, 20 Feb 2006 20:21:47 -0400 (AST) +Received: by zproxy.gmail.com with SMTP id k1so1101943nzf + for ; + Mon, 20 Feb 2006 16:21:51 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:user-agent:x-accept-language:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding; + b=GFbt8OQVq+Jl1I1zSslBa7/hYuxm3Dbt4kMm+VQsEz+aw2e53UvinL4G8HNvR+lJNix0dagz6tq1yOUdukjURIVoJu4Zc3dsPmrLwXljHkxHHkQSBp1x7QR6abBRMnVlBIkFQy0wF9z1bzGRf9DIyTlGo96YhMvfm+Uow8an/nw= +Received: by 10.36.39.15 with SMTP id m15mr937028nzm; + Mon, 20 Feb 2006 16:21:50 -0800 (PST) +Received: from ?10.1.1.24? ( [203.217.18.65]) + by mx.gmail.com with ESMTP id m2sm2655515nzf.2006.02.20.16.21.49; + Mon, 20 Feb 2006 16:21:50 -0800 (PST) +Message-ID: <43FA5D20.2080805@gmail.com> +Date: Tue, 21 Feb 2006 11:21:52 +1100 +From: Chris +User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Marcos +CC: pgsql-performance@postgresql.org +Subject: Re: Creating a correct and real benchmark +References: <1140432636.1170.6.camel@servidor> +In-Reply-To: +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, score=0.125 required=5 tests=[AWL=0.125] +X-Spam-Score: 0.125 +X-Spam-Level: +X-Archive-Number: 200602/322 +X-Sequence-Number: 17308 + +PFC wrote: +> +>> I'm developing a search engine using the postgresql's databas. I've +>> already doing some tunnings looking increase the perform. +>> +>> Now, I'd like of do a realistic test of perfom with number X of queries +>> for know the performance with many queries. +>> +>> What the corret way to do this? +> +> +> +> I guess the only way to know how it will perform with your own +> application is to benchmark it with queries coming from your own +> application. You can create a test suite with a number of typical +> queries and use your favourite scripting language to spawn a number of +> threads and hammer the database. I find it interesting to measure the +> responsiveness of the server while torturing it, simply by measuring +> the time it takes to respond to a simple query and graphing it. Also +> you should not have N threads issue the exact same queries, because +> then you will hit a too small dataset. Introduce some randomness in the +> testing, for instance. Benchmarking from another machine makes sure the +> test client's CPU usage is not a part of the problem. + +The other advice on top of this is don't just import a small amount of data. + +If your application is going to end up with 200,000 rows - then test +with 200,000 rows or more so you know exactly how it will handle under +"production" conditions. + +From pgsql-performance-owner@postgresql.org Tue Feb 21 01:13:57 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 8894E9DCC00 + for ; + Tue, 21 Feb 2006 01:13:56 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 90799-09 + for ; + Tue, 21 Feb 2006 01:13:55 -0400 (AST) +X-Greylist: delayed 22:31:16.009559 by SQLgrey- +Received: from mail.auptyma.com (64-60-124-12.cust.telepacific.net + [64.60.124.12]) by postgresql.org (Postfix) with ESMTP id D7E929DCBFC + for ; + Tue, 21 Feb 2006 01:13:53 -0400 (AST) +Received: from demo1 (64-60-124-12.cust.telepacific.net [64.60.124.12]) + (authenticated bits=0) + by mail.auptyma.com (8.13.1/8.13.1) with ESMTP id k1L4q5jk023289 + (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO) + for ; Mon, 20 Feb 2006 20:52:05 -0800 +Message-ID: <028401c636a5$907fb4b0$3100000a@demo1> +From: "Virag Saksena" +To: +Subject: Cost Issue - How do I force a Hash Join +Date: Mon, 20 Feb 2006 21:13:34 -0800 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0281_01C63662.81EB6360" +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2600.0000 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 +X-Greylist: Sender succeded SMTP AUTH authentication, not delayed by + milter-greylist-1.7.5 (mail.auptyma.com [10.0.0.47]); + Mon, 20 Feb 2006 20:52:05 -0800 (PST) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.081 required=5 tests=[AWL=0.080, + HTML_MESSAGE=0.001] +X-Spam-Score: 0.081 +X-Spam-Level: +X-Archive-Number: 200602/323 +X-Sequence-Number: 17309 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0281_01C63662.81EB6360 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +Hi, + I have query where I do two inline queries (which involves grouping) = +and then join them with an outer join. +The individual queries run in 50-300 ms. However the optimizer is = +choosing a nested loop to join them rather than a Hash join +causing the complete query to take 500+ seconds. It expects that it will = +get 1 row out from each of the sources, but here is gets +several thousand rows. + +Is there any way I can get a hash join used on the outer join, while = +preserving the nested loops. + + +explain analyze +select o1.objaddr, o1.fieldname, o1.objsig, +o1.totmem, o1.cnt, +o2.totmem, o2.cnt +from +( select min(ao.objaddr) as objaddr, count(*) as cnt, + sum(ao.totmem) as totmem, ao.objsig, ar.fieldname, ao.objtype + from jam_heapobj ao, jam_heaprel ar + where ar.heap_id =3D 1 and ar.parentaddr =3D 0 and ar.fieldname =3D = +'K' + and ao.heap_id =3D ar.heap_id and ao.objaddr =3D ar.childaddr + group by ao.objsig, ar.fieldname, ao.objtype) o1 +left outer join +(select min(bo.objaddr) as objaddr, count(*) as cnt, + sum(bo.totmem) as totmem, bo.objsig, br.fieldname, bo.objtype + from jam_heapobj bo, jam_heaprel br + where br.heap_id =3D 0 and br.parentaddr =3D 0 and br.fieldname =3D = +'K' + and bo.heap_id =3D br.heap_id and bo.objaddr =3D br.childaddr +group by bo.objsig, br.fieldname, bo.objtype) o2 +on ( o2.objsig =3D o1.objsig and o2.objtype =3D o1.objtype + and o2.fieldname =3D o1.fieldname) + order by o1.totmem - coalesce(o2.totmem,0) desc; + + Sort (cost=3D16305.41..16305.42 rows=3D1 width=3D562) (actual = +time=3D565997.769..566016.255 rows=3D6115 loops=3D1) + Sort Key: (o1.totmem - COALESCE(o2.totmem, 0::bigint)) + ->Nested Loop Left Join (cost=3D16305.22..16305.40 rows=3D1 = +width=3D562) (actual time=3D612.631..565896.047 rows=3D6115 loops=3D1) + Join Filter: ((("inner".objsig)::text =3D ("outer".objsig)::text) = +AND (("inner".objtype)::text =3D ("outer".objtype)::text) AND = +(("inner".fieldname)::text =3D ("outer".fieldname)::text)) + ->Subquery Scan o1 (cost=3D12318.12..12318.15 rows=3D1 width=3D514) = +(actual time=3D309.659..413.311 rows=3D6115 loops=3D1) + ->HashAggregate (cost=3D12318.12..12318.14 rows=3D1 width=3D54) = +(actual time=3D309.649..367.206 rows=3D6115 loops=3D1) + ->Nested Loop (cost=3D0.00..12317.90 rows=3D10 width=3D54) = +(actual time=3D0.243..264.116 rows=3D6338 loops=3D1) + ->Index Scan using jam_heaprel_n1 on jam_heaprel ar = +(cost=3D0.00..12275.00 rows=3D7 width=3D19) (actual time=3D0.176..35.780 = +rows=3D6338 loops=3D1) + Index Cond: ((heap_id =3D 1) AND (parentaddr =3D 0)) + Filter: ((fieldname)::text =3D 'K'::text) + ->Index Scan using jam_heapobj_u1 on jam_heapobj ao = +(cost=3D0.00..6.10 rows=3D2 width=3D51) (actual time=3D0.019..0.022 = +rows=3D1 loops=3D6338) + Index Cond: ((ao.heap_id =3D 1) AND (ao.objaddr =3D = +"outer".childaddr)) + ->Subquery Scan o2 (cost=3D3987.10..3987.13 rows=3D1 width=3D514) = +(actual time=3D0.062..75.171 rows=3D6038 loops=3D6115) + ->HashAggregate (cost=3D3987.10..3987.12 rows=3D1 width=3D54) = +(actual time=3D0.056..36.469 rows=3D6038 loops=3D6115) + ->Nested Loop (cost=3D0.00..3987.05 rows=3D2 width=3D54) (actual = +time=3D0.145..257.876 rows=3D6259 loops=3D1) + ->Index Scan using jam_heaprel_n1 on jam_heaprel br = +(cost=3D0.00..3974.01 rows=3D3 width=3D19) (actual time=3D0.074..35.124 = +rows=3D6259 loops=3D1) + Index Cond: ((heap_id =3D 0) AND (parentaddr =3D 0)) + Filter: ((fieldname)::text =3D 'K'::text) + ->Index Scan using jam_heapobj_u1 on jam_heapobj bo = +(cost=3D0.00..4.33 rows=3D1 width=3D51) (actual time=3D0.018..0.022 = +rows=3D1 loops=3D6259) + Index Cond: ((bo.heap_id =3D 0) AND (bo.objaddr =3D = +"outer".childaddr)) + Total runtime: 566044.187 ms +(21 rows) + +Regards, + +Virag + +------=_NextPart_000_0281_01C63662.81EB6360 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
Hi,
+
    I have query where I = +do two=20 +inline queries (which involves grouping) and then join them with an = +outer=20 +join.
+
The individual queries run in 50-300 = +ms. However=20 +the optimizer is choosing a nested loop to join them rather than a Hash=20 +join
+
causing the complete query to take 500+ = +seconds. It=20 +expects that it will get 1 row out from each of the sources, but here is = + +gets
+
several thousand rows.
+
 
+
Is there any way I can get a hash join = +used on the=20 +outer join, while preserving the nested loops.
+
 
+
 
+
explain analyze
select o1.objaddr, = +o1.fieldname,=20 +o1.objsig,
o1.totmem, o1.cnt,
o2.totmem, o2.cnt
from
( = +select=20 +min(ao.objaddr) as objaddr, count(*) as=20 +cnt,
         sum(ao.totmem) = +as=20 +totmem, ao.objsig, ar.fieldname, ao.objtype
    from=20 +jam_heapobj ao, jam_heaprel ar
   where ar.heap_id =3D = +1  and=20 +ar.parentaddr =3D 0 and ar.fieldname =3D 'K'
     = +and=20 +ao.heap_id =3D ar.heap_id and ao.objaddr =3D = +ar.childaddr
   group by=20 +ao.objsig, ar.fieldname, ao.objtype) o1
left outer join
(select=20 +min(bo.objaddr) as objaddr, count(*) as=20 +cnt,
        sum(bo.totmem) as = +totmem,=20 +bo.objsig, br.fieldname, bo.objtype
   from jam_heapobj bo, = + +jam_heaprel br
  where br.heap_id =3D 0  and br.parentaddr = +=3D 0 and=20 +br.fieldname =3D 'K'
    and bo.heap_id =3D br.heap_id = +and=20 +bo.objaddr =3D br.childaddr
group by bo.objsig, br.fieldname, = +bo.objtype)=20 +o2
on ( o2.objsig =3D o1.objsig and o2.objtype =3D = +o1.objtype
 and=20 +o2.fieldname =3D o1.fieldname)
 order by o1.totmem - = +coalesce(o2.totmem,0)=20 +desc;
+
 
+
 Sort (cost=3D16305.41..16305.42 = +rows=3D1=20 +width=3D562) (actual time=3D565997.769..566016.255 rows=3D6115 = +loops=3D1)
  Sort=20 +Key: (o1.totmem - COALESCE(o2.totmem, 0::bigint))
  ->Nested = +Loop=20 +Left Join (cost=3D16305.22..16305.40 rows=3D1 width=3D562) (actual=20 +time=3D612.631..565896.047 rows=3D6115 loops=3D1)
    = +Join Filter:=20 +((("inner".objsig)::text =3D ("outer".objsig)::text) AND = +(("inner".objtype)::text=20 +=3D ("outer".objtype)::text) AND (("inner".fieldname)::text =3D=20 +("outer".fieldname)::text))
    ->Subquery Scan o1=20 +(cost=3D12318.12..12318.15 rows=3D1 width=3D514) (actual = +time=3D309.659..413.311=20 +rows=3D6115 loops=3D1)
      = +->HashAggregate=20 +(cost=3D12318.12..12318.14 rows=3D1 width=3D54) (actual = +time=3D309.649..367.206=20 +rows=3D6115 loops=3D1)
        = +->Nested=20 +Loop (cost=3D0.00..12317.90 rows=3D10 width=3D54) (actual = +time=3D0.243..264.116=20 +rows=3D6338 = +loops=3D1)
         =20 +->Index Scan using jam_heaprel_n1 on jam_heaprel ar = +(cost=3D0.00..12275.00=20 +rows=3D7 width=3D19) (actual time=3D0.176..35.780 rows=3D6338=20 +loops=3D1)
          = +; =20 +Index Cond: ((heap_id =3D 1) AND (parentaddr =3D=20 +0))
           = +=20 +Filter: ((fieldname)::text =3D=20 +'K'::text)
          = +->Index=20 +Scan using jam_heapobj_u1 on jam_heapobj ao (cost=3D0.00..6.10 rows=3D2 = +width=3D51)=20 +(actual time=3D0.019..0.022 rows=3D1=20 +loops=3D6338)
         &n= +bsp; =20 +Index Cond: ((ao.heap_id =3D 1) AND (ao.objaddr =3D=20 +"outer".childaddr))
    ->Subquery Scan o2=20 +(cost=3D3987.10..3987.13 rows=3D1 width=3D514) (actual = +time=3D0.062..75.171 rows=3D6038=20 +loops=3D6115)
      ->HashAggregate=20 +(cost=3D3987.10..3987.12 rows=3D1 width=3D54) (actual = +time=3D0.056..36.469 rows=3D6038=20 +loops=3D6115)
        ->Nested = +Loop=20 +(cost=3D0.00..3987.05 rows=3D2 width=3D54) (actual time=3D0.145..257.876 = +rows=3D6259=20 +loops=3D1)
          = +->Index=20 +Scan using jam_heaprel_n1 on jam_heaprel br (cost=3D0.00..3974.01 = +rows=3D3 width=3D19)=20 +(actual time=3D0.074..35.124 rows=3D6259=20 +loops=3D1)
          = +; =20 +Index Cond: ((heap_id =3D 0) AND (parentaddr =3D=20 +0))
           = +=20 +Filter: ((fieldname)::text =3D=20 +'K'::text)
          = +->Index=20 +Scan using jam_heapobj_u1 on jam_heapobj bo (cost=3D0.00..4.33 rows=3D1 = +width=3D51)=20 +(actual time=3D0.018..0.022 rows=3D1=20 +loops=3D6259)
         &n= +bsp; =20 +Index Cond: ((bo.heap_id =3D 0) AND (bo.objaddr =3D=20 +"outer".childaddr))
 Total runtime: 566044.187 ms
(21=20 +rows)
+
Regards,
+
 
+
Virag
+ +------=_NextPart_000_0281_01C63662.81EB6360-- + + +From pgsql-performance-owner@postgresql.org Tue Feb 21 01:36:07 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 38DAB9DCDC6 + for ; + Tue, 21 Feb 2006 01:36:02 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 93746-09 + for ; + Tue, 21 Feb 2006 01:36:01 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id EA8569DCDC4 + for ; + Tue, 21 Feb 2006 01:35:57 -0400 (AST) +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 k1L5Zt6H004361; + Tue, 21 Feb 2006 00:35:56 -0500 (EST) +To: "Virag Saksena" +cc: pgsql-performance@postgresql.org +Subject: Re: Cost Issue - How do I force a Hash Join +In-reply-to: <028401c636a5$907fb4b0$3100000a@demo1> +References: <028401c636a5$907fb4b0$3100000a@demo1> +Comments: In-reply-to "Virag Saksena" + message dated "Mon, 20 Feb 2006 21:13:34 -0800" +Date: Tue, 21 Feb 2006 00:35:55 -0500 +Message-ID: <4360.1140500155@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.11 required=5 tests=[AWL=0.110] +X-Spam-Score: 0.11 +X-Spam-Level: +X-Archive-Number: 200602/324 +X-Sequence-Number: 17310 + +"Virag Saksena" writes: +> The individual queries run in 50-300 ms. However the optimizer is = +> choosing a nested loop to join them rather than a Hash join +> causing the complete query to take 500+ seconds. It expects that it will = +> get 1 row out from each of the sources, but here is gets +> several thousand rows. + +The best approach is to see if you can't fix that estimation error. +Are the stats up to date on these tables? If so, maybe raising the +statistics targets would help. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Feb 21 01:59:37 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 800389DD607 + for ; + Tue, 21 Feb 2006 01:59:35 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 97305-07 + for ; + Tue, 21 Feb 2006 01:59:34 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from moonunit2.moonview.localnet (wsip-68-15-5-150.sd.sd.cox.net + [68.15.5.150]) by postgresql.org (Postfix) with ESMTP id 3259C9DD605 + for ; + Tue, 21 Feb 2006 01:59:32 -0400 (AST) +Received: from [192.168.0.3] (moonunit3.moonview.localnet [192.168.0.3]) + by moonunit2.moonview.localnet (8.13.1/8.13.1) with ESMTP id + k1L6038m026180 + for ; Mon, 20 Feb 2006 22:00:03 -0800 +Message-ID: <43FAAB06.5030901@modgraph-usa.com> +Date: Mon, 20 Feb 2006 21:54:14 -0800 +From: "Craig A. James" +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Cost Issue - How do I force a Hash Join +References: <028401c636a5$907fb4b0$3100000a@demo1> + <4360.1140500155@sss.pgh.pa.us> +In-Reply-To: <4360.1140500155@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, score=0.095 required=5 tests=[AWL=0.095] +X-Spam-Score: 0.095 +X-Spam-Level: +X-Archive-Number: 200602/325 +X-Sequence-Number: 17311 + +"Virag Saksena" writes: +>> The individual queries run in 50-300 ms. However the optimizer is +>> choosing a nested loop to join them rather than a Hash join... + +I have what appears to be the identical problem. + +This is a straightforward query that should be fairly quick, but takes about 30 minutes. It's a query across three tables, call them A, B, and C. The tables are joined on indexed columns. + +Here's a quick summary: + + Table A -----> Table B -----> Table C + A_ID B_ID C_ID + A_ID NAME + C_ID + +Tables A and B have 6 million rows each. Table C is small: 67 names, no repeats. All columns involved in the join are indexed. + +Summary: + 1. Query B only: 2.7 seconds, 302175 rows returned + 2. Join B and C: 4.3 seconds, exact same answer + 3. Join A and B: 7.2 minutes, exact same answer + 4. Join A, B, C: 32.7 minutes, exact same answer + +Looking at these: + + Query #1 is doing the real work: finding the rows of interest. + + Queries #1 and #2 ought to be virtually identical, since Table C has + just one row with C_ID = 9, but the time almost doubles. + + Query #3 should take a bit longer than Query #1 because it has to join + 300K rows, but the indexes should make this take just a few seconds, + certainly well under a minute. + + Query #4 should be identical to Query #3, again because there's only + one row in Table C. 32 minutes is pretty horrible for such a + straightforward query. + +It looks to me like the problem is the use of nested loops when a hash join should be used, but I'm no expert at query planning. + +This is psql 8.0.3. Table definitions are at the end. (Table and column names are altered to protect the guilty, otherwise these are straight from Postgres.) I ran "vacuum full analyze" after the last data were added. Hardware is a Dell, 2-CPU Xeon, 4 GB memory, database is on a single SATA 7200RPM disk. + +Thanks, +Craig + +---------------------------- + + +QUERY #1: +--------- + +explain analyze select B.A_ID from B where B.B_ID = 9; + + Index Scan using i_B_B_ID on B (cost=0.00..154401.36 rows=131236 width=4) (actual time=0.158..1387.251 rows=302175 loops=1) + Index Cond: (B_ID = 9) + Total runtime: 2344.053 ms + + +QUERY #2: +--------- + +explain analyze select B.A_ID from B join C on (B.C_ID = C.C_ID) where C.name = 'Joe'; + + Nested Loop (cost=0.00..258501.92 rows=177741 width=4) (actual time=0.349..3392.532 rows=302175 loops=1) + -> Seq Scan on C (cost=0.00..12.90 rows=1 width=4) (actual time=0.232..0.336 rows=1 loops=1) + Filter: ((name)::text = 'Joe'::text) + -> Index Scan using i_B_C_ID on B (cost=0.00..254387.31 rows=328137 width=8) (actual time=0.102..1290.002 rows=302175 loops=1) + Index Cond: (B.C_ID = "outer".C_ID) + Total runtime: 4373.916 ms + + +QUERY #3: +--------- + +explain analyze + select A.A_ID from A + join B on (A.A_ID = B.A_ID) + where B.B_ID = 9; + + Nested Loop (cost=0.00..711336.41 rows=131236 width=4) (actual time=37.118..429419.347 rows=302175 loops=1) + -> Index Scan using i_B_B_ID on B (cost=0.00..154401.36 rows=131236 width=4) (actual time=27.344..8858.489 rows=302175 loops=1) + Index Cond: (B_ID = 9) + -> Index Scan using pk_A_test on A (cost=0.00..4.23 rows=1 width=4) (actual time=1.372..1.376 rows=1 loops=302175) + Index Cond: (A.A_ID = "outer".A_ID) + Total runtime: 430467.686 ms + + +QUERY #4: +--------- +explain analyze + select A.A_ID from A + join B on (A.A_ID = B.A_ID) + join C on (B.B_ID = C.B_ID) + where C.name = 'Joe'; + + Nested Loop (cost=0.00..1012793.38 rows=177741 width=4) (actual time=70.184..1960112.247 rows=302175 loops=1) + -> Nested Loop (cost=0.00..258501.92 rows=177741 width=4) (actual time=52.114..17753.638 rows=302175 loops=1) + -> Seq Scan on C (cost=0.00..12.90 rows=1 width=4) (actual time=0.109..0.176 rows=1 loops=1) + Filter: ((name)::text = 'Joe'::text) + -> Index Scan using i_B_B_ID on B (cost=0.00..254387.31 rows=328137 width=8) (actual time=51.985..15566.896 rows=302175 loops=1) + Index Cond: (B.B_ID = "outer".B_ID) + -> Index Scan using pk_A_test on A (cost=0.00..4.23 rows=1 width=4) (actual time=6.407..6.412 rows=1 loops=302175) + Index Cond: (A.A_ID = "outer".A_ID) + Total runtime: 1961200.079 ms + + +TABLE DEFINITIONS: +------------------ + +xxx => \d a + Table "xxx.a" + Column | Type | Modifiers +-------------------+------------------------+----------- + a_id | integer | not null + ... more columns + +Indexes: + "pk_a_id" PRIMARY KEY, btree (a_id) + ... more indexes on other columns + +xxx => \d b + Table "xxx.b" + Column | Type | Modifiers +--------------------------+------------------------+----------- + b_id | integer | not null + a_id | integer | not null + c_id | integer | not null + ... more columns + +Indexes: + "b_pkey" PRIMARY KEY, btree (b_id) + "i_b_a_id" btree (a_id) + "i_b_c_id" btree (c_id) + + +xxx=> \d c + Table "xxx.c" + Column | Type | Modifiers +---------------+------------------------+----------- + c_id | integer | not null + name | character varying(200) | + ... more columns +Indexes: + "c_pkey" PRIMARY KEY, btree (c_id) + +From pgsql-performance-owner@postgresql.org Tue Feb 21 02:34:05 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id BD8049DCDD0 + for ; + Tue, 21 Feb 2006 02:34:02 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 03043-10 + for ; + Tue, 21 Feb 2006 02:34:02 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.auptyma.com (64-60-124-12.cust.telepacific.net + [64.60.124.12]) by postgresql.org (Postfix) with ESMTP id B40B89DCDCC + for ; + Tue, 21 Feb 2006 02:33:58 -0400 (AST) +Received: from demo1 (64-60-124-12.cust.telepacific.net [64.60.124.12]) + (authenticated bits=0) + by mail.auptyma.com (8.13.1/8.13.1) with ESMTP id k1L6CAWu023937 + (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO); + Mon, 20 Feb 2006 22:12:10 -0800 +Message-ID: <02a101c636b0$c08e19c0$3100000a@demo1> +From: "Virag Saksena" +To: "Tom Lane" +Cc: +References: <028401c636a5$907fb4b0$3100000a@demo1> + <4360.1140500155@sss.pgh.pa.us> +Subject: Re: Cost Issue - How do I force a Hash Join +Date: Mon, 20 Feb 2006 22:33:39 -0800 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2600.0000 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 +X-Greylist: Sender succeded SMTP AUTH authentication, not delayed by + milter-greylist-1.7.5 (mail.auptyma.com [10.0.0.47]); + Mon, 20 Feb 2006 22:12:11 -0800 (PST) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.09 required=5 tests=[AWL=0.090] +X-Spam-Score: 0.09 +X-Spam-Level: +X-Archive-Number: 200602/326 +X-Sequence-Number: 17312 + +Tables are analyzed, though I would love to find a way to increase it's +accuracy of statistics +Tried raising the statistics target upto 100, but it did not help. Should I +bump it even more + +However I found that if I add depth to the group by clauses, it somehow +tells the optimizer that it would get more than 1 row +and it goes to a Hash Join .... +For this query, only rows with one value of depth are accessed, so we are +okay ... but I would like to see if there is some other +way I can get a better approximation for the costs + + Sort (cost=25214.36..25214.39 rows=10 width=958) (actual +time=9798.860..9815.670 rows=6115 loops=1) + Sort Key: (o1.totmem - COALESCE(o2.totmem, 0::bigint)) + ->Hash Left Join (cost=25213.83..25214.19 rows=10 width=958) (actual +time=8526.248..9755.721 rows=6115 loops=1) + Hash Cond: ((("outer".objsig)::text = ("inner".objsig)::text) AND +(("outer".objtype)::text = ("inner".objtype)::text) AND +(("outer".fieldname)::text = ("inner".fieldname)::text)) + ->Subquery Scan o1 (cost=18993.48..18993.66 rows=10 width=990) (actual +time=6059.880..6145.223 rows=6115 loops=1) + ->HashAggregate (cost=18993.48..18993.56 rows=10 width=46) (actual +time=6059.871..6094.897 rows=6115 loops=1) + ->Nested Loop (cost=0.00..18993.22 rows=15 width=46) (actual +time=45.510..5980.807 rows=6338 loops=1) + ->Index Scan using jam_heaprel_n1 on jam_heaprel ar +(cost=0.00..18932.01 rows=10 width=19) (actual time=45.374..205.520 +rows=6338 loops=1) + Index Cond: ((heap_id = 1) AND (parentaddr = 0)) + Filter: ((fieldname)::text = 'K'::text) + ->Index Scan using jam_heapobj_u1 on jam_heapobj ao +(cost=0.00..6.10 rows=2 width=43) (actual time=0.885..0.890 rows=1 +loops=6338) + Index Cond: ((ao.heap_id = 1) AND (ao.objaddr = +"outer".childaddr)) + ->Hash (cost=6220.34..6220.34 rows=2 width=982) (actual +time=2466.178..2466.178 rows=0 loops=1) + ->Subquery Scan o2 (cost=6220.30..6220.34 rows=2 width=982) (actual +time=2225.242..2433.744 rows=6038 loops=1) + ->HashAggregate (cost=6220.30..6220.32 rows=2 width=46) (actual +time=2225.233..2366.890 rows=6038 loops=1) + ->Nested Loop (cost=0.00..6220.27 rows=2 width=46) (actual +time=0.449..2149.257 rows=6259 loops=1) + ->Index Scan using jam_heaprel_n1 on jam_heaprel br +(cost=0.00..6202.89 rows=4 width=19) (actual time=0.296..51.310 rows=6259 +loops=1) + Index Cond: ((heap_id = 0) AND (parentaddr = 0)) + Filter: ((fieldname)::text = 'K'::text) + ->Index Scan using jam_heapobj_u1 on jam_heapobj bo +(cost=0.00..4.33 rows=1 width=43) (actual time=0.294..0.300 rows=1 +loops=6259) + Index Cond: ((bo.heap_id = 0) AND (bo.objaddr = +"outer".childaddr)) + Total runtime: 9950.192 ms + +Regards, + +Virag + +----- Original Message ----- +From: "Tom Lane" +To: "Virag Saksena" +Cc: +Sent: Monday, February 20, 2006 9:35 PM +Subject: Re: [PERFORM] Cost Issue - How do I force a Hash Join + + +> "Virag Saksena" writes: +> > The individual queries run in 50-300 ms. However the optimizer is = +> > choosing a nested loop to join them rather than a Hash join +> > causing the complete query to take 500+ seconds. It expects that it will += +> > get 1 row out from each of the sources, but here is gets +> > several thousand rows. +> +> The best approach is to see if you can't fix that estimation error. +> Are the stats up to date on these tables? If so, maybe raising the +> statistics targets would help. +> +> regards, tom lane +> + + +From pgsql-performance-owner@postgresql.org Tue Feb 21 11:57:16 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 144C99DC9C7 + for ; + Tue, 21 Feb 2006 11:57:16 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 95886-05 + for ; + Tue, 21 Feb 2006 11:57:20 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.206]) + by postgresql.org (Postfix) with ESMTP id 93F379DC9A7 + for ; + Tue, 21 Feb 2006 11:57:13 -0400 (AST) +Received: by zproxy.gmail.com with SMTP id r28so1264060nza + for ; + Tue, 21 Feb 2006 07:57:15 -0800 (PST) +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=lbap1k8dXPtXrRCtILlpu2h9Vp1Tp3yM2C59WtOLdzjDBmYn2kvZboBhqwAkp3/eMDEcWpsi/ZsnfU4FWnKC7Tg8hqu0oXzXhH0w7XiIy2EYJueHVqRl3UTJ07jqqB6q3egywqrZbNI+Dha7haxWdGAsWmSe0gBHiYDFCQWVWKU= +Received: by 10.36.43.6 with SMTP id q6mr7220970nzq; + Tue, 21 Feb 2006 07:57:12 -0800 (PST) +Received: by 10.36.106.12 with HTTP; Tue, 21 Feb 2006 07:57:12 -0800 (PST) +Message-ID: +Date: Tue, 21 Feb 2006 17:57:12 +0200 +From: "Ibrahim Tekin" +To: pgsql-performance@postgresql.org +Subject: LIKE query on indexes +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_22470_31490145.1140537432544" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.76 required=5 tests=[AWL=0.116, HTML_00_10=0.642, + HTML_MESSAGE=0.001] +X-Spam-Score: 0.76 +X-Spam-Level: +X-Archive-Number: 200602/327 +X-Sequence-Number: 17313 + +------=_Part_22470_31490145.1140537432544 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +hi, +i have btree index on a text type field. i want see rows which starts with +certain characters on that field. so i write a query like this: + +SELECT * FROM mytable WHERE myfield LIKE 'john%' + +since this condition is from start of the field, query planner should use +index to find such elements but explain command shows me it will do a +sequential scan. + +is this lack of a feature or i am wrong somewhere? + +------=_Part_22470_31490145.1140537432544 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +hi,
i have btree index on a text type field. i want see rows which start= +s with certain characters on that field. so i write a query like this:
<= +br>SELECT * FROM mytable WHERE myfield LIKE 'john%'

since this condi= +tion is from start of the field, query planner should use index to find suc= +h elements but explain command shows me it will do a sequential scan. +

is this lack of a feature or i am wrong somewhere?
+ +------=_Part_22470_31490145.1140537432544-- + +From pgsql-performance-owner@postgresql.org Tue Feb 21 12:18:04 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 16D089DC83D + for ; + Tue, 21 Feb 2006 12:18:04 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 99934-04 + for ; + Tue, 21 Feb 2006 12:18:02 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id B68569DC82A + for ; + Tue, 21 Feb 2006 12:18:01 -0400 (AST) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Tue, 21 Feb 2006 16:18:00 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 21 Feb 2006 10:18:00 -0600 +Subject: Re: LIKE query on indexes +From: Scott Marlowe +To: Ibrahim Tekin +Cc: pgsql-performance@postgresql.org +In-Reply-To: +References: +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1140538679.5777.3.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Tue, 21 Feb 2006 10:18:00 -0600 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.158 required=5 tests=[AWL=0.157, + UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 0.158 +X-Spam-Level: +X-Archive-Number: 200602/328 +X-Sequence-Number: 17314 + +On Tue, 2006-02-21 at 09:57, Ibrahim Tekin wrote: +> hi, +> i have btree index on a text type field. i want see rows which starts +> with certain characters on that field. so i write a query like this: +> +> SELECT * FROM mytable WHERE myfield LIKE 'john%' +> +> since this condition is from start of the field, query planner should +> use index to find such elements but explain command shows me it will +> do a sequential scan. +> +> is this lack of a feature or i am wrong somewhere? + +This is an artifact of how PostgreSQL handles locales other than ASCII. + +If you want such a query to use an index, you need to back up your +database, and re-initdb with --locale=C as an argument. Note that you +then will NOT get locale specific matching and sorting. + +From pgsql-performance-owner@postgresql.org Tue Feb 21 12:34:22 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 784639DC82A + for ; + Tue, 21 Feb 2006 12:34:21 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 00749-06 + for ; + Tue, 21 Feb 2006 12:34:19 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx2.surnet.cl (mx2.surnet.cl [216.155.73.181]) + by postgresql.org (Postfix) with ESMTP id 4D0409DC9DD + for ; + Tue, 21 Feb 2006 12:34:18 -0400 (AST) +Received: from unknown (HELO cluster.surnet.cl) ([216.155.73.165]) + by mx2.surnet.cl with ESMTP; 21 Feb 2006 13:53:44 -0300 +X-IronPort-AV: i="3.99,385,1131332400"; + d="scan'208"; a="29103468:sNHT18527272" +Received: from alvh.no-ip.org (201.220.122.204) by cluster.surnet.cl (7.0.043) + (authenticated as alvherre@surnet.cl) + id 43A978FD007C15AF; Tue, 21 Feb 2006 13:34:17 -0300 +Received: by alvh.no-ip.org (Postfix, from userid 1000) + id F17B8C2C2DD; Tue, 21 Feb 2006 13:34:16 -0300 (CLST) +Date: Tue, 21 Feb 2006 13:34:16 -0300 +From: Alvaro Herrera +To: Scott Marlowe +Cc: Ibrahim Tekin , pgsql-performance@postgresql.org +Subject: Re: LIKE query on indexes +Message-ID: <20060221163416.GC6541@surnet.cl> +Mail-Followup-To: Scott Marlowe , + Ibrahim Tekin , pgsql-performance@postgresql.org +References: + <1140538679.5777.3.camel@state.g2switchworks.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1140538679.5777.3.camel@state.g2switchworks.com> +User-Agent: Mutt/1.5.11+cvs20060126 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=1.743 required=5 tests=[AWL=-0.176, + DNS_FROM_RFC_ABUSE=0.479, DNS_FROM_RFC_POST=1.44] +X-Spam-Score: 1.743 +X-Spam-Level: * +X-Archive-Number: 200602/329 +X-Sequence-Number: 17315 + +Scott Marlowe wrote: +> On Tue, 2006-02-21 at 09:57, Ibrahim Tekin wrote: +> > hi, +> > i have btree index on a text type field. i want see rows which starts +> > with certain characters on that field. so i write a query like this: +> > +> > SELECT * FROM mytable WHERE myfield LIKE 'john%' +> > +> > since this condition is from start of the field, query planner should +> > use index to find such elements but explain command shows me it will +> > do a sequential scan. +> > +> > is this lack of a feature or i am wrong somewhere? +> +> This is an artifact of how PostgreSQL handles locales other than ASCII. +> +> If you want such a query to use an index, you need to back up your +> database, and re-initdb with --locale=C as an argument. + +... or you can choose to create an index with the text_pattern_ops +operator class, which would be used in a LIKE constraint regardless of +locale. + +http://www.postgresql.org/docs/8.1/static/indexes-opclass.html + +-- +Alvaro Herrera http://www.CommandPrompt.com/ +The PostgreSQL Company - Command Prompt, Inc. + +From pgsql-performance-owner@postgresql.org Tue Feb 21 12:42:28 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id B82149DC82A + for ; + Tue, 21 Feb 2006 12:42:27 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 00863-09 + for ; + Tue, 21 Feb 2006 12:42:25 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id 322839DC86D + for ; + Tue, 21 Feb 2006 12:42:25 -0400 (AST) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Tue, 21 Feb 2006 16:42:24 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 21 Feb 2006 10:42:24 -0600 +Subject: Re: LIKE query on indexes +From: Scott Marlowe +To: Alvaro Herrera +Cc: Ibrahim Tekin , pgsql-performance@postgresql.org +In-Reply-To: <20060221163416.GC6541@surnet.cl> +References: + <1140538679.5777.3.camel@state.g2switchworks.com> + <20060221163416.GC6541@surnet.cl> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1140540144.5777.5.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Tue, 21 Feb 2006 10:42:24 -0600 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.157 required=5 tests=[AWL=0.156, + UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 0.157 +X-Spam-Level: +X-Archive-Number: 200602/330 +X-Sequence-Number: 17316 + +On Tue, 2006-02-21 at 10:34, Alvaro Herrera wrote: +> Scott Marlowe wrote: +> > On Tue, 2006-02-21 at 09:57, Ibrahim Tekin wrote: +> > > hi, +> > > i have btree index on a text type field. i want see rows which starts +> > > with certain characters on that field. so i write a query like this: +> > > +> > > SELECT * FROM mytable WHERE myfield LIKE 'john%' +> > > +> > > since this condition is from start of the field, query planner should +> > > use index to find such elements but explain command shows me it will +> > > do a sequential scan. +> > > +> > > is this lack of a feature or i am wrong somewhere? +> > +> > This is an artifact of how PostgreSQL handles locales other than ASCII. +> > +> > If you want such a query to use an index, you need to back up your +> > database, and re-initdb with --locale=C as an argument. +> +> ... or you can choose to create an index with the text_pattern_ops +> operator class, which would be used in a LIKE constraint regardless of +> locale. +> +> http://www.postgresql.org/docs/8.1/static/indexes-opclass.html + +Good point. I tend to view the world from the perspective of the 7.4 +and before user... + + +From pgsql-performance-owner@postgresql.org Tue Feb 21 13:40:24 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id CE7B19DC83D + for ; + Tue, 21 Feb 2006 13:40:23 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 12252-04 + for ; + Tue, 21 Feb 2006 13:40:22 -0400 (AST) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 923E89DC871 + for ; + Tue, 21 Feb 2006 13:40:21 -0400 (AST) +Received: from mail.envysolutions.com (mark.mielke.cc [206.248.142.186]) + by svr4.postgresql.org (Postfix) with ESMTP id B36F15AF078 + for ; + Tue, 21 Feb 2006 17:40:19 +0000 (GMT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mail.envysolutions.com (Postfix) with ESMTP id 6A2451CCF5; + Tue, 21 Feb 2006 12:40:48 -0500 (EST) +Received: from mail.envysolutions.com ([127.0.0.1]) + by localhost (mark.mielke.cc [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 07931-05; Tue, 21 Feb 2006 12:40:48 -0500 (EST) +Received: by mail.envysolutions.com (Postfix, from userid 500) + id 545541CE15; Tue, 21 Feb 2006 12:40:48 -0500 (EST) +Date: Tue, 21 Feb 2006 12:40:48 -0500 +From: mark@mark.mielke.cc +To: Ibrahim Tekin +Cc: pgsql-performance@postgresql.org +Subject: Re: LIKE query on indexes +Message-ID: <20060221174048.GA8108@mark.mielke.cc> +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned: amavisd-new at mail.envysolutions.com +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.659 required=5 tests=[AWL=0.109, NO_REAL_NAME=0.55] +X-Spam-Score: 0.659 +X-Spam-Level: +X-Archive-Number: 200602/331 +X-Sequence-Number: 17317 + +On Tue, Feb 21, 2006 at 05:57:12PM +0200, Ibrahim Tekin wrote: +> i have btree index on a text type field. i want see rows which starts with +> certain characters on that field. so i write a query like this: +> SELECT * FROM mytable WHERE myfield LIKE 'john%' +> since this condition is from start of the field, query planner should use +> index to find such elements but explain command shows me it will do a +> sequential scan. +> is this lack of a feature or i am wrong somewhere? + +Is the query fast enough? How big is your table? What does explain +analyze select tell you? + +Cheers, +mark + +-- +mark@mielke.cc / markm@ncf.ca / markm@nortel.com __________________________ +. . _ ._ . . .__ . . ._. .__ . . . .__ | Neighbourhood Coder +|\/| |_| |_| |/ |_ |\/| | |_ | |/ |_ | +| | | | | \ | \ |__ . | | .|. |__ |__ | \ |__ | Ottawa, Ontario, Canada + + One ring to rule them all, one ring to find them, one ring to bring them all + and in the darkness bind them... + + http://mark.mielke.cc/ + + +From pgsql-performance-owner@postgresql.org Tue Feb 21 16:12:24 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 654979DCA07 + for ; + Tue, 21 Feb 2006 16:12:22 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37902-02 + for ; + Tue, 21 Feb 2006 16:12:22 -0400 (AST) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id A98549DCA14 + for ; + Tue, 21 Feb 2006 16:12:19 -0400 (AST) +Received: from PHOENIX.istructure.com (mail.istructure.com [24.199.154.122]) + by svr4.postgresql.org (Postfix) with ESMTP id 3CF8B5AF090 + for ; + Tue, 21 Feb 2006 20:12:19 +0000 (GMT) +Content-class: urn:content-classes:message +Subject: Help with nested loop left join performance +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Date: Tue, 21 Feb 2006 15:12:03 -0500 +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Message-ID: <1B1B254441DB31448BD34C5BD73B0B8B28FBF6@PHOENIX.istructure.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: Help with nested loop left join performance +Thread-Index: AcY3IxSB9XbHxXv6Sd+UJpqEYkWq5w== +From: "George Woodring" +To: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.152 required=5 tests=[AWL=0.152] +X-Spam-Score: 0.152 +X-Spam-Level: +X-Archive-Number: 200602/333 +X-Sequence-Number: 17319 + +I am running 7.4.8 and have a query that I have been running for a while +that has recently have experienced a slowdown. The original query +involves a UNION but I have narrowed it down to this half of the query +as being my issue. (The other half take 4 seconds). + +The only issue that I have had is index bloat which I had to reindex the +entire cluster to get rid of. My query has been slow since the start of +the index bloat. + +Thanks in advance + +Woody + + + + +explain analyze SELECT column1, column2, column3, column4, column5, +column6, column7, column8 FROM (SELECT CASE status WHEN 0 THEN 0 WHEN 1 +THEN 1 ELSE -1 END AS column1, mac AS column2, account AS column3, +number || ' ' || address AS column4, 'qmod' || '.' || 'dmod' AS column5, +node AS column6, grid AS column7, boxtype AS column8, number, address +FROM settop_billing LEFT OUTER JOIN (dhct JOIN dhct_davic USING(mac)) +USING (mac) WHERE region=3D'GTown1E' AND node=3D'1E012' ) AS foo; + +=20 +QUERY PLAN + +------------------------------------------------------------------------ +------------------------------------------------------------------------ +-------------- + Nested Loop Left Join (cost=3D38659.85..55988.94 rows=3D2 width=3D84) +(actual time=3D14054.297..294973.046 rows=3D418 loops=3D1) + Join Filter: ("outer".mac =3D "inner".mac) + -> Index Scan using settop_billing_region_node_index on +settop_billing (cost=3D0.00..7.99 rows=3D2 width=3D82) (actual +time=3D0.115..8.582 rows=3D418 loops=3D1) Index Cond: = +(((region)::text +=3D 'GTown1E'::text) AND ((node)::text =3D '1E012'::text)) + -> Materialize (cost=3D38659.85..42508.98 rows=3D384913 width=3D8) +(actual time=3D2.211..286.267 rows=3D382934 loops=3D418) + -> Hash Join (cost=3D14784.66..38659.85 rows=3D384913 = +width=3D8) +(actual time=3D923.855..13647.840 rows=3D382934 loops=3D1) + Hash Cond: ("outer".mac =3D "inner".mac) + -> Append (cost=3D0.00..8881.11 rows=3D384912 = +width=3D8) +(actual time=3D0.023..10914.365 rows=3D384900 loops=3D1) + -> Seq Scan on dhct_davic (cost=3D0.00..0.00 = +rows=3D1 +width=3D8) (actual time=3D0.002..0.002 rows=3D0 loops=3D1) + -> Seq Scan on probe_dhct_davic dhct_davic +(cost=3D0.00..8881.11 rows=3D384911 width=3D8) (actual = +time=3D0.018..10505.255 +rows=3D384900 loops=3D1) + -> Hash (cost=3D12154.13..12154.13 rows=3D410613 = +width=3D6) +(actual time=3D923.433..923.433 rows=3D0 loops=3D1) + -> Seq Scan on dhct (cost=3D0.00..12154.13 +rows=3D410613 width=3D6) (actual time=3D0.019..534.641 rows=3D409576 = +loops=3D1) + Total runtime: 294994.440 ms +(13 rows) + +The tables involved are defined as follows: + + Table +"public.settop_billing" + Column | Type | +Modifiers +-----------------+------------------------+----------------------------- +--------------------------------------------------- + cable_billingid | integer | not null default +nextval('public.new_cable_billing_cable_billingid_seq'::text) + mac | macaddr | not null + account | character varying(20) | + number | character varying(12) | + address | character varying(200) | + name | character varying(100) | + phone | character varying(10) | + region | character varying(30) | + node | character varying(10) | + grid | character varying(15) | + lat | numeric | + long | numeric | + boxtype | character(1) | +Indexes: + "settop_billing_mac_index" unique, btree (mac) + "settop_billing_account_index" btree (account) + "settop_billing_lat_log_index" btree (lat, long) + "settop_billing_region_node_index" btree (region, node) +Inherits: cable_billing + + Table "public.dhct" + Column | Type | Modifiers +------------+-----------------------+----------------------------------- +-------- + dhctid | integer | not null default +nextval('dhct_id'::text) + mac | macaddr | not null + ip | inet | + serial | macaddr | + admin_stat | integer | + oper_stat | integer | + qmod | character varying(50) | + dmod | integer | + hub | character varying(50) | + dncs | character varying(50) | + auth | text | + updtime | integer | +Indexes: + "dhct_pkey" primary key, btree (mac) + "dhct_qmod_index" btree (qmod) +=20 + Table "iprobe024.probe_dhct_davic" + Column | Type | Modifiers +---------+-----------------------+-------------------------------------- +---------------------- + davicid | integer | not null default +nextval('public.davic_davicid_seq'::text) + mac | macaddr | not null + type | character varying(10) | default 'davic'::character varying + source | character varying(20) | + status | smallint | + updtime | integer | + avail1 | integer | +Indexes: + "probe_dhct_davic_mac_index" unique, btree (mac) +Inherits: dhct_davic +=20 + +---------------------------------------- +iGLASS Networks +211-A S. Salem St +Apex NC 27502 +(919) 387-3550 x813 +www.iglass.net + +From pgsql-performance-owner@postgresql.org Tue Feb 21 16:12:19 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 3EB7C9DCA07 + for ; + Tue, 21 Feb 2006 16:12:19 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 36940-07 + for ; + Tue, 21 Feb 2006 16:12:19 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.202]) + by postgresql.org (Postfix) with ESMTP id 7CF2C9DCA5E + for ; + Tue, 21 Feb 2006 16:12:16 -0400 (AST) +Received: by zproxy.gmail.com with SMTP id v1so1325985nzb + for ; + Tue, 21 Feb 2006 12:12:17 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; + b=jp0wAxE1Q6z9yIZYosUu38pMfuY9Ov/OzylyPRfwyHRCa5OVCdAd7E0px7hAT/Xg0wDS4MgloMgyk68TWes2rBCBrDAnh2oeBxhTBgsCRwroEOq/JydQqG1j5PMAc5uuNE25DsXB+x49TcrcHaZs/GKCWob9CiAB7bcPONp/5Ic= +Received: by 10.36.90.14 with SMTP id n14mr1409436nzb; + Tue, 21 Feb 2006 12:12:17 -0800 (PST) +Received: by 10.36.106.12 with HTTP; Tue, 21 Feb 2006 12:12:17 -0800 (PST) +Message-ID: +Date: Tue, 21 Feb 2006 22:12:17 +0200 +From: "Ibrahim Tekin" +To: "mark@mark.mielke.cc" +Subject: Re: LIKE query on indexes +Cc: pgsql-performance@postgresql.org +In-Reply-To: <20060221174048.GA8108@mark.mielke.cc> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_25273_32919795.1140552737301" +References: + <20060221174048.GA8108@mark.mielke.cc> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.44 required=5 tests=[AWL=0.439, HTML_MESSAGE=0.001] +X-Spam-Score: 0.44 +X-Spam-Level: +X-Archive-Number: 200602/332 +X-Sequence-Number: 17318 + +------=_Part_25273_32919795.1140552737301 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +my database encoding is unicode. +i have two table, one is 3.64gb on hdd and has 2.2 million records. it take= +s +140 secs to run on my AMD Turion 64 M 800MHz/1GB laptop. +second table is 1.2gb, 220000 records, and takes 56 secs to run. + +explain says 'Seq Scan on mytable, ..' + +On 2/21/06, mark@mark.mielke.cc wrote: +> +> On Tue, Feb 21, 2006 at 05:57:12PM +0200, Ibrahim Tekin wrote: +> > i have btree index on a text type field. i want see rows which starts +> with +> > certain characters on that field. so i write a query like this: +> > SELECT * FROM mytable WHERE myfield LIKE 'john%' +> > since this condition is from start of the field, query planner should +> use +> > index to find such elements but explain command shows me it will do a +> > sequential scan. +> > is this lack of a feature or i am wrong somewhere? +> +> Is the query fast enough? How big is your table? What does explain +> analyze select tell you? +> +> Cheers, +> mark +> +> -- +> mark@mielke.cc / markm@ncf.ca / markm@nortel.com +> __________________________ +> . . _ ._ . . .__ . . ._. .__ . . . .__ | Neighbourhood Coder +> |\/| |_| |_| |/ |_ |\/| | |_ | |/ |_ | +> | | | | | \ | \ |__ . | | .|. |__ |__ | \ |__ | Ottawa, Ontario, +> Canada +> +> One ring to rule them all, one ring to find them, one ring to bring the= +m +> all +> and in the darkness bind them... +> +> http://mark.mielke.cc/ +> +> + +------=_Part_25273_32919795.1140552737301 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +my database encoding is unicode.
+i have two table, one is 3.64gb on hdd and has 2.2 million records. it take= +s 140 secs to run on my AMD Turion 64 M 800MHz/1GB laptop.
second table = +is 1.2gb, 220000 records, and takes 56 secs to run.

explain says 'Se= +q Scan on mytable, ..' +

On 2/21/06, mark@mark.mielke.cc = +<mark@mark.mielke.cc> wrot= +e: +
On Tue, Feb 21, 2= +006 at 05:57:12PM +0200, Ibrahim Tekin wrote:
> i have btree index on= + a text type field. i want see rows which starts with +
> certain characters on that field. so i write a query like this:>     SELECT * FROM mytable WHERE myfield LIKE 'joh= +n%'
> since this condition is from start of the field, query planner = +should use
> index to find such elements but explain command shows me= + it will do a +
> sequential scan.
> is this lack of a feature or i am wrong s= +omewhere?

Is the query fast enough? How big is your table? What does= + explain
analyze select tell you?

Cheers,
mark

--
+mark@mielke.cc / markm@ncf.ca / markm@no= +rtel.com     __________________________
. &= +nbsp;.  _  ._  . .   .__  = +;  .  . ._. .__ .   . . .__  | Neig= +hbourhood Coder +
|\/| |_| |_| |/    |_     |\/|&= +nbsp; |  |_  |   |/  |_ &= +nbsp; |
|  | | | | \ | \   |__ .  | &= +nbsp;| .|. |__ |__ | \ |__  | Ottawa, Ontario, Canada

&nbs= +p; One ring to rule them all, one ring to find them, one ring to bring= + them all +
            = +;           and in the da= +rkness bind them...

        = +            &nb= +sp;      http:/= +/mark.mielke.cc/


+ +------=_Part_25273_32919795.1140552737301-- + +From pgsql-performance-owner@postgresql.org Tue Feb 21 16:28:16 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 1A14B9DCA1C + for ; + Tue, 21 Feb 2006 16:28:15 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 40217-02 + for ; + Tue, 21 Feb 2006 16:28:15 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.193]) + by postgresql.org (Postfix) with ESMTP id 3E7369DCA4B + for ; + Tue, 21 Feb 2006 16:28:10 -0400 (AST) +Received: by zproxy.gmail.com with SMTP id n1so1334284nzf + for ; + Tue, 21 Feb 2006 12:28:12 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; + b=dMLXK7yZO+VL98f6XeQSuuV8yfLR9MCo2qZCsOaNj/y1zTzKVI/4ZKRXFS9hDcOfJtlMl63KhvSfWBoU5vFn+LeeVnLB0EVJDa2qLZ6amMThLR2y68e5z4rtM93DzL07hb+1f/BexkiiOfxasxkSFI9PaZF7oHy7E2HdZdoLybA= +Received: by 10.36.247.33 with SMTP id u33mr4982047nzh; + Tue, 21 Feb 2006 12:28:09 -0800 (PST) +Received: by 10.36.106.12 with HTTP; Tue, 21 Feb 2006 12:28:09 -0800 (PST) +Message-ID: +Date: Tue, 21 Feb 2006 22:28:09 +0200 +From: "Ibrahim Tekin" +To: "Scott Marlowe" , + "Ibrahim Tekin" , pgsql-performance@postgresql.org +Subject: Re: LIKE query on indexes +In-Reply-To: <20060221163416.GC6541@surnet.cl> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_25486_19611329.1140553689280" +References: + <1140538679.5777.3.camel@state.g2switchworks.com> + <20060221163416.GC6541@surnet.cl> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.36 required=5 tests=[AWL=0.359, HTML_MESSAGE=0.001] +X-Spam-Score: 0.36 +X-Spam-Level: +X-Archive-Number: 200602/334 +X-Sequence-Number: 17320 + +------=_Part_25486_19611329.1140553689280 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +this trick did the job. +thanks. + +On 2/21/06, Alvaro Herrera wrote: +> +> Scott Marlowe wrote: +> > On Tue, 2006-02-21 at 09:57, Ibrahim Tekin wrote: +> > > hi, +> > > i have btree index on a text type field. i want see rows which starts +> > > with certain characters on that field. so i write a query like this: +> > > +> > > SELECT * FROM mytable WHERE myfield LIKE 'john%' +> > > +> > > since this condition is from start of the field, query planner should +> > > use index to find such elements but explain command shows me it will +> > > do a sequential scan. +> > > +> > > is this lack of a feature or i am wrong somewhere? +> > +> > This is an artifact of how PostgreSQL handles locales other than ASCII. +> > +> > If you want such a query to use an index, you need to back up your +> > database, and re-initdb with --locale=3DC as an argument. +> +> ... or you can choose to create an index with the text_pattern_ops +> operator class, which would be used in a LIKE constraint regardless of +> locale. +> +> http://www.postgresql.org/docs/8.1/static/indexes-opclass.html +> +> -- +> Alvaro Herrera +> http://www.CommandPrompt.com/ +> The PostgreSQL Company - Command Prompt, Inc. +> + +------=_Part_25486_19611329.1140553689280 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +this trick did the job.
thanks.

On 2/21/06, Alvaro Herrera <alvherre@commandprompt.com> w= +rote: +
Scott Marl= +owe wrote:
> On Tue, 2006-02-21 at 09:57, Ibrahim Tekin wrote:
>= +; > hi, +
> > i have btree index on a text type field. i want see rows whic= +h starts
> > with certain characters on that field. so i write a q= +uery like this:
> >
> > SELECT * FROM mytable WHERE myfie= +ld LIKE 'john%' +
> >
> > since this condition is from start of the field,= + query planner should
> > use index to find such elements but expl= +ain command shows me it will
> > do a sequential scan.
> >= +; +
> > is this lack of a feature or i am wrong somewhere?
>> This is an artifact of how PostgreSQL handles locales other than ASCI= +I.
>
> If you want such a query to use an index, you need to ba= +ck up your +
> database, and re-initdb with --locale=3DC as an argument.

.= +.. or you can choose to create an index with the text_pattern_ops
operat= +or class, which would be used in a LIKE constraint regardless of
locale. +

http://www.postgresql.org/docs/8.1/static/indexes-opclass.html<= +br>
--
Alvaro Herrera        = +            &nb= +sp;            +http://www.CommandPrompt.com/
The PostgreSQL Company - Command Promp= +t, Inc.

+ +------=_Part_25486_19611329.1140553689280-- + +From pgsql-performance-owner@postgresql.org Tue Feb 21 20:15:02 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 238A89DC860 + for ; + Tue, 21 Feb 2006 20:15:01 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 76207-05 + for ; + Tue, 21 Feb 2006 20:15:01 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 31B039DC857 + for ; + Tue, 21 Feb 2006 20:14:55 -0400 (AST) +Received: by noel.decibel.org (Postfix, from userid 1001) + id CD45656412; Tue, 21 Feb 2006 18:14:56 -0600 (CST) +Received: (hashcash-sendmail, from uid 1001); Tue, 21 Feb 2006 18:14:56 -0600 +Date: Tue, 21 Feb 2006 18:14:56 -0600 +From: "Jim C. Nasby" +To: andrew@pillette.com +Cc: pgsql-performance@postgresql.org +Subject: Re: How to optimize a JOIN with BETWEEN? +Message-ID: <20060222001456.GZ77800@pervasive.com> +References: <200602200406.k1K46CB09448@pillette.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <200602200406.k1K46CB09448@pillette.com> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060222:andrew@pillette.com::vFm9cYU8FU+Nqn8Y:000000000000000000 + 00000000000000000000000026r1 +X-Hashcash: + 1:20:060222:pgsql-performance@postgresql.org::SQUlId0lXKQ2nKtg:00000 + 0000000000000000000000005YUY +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.104 required=5 tests=[AWL=0.104] +X-Spam-Score: 0.104 +X-Spam-Level: +X-Archive-Number: 200602/335 +X-Sequence-Number: 17321 + +Use a gist index. Easiest way would be to define a box with mindate at +one corner and maxdate at the other corner, and then search for +point(obsdate,obsdate) that lie with in the box. + +A more detailed explination is in the archives somewhere... + +On Sun, Feb 19, 2006 at 08:06:12PM -0800, andrew@pillette.com wrote: +> Here's a simplified version of the schema: +> +> Table A has an ID field, an observation date, and other stuff. There are about 20K IDs and 3K observations per ID. Table B has a matching ID field, minimum and maximum dates, a code, and other stuff, about 0-50 records per ID. For a given ID, the dates in B never overlap. On A, the PK is (id, obsdate). On B, the PK is (id, mindate). I want +> +> SELECT a.id, b.code, AVG(other stuff) FROM A LEFT JOIN B ON a.id=b.id AND a.obsdate BETWEEN b.mindate AND b.maxdate GROUP BY 1,2; +> +> Is there a way to smarten the query to take advantage of the fact at most one record of B matches A? Also, I have a choice between using a LEFT JOIN or inserting dummy records into B to fill in the gaps in the covered dates, which would make exactly one matching record. Would this make a difference? +> +> Thanks. +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 4: Have you searched our list archives? +> +> http://archives.postgresql.org +> + +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Wed Feb 22 05:43:41 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 04E289DCC16 + for ; + Wed, 22 Feb 2006 05:43:40 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 82445-03 + for ; + Wed, 22 Feb 2006 05:43:42 -0400 (AST) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id CD3079DCC24 + for ; + Wed, 22 Feb 2006 05:43:38 -0400 (AST) +Received: from pih-relay06.plus.net (pih-relay06.plus.net [212.159.14.133]) + by svr4.postgresql.org (Postfix) with ESMTP id 2FEDF5AF097 + for ; + Wed, 22 Feb 2006 09:43:41 +0000 (GMT) +Received: from [213.162.97.75] (helo=mail.metronet.co.uk) + by pih-relay06.plus.net with esmtp (Exim) id 1FBqWz-0000Zu-7X; + Wed, 22 Feb 2006 09:43:33 +0000 +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 68CCE414B19; Wed, 22 Feb 2006 09:38:05 +0000 (GMT) +Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP id F406C15EA6; + Wed, 22 Feb 2006 09:38:04 +0000 (GMT) +Message-ID: <43FC30FC.3080800@archonet.com> +Date: Wed, 22 Feb 2006 09:38:04 +0000 +From: Richard Huxton +User-Agent: Thunderbird 1.5 (X11/20051201) +MIME-Version: 1.0 +To: George Woodring +Cc: pgsql-performance@postgresql.org +Subject: Re: Help with nested loop left join performance +References: <1B1B254441DB31448BD34C5BD73B0B8B28FBF6@PHOENIX.istructure.com> +In-Reply-To: <1B1B254441DB31448BD34C5BD73B0B8B28FBF6@PHOENIX.istructure.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, score=0.118 required=5 tests=[AWL=0.118] +X-Spam-Score: 0.118 +X-Spam-Level: +X-Archive-Number: 200602/336 +X-Sequence-Number: 17322 + +George Woodring wrote: +> +> explain analyze SELECT column1, column2, column3, column4, column5, +> column6, column7, column8 FROM (SELECT CASE status WHEN 0 THEN 0 WHEN 1 +> THEN 1 ELSE -1 END AS column1, mac AS column2, account AS column3, +> number || ' ' || address AS column4, 'qmod' || '.' || 'dmod' AS column5, +> node AS column6, grid AS column7, boxtype AS column8, number, address +> FROM settop_billing LEFT OUTER JOIN (dhct JOIN dhct_davic USING(mac)) +> USING (mac) WHERE region='GTown1E' AND node='1E012' ) AS foo; + +Ach y fi! Let's format that a bit better, eh? + +explain analyze +SELECT column1, column2, column3, column4, column5,column6, column7, column8 +FROM ( + SELECT + CASE status WHEN 0 THEN 0 WHEN 1 THEN 1 ELSE -1 END AS column1, + mac AS column2, + account AS column3, + number || ' ' || address AS column4, + 'qmod' || '.' || 'dmod' AS column5, + node AS column6, + grid AS column7, + boxtype AS column8, + number, + address + FROM + settop_billing + LEFT OUTER JOIN + (dhct JOIN dhct_davic USING(mac)) + USING + (mac) + WHERE + region='GTown1E' AND node='1E012' +) AS foo; + +Now we can see what's happening. Well, looking at it laid out like that, +I'm suspcious of the (dhct JOIN dhct_davic) on the outside of an outer +join. Looking at your explain we do indeed have two sequential scans +over the tables in question - the big one being dhct... + +> -> Append (cost=0.00..8881.11 rows=384912 width=8) +> (actual time=0.023..10914.365 rows=384900 loops=1) +> -> Seq Scan on dhct_davic (cost=0.00..0.00 rows=1 +> width=8) (actual time=0.002..0.002 rows=0 loops=1) +> -> Seq Scan on probe_dhct_davic dhct_davic +> (cost=0.00..8881.11 rows=384911 width=8) (actual time=0.018..10505.255 +> rows=384900 loops=1) +> -> Hash (cost=12154.13..12154.13 rows=410613 width=6) +> (actual time=923.433..923.433 rows=0 loops=1) +> -> Seq Scan on dhct (cost=0.00..12154.13 +> rows=410613 width=6) (actual time=0.019..534.641 rows=409576 loops=1) + +With 7.4 I seem to remember that explicit JOINs force the evaluation +order, but I'm not if even later versions will rewrite your query. It's +too early in the morning for me to figure out if it's safe in all cases. + +Anyway, for your purposes, I'd say something more like: + FROM settop_billing LEFT JOIN dhct LEFT JOIN dhct_davic + +That should let the planner do the joins in a more reasonable order. +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Wed Feb 22 06:39:23 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id BC1799DCADB + for ; + Wed, 22 Feb 2006 06:39:22 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 86122-09 + for ; + Wed, 22 Feb 2006 06:39:24 -0400 (AST) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 454619DC9C5 + for ; + Wed, 22 Feb 2006 06:39:20 -0400 (AST) +Received: from az18nt142.honeywell.com (az18nt142.honeywell.com + [199.64.7.142]) + by svr4.postgresql.org (Postfix) with ESMTP id 468705AF03F + for ; + Wed, 22 Feb 2006 10:39:23 +0000 (GMT) +Received: from az18cn848.global.ds.honeywell.com ([131.127.167.39]) by + az18nt142.honeywell.com with InterScan Messaging Security Suite; + Wed, 22 Feb 2006 03:38:36 -0700 +Received: from AZ18EV805.global.ds.honeywell.com ([131.127.167.25]) by + az18cn848.global.ds.honeywell.com with Microsoft + SMTPSVC(6.0.3790.1830); Wed, 22 Feb 2006 03:38:50 -0700 +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_01C6379C.30113DE0" +Subject: +Date: Wed, 22 Feb 2006 03:38:58 -0700 +Message-ID: + <544485BC51F81A41AC1A72CFA69013654D93B6@AZ18EV805.global.ds.honeywell.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Index: AcY4DcrA/4/ZBn+nSdOy1kl4zCqCXA== +From: "Chethana, Rao (IE10)" +To: +X-OriginalArrivalTime: 22 Feb 2006 10:38:50.0165 (UTC) + FILETIME=[2AF34650:01C6379C] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.673 required=5 tests=[AWL=-0.673, + HTML_MESSAGE=0.001, MISSING_SUBJECT=1.345] +X-Spam-Score: 0.673 +X-Spam-Level: +X-Archive-Number: 200602/337 +X-Sequence-Number: 17323 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C6379C.30113DE0 +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: quoted-printable + +Hello! + +=20 + +This is Chethana. I need to know how to improve the performance of +postgresql. It is rich in features but slow in performance. + +Pls do reply back ASAP. + +=20 + +Thank you, + +Chethana. + +=20 + + +------_=_NextPart_001_01C6379C.30113DE0 +Content-Type: text/html; + charset="US-ASCII" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + +
+ +

Hello!

+ +

 

+ +

This is Chethana.  I need to know how to improve = +the +performance of  postgresql.    It is rich in = +features but slow in performance.

+ +

Pls do reply back ASAP.

+ +

 

+ +

Thank you,

+ +

Chethana.

+ +

 

+ +
+ + + + + +------_=_NextPart_001_01C6379C.30113DE0-- + +From pgsql-performance-owner@postgresql.org Wed Feb 22 06:47:34 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id C71279DC9B4 + for ; + Wed, 22 Feb 2006 06:47:33 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 88483-10 + for ; + Wed, 22 Feb 2006 06:47:35 -0400 (AST) +X-Greylist: delayed 01:03:55.324282 by SQLgrey- +Received: from pih-relay06.plus.net (pih-relay06.plus.net [212.159.14.133]) + by postgresql.org (Postfix) with ESMTP id 0AE3B9DC800 + for ; + Wed, 22 Feb 2006 06:47:30 -0400 (AST) +Received: from [213.162.97.75] (helo=mail.metronet.co.uk) + by pih-relay06.plus.net with esmtp (Exim) id 1FBrWv-0002Ia-9l; + Wed, 22 Feb 2006 10:47:33 +0000 +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 EA893407E00; Wed, 22 Feb 2006 10:47:25 +0000 (GMT) +Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP id 7D3AB15EA6; + Wed, 22 Feb 2006 10:47:25 +0000 (GMT) +Message-ID: <43FC413C.8090909@archonet.com> +Date: Wed, 22 Feb 2006 10:47:24 +0000 +From: Richard Huxton +User-Agent: Thunderbird 1.5 (X11/20051201) +MIME-Version: 1.0 +To: "Chethana, Rao (IE10)" +Cc: pgsql-performance@postgresql.org +Subject: Re: +References: + <544485BC51F81A41AC1A72CFA69013654D93B6@AZ18EV805.global.ds.honeywell.com> +In-Reply-To: + <544485BC51F81A41AC1A72CFA69013654D93B6@AZ18EV805.global.ds.honeywell.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, score=0.118 required=5 tests=[AWL=0.118] +X-Spam-Score: 0.118 +X-Spam-Level: +X-Archive-Number: 200602/338 +X-Sequence-Number: 17324 + +Chethana, Rao (IE10) wrote: +> +> This is Chethana. I need to know how to improve the performance of +> postgresql. It is rich in features but slow in performance. + +You'll need to provide some details first. + +How are you using PostgreSQL? +How many concurrent users? +Mostly updates or small selects or large summary reports? + +What hardware do you have? +What configuration changes have you made? + +Are you having problems with all queries or only some? +Have you checked the plans for these with EXPLAIN ANALYSE? +Have you made sure your tables are vacuumed and analysed? + +That should be a start +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Wed Feb 22 06:51:21 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 763109DCADB + for ; + Wed, 22 Feb 2006 06:51:20 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 89095-10 + for ; + Wed, 22 Feb 2006 06:51:22 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.193]) + by postgresql.org (Postfix) with ESMTP id 129729DC800 + for ; + Wed, 22 Feb 2006 06:51:17 -0400 (AST) +Received: by zproxy.gmail.com with SMTP id 34so1385089nzf + for ; + Wed, 22 Feb 2006 02:51:20 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; + b=CJY5Nh8iN2JdXebbJo5xr6MnDdvtUngoaujG/idvEhuEi4NaB1uj91IxxHRDzXNEI3WlOvUFAw2y4iHTGkyAecP4qnoNZtvMXQ1mvXPfeGN0V5VkdYuxHdaZ6vQtO+CUie2wYY8SqMFM5iiBWN1QIHZ++c4cC41gy8JtBiFwNQo= +Received: by 10.36.250.45 with SMTP id x45mr2864551nzh; + Wed, 22 Feb 2006 02:51:20 -0800 (PST) +Received: by 10.36.72.8 with HTTP; Wed, 22 Feb 2006 02:51:20 -0800 (PST) +Message-ID: <674d1f8a0602220251h250b5beet42ff7275ca116b61@mail.gmail.com> +Date: Wed, 22 Feb 2006 16:21:20 +0530 +From: "Gourish Singbal" +To: "Chethana, Rao (IE10)" +Subject: Re: +Cc: pgsql-performance@postgresql.org +In-Reply-To: + <544485BC51F81A41AC1A72CFA69013654D93B6@AZ18EV805.global.ds.honeywell.com> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_2214_4107557.1140605480487" +References: + <544485BC51F81A41AC1A72CFA69013654D93B6@AZ18EV805.global.ds.honeywell.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.132 required=5 tests=[AWL=0.131, + HTML_MESSAGE=0.001] +X-Spam-Score: 0.132 +X-Spam-Level: +X-Archive-Number: 200602/339 +X-Sequence-Number: 17325 + +------=_Part_2214_4107557.1140605480487 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +try this. + +http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html +http://www.powerpostgresql.com/PerfList + +Performance depends on the postgresql.conf parameters apart from the +hardware details. + + +On 2/22/06, Chethana, Rao (IE10) wrote: +> +> Hello! +> +> +> +> This is Chethana. I need to know how to improve the performance of +> postgresql. It is rich in features but slow in performance. +> +> Pls do reply back ASAP. +> +> +> +> Thank you, +> +> Chethana. +> +> +> + + + +-- +Best, +Gourish Singbal + +------=_Part_2214_4107557.1140605480487 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +
 
+
try this.
+
 
+ + +
Performance depends on the postgresql.conf parameters apart from the h= +ardware details.
+
 
+
 
+
On 2/22/06, = +Chethana, Rao (IE10) <= +Chethana.Rao@honeywell.com> wrote: +
+
+

Hello!

+

 

+

This is Chethana.  I need to know how to improve the perfo= +rmance of  postgresql.    It is rich in features but sl= +ow in performance. +

+

Pls do reply back ASAP.

+

 

+

Thank you,

+

Chethana.

+

 




--
Best,
Gourish Singbal=20 + +------=_Part_2214_4107557.1140605480487-- + +From pgsql-performance-owner@postgresql.org Wed Feb 22 10:24:21 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 6737B9DC806 + for ; + Wed, 22 Feb 2006 10:24:20 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 23913-01 + for ; + Wed, 22 Feb 2006 10:24:22 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from ptb-relay03.plus.net (ptb-relay03.plus.net [212.159.14.214]) + by postgresql.org (Postfix) with ESMTP id DC2D29DC877 + for ; + Wed, 22 Feb 2006 10:24:14 -0400 (AST) +Received: from [213.162.97.75] (helo=mail.metronet.co.uk) + by ptb-relay03.plus.net with esmtp (Exim) id 1FBuug-0005D8-5K; + Wed, 22 Feb 2006 14:24:18 +0000 +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 0D09740DA44; Wed, 22 Feb 2006 14:22:02 +0000 (GMT) +Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP id D7CDE15EA6; + Wed, 22 Feb 2006 14:22:01 +0000 (GMT) +Message-ID: <43FC7389.4050408@archonet.com> +Date: Wed, 22 Feb 2006 14:22:01 +0000 +From: Richard Huxton +User-Agent: Thunderbird 1.5 (X11/20051201) +MIME-Version: 1.0 +To: "Chethana, Rao (IE10)" +Cc: pgsql-performance@postgresql.org +Subject: Re: --pls reply ASAP +References: + <544485BC51F81A41AC1A72CFA690136552384E@AZ18EV805.global.ds.honeywell.com> +In-Reply-To: + <544485BC51F81A41AC1A72CFA690136552384E@AZ18EV805.global.ds.honeywell.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, score=0.121 required=5 tests=[AWL=0.121] +X-Spam-Score: 0.121 +X-Spam-Level: +X-Archive-Number: 200602/340 +X-Sequence-Number: 17326 + +Chethana, Rao (IE10) wrote: +> Hello! +> +> Thank you for responding quickly. I really need ur help. + +Please make sure you cc: the list - I don't read this inbox regularly. + +> Sir, here r the answers for ur questions, please do tell me what to do +> next(regarding increasing performance of postgresql), so that I can +> proceed further. +> +> How are you using PostgreSQL? +> We r using 7.4.3 with max of (512*6) around 3000 records. + +Max of what are (512*6)? Rows? Tables? Sorry - I don't understand what +you mean here. + +Oh, and upgrade to the latest release of 7.4.x - there are important +bugfixes. + +> How many concurrent users? +> It configures for 100, but we r using 4 or 5 only. +> +> Mostly updates or small selects or large summary reports? +> Update,delete,insert operations. +> +> What hardware do you have? +> X86 based, 233 MHz, 256 MB RAM. + +Hmm - not blazing fast, but it'll certainly run on that. + +> What configuration changes have you made? +> No changes, we've used default settings. + +That will need changing. As Gourish suggested in another reply, read the +notes here: +http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html + +You'll want to be careful with the memory settings given that you've +only got 256MB to play with. Don't allocate too much to PostgreSQL +itself, let the o.s. cache some files for you. + +> Are you having problems with all queries or only some? +> Only some queries, particularly foreign key. + +Are you happy that there are indexes on the referring side of the +foreign key where necessary? The primary keys you reference will have +indexes on them, the other side will not unless you add them yourself. + +> Have you checked the plans for these with EXPLAIN ANALYSE? +> No. + +That would be something worth doing then. Find a bad query, run EXPLAIN +ANALYSE SELECT ... and post a new question with the output and details +of the tables involved. + +> Have you made sure your tables are vacuumed and analysed? +> Yes. + +Good. With the limited amount of RAM you have, you'll want to use it as +efficiently as possible. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Wed Feb 22 11:04:13 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 2D93B9DCC0D + for ; + Wed, 22 Feb 2006 11:04:12 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25644-10 + for ; + Wed, 22 Feb 2006 11:04:16 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 98BA49DCC19 + for ; + Wed, 22 Feb 2006 11:04:09 -0400 (AST) +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 k1MF4502011674; + Wed, 22 Feb 2006 10:04:05 -0500 (EST) +To: Richard Huxton +cc: George Woodring , + pgsql-performance@postgresql.org +Subject: Re: Help with nested loop left join performance +In-reply-to: <43FC30FC.3080800@archonet.com> +References: <1B1B254441DB31448BD34C5BD73B0B8B28FBF6@PHOENIX.istructure.com> + <43FC30FC.3080800@archonet.com> +Comments: In-reply-to Richard Huxton + message dated "Wed, 22 Feb 2006 09:38:04 +0000" +Date: Wed, 22 Feb 2006 10:04:05 -0500 +Message-ID: <11673.1140620645@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.11 required=5 tests=[AWL=0.110] +X-Spam-Score: 0.11 +X-Spam-Level: +X-Archive-Number: 200602/341 +X-Sequence-Number: 17327 + +Richard Huxton writes: +> George Woodring wrote: +>> FROM +>> settop_billing +>> LEFT OUTER JOIN +>> (dhct JOIN dhct_davic USING(mac)) +>> USING +>> (mac) +>> WHERE +>> region='GTown1E' AND node='1E012' + +> With 7.4 I seem to remember that explicit JOINs force the evaluation +> order, but I'm not if even later versions will rewrite your query. It's +> too early in the morning for me to figure out if it's safe in all cases. + +CVS HEAD can re-order left joins in common cases, but no existing +release will touch the ordering of outer joins at all. + +It's impossible to tell here which tables the WHERE-clause restrictions +actually bear on, so there's no way to say whether a different join +order would help. My guess though is that George may be stuck --- in +general you can't move a join into or out of the right side of a left +join without changing the answers. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Feb 22 11:48:44 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 5E7689DCBB9 + for ; + Wed, 22 Feb 2006 11:48:43 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 33886-08 + for ; + Wed, 22 Feb 2006 11:48:47 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.clickspace.com (router2.clickspace.com [65.110.166.227]) + by postgresql.org (Postfix) with ESMTP id 72F0D9DC838 + for ; + Wed, 22 Feb 2006 11:48:40 -0400 (AST) +Received: from [10.0.1.3] ([68.147.204.179]) + (authenticated user brendan@clickspace.com) by mail.clickspace.com + (using TLSv1/SSLv3 with cipher RC4-SHA (128 bits)); + Wed, 22 Feb 2006 08:48:44 -0700 +In-Reply-To: +References: + <1140538679.5777.3.camel@state.g2switchworks.com> + <20060221163416.GC6541@surnet.cl> + +Mime-Version: 1.0 (Apple Message framework v746.2) +Content-Type: multipart/signed; micalg=sha1; boundary=Apple-Mail-2--892633001; + protocol="application/pkcs7-signature" +Message-Id: <78873B6F-1572-467C-8F98-9715FC8AC4AC@clickspace.com> +Cc: "Scott Marlowe" , + pgsql-performance@postgresql.org +From: Brendan Duddridge +Subject: Re: LIKE query on indexes +Date: Wed, 22 Feb 2006 08:48:43 -0700 +To: Ibrahim Tekin +X-Mailer: Apple Mail (2.746.2) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.105 required=5 tests=[AWL=0.104, + HTML_MESSAGE=0.001] +X-Spam-Score: 0.105 +X-Spam-Level: +X-Archive-Number: 200602/342 +X-Sequence-Number: 17328 + + +--Apple-Mail-2--892633001 +Content-Type: multipart/alternative; + boundary=Apple-Mail-1--892633558 + + +--Apple-Mail-1--892633558 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset=US-ASCII; + delsp=yes; + format=flowed + +Hi, + +Can this technique work with case insensitive ILIKE? + +It didn't seem to use the index when I used ILIKE instead of LIKE. + +Thanks, + +____________________________________________________________________ +Brendan Duddridge | CTO | 403-277-5591 x24 | brendan@clickspace.com + +ClickSpace Interactive Inc. +Suite L100, 239 - 10th Ave. SE +Calgary, AB T2G 0V9 + +http://www.clickspace.com + +On Feb 21, 2006, at 1:28 PM, Ibrahim Tekin wrote: + +> this trick did the job. +> thanks. +> +> On 2/21/06, Alvaro Herrera wrote: +> Scott Marlowe wrote: +> > On Tue, 2006-02-21 at 09:57, Ibrahim Tekin wrote: +> > > hi, +> > > i have btree index on a text type field. i want see rows which +> starts +> > > with certain characters on that field. so i write a query like +> this: +> > > +> > > SELECT * FROM mytable WHERE myfield LIKE 'john%' +> > > +> > > since this condition is from start of the field, query planner +> should +> > > use index to find such elements but explain command shows me it +> will +> > > do a sequential scan. +> > > +> > > is this lack of a feature or i am wrong somewhere? +> > +> > This is an artifact of how PostgreSQL handles locales other than +> ASCII. +> > +> > If you want such a query to use an index, you need to back up your +> > database, and re-initdb with --locale=C as an argument. +> +> ... or you can choose to create an index with the text_pattern_ops +> operator class, which would be used in a LIKE constraint regardless of +> locale. +> +> http://www.postgresql.org/docs/8.1/static/indexes-opclass.html +> +> -- +> Alvaro Herrera http:// +> www.CommandPrompt.com/ +> The PostgreSQL Company - Command Prompt, Inc. +> + + +--Apple-Mail-1--892633558 +Content-Transfer-Encoding: quoted-printable +Content-Type: text/html; + charset=ISO-8859-1 + +Hi,

Can this technique work = +with case insensitive ILIKE?

It didn't seem to use the = +index when I used ILIKE instead of LIKE.

Thanks,

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

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

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

On Feb 21, 2006, at 1:28 PM, Ibrahim Tekin = +wrote:

this trick did the job.
thanks.

On 2/21/06, Alvaro = +Herrera <alvherre@commandprompt.com&= +gt; wrote:
Scott Marlowe wrote:
> On Tue, 2006-02-21 at 09:57, Ibrahim = +Tekin wrote:
> > hi,
> > i have btree index on a text = +type field. i want see rows which starts
> > with certain = +characters on that field. so i write a query like this:
> = +>
> > SELECT * FROM mytable WHERE myfield LIKE 'john%' = +
> >
> > since this condition is from start of the = +field, query planner should
> > use index to find such elements = +but explain command shows me it will
> > do a sequential = +scan.
> >
> > is this lack of a feature or i am wrong = +somewhere?
>
> This is an artifact of how PostgreSQL handles = +locales other than ASCII.
>
> If you want such a query to = +use an index, you need to back up your
> database, and re-initdb = +with --locale=3DC as an argument.

... or you can choose to create = +an index with the text_pattern_ops
operator class, which would be = +used in a LIKE constraint regardless of
locale.

ht= +tp://www.postgresql.org/docs/8.1/static/indexes-opclass.html

--= +
Alvaro Herrera=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 = +http://www.CommandPrompt.com/
The PostgreSQL Company - Command = +Prompt, = +Inc.


<= +/HTML>= + +--Apple-Mail-1--892633558-- + +--Apple-Mail-2--892633001 +Content-Transfer-Encoding: base64 +Content-Type: application/pkcs7-signature; + name=smime.p7s +Content-Disposition: attachment; + filename=smime.p7s + +MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIGIDCCAtkw +ggJCoAMCAQICAw84ujANBgkqhkiG9w0BAQQFADBiMQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhh +d3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNvbmFsIEZyZWVt +YWlsIElzc3VpbmcgQ0EwHhcNMDUwNzI5MjAxMTQzWhcNMDYwNzI5MjAxMTQzWjBIMR8wHQYDVQQD +ExZUaGF3dGUgRnJlZW1haWwgTWVtYmVyMSUwIwYJKoZIhvcNAQkBFhZicmVuZGFuQGNsaWNrc3Bh +Y2UuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqWfMCdFgKzXroGNqJuU3eyDC +K/Gxts3mtmIdgcHGmUjRKdlBSfkmcCBUDPJIt4QQc91sY3h8Itg0EAsF+1yFECU6afn/1SEAHSDK +6Q86PclF58/Dux2FYNGpeIAw/lisZ2UCyIYoUiWtEDKCBq5jDuYzcGkFS5Csz+/rEL+BHTXQVqnS +nUdUaXu9xdZn4wgjB/n65UEYRqr0LGN53CGsFcA9uC+ViS7WyBtzJcP02LMNT+cAZ7TKHw4Q/ZeG +5ptPgQHLTD2wza3GMbPQ4fYK6aNPA+lVzslLSCjyQpg55gVyQQlV0k/5zU5Q5m48ZtqwOqN+fPYd +eIB7H5y1SFLd/wIDAQABozMwMTAhBgNVHREEGjAYgRZicmVuZGFuQGNsaWNrc3BhY2UuY29tMAwG +A1UdEwEB/wQCMAAwDQYJKoZIhvcNAQEEBQADgYEAT+6hGvStHoRO0OCHlJev31BpUlvPSpbYVKJN +i5kCMF164sSX7j0IRvcyU6DfUuW7samTluXJbANyuX1ZIpXulGen5EEc2NV7eU/rMz6ExklMShTh +++azcvmMjOzTuqXi3ZsIjwzBBhqCB0U++kYlMlHEYla2qKLFbXY6PiH0a8swggM/MIICqKADAgEC +AgENMA0GCSqGSIb3DQEBBQUAMIHRMQswCQYDVQQGEwJaQTEVMBMGA1UECBMMV2VzdGVybiBDYXBl +MRIwEAYDVQQHEwlDYXBlIFRvd24xGjAYBgNVBAoTEVRoYXd0ZSBDb25zdWx0aW5nMSgwJgYDVQQL +Ex9DZXJ0aWZpY2F0aW9uIFNlcnZpY2VzIERpdmlzaW9uMSQwIgYDVQQDExtUaGF3dGUgUGVyc29u +YWwgRnJlZW1haWwgQ0ExKzApBgkqhkiG9w0BCQEWHHBlcnNvbmFsLWZyZWVtYWlsQHRoYXd0ZS5j +b20wHhcNMDMwNzE3MDAwMDAwWhcNMTMwNzE2MjM1OTU5WjBiMQswCQYDVQQGEwJaQTElMCMGA1UE +ChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNvbmFs +IEZyZWVtYWlsIElzc3VpbmcgQ0EwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMSmPFVzVftO +ucqZWh5owHUEcJ3f6f+jHuy9zfVb8hp2vX8MOmHyv1HOAdTlUAow1wJjWiyJFXCO3cnwK4Vaqj9x +VsuvPAsH5/EfkTYkKhPPK9Xzgnc9A74r/rsYPge/QIACZNenprufZdHFKlSFD0gEf6e20TxhBEAe +ZBlyYLf7AgMBAAGjgZQwgZEwEgYDVR0TAQH/BAgwBgEB/wIBADBDBgNVHR8EPDA6MDigNqA0hjJo +dHRwOi8vY3JsLnRoYXd0ZS5jb20vVGhhd3RlUGVyc29uYWxGcmVlbWFpbENBLmNybDALBgNVHQ8E +BAMCAQYwKQYDVR0RBCIwIKQeMBwxGjAYBgNVBAMTEVByaXZhdGVMYWJlbDItMTM4MA0GCSqGSIb3 +DQEBBQUAA4GBAEiM0VCD6gsuzA2jZqxnD3+vrL7CF6FDlpSdf0whuPg2H6otnzYvwPQcUCCTcDz9 +reFhYsPZOhl+hLGZGwDFGguCdJ4lUJRix9sncVcljd2pnDmOjCBPZV+V2vf3h9bGCE6u9uo05RAa +WzVNd+NWIXiC3CEZNd4ksdMdRv9dX2VPMYIC5zCCAuMCAQEwaTBiMQswCQYDVQQGEwJaQTElMCMG +A1UEChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNv +bmFsIEZyZWVtYWlsIElzc3VpbmcgQ0ECAw84ujAJBgUrDgMCGgUAoIIBUzAYBgkqhkiG9w0BCQMx +CwYJKoZIhvcNAQcBMBwGCSqGSIb3DQEJBTEPFw0wNjAyMjIxNTQ4NDRaMCMGCSqGSIb3DQEJBDEW +BBRdx9twrcfRI9od+0IxotmDqJvUxTB4BgkrBgEEAYI3EAQxazBpMGIxCzAJBgNVBAYTAlpBMSUw +IwYDVQQKExxUaGF3dGUgQ29uc3VsdGluZyAoUHR5KSBMdGQuMSwwKgYDVQQDEyNUaGF3dGUgUGVy +c29uYWwgRnJlZW1haWwgSXNzdWluZyBDQQIDDzi6MHoGCyqGSIb3DQEJEAILMWugaTBiMQswCQYD +VQQGEwJaQTElMCMGA1UEChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMj +VGhhd3RlIFBlcnNvbmFsIEZyZWVtYWlsIElzc3VpbmcgQ0ECAw84ujANBgkqhkiG9w0BAQEFAASC +AQAcEMltD19TKplRE4YhSvYP5RynXaaoqlFKxbqNRZD19cHDsnZjbSl+mqSjbxuUKtX8nyuY1hpI +yb4mIoYUIOzkyj1/8g38GrD8WOwzMPGpUDrehI8GaWBQj2hczqv06RpEY6sQrNBc2x3Duiq2R72t +YHmCYl7sc49ckvQN7Hzq9Y+kxN0soQ7e9tlbd1W9HdYQMBu/CSYFrXACbgbWbNzlP1m/Q8ce5i2K ++RydFaqyRtVFx+XkCba1gDiH2cmnXD5kjMKFRihAdEDSeScCLMX/amq0i9+VGRV4AEcUQyUPKptQ +Eq9EL3JX0wJyqxSu1LMFaQuYWYWxmYl3Zn2KykJQAAAAAAAA + +--Apple-Mail-2--892633001-- + + +From pgsql-performance-owner@postgresql.org Wed Feb 22 12:32:39 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 0E87F9DC857 + for ; + Wed, 22 Feb 2006 12:32:39 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 40909-04 + for ; + Wed, 22 Feb 2006 12:32:36 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from yertle.kcilink.com (yertle.kcilink.com [65.205.34.180]) + by postgresql.org (Postfix) with ESMTP id 55CAF9DC838 + for ; + Wed, 22 Feb 2006 12:32:35 -0400 (AST) +Received: from [192.168.1.3] (unknown [192.168.1.3]) + by yertle.kcilink.com (Postfix) with ESMTP id C3092B80D + for ; + Wed, 22 Feb 2006 11:32:34 -0500 (EST) +Mime-Version: 1.0 (Apple Message framework v746.2) +In-Reply-To: + <544485BC51F81A41AC1A72CFA69013654D93B6@AZ18EV805.global.ds.honeywell.com> +References: + <544485BC51F81A41AC1A72CFA69013654D93B6@AZ18EV805.global.ds.honeywell.com> +Content-Type: multipart/alternative; boundary=Apple-Mail-1--890003781 +Message-Id: <297FB0D7-454C-4C08-A1E6-749F54D6FCB9@khera.org> +From: Vivek Khera +Subject: Re: +Date: Wed, 22 Feb 2006 11:32:33 -0500 +To: Postgresql Performance +X-Mailer: Apple Mail (2.746.2) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.068 required=5 tests=[AWL=0.067, + HTML_MESSAGE=0.001] +X-Spam-Score: 0.068 +X-Spam-Level: +X-Archive-Number: 200602/343 +X-Sequence-Number: 17329 + + +--Apple-Mail-1--890003781 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset=US-ASCII; + delsp=yes; + format=flowed + + +On Feb 22, 2006, at 5:38 AM, Chethana, Rao (IE10) wrote: + +> It is rich in features but slow in performance. + +No, it is fast and feature-rich. But you have to tune it for your +specific needs; the default configuration is not ideal for large DBs. + + +--Apple-Mail-1--890003781 +Content-Transfer-Encoding: quoted-printable +Content-Type: text/html; + charset=ISO-8859-1 + +
On Feb 22, 2006, = +at 5:38 AM, Chethana, Rao (IE10) wrote:

It is rich in = +features but slow in = +performance.

No, = +it is fast and feature-rich.=A0 But you have to tune it for your = +specific needs; the default configuration is not ideal for large = +DBs.

= + +--Apple-Mail-1--890003781-- + +From pgsql-performance-owner@postgresql.org Wed Feb 22 12:57:28 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 2427E9DC857 + for ; + Wed, 22 Feb 2006 12:57:26 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 44808-06 + for ; + Wed, 22 Feb 2006 12:57:24 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from gwmta.wicourts.gov (gwmta.wicourts.gov [165.219.244.99]) + by postgresql.org (Postfix) with ESMTP id 664D59DC838 + for ; + Wed, 22 Feb 2006 12:57:22 -0400 (AST) +Received: from Courts-MTA by gwmta.wicourts.gov + with Novell_GroupWise; Wed, 22 Feb 2006 10:57:22 -0600 +Message-Id: <43FC4384.EE98.0025.0@wicourts.gov> +X-Mailer: Novell GroupWise Internet Agent 7.0 +Date: Wed, 22 Feb 2006 10:57:08 -0600 +From: "Kevin Grittner" +To: +Subject: Good News re count(*) in 8.1 +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.053 required=5 tests=[AWL=0.053] +X-Spam-Score: 0.053 +X-Spam-Level: +X-Archive-Number: 200602/344 +X-Sequence-Number: 17330 + +I hesitate to raise this issue again, but I've noticed something which I +thought might be worth mentioning. I've never thought the performance +of count(*) on a table was a significant issue, but I'm prepared to say +that -- for me, at least -- it is officially and totally a NON-issue. + +We are replicating data from 72 source databases, each with the +official copy of a subset of the data, to four identical consolidated +databases, spread to separate locations, to serve our web site and other +organization-wide needs. Currently, two of these central databases are +running a commercial product and two are running PostgreSQL. There have +been several times that I have run a SELECT COUNT(*) on an entire table +on all central machines. On identical hardware, with identical data, +and equivalent query loads, the PostgreSQL databases have responded with +a count in 50% to 70% of the time of the commercial product, in spite of +the fact that the commercial product does a scan of a non-clustered +index while PostgreSQL scans the data pages. + +The tables have had from a few million to 132 million rows. The +databases are about 415 GB each. The servers have 6 GB RAM each. We've +been running PostgreSQL 8.1, tuned and maintained based on advice from +the documentation and these lists. + +I suspect that where people report significantly worse performance for +count(*) under PostgreSQL than some other product, it may sometimes be +the case that they have not properly tuned PostgreSQL, or paid attention +to maintenance issues regarding dead space in the tables. + +My recent experience, for what it's worth. + +-Kevin + + +From pgsql-performance-owner@postgresql.org Wed Feb 22 13:13:09 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 872389DC99D + for ; + Wed, 22 Feb 2006 13:13:07 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 47323-04 + for ; + Wed, 22 Feb 2006 13:13:05 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.Mi8.com (d01gw01.mi8.com [63.240.6.47]) + by postgresql.org (Postfix) with ESMTP id BF6579DC9AD + for ; + Wed, 22 Feb 2006 13:13:04 -0400 (AST) +Received: from 172.16.1.25 by mail.Mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D1)); Wed, 22 Feb 2006 12:12:36 -0500 +X-Server-Uuid: 241911D6-425B-44B9-A073-E3FE0F8FC774 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.175]) by + D01HOST03.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Wed, 22 Feb + 2006 12:12:03 -0500 +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.105]) with Microsoft Exchange Server HTTP-DAV ; Wed, 22 Feb + 2006 17:12:02 +0000 +User-Agent: Microsoft-Entourage/11.2.1.051004 +Date: Wed, 22 Feb 2006 09:11:50 -0800 +Subject: Re: Good News re count(*) in 8.1 +From: "Luke Lonergan" +To: "Kevin Grittner" , + pgsql-performance@postgresql.org +Message-ID: +Thread-Topic: [PERFORM] Good News re count(*) in 8.1 +Thread-Index: AcY30SXcnUYXYsFBQPGESRUQSJ7U+gAAevHz +In-Reply-To: <43FC4384.EE98.0025.0@wicourts.gov> +MIME-Version: 1.0 +X-OriginalArrivalTime: 22 Feb 2006 17:12:03.0285 (UTC) + FILETIME=[198BB050:01C637D3] +X-WSS-ID: 6FE2440A31W10045603-07-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, score=1.324 required=5 tests=[AWL=0.071, + RCVD_NUMERIC_HELO=1.253] +X-Spam-Score: 1.324 +X-Spam-Level: * +X-Archive-Number: 200602/345 +X-Sequence-Number: 17331 + +Kevin, + +On 2/22/06 8:57 AM, "Kevin Grittner" wrote: + +> I hesitate to raise this issue again, but I've noticed something which I +> thought might be worth mentioning. I've never thought the performance +> of count(*) on a table was a significant issue, but I'm prepared to say +> that -- for me, at least -- it is officially and totally a NON-issue. + +Cool! Kudos to Tom for implementing the improvements in the executor to +move tuples faster through the pipeline. + +We see a CPU limit (yes, another limit) of about 300MB/s now on Opteron 250 +processors running on Linux. The filesystem can do 420MB/s sequential scan +in 8k pages, but Postgres count(*) on 8.1.3 can only do about 300MB/s. This +is still a very large improvement over past versions, but we'd always like +to see more... + +- Luke + + + +From pgsql-performance-owner@postgresql.org Wed Feb 22 13:16:43 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 544639DC9AD + for ; + Wed, 22 Feb 2006 13:16:41 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 47304-07 + for ; + Wed, 22 Feb 2006 13:16:39 -0400 (AST) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 743BA9DC838 + for ; + Wed, 22 Feb 2006 13:16:38 -0400 (AST) +Received: from smtpout.mac.com (smtpout.mac.com [17.250.248.73]) + by svr4.postgresql.org (Postfix) with ESMTP id 3E2265AF025 + for ; + Wed, 22 Feb 2006 17:16:37 +0000 (GMT) +Received: from mac.com (smtpin02-en2 [10.13.10.147]) + by smtpout.mac.com (Xserve/8.12.11/smtpout16/MantshX 4.0) with ESMTP id + k1MHGXWv014985; Wed, 22 Feb 2006 09:16:33 -0800 (PST) +Received: from [192.168.1.3] (cpe-24-208-119-74.kc.res.rr.com [24.208.119.74]) + (authenticated bits=0) + by mac.com (Xserve/smtpin02/MantshX 4.0) with ESMTP id k1MHGWVr000605; + Wed, 22 Feb 2006 09:16:32 -0800 (PST) +In-Reply-To: <43FC7389.4050408@archonet.com> +References: + <544485BC51F81A41AC1A72CFA690136552384E@AZ18EV805.global.ds.honeywell.com> + <43FC7389.4050408@archonet.com> +Mime-Version: 1.0 (Apple Message framework v746.2) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: +Cc: "Chethana, Rao (IE10)" , + pgsql-performance@postgresql.org +Content-Transfer-Encoding: 7bit +From: Theodore LoScalzo +Subject: Re: --pls reply ASAP +Date: Wed, 22 Feb 2006 11:16:30 -0600 +To: Richard Huxton +X-Mailer: Apple Mail (2.746.2) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=1.44 required=5 tests=[DNS_FROM_RFC_POST=1.44] +X-Spam-Score: 1.44 +X-Spam-Level: * +X-Archive-Number: 200602/346 +X-Sequence-Number: 17332 + +I know I am sticking my nose in an area here that I have not been +involved in but +this issue is important to me. +Chethana I have a couple of questions based on what you said you are +using as a +platform. see below : + +On Feb 22, 2006, at 8:22 AM, Richard Huxton wrote: + +> Chethana, Rao (IE10) wrote: +>> Hello! +>> Thank you for responding quickly. I really need ur help. +> +> Please make sure you cc: the list - I don't read this inbox regularly. +> +>> Sir, here r the answers for ur questions, please do tell me what +>> to do +>> next(regarding increasing performance of postgresql), so that I can +>> proceed further. +>> How are you using PostgreSQL? +>> We r using 7.4.3 with max of (512*6) around 3000 records. +> +> Max of what are (512*6)? Rows? Tables? Sorry - I don't understand +> what you mean here. +> +> Oh, and upgrade to the latest release of 7.4.x - there are +> important bugfixes. +> +>> How many concurrent users? +>> It configures for 100, but we r using 4 or 5 only. +>> Mostly updates or small selects or large summary reports? +>> Update,delete,insert operations. +>> What hardware do you have? +>> X86 based, 233 MHz, 256 MB RAM. +What Operating System are you running this on?? +How much "other" stuff or applications are you running on the box +Is this a IDE hard drive system?? SCSI?? Bus Speed?? is it a older +server or a pc?? +You dont have a large database at all but quick access to the data +that is residing in +the database has a lot to do with how the hardware is configured and +what other programs +are using the limited system resources! +> +> Hmm - not blazing fast, but it'll certainly run on that. +> +>> What configuration changes have you made? +>> No changes, we've used default settings. +> +> That will need changing. As Gourish suggested in another reply, +> read the notes here: +> http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html +> +> You'll want to be careful with the memory settings given that +> you've only got 256MB to play with. Don't allocate too much to +> PostgreSQL itself, let the o.s. cache some files for you. +> +>> Are you having problems with all queries or only some? +>> Only some queries, particularly foreign key. +> +> Are you happy that there are indexes on the referring side of the +> foreign key where necessary? The primary keys you reference will +> have indexes on them, the other side will not unless you add them +> yourself. +> +>> Have you checked the plans for these with EXPLAIN ANALYSE? +>> No. +> +> That would be something worth doing then. Find a bad query, run +> EXPLAIN ANALYSE SELECT ... and post a new question with the output +> and details of the tables involved. +> +>> Have you made sure your tables are vacuumed and analysed? +>> Yes. +> +> Good. With the limited amount of RAM you have, you'll want to use +> it as efficiently as possible. +> +> -- +> Richard Huxton +> Archonet Ltd +Theodore LoScalzo + +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 3: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faq + + +From pgsql-performance-owner@postgresql.org Wed Feb 22 13:27:02 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id B1AAB9DC877 + for ; + Wed, 22 Feb 2006 13:27:00 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 49129-06 + for ; + Wed, 22 Feb 2006 13:26:59 -0400 (AST) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 5728C9DC99D + for ; + Wed, 22 Feb 2006 13:26:58 -0400 (AST) +Received: from zeus.liquidweb.com (zeus.liquidweb.com [64.91.224.170]) + by svr4.postgresql.org (Postfix) with ESMTP id 86D4C5AF18C + for ; + Wed, 22 Feb 2006 17:26:58 +0000 (GMT) +Received: from cpusoftw by zeus.liquidweb.com with local (Exim 4.52) + id 1FBxlH-0003Kt-9V + for pgsql-performance@postgresql.org; Wed, 22 Feb 2006 12:26:47 -0500 +From: "ryan groth" +To: pgsql-performance@postgresql.org +Subject: Joins and full index scans...mysql vs postgres? +X-Mailer: NeoMail 1.27 +X-IPAddress: 127.0.0.1 +MIME-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Message-Id: +Date: Wed, 22 Feb 2006 12:26:47 -0500 +X-AntiAbuse: This header was added to track abuse, + please include it with any abuse report +X-AntiAbuse: Primary Hostname - zeus.liquidweb.com +X-AntiAbuse: Original Domain - postgresql.org +X-AntiAbuse: Originator/Caller UID/GID - [32069 32069] / [47 12] +X-AntiAbuse: Sender Address Domain - cpusoftware.com +X-Source: +X-Source-Args: +X-Source-Dir: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200602/347 +X-Sequence-Number: 17333 + +I am issing a query like this: +SELECT * + FROM users users + LEFT JOIN phorum_users_base ON users.uid = phorum_users_base.user_id + LEFT JOIN useraux ON useraux.uid = users.uid; + +The joins are all on the PKs of the tables. It takes 1000ms to run on +postgres. The identical mysql version runs in 230ms. The problem seems +to stem from postgres's insistence to do three complete table scans, +where mysql does one and joins 1:1 against the results of the first. I +have switched the joins to inner joins and the difference is negligible. +Here are the explains on both postgres and mysql. Is there a way to +optimize this basic query for postgres that I am missing? + +Postgres Explain + +Merge Left Join (cost=0.00..2656.36 rows=6528 width=1522) +Merge Cond: ("outer".uid = "inner".uid) + -> Merge Left Join (cost=0.00..1693.09 rows=6528 width=1264) + Merge Cond: ("outer".uid = "inner".user_id) + -> Index Scan using users_pkey on users (cost=0.00..763.81 +rows=6528 width=100) + -> Index Scan using phorum_users_base_pkey on phorum_users_base + (cost=0.00..822.92 rows=9902 width=1168) + -> Index Scan using useraux_pkey on useraux (cost=0.00..846.40 +rows=7582 width=262) + + +MySQL Explain: + +id,select_type,table,possible_keys,key,key_len,ref,rows,extra +1, 'PRIMARY', 'USERS', 'ALL', '', '', '', '', 6528, '' +1, 'PRIMARY', 'phorum_users_base', 'eq_ref', 'PRIMARY', 'PRIMARY', '4', +'wh2o.USERS.UID', 1, '' +1, 'PRIMARY', 'useraux', 'eq_ref', 'PRIMARY', 'PRIMARY', '4', +'wh2o.USERS.UID', 1, '' + + +From pgsql-performance-owner@postgresql.org Wed Feb 22 13:42:08 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 6A8979DC99D + for ; + Wed, 22 Feb 2006 13:42:06 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 49435-10 + for ; + Wed, 22 Feb 2006 13:42:05 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id A5A109DC877 + for ; + Wed, 22 Feb 2006 13:42:03 -0400 (AST) +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 k1MHg3qg013378; + Wed, 22 Feb 2006 12:42:03 -0500 (EST) +To: "Kevin Grittner" +cc: pgsql-performance@postgresql.org +Subject: Re: Good News re count(*) in 8.1 +In-reply-to: <43FC4384.EE98.0025.0@wicourts.gov> +References: <43FC4384.EE98.0025.0@wicourts.gov> +Comments: In-reply-to "Kevin Grittner" + message dated "Wed, 22 Feb 2006 10:57:08 -0600" +Date: Wed, 22 Feb 2006 12:42:02 -0500 +Message-ID: <13377.1140630122@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.111 required=5 tests=[AWL=0.111] +X-Spam-Score: 0.111 +X-Spam-Level: +X-Archive-Number: 200602/348 +X-Sequence-Number: 17334 + +"Kevin Grittner" writes: +> We are replicating data from 72 source databases, each with the +> official copy of a subset of the data, to four identical consolidated +> databases, spread to separate locations, to serve our web site and other +> organization-wide needs. Currently, two of these central databases are +> running a commercial product and two are running PostgreSQL. There have +> been several times that I have run a SELECT COUNT(*) on an entire table +> on all central machines. On identical hardware, with identical data, +> and equivalent query loads, the PostgreSQL databases have responded with +> a count in 50% to 70% of the time of the commercial product, in spite of +> the fact that the commercial product does a scan of a non-clustered +> index while PostgreSQL scans the data pages. + +Interesting. I think though that the people who are complaining come +from databases where COUNT(*) takes constant time because the DB keeps +a running count in the table's metadata. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Feb 22 13:52:54 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id E06489DCAEE + for ; + Wed, 22 Feb 2006 13:52:51 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 53043-04 + for ; + Wed, 22 Feb 2006 13:52:50 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from cassarossa.samfundet.no (cassarossa.samfundet.no + [129.241.93.19]) + by postgresql.org (Postfix) with ESMTP id EA3899DCA42 + for ; + Wed, 22 Feb 2006 13:52:48 -0400 (AST) +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 1FByAR-0007bk-KW + for pgsql-performance@postgresql.org; Wed, 22 Feb 2006 18:52:47 +0100 +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1FByAO-0003xJ-00 + for ; Wed, 22 Feb 2006 18:52:44 +0100 +Date: Wed, 22 Feb 2006 18:52:44 +0100 +From: "Steinar H. Gunderson" +To: pgsql-performance@postgresql.org +Subject: Re: Joins and full index scans...mysql vs postgres? +Message-ID: <20060222175244.GA15150@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.14.3 on a x86_64 +X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ +User-Agent: Mutt/1.5.11+cvs20060126 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.081 required=5 tests=[AWL=0.081] +X-Spam-Score: 0.081 +X-Spam-Level: +X-Archive-Number: 200602/349 +X-Sequence-Number: 17335 + +On Wed, Feb 22, 2006 at 12:26:47PM -0500, ryan groth wrote: +> Postgres Explain + +We need to see EXPLAIN ANALYZE results here. + +What's your work_mem set to? + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-performance-owner@postgresql.org Wed Feb 22 14:11:24 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 23C059DC877 + for ; + Wed, 22 Feb 2006 14:11:22 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 56952-02 + for ; + Wed, 22 Feb 2006 14:11:21 -0400 (AST) +X-Greylist: delayed 00:44:23.922466 by SQLgrey- +Received: from zeus.liquidweb.com (zeus.liquidweb.com [64.91.224.170]) + by postgresql.org (Postfix) with ESMTP id DA71F9DC838 + for ; + Wed, 22 Feb 2006 14:11:18 -0400 (AST) +Received: from cpusoftw by zeus.liquidweb.com with local (Exim 4.52) + id 1FBySH-0005Rw-1H; Wed, 22 Feb 2006 13:11:13 -0500 +From: "ryan groth" +To: "Steinar H. Gunderson" , + pgsql-performance@postgresql.org +Subject: Re: Joins and full index scans...mysql vs postgres? +X-Mailer: NeoMail 1.27 +X-IPAddress: 127.0.0.1 +MIME-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Message-Id: +Date: Wed, 22 Feb 2006 13:11:13 -0500 +X-AntiAbuse: This header was added to track abuse, + please include it with any abuse report +X-AntiAbuse: Primary Hostname - zeus.liquidweb.com +X-AntiAbuse: Original Domain - postgresql.org +X-AntiAbuse: Originator/Caller UID/GID - [32069 32069] / [47 12] +X-AntiAbuse: Sender Address Domain - cpusoftware.com +X-Source: +X-Source-Args: +X-Source-Dir: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200602/350 +X-Sequence-Number: 17336 + +Does this work: + +"Merge Left Join (cost=0.00..2656.36 rows=6528 width=1522) (actual +time=0.057..123.659 rows=6528 loops=1)" +" Merge Cond: ("outer".uid = "inner".uid)" +" -> Merge Left Join (cost=0.00..1693.09 rows=6528 width=1264) +(actual time=0.030..58.876 rows=6528 loops=1)" +" Merge Cond: ("outer".uid = "inner".user_id)" +" -> Index Scan using users_pkey on users (cost=0.00..763.81 +rows=6528 width=100) (actual time=0.016..9.446 rows=6528 loops=1)" +" -> Index Scan using phorum_users_base_pkey on +phorum_users_base (cost=0.00..822.92 rows=9902 width=1168) (actual +time=0.007..15.674 rows=9845 loops=1)" +" -> Index Scan using useraux_pkey on useraux (cost=0.00..846.40 +rows=7582 width=262) (actual time=0.007..11.935 rows=7529 loops=1)" +"Total runtime: 127.442 ms" + + +> On Wed, Feb 22, 2006 at 12:26:47PM -0500, ryan groth wrote: +> > Postgres Explain +> +> We need to see EXPLAIN ANALYZE results here. +> +> What's your work_mem set to? +> +> /* Steinar */ +> -- +> Homepage: http://www.sesse.net/ +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 3: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faq +> +> + +-- + + +> On Wed, Feb 22, 2006 at 12:26:47PM -0500, ryan groth wrote: +> > Postgres Explain +> +> We need to see EXPLAIN ANALYZE results here. +> +> What's your work_mem set to? +> +> /* Steinar */ +> -- +> Homepage: http://www.sesse.net/ +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 3: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faq +> +> + +-- + + +From pgsql-performance-owner@postgresql.org Wed Feb 22 14:21:14 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 138C79DC93E + for ; + Wed, 22 Feb 2006 14:21:14 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 57005-08 + for ; + Wed, 22 Feb 2006 14:21:13 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from zeus.liquidweb.com (zeus.liquidweb.com [64.91.224.170]) + by postgresql.org (Postfix) with ESMTP id 80F139DC838 + for ; + Wed, 22 Feb 2006 14:21:11 -0400 (AST) +Received: from cpusoftw by zeus.liquidweb.com with local (Exim 4.52) + id 1FBybo-0005wh-Vn; Wed, 22 Feb 2006 13:21:05 -0500 +From: "ryan groth" +To: "ryan groth" , + "Steinar H. Gunderson" , + pgsql-performance@postgresql.org +Subject: Re: Joins and full index scans...mysql vs postgres? +X-Mailer: NeoMail 1.27 +X-IPAddress: 127.0.0.1 +MIME-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Message-Id: +Date: Wed, 22 Feb 2006 13:21:04 -0500 +X-AntiAbuse: This header was added to track abuse, + please include it with any abuse report +X-AntiAbuse: Primary Hostname - zeus.liquidweb.com +X-AntiAbuse: Original Domain - postgresql.org +X-AntiAbuse: Originator/Caller UID/GID - [32069 32069] / [47 12] +X-AntiAbuse: Sender Address Domain - cpusoftware.com +X-Source: +X-Source-Args: +X-Source-Dir: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200602/351 +X-Sequence-Number: 17337 + + +workmem is set to the default, increasing it decreases performance. + +> Does this work: +> +> "Merge Left Join (cost=0.00..2656.36 rows=6528 width=1522) (actual +> time=0.057..123.659 rows=6528 loops=1)" +> " Merge Cond: ("outer".uid = "inner".uid)" +> " -> Merge Left Join (cost=0.00..1693.09 rows=6528 width=1264) +> (actual time=0.030..58.876 rows=6528 loops=1)" +> " Merge Cond: ("outer".uid = "inner".user_id)" +> " -> Index Scan using users_pkey on users (cost=0.00..763.81 +> rows=6528 width=100) (actual time=0.016..9.446 rows=6528 loops=1)" +> " -> Index Scan using phorum_users_base_pkey on +> phorum_users_base (cost=0.00..822.92 rows=9902 width=1168) (actual +> time=0.007..15.674 rows=9845 loops=1)" +> " -> Index Scan using useraux_pkey on useraux (cost=0.00..846.40 +> rows=7582 width=262) (actual time=0.007..11.935 rows=7529 loops=1)" +> "Total runtime: 127.442 ms" +> +> +> > On Wed, Feb 22, 2006 at 12:26:47PM -0500, ryan groth wrote: +> > > Postgres Explain +> > +> > We need to see EXPLAIN ANALYZE results here. +> > +> > What's your work_mem set to? +> > +> > /* Steinar */ +> > -- +> > Homepage: http://www.sesse.net/ +> > +> > ---------------------------(end of broadcast)--------------------------- +> > TIP 3: Have you checked our extensive FAQ? +> > +> > http://www.postgresql.org/docs/faq +> > +> > +> +> -- +> +> +> > On Wed, Feb 22, 2006 at 12:26:47PM -0500, ryan groth wrote: +> > > Postgres Explain +> > +> > We need to see EXPLAIN ANALYZE results here. +> > +> > What's your work_mem set to? +> > +> > /* Steinar */ +> > -- +> > Homepage: http://www.sesse.net/ +> > +> > ---------------------------(end of broadcast)--------------------------- +> > TIP 3: Have you checked our extensive FAQ? +> > +> > http://www.postgresql.org/docs/faq +> > +> > +> +> -- +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 4: Have you searched our list archives? +> +> http://archives.postgresql.org +> +> + +-- + + +From pgsql-performance-owner@postgresql.org Wed Feb 22 14:31:36 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 5D9499DC877 + for ; + Wed, 22 Feb 2006 14:31:34 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 57371-08 + for ; + Wed, 22 Feb 2006 14:31:34 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by postgresql.org (Postfix) with ESMTP id 6A0479DC838 + for ; + Wed, 22 Feb 2006 14:31:32 -0400 (AST) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id 0BB4E3661C; Wed, 22 Feb 2006 10:28:25 -0800 (PST) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id 0992E3660C; Wed, 22 Feb 2006 10:28:25 -0800 (PST) +Date: Wed, 22 Feb 2006 10:28:25 -0800 (PST) +From: Stephan Szabo +To: ryan groth +Cc: "Steinar H. Gunderson" , + pgsql-performance@postgresql.org +Subject: Re: Joins and full index scans...mysql vs postgres? +In-Reply-To: +Message-ID: <20060222102713.Y73083@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, score=0.141 required=5 tests=[AWL=0.141] +X-Spam-Score: 0.141 +X-Spam-Level: +X-Archive-Number: 200602/352 +X-Sequence-Number: 17338 + +On Wed, 22 Feb 2006, ryan groth wrote: + +> Does this work: +> +> "Merge Left Join (cost=0.00..2656.36 rows=6528 width=1522) (actual +> time=0.057..123.659 rows=6528 loops=1)" +> " Merge Cond: ("outer".uid = "inner".uid)" +> " -> Merge Left Join (cost=0.00..1693.09 rows=6528 width=1264) +> (actual time=0.030..58.876 rows=6528 loops=1)" +> " Merge Cond: ("outer".uid = "inner".user_id)" +> " -> Index Scan using users_pkey on users (cost=0.00..763.81 +> rows=6528 width=100) (actual time=0.016..9.446 rows=6528 loops=1)" +> " -> Index Scan using phorum_users_base_pkey on +> phorum_users_base (cost=0.00..822.92 rows=9902 width=1168) (actual +> time=0.007..15.674 rows=9845 loops=1)" +> " -> Index Scan using useraux_pkey on useraux (cost=0.00..846.40 +> rows=7582 width=262) (actual time=0.007..11.935 rows=7529 loops=1)" +> "Total runtime: 127.442 ms" + +Well, this implies the query took about 127 ms on the server side. Where +did the 1000 ms number come from (was that on a client, and if so, what +type)? + +From pgsql-performance-owner@postgresql.org Wed Feb 22 14:53:05 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id D484F9DC93E + for ; + Wed, 22 Feb 2006 14:53:03 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 61688-06 + for ; + Wed, 22 Feb 2006 14:53:03 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from zeus.liquidweb.com (zeus.liquidweb.com [64.91.224.170]) + by postgresql.org (Postfix) with ESMTP id 93B499DC89B + for ; + Wed, 22 Feb 2006 14:53:01 -0400 (AST) +Received: from cpusoftw by zeus.liquidweb.com with local (Exim 4.52) + id 1FBz6X-0007Do-9z; Wed, 22 Feb 2006 13:52:49 -0500 +From: "ryan groth" +To: Stephan Szabo , + ryan groth , + "Steinar H. Gunderson" , + pgsql-performance@postgresql.org +Subject: Re: Joins and full index scans...mysql vs postgres? +X-Mailer: NeoMail 1.27 +X-IPAddress: 127.0.0.1 +MIME-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Message-Id: +Date: Wed, 22 Feb 2006 13:52:49 -0500 +X-AntiAbuse: This header was added to track abuse, + please include it with any abuse report +X-AntiAbuse: Primary Hostname - zeus.liquidweb.com +X-AntiAbuse: Original Domain - postgresql.org +X-AntiAbuse: Originator/Caller UID/GID - [32069 32069] / [47 12] +X-AntiAbuse: Sender Address Domain - cpusoftware.com +X-Source: +X-Source-Args: +X-Source-Dir: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200602/353 +X-Sequence-Number: 17339 + +Hmm, it came from the timer on the pgadmin III sql query tool. I guess +the 1,000ms includes the round-trip? See the wierd thing is that +mysqlserver is running default configuration on a virtual machine +(P3/1.3GHZ conf'd for 128mb ram) over a 100m/b ethernet connection. +Postgres is running on a real P4/3.0ghz 4GB running localhost. Timings +from the mysql query tool indicate that the 6.5k record query runs in +"1.3346s (.3361s)" vs. the pgadmin query tool saying that the query runs +"997+3522 ms". Am I reading these numbers wrong? Are these numbers +reflective of application performance? Is there an optimization I am +missing? + +Ryan + + +> On Wed, 22 Feb 2006, ryan groth wrote: +> +> > Does this work: +> > +> > "Merge Left Join (cost=0.00..2656.36 rows=6528 width=1522) (actual +> > time=0.057..123.659 rows=6528 loops=1)" +> > " Merge Cond: ("outer".uid = "inner".uid)" +> > " -> Merge Left Join (cost=0.00..1693.09 rows=6528 width=1264) +> > (actual time=0.030..58.876 rows=6528 loops=1)" +> > " Merge Cond: ("outer".uid = "inner".user_id)" +> > " -> Index Scan using users_pkey on users (cost=0.00..763.81 +> > rows=6528 width=100) (actual time=0.016..9.446 rows=6528 loops=1)" +> > " -> Index Scan using phorum_users_base_pkey on +> > phorum_users_base (cost=0.00..822.92 rows=9902 width=1168) (actual +> > time=0.007..15.674 rows=9845 loops=1)" +> > " -> Index Scan using useraux_pkey on useraux (cost=0.00..846.40 +> > rows=7582 width=262) (actual time=0.007..11.935 rows=7529 loops=1)" +> > "Total runtime: 127.442 ms" +> +> Well, this implies the query took about 127 ms on the server side. Where +> did the 1000 ms number come from (was that on a client, and if so, what +> type)? +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 6: explain analyze is your friend +> +> + +-- + + +From pgsql-performance-owner@postgresql.org Wed Feb 22 15:13:37 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 711179DC9AD + for ; + Wed, 22 Feb 2006 15:13:37 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 65088-08 + for ; + Wed, 22 Feb 2006 15:13:37 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id 5FD189DC99D + for ; + Wed, 22 Feb 2006 15:13:35 -0400 (AST) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Wed, 22 Feb 2006 19:13:36 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 22 Feb 2006 13:13:36 -0600 +Subject: Re: Joins and full index scans...mysql vs postgres? +From: Scott Marlowe +To: ryan groth +Cc: "Steinar H. Gunderson" , + pgsql-performance@postgresql.org +In-Reply-To: +References: +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1140635616.5777.35.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Wed, 22 Feb 2006 13:13:36 -0600 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.156 required=5 tests=[AWL=0.155, + UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 0.156 +X-Spam-Level: +X-Archive-Number: 200602/354 +X-Sequence-Number: 17340 + +On Wed, 2006-02-22 at 12:11, ryan groth wrote: +> Does this work: +> +> "Merge Left Join (cost=0.00..2656.36 rows=6528 width=1522) (actual +> time=0.057..123.659 rows=6528 loops=1)" +> " Merge Cond: ("outer".uid = "inner".uid)" +> " -> Merge Left Join (cost=0.00..1693.09 rows=6528 width=1264) +> (actual time=0.030..58.876 rows=6528 loops=1)" +> " Merge Cond: ("outer".uid = "inner".user_id)" +> " -> Index Scan using users_pkey on users (cost=0.00..763.81 +> rows=6528 width=100) (actual time=0.016..9.446 rows=6528 loops=1)" +> " -> Index Scan using phorum_users_base_pkey on +> phorum_users_base (cost=0.00..822.92 rows=9902 width=1168) (actual +> time=0.007..15.674 rows=9845 loops=1)" +> " -> Index Scan using useraux_pkey on useraux (cost=0.00..846.40 +> rows=7582 width=262) (actual time=0.007..11.935 rows=7529 loops=1)" +> "Total runtime: 127.442 ms" + +In MySQL, have you tried writing a short perl or php script or even +timing the mysql client running in one shot mode (I assume it can do +that) from the outside to see how long it takes to actually run the +query AND retrieve the data? + +My guess is most of the time for both queries will be taken in +delivering the data. + +From pgsql-performance-owner@postgresql.org Wed Feb 22 15:16:21 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 7E0D89DCC0D + for ; + Wed, 22 Feb 2006 15:16:20 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 65884-04 + for ; + Wed, 22 Feb 2006 15:16:19 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from out4.smtp.messagingengine.com (out4.smtp.messagingengine.com + [66.111.4.28]) by postgresql.org (Postfix) with ESMTP id 85E669DCC3A + for ; + Wed, 22 Feb 2006 15:16:17 -0400 (AST) +Received: from frontend1.internal (mysql-sessions.internal [10.202.2.149]) + by frontend1.messagingengine.com (Postfix) with ESMTP id 8B8C8D37971 + for ; + Wed, 22 Feb 2006 14:16:17 -0500 (EST) +Received: from web2.messagingengine.com ([10.202.2.211]) + by frontend1.internal (MEProxy); Wed, 22 Feb 2006 14:16:17 -0500 +Received: by web2.messagingengine.com (Postfix, from userid 99) + id A210713EFF; Wed, 22 Feb 2006 14:16:10 -0500 (EST) +Message-Id: <1140635770.1612.255019877@webmail.messagingengine.com> +X-Sasl-Enc: qCoH4eTFI4WGzziOKX83r4Cd9O43TMTTab3xvVgV2wBj 1140635770 +From: "Jeremy Haile" +To: pgsql-performance@postgresql.org +Content-Disposition: inline +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset="ISO-8859-1" +MIME-Version: 1.0 +X-Mailer: MIME::Lite 5022 (F2.73; T1.15; A1.64; B3.05; Q3.03) +Subject: Slow query +Date: Wed, 22 Feb 2006 14:16:10 -0500 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.439 required=5 tests=[AWL=-0.040, + DNS_FROM_RFC_ABUSE=0.479] +X-Spam-Score: 0.439 +X-Spam-Level: +X-Archive-Number: 200602/355 +X-Sequence-Number: 17341 + +I am running a query that joins against several large tables (~5 million +rows each). The query takes an exteremely long time to run, and the +explain output is a bit beyond my level of understanding. It is an +auto-generated query, so the aliases are fairly ugly. I can clean them +up (rename them) if it would help. Also, let me know if I can send any +more information that would help (e.g. table schema) + +Also, is there any resources where I can get a better understanding of +what PostgreSQL means when it says "Sort" "Sort Key" "Bitmap Index Scan" +"Hash Cond" etc. etc. - and how to recognize problems by looking at the +output. I can understand the output for simple queries (e.g. is the +planner using an index or performing a seq. scan), but when you get to +more complex queries like the one below I lose my way =) + +I would really appreciate it if someone from this list could tell me if +there is anything that is obviously wrong with the query or schema and +what I could do to improve the performance. + +PostgreSQL 8.1 +RedHat Enterprise Linux 4 + +--QUERY +select distinct city4_.region_id as region1_29_, city4_1_.name as +name29_, city4_.state_id as state2_30_ +from registered_voters registered0_ + inner join registered_voter_addresses addresses1_ on + registered0_.registered_voter_id=addresses1_.registered_voter_id + inner join registered_voter_addresses_regions regions2_ on + addresses1_.address_id=regions2_.registered_voter_addresses_address_id + inner join regions region3_ on + regions2_.regions_region_id=region3_.region_id + inner join cities city4_ on + addresses1_.city_id=city4_.region_id + inner join regions city4_1_ on + city4_.region_id=city4_1_.region_id +where region3_.region_id='093c44e8-f3b2-4c60-8be3-2b4d148f9f5a' +order by city4_1_.name + + +--EXPLAIN/ANALYZE OUTPUT +"Unique (cost=3572907.42..3623589.94 rows=4076438 width=93) (actual +time=2980825.714..3052333.753 rows=1124 loops=1)" +" -> Sort (cost=3572907.42..3585578.05 rows=5068252 width=93) (actual +time=2980825.710..2987407.888 rows=4918204 loops=1)" +" Sort Key: city4_1_.name, city4_.region_id, city4_.state_id" +" -> Hash Join (cost=717783.40..1430640.10 rows=5068252 +width=93) (actual time=1400141.559..2016131.467 rows=4918204 loops=1)" +" Hash Cond: +(("outer".registered_voter_addresses_address_id)::text = +("inner".address_id)::text)" +" -> Bitmap Heap Scan on +registered_voter_addresses_regions regions2_ (cost=54794.95..575616.49 +rows=5116843 width=80) (actual time=45814.469..155044.478 rows=4918205 +loops=1)" +" Recheck Cond: +('093c44e8-f3b2-4c60-8be3-2b4d148f9f5a'::text = +(regions_region_id)::text)" +" -> Bitmap Index Scan on +reg_voter_address_region_region_idx (cost=0.00..54794.95 rows=5116843 +width=0) (actual time=45807.157..45807.157 rows=4918205 loops=1)" +" Index Cond: +('093c44e8-f3b2-4c60-8be3-2b4d148f9f5a'::text = +(regions_region_id)::text)" +" -> Hash (cost=642308.89..642308.89 rows=741420 +width=173) (actual time=1354217.934..1354217.934 rows=4918204 loops=1)" +" -> Hash Join (cost=328502.66..642308.89 +rows=741420 width=173) (actual time=204565.031..1268303.832 rows=4918204 +loops=1)" +" Hash Cond: +(("outer".registered_voter_id)::text = +("inner".registered_voter_id)::text)" +" -> Seq Scan on registered_voters +registered0_ (cost=0.00..173703.02 rows=4873202 width=40) (actual +time=0.005..39364.261 rows=4873167 loops=1)" +" -> Hash (cost=303970.34..303970.34 +rows=748528 width=213) (actual time=204523.861..204523.861 rows=4918204 +loops=1)" +" -> Hash Join (cost=263.22..303970.34 +rows=748528 width=213) (actual time=101.628..140936.062 rows=4918204 +loops=1)" +" Hash Cond: +(("outer".city_id)::text = ("inner".region_id)::text)" +" -> Seq Scan on +registered_voter_addresses addresses1_ (cost=0.00..271622.23 +rows=4919923 width=120) (actual time=0.025..98416.667 rows=4918205 +loops=1)" +" -> Hash (cost=260.35..260.35 +rows=1147 width=173) (actual time=101.582..101.582 rows=1147 loops=1)" +" -> Hash Join +(cost=48.80..260.35 rows=1147 width=173) (actual time=88.608..98.984 +rows=1147 loops=1)" +" Hash Cond: +(("outer".region_id)::text = ("inner".region_id)::text)" +" -> Seq Scan on +regions city4_1_ (cost=0.00..162.39 rows=7539 width=53) (actual +time=0.048..35.204 rows=7539 loops=1)" +" -> Hash +(cost=45.93..45.93 rows=1147 width=120) (actual time=48.896..48.896 +rows=1147 loops=1)" +" -> Nested Loop + (cost=0.00..45.93 rows=1147 width=120) (actual time=35.791..47.012 +rows=1147 loops=1)" +" -> Index +Scan using regions_pkey on regions region3_ (cost=0.00..5.99 rows=1 +width=40) (actual time=35.761..35.763 rows=1 loops=1)" +" +Index Cond: ((region_id)::text = +'093c44e8-f3b2-4c60-8be3-2b4d148f9f5a'::text)" +" -> Seq +Scan on cities city4_ (cost=0.00..28.47 rows=1147 width=80) (actual +time=0.022..9.476 rows=1147 loops=1)" +"Total runtime: 3052707.269 ms" + + +From pgsql-performance-owner@postgresql.org Wed Feb 22 18:07:37 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id C4D299DC84B + for ; + Wed, 22 Feb 2006 18:07:36 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 88947-07 + for ; + Wed, 22 Feb 2006 18:07:38 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.197]) + by postgresql.org (Postfix) with ESMTP id B50959DC832 + for ; + Wed, 22 Feb 2006 18:07:34 -0400 (AST) +Received: by zproxy.gmail.com with SMTP id n1so1650402nzf + for ; + Wed, 22 Feb 2006 14:07:36 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:sender:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; + b=Wc/LWC3L2wyVHy/4w25yZCbML8PrDZ4p4JOTXKTRUXh476Xg0ADcTIQ1x5l/RQvUeU4CxSD/XSTy/EhHVMNV+TY5GNDY6l44Nc+TKkSQliR4SmdTmvH652//78yoBKqMKIPW9jx8ak7oldaHLd+8ri2n93maTwY7sFEQvJ1MW9I= +Received: by 10.36.90.14 with SMTP id n14mr2998531nzb; + Wed, 22 Feb 2006 14:07:36 -0800 (PST) +Received: by 10.36.128.16 with HTTP; Wed, 22 Feb 2006 14:07:35 -0800 (PST) +Message-ID: <415a0600602221407h5287ab7cl93ed2d796d8c9460@mail.gmail.com> +Date: Wed, 22 Feb 2006 14:07:35 -0800 +From: Orion +To: pgsql-performance@postgresql.org +Subject: Re: Large Database Design Help +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, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200602/356 +X-Sequence-Number: 17342 + +I just wanted to thank everyone for your input on my question. You've +given me a lot of tools to solve my problem here. + +Orion + +From pgsql-performance-owner@postgresql.org Wed Feb 22 19:39:09 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id DCF899DC93E + for ; + Wed, 22 Feb 2006 19:39:08 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 98383-10 + for ; + Wed, 22 Feb 2006 19:39:11 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from peufeu.com (unknown [82.67.9.10]) + by postgresql.org (Postfix) with ESMTP id 89A409DC832 + for ; + Wed, 22 Feb 2006 19:18:13 -0400 (AST) +Received: (qmail 15440 invoked from network); 23 Feb 2006 00:19:00 +0100 +Received: from unknown (HELO apollo13) (82.67.9.10) + by boutiquenumerique.com with SMTP; 23 Feb 2006 00:19:00 +0100 +To: "ryan groth" , + "Stephan Szabo" , + "Steinar H. Gunderson" , + pgsql-performance@postgresql.org +Subject: Re: Joins and full index scans...mysql vs postgres? +References: +Message-ID: +Date: Thu, 23 Feb 2006 00:18:58 +0100 +From: PFC +Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +In-Reply-To: +User-Agent: Opera M2/8.51 (Linux, build 1462) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.1 required=5 tests=[AWL=0.100] +X-Spam-Score: 0.1 +X-Spam-Level: +X-Archive-Number: 200602/357 +X-Sequence-Number: 17343 + + +> "997+3522 ms". Am I reading these numbers wrong? Are these numbers +> reflective of application performance? Is there an optimization I am +> missing? + + It also reflects the time it takes to pgadmin to insert the results into +its GUI... + + If you want to get an approximation of the time the server needs to +process your request, without the data marshalling time on the network and +anything, you can either use EXPLAIN ANALYZE (but mysql doesn't have it, +and the instrumentation adds overhead), or simply something like "SELECT +sum(1) FROM (query to benchmark)", which only returns 1 row, and the sum() +overhead is minimal, and it works on most databases. I find it useful +because in knowing which portion of the time is spent by the server +processing the query, or in data transfer, or in data decoding on the +client side, or simply in displaying... + +From pgsql-performance-owner@postgresql.org Wed Feb 22 19:58:44 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 1AFB99DC89B + for ; + Wed, 22 Feb 2006 19:58:44 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 04621-01 + for ; + Wed, 22 Feb 2006 19:58:46 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.202]) + by postgresql.org (Postfix) with ESMTP id 8651F9DC868 + for ; + Wed, 22 Feb 2006 19:58:41 -0400 (AST) +Received: by zproxy.gmail.com with SMTP id i11so1555229nzh + for ; + Wed, 22 Feb 2006 15:58:44 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:user-agent:x-accept-language:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding; + b=oZ3aMtcYZWBMA2SqGMFmAnkSBomE3FZ7HTwFHmvsRdPZnK+FGeP5QW5uoHX/V1yEvcTsYWqq8R7hDIUQxs+0EQfHmCB44IR45DH1Normq1lVmwqqjX2JQNlSiQEc6EJoT7aVtp5uP9kZnSDEJkrCe+N10vAuqWuaFdXo9/DS93g= +Received: by 10.36.157.19 with SMTP id f19mr5665694nze; + Wed, 22 Feb 2006 15:58:43 -0800 (PST) +Received: from ?10.1.1.23? ( [203.217.18.65]) + by mx.gmail.com with ESMTP id 37sm1263416nzf.2006.02.22.15.58.42; + Wed, 22 Feb 2006 15:58:43 -0800 (PST) +Message-ID: <43FCFAAF.1090404@gmail.com> +Date: Thu, 23 Feb 2006 10:58:39 +1100 +From: Chris +User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: ryan groth +CC: pgsql-performance@postgresql.org +Subject: Re: Joins and full index scans...mysql vs postgres? +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, score=0.124 required=5 tests=[AWL=0.124] +X-Spam-Score: 0.124 +X-Spam-Level: +X-Archive-Number: 200602/358 +X-Sequence-Number: 17344 + +ryan groth wrote: +> I am issing a query like this: +> SELECT * +> FROM users users +> LEFT JOIN phorum_users_base ON users.uid = phorum_users_base.user_id +> LEFT JOIN useraux ON useraux.uid = users.uid; +> + + +I'm not sure if postgres would rewrite your query to do the joins +properly, though I guess someone else might've already suggested this :) + + +I'm probably wrong but I read that as: + +join users -> phorum_users_base (ON users.uid = phorum_users_base.user_id) + +join phorum_users_base -> useraux (ON useraux.uid = users.uid) which +won't be indexable because u.uid doesn't exist in phorum_users_base. + + + +Try + +SELECT * +FROM users users +LEFT JOIN phorum_users_base ON users.uid = phorum_users_base.user_id +LEFT JOIN useraux ON useraux.uid = phorum_users_base.user_id + +or + +SELECT * +FROM users u, phorum_users_base pub, useraux ua WHERE u.uid = +pub.user_id AND au.uid = u.uid AND pub.user_id=au.uid; + + +-- +Postgresql & php tutorials +http://www.designmagick.com/ + +From pgsql-performance-owner@postgresql.org Wed Feb 22 22:48:38 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 1D3199DC97F + for ; + Wed, 22 Feb 2006 22:48:38 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 39500-09 + for ; + Wed, 22 Feb 2006 22:48:42 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from houston.familyhealth.com.au (houston.au.fhnetwork.com + [203.22.197.21]) + by postgresql.org (Postfix) with ESMTP id 69D9E9DC868 + for ; + Wed, 22 Feb 2006 22:48:35 -0400 (AST) +Received: from houston.familyhealth.com.au (localhost [127.0.0.1]) + by houston.familyhealth.com.au (Postfix) with ESMTP id 299B4250A7; + Thu, 23 Feb 2006 10:48:35 +0800 (WST) +Received: from [127.0.0.1] (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (Postfix) with ESMTP id BEEFC2507D; + Thu, 23 Feb 2006 10:48:30 +0800 (WST) +Message-ID: <43FD235B.7000207@familyhealth.com.au> +Date: Thu, 23 Feb 2006 10:52:11 +0800 +From: Christopher Kings-Lynne +User-Agent: Thunderbird 1.5 (Windows/20051201) +MIME-Version: 1.0 +To: ryan groth +Cc: Stephan Szabo , + "Steinar H. Gunderson" , + pgsql-performance@postgresql.org +Subject: Re: Joins and full index scans...mysql vs postgres? +References: +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-familyhealth-MailScanner-Information: Please contact the ISP for more + information +X-familyhealth-MailScanner: Found to be clean +X-familyhealth-MailScanner-From: chriskl@familyhealth.com.au +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.096 required=5 tests=[AWL=0.096] +X-Spam-Score: 0.096 +X-Spam-Level: +X-Archive-Number: 200602/359 +X-Sequence-Number: 17345 + +The pgAdmin query tool is known to give an answer about 5x the real +answer - don't believe it! + +ryan groth wrote: +> Hmm, it came from the timer on the pgadmin III sql query tool. I guess +> the 1,000ms includes the round-trip? See the wierd thing is that +> mysqlserver is running default configuration on a virtual machine +> (P3/1.3GHZ conf'd for 128mb ram) over a 100m/b ethernet connection. +> Postgres is running on a real P4/3.0ghz 4GB running localhost. Timings +> from the mysql query tool indicate that the 6.5k record query runs in +> "1.3346s (.3361s)" vs. the pgadmin query tool saying that the query runs +> "997+3522 ms". Am I reading these numbers wrong? Are these numbers +> reflective of application performance? Is there an optimization I am +> missing? +> +> Ryan +> +> +>> On Wed, 22 Feb 2006, ryan groth wrote: +>> +>>> Does this work: +>>> +>>> "Merge Left Join (cost=0.00..2656.36 rows=6528 width=1522) (actual +>>> time=0.057..123.659 rows=6528 loops=1)" +>>> " Merge Cond: ("outer".uid = "inner".uid)" +>>> " -> Merge Left Join (cost=0.00..1693.09 rows=6528 width=1264) +>>> (actual time=0.030..58.876 rows=6528 loops=1)" +>>> " Merge Cond: ("outer".uid = "inner".user_id)" +>>> " -> Index Scan using users_pkey on users (cost=0.00..763.81 +>>> rows=6528 width=100) (actual time=0.016..9.446 rows=6528 loops=1)" +>>> " -> Index Scan using phorum_users_base_pkey on +>>> phorum_users_base (cost=0.00..822.92 rows=9902 width=1168) (actual +>>> time=0.007..15.674 rows=9845 loops=1)" +>>> " -> Index Scan using useraux_pkey on useraux (cost=0.00..846.40 +>>> rows=7582 width=262) (actual time=0.007..11.935 rows=7529 loops=1)" +>>> "Total runtime: 127.442 ms" +>> Well, this implies the query took about 127 ms on the server side. Where +>> did the 1000 ms number come from (was that on a client, and if so, what +>> type)? +>> +>> ---------------------------(end of broadcast)--------------------------- +>> TIP 6: explain analyze is your friend +>> +>> +> + + +From pgsql-performance-owner@postgresql.org Wed Feb 22 23:52:50 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 05D719DC99C + for ; + Wed, 22 Feb 2006 23:52:48 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 55585-05 + for ; + Wed, 22 Feb 2006 23:52:53 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) + by postgresql.org (Postfix) with ESMTP id 076579DC97F + for ; + Wed, 22 Feb 2006 23:52:46 -0400 (AST) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1FC7X6-0005DW-00; Wed, 22 Feb 2006 22:52:48 -0500 +To: "Kevin Grittner" +Cc: +Subject: Re: Good News re count(*) in 8.1 +References: <43FC4384.EE98.0025.0@wicourts.gov> +In-Reply-To: <43FC4384.EE98.0025.0@wicourts.gov> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 22 Feb 2006 22:52:48 -0500 +Message-ID: <87irr6zq7j.fsf@stark.xeocode.com> +Lines: 16 +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, score=0.13 required=5 tests=[AWL=0.130] +X-Spam-Score: 0.13 +X-Spam-Level: +X-Archive-Number: 200602/360 +X-Sequence-Number: 17346 + + +"Kevin Grittner" writes: + +> There have been several times that I have run a SELECT COUNT(*) on an entire +> table on all central machines. On identical hardware, with identical data, +> and equivalent query loads, the PostgreSQL databases have responded with a +> count in 50% to 70% of the time of the commercial product, in spite of the +> fact that the commercial product does a scan of a non-clustered index while +> PostgreSQL scans the data pages. + +I take it these are fairly narrow rows? The big benefit of index-only scans +come in when you're scanning extremely wide tables, often counting rows +matching some indexed criteria. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Thu Feb 23 06:21:42 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id EB0B49DC88B + for ; + Thu, 23 Feb 2006 06:21:41 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 12121-10 + for ; + Thu, 23 Feb 2006 06:21:43 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from moutng.kundenserver.de (moutng.kundenserver.de + [212.227.126.187]) + by postgresql.org (Postfix) with ESMTP id 2E4959DC833 + for ; + Thu, 23 Feb 2006 06:21:39 -0400 (AST) +Received: from [84.143.19.230] (helo=pse.dyndns.org) + by mrelayeu.kundenserver.de (node=mrelayeu8) with ESMTP (Nemesis), + id 0ML2ov-1FCDbK2d32-0007mt; Thu, 23 Feb 2006 11:21:38 +0100 +Received: from pse1 ([192.168.0.3]) by pse.dyndns.org with esmtp (Exim 4.44) + id 1FCDbI-0001YX-2H; Thu, 23 Feb 2006 11:21:32 +0100 +Message-ID: <43FD8CA6.10802@pse-consulting.de> +Date: Thu, 23 Feb 2006 10:21:26 +0000 +From: Andreas Pflug +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Christopher Kings-Lynne +CC: ryan groth , + Stephan Szabo , + "Steinar H. Gunderson" , + pgsql-performance@postgresql.org +Subject: Re: Joins and full index scans...mysql vs postgres? +References: + <43FD235B.7000207@familyhealth.com.au> +In-Reply-To: <43FD235B.7000207@familyhealth.com.au> +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-Provags-ID: kundenserver.de abuse@kundenserver.de + login:0ce7ee5c3478b8d72edd8e05ccd40b70 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.081 required=5 tests=[AWL=0.081] +X-Spam-Score: 0.081 +X-Spam-Level: +X-Archive-Number: 200602/361 +X-Sequence-Number: 17347 + +Christopher Kings-Lynne wrote: +> The pgAdmin query tool is known to give an answer about 5x the real +> answer - don't believe it! + +Everybody please forget immediately the factor 5. It's no factor at all, +but the GUI update time that is *added*, which depends on rows*columns. + + +> ryan groth wrote: +> +>> the pgadmin query tool saying that the query runs +>> "997+3522 ms". + +Means 997ms until all data is at the client (libpq reports the rowset), +the rest is GUI overhead. + +Regards, +Andreas + +From pgsql-performance-owner@postgresql.org Thu Feb 23 08:35:59 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 961F69DC806 + for ; + Thu, 23 Feb 2006 08:35:58 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 35107-02 + for ; + Thu, 23 Feb 2006 08:36:00 -0400 (AST) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 0204B9DC876 + for ; + Thu, 23 Feb 2006 08:35:56 -0400 (AST) +Received: from server19320152131.serverpool.info + (server19320152131.serverpool.info [193.201.52.131]) + by svr4.postgresql.org (Postfix) with ESMTP id 5B16E5AF84B + for ; + Thu, 23 Feb 2006 12:35:58 +0000 (GMT) +Received: from [192.168.0.83] (p548EE499.dip.t-dialin.net [84.142.228.153]) + by server19320152131.serverpool.info (Postfix) with ESMTP id + 4F80A190058 for ; + Thu, 23 Feb 2006 13:35:52 +0100 (CET) +Message-ID: <43FDAC27.7050305@profiling-company.de> +Date: Thu, 23 Feb 2006 13:35:51 +0100 +From: Kjeld Peters +User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051019) +X-Accept-Language: de-DE, de, en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Created Index is not used +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, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200602/362 +X-Sequence-Number: 17348 + +Select and update statements are quite slow on a large table with more +than 600,000 rows. The table consists of 11 columns (nothing special). +The column "id" (int8) is primary key and has a btree index on it. + +The following select statement takes nearly 500ms: + +SELECT * FROM table WHERE id = 600000; + +A prepending "EXPLAIN" to the statement reveals a seq scan: + +EXPLAIN SELECT * FROM table WHERE id = 600000; + +"Seq Scan on table (cost=0.00..15946.48 rows=2 width=74)" +" Filter: (id = 600000)" + +I tried a full vacuum and a reindex, but had no effect. Why is +PostgreSQL not using the created index? + +Or is there any other way to improve performance on this query? + +The PostgreSQL installation is an out of the box installation with no +further optimization. The server is running SUSE Linux 9.1, kernel +2.6.4-52-smp. (Quad Xeon 2.8GHz, 1GB RAM) + +SELECT version(); +"PostgreSQL 7.4.2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.3.3 +(SuSE Linux)" + + +Thanks for any hints, +Kjeld + +From pgsql-performance-owner@postgresql.org Thu Feb 23 09:07:57 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 967529DC9B2 + for ; + Thu, 23 Feb 2006 09:07:56 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 41332-04 + for ; + Thu, 23 Feb 2006 09:07:58 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.tacotec.de (mail.tacotec.de [83.137.101.41]) + by postgresql.org (Postfix) with ESMTP id A48109DC9E5 + for ; + Thu, 23 Feb 2006 09:07:52 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by mail.tacotec.de (Postfix) with ESMTP id 4521711D4ED; + Thu, 23 Feb 2006 14:07:54 +0100 (CET) +Received: from mail.tacotec.de ([83.137.101.41]) + by localhost (hera.tacotec.de [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 28938-03; Thu, 23 Feb 2006 14:07:54 +0100 (CET) +Received: from kingfisher.intern.logix-tt.com (Mea8d.m.pppool.de + [89.49.234.141]) + by mail.tacotec.de (Postfix) with ESMTP id E8A6911D3E5; + Thu, 23 Feb 2006 14:07:53 +0100 (CET) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id 379BB181C0F6B; + Thu, 23 Feb 2006 13:46:04 +0100 (CET) +Message-ID: <43FDAE8A.60805@logix-tt.com> +Date: Thu, 23 Feb 2006 13:46:02 +0100 +From: Markus Schaber +Organization: Logical Tracking and Tracing International AG, Switzerland +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Kjeld Peters +Cc: pgsql-performance@postgresql.org +Subject: Re: Created Index is not used +References: <43FDAC27.7050305@profiling-company.de> +In-Reply-To: <43FDAC27.7050305@profiling-company.de> +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=ISO-8859-15 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at mail.tacotec.de +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.122 required=5 tests=[AWL=0.122] +X-Spam-Score: 0.122 +X-Spam-Level: +X-Archive-Number: 200602/365 +X-Sequence-Number: 17351 + +Hi, Kjeld, + +Kjeld Peters wrote: +> Select and update statements are quite slow on a large table with more +> than 600,000 rows. The table consists of 11 columns (nothing special). +> The column "id" (int8) is primary key and has a btree index on it. +> +> The following select statement takes nearly 500ms: +> +> SELECT * FROM table WHERE id = 600000; + +Known issue which is fixed in 8.X servers, postgreSQL sees your 600000 +as int4 literal and does not grasp that the int8 index works for it. + +SELECT * FROM table WHERE id = 600000::int8; + +should do it. + +> SELECT version(); +> "PostgreSQL 7.4.2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.3.3 +> (SuSE Linux)" + +Btw, you should update to 7.4.12, there are importand bug fixes and it +is upgradable "in place", without dumping and reloading the database. + +HTH, +Markus + +-- +Markus Schaber | Logical Tracking&Tracing International AG +Dipl. Inf. | Software Development GIS + +Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org + +From pgsql-performance-owner@postgresql.org Thu Feb 23 08:52:37 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 7D0189DC9E5 + for ; + Thu, 23 Feb 2006 08:52:36 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 35484-07 + for ; + Thu, 23 Feb 2006 08:52:39 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.206]) + by postgresql.org (Postfix) with ESMTP id 195BF9DC9B2 + for ; + Thu, 23 Feb 2006 08:52:32 -0400 (AST) +Received: by zproxy.gmail.com with SMTP id j2so46294nzf + for ; + Thu, 23 Feb 2006 04:52:35 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; + b=rDsHlYjV/Kxp88A8Lhs++ebsLhsqwhH/Tk/vkP+N26SFcx9NQdelrHYzt//3B76VslUbnADSuLYiSX04f9k5Xv4Qppkkc5fE24vdtLtF2C25M/DH+krgvnB9c0caZBTeCoAUOEX6oQT51zjPF0z/nk8+QI6+3LSMQ2UXNQNNgb8= +Received: by 10.37.18.35 with SMTP id v35mr2293073nzi; + Thu, 23 Feb 2006 04:52:35 -0800 (PST) +Received: by 10.36.106.12 with HTTP; Thu, 23 Feb 2006 04:52:35 -0800 (PST) +Message-ID: +Date: Thu, 23 Feb 2006 14:52:35 +0200 +From: "Ibrahim Tekin" +To: "Brendan Duddridge" +Subject: Re: LIKE query on indexes +Cc: "Scott Marlowe" , + pgsql-performance@postgresql.org +In-Reply-To: <78873B6F-1572-467C-8F98-9715FC8AC4AC@clickspace.com> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_5700_33202965.1140699155449" +References: + <1140538679.5777.3.camel@state.g2switchworks.com> + <20060221163416.GC6541@surnet.cl> + + <78873B6F-1572-467C-8F98-9715FC8AC4AC@clickspace.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.312 required=5 tests=[AWL=0.311, + HTML_MESSAGE=0.001] +X-Spam-Score: 0.312 +X-Spam-Level: +X-Archive-Number: 200602/363 +X-Sequence-Number: 17349 + +------=_Part_5700_33202965.1140699155449 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +hi, + +i ran a query with ILIKE but it doesn't use the index. + +but i tried following method, and it worked. there is 3 extra lower() +overhead but i don't think it will effect the performance. + +CREATE INDEX index_name ON mytable (lower(column) varchar_pattern_ops); + +SELECT * FROM mytable WHERE lower(column) LIKE lower('beginswith%') + +if insert operations are high in database. you use only this index to searc= +h +case sensitive. + +say you want this: +SELECT * FROM mytable WHERE column LIKE 'beGinsWith%' + +write this: +SELECT * FROM mytable WHERE lower(column) LIKE lower('beGinsWith%') AND +column LIKE 'beGinsWith%' + +than query planner will search on index, than scan the resulting bitmap +heap. + + +On 2/22/06, Brendan Duddridge wrote: +> +> Hi, +> Can this technique work with case insensitive ILIKE? +> +> It didn't seem to use the index when I used ILIKE instead of LIKE. +> Thanks, +> * +> *____________________________________________________________________ +> *Brendan Duddridge* | CTO | 403-277-5591 x24 | brendan@clickspace.com +> * +> *ClickSpace Interactive Inc. +> Suite L100, 239 - 10th Ave. SE +> Calgary, AB T2G 0V9 +> +> http://www.clickspace.com +> +> On Feb 21, 2006, at 1:28 PM, Ibrahim Tekin wrote: +> +> this trick did the job. +> thanks. +> +> On 2/21/06, Alvaro Herrera wrote: +> > +> > Scott Marlowe wrote: +> > > On Tue, 2006-02-21 at 09:57, Ibrahim Tekin wrote: +> > > > hi, +> > > > i have btree index on a text type field. i want see rows which +> > starts +> > > > with certain characters on that field. so i write a query like this= +: +> > > > +> > > > SELECT * FROM mytable WHERE myfield LIKE 'john%' +> > > > +> > > > since this condition is from start of the field, query planner +> > should +> > > > use index to find such elements but explain command shows me it wil= +l +> > > > do a sequential scan. +> > > > +> > > > is this lack of a feature or i am wrong somewhere? +> > > +> > > This is an artifact of how PostgreSQL handles locales other than +> > ASCII. +> > > +> > > If you want such a query to use an index, you need to back up your +> > > database, and re-initdb with --locale=3DC as an argument. +> > +> > ... or you can choose to create an index with the text_pattern_ops +> > operator class, which would be used in a LIKE constraint regardless of +> > locale. +> > +> > http://www.postgresql.org/docs/8.1/static/indexes-opclass.html +> > +> > -- +> > Alvaro Herrera http://www.CommandPrompt.= +com/ +> > The PostgreSQL Company - Command Prompt, Inc. +> > +> +> +> +> + +------=_Part_5700_33202965.1140699155449 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +hi,

i ran a query with ILIKE but it doesn't use the index.

bu= +t i tried following method, and it worked. there is 3 extra lower() overhea= +d but i don't think it will effect the performance.

CREATE INDEX ind= +ex_name ON mytable (lower(column) varchar_pattern_ops); +

SELECT * FROM mytable WHERE lower(column) LIKE lower('beginswith%')= +

if insert operations are high in database. you use only this index = +to search case sensitive.

say you want this:
SELECT * FROM mytabl= +e WHERE column LIKE 'beGinsWith%' +

write this:
SELECT * FROM mytable WHERE lower(column) LIKE lower= +('beGinsWith%') AND column LIKE 'beGinsWith%'

than query planner wil= +l search on index, than scan the resulting bitmap heap.


+On 2/22/06, Brend= +an Duddridge <brendan@clic= +kspace.com> wrote:
+Hi,

Can this technique work with case insensitive ILIKE?= +

It didn't seem to use the index when I used ILIKE= + instead of LIKE.

Thanks,
+
______________________________________= +______________________________
Brendan Duddridge | CTO | 403= +-277-5591 x24 |   +brendan@clickspace.com
+
ClickSpace Interactive Inc.
Suite L100, 239 - 10th Ave. SE
Calg= +ary, AB  T2G 0V9

+http://www.clickspace.com 

On Feb 21, 2006, = +at 1:28 PM, Ibrahim Tekin wrote: +

this trick did the job.
thanks.
= +
On 2/21/06, Alvaro Herrera < +alvherre@commandprompt.com> wrote:
Scott Marlowe wrote:
> On Tue, 2006-0= +2-21 at 09:57, Ibrahim Tekin wrote: +
> > hi,
> > i have btree index on a text type field. i = +want see rows which starts
> > with certain characters on that fie= +ld. so i write a query like this:
> >
> > SELECT * FROM m= +ytable WHERE myfield LIKE 'john%'=20 +
> >
> > since this condition is from start of the field,= + query planner should
> > use index to find such elements but expl= +ain command shows me it will
> > do a sequential scan.
> >= +;=20 +
> > is this lack of a feature or i am wrong somewhere?
>> This is an artifact of how PostgreSQL handles locales other than ASCI= +I.
>
> If you want such a query to use an index, you need to ba= +ck up your=20 +
> database, and re-initdb with --locale=3DC as an argument.

.= +.. or you can choose to create an index with the text_pattern_ops
operat= +or class, which would be used in a LIKE constraint regardless of
locale.= +=20 +

http://www.postgresql.org/docs/8.1/static/indexes-opclass.html<= +br> +
--
Alvaro Herrera        &nb= +sp;            = +            http://www.CommandPrompt.com/
Th= +e PostgreSQL Company - Command Prompt, Inc. +


+

+ +------=_Part_5700_33202965.1140699155449-- + +From pgsql-performance-owner@postgresql.org Thu Feb 23 09:01:30 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 1E8649DC876 + for ; + Thu, 23 Feb 2006 09:01:30 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 36149-09 + for ; + Thu, 23 Feb 2006 09:01:33 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx1.hive.is (scania.ipf.is [85.197.192.147]) + by postgresql.org (Postfix) with SMTP id 6F0DE9DC806 + for ; + Thu, 23 Feb 2006 09:01:27 -0400 (AST) +Received: (qmail 49485 invoked by uid 1010); 23 Feb 2006 13:01:45 -0000 +Received: from 85.197.216.186 by scania.ipf.is (envelope-from , + uid 1009) with qmail-scanner-1.25-st-qms + (clamdscan: 0.88/1283. spamassassin: 3.1.0. perlscan: 1.25-st-qms. + Clear:RC:1(85.197.216.186):SA:0(-4.1/4.0):. + Processed in 1.595911 secs); 23 Feb 2006 13:01:45 -0000 +X-Antivirus-HIVE-Mail-From: gnari@hive.is via scania.ipf.is +X-Antivirus-HIVE: 1.25-st-qms (Clear:RC:1(85.197.216.186):SA:0(-4.1/4.0):. + Processed in 1.595911 secs Process 49460) +Received: from dsl-216-186.hive.is (HELO ?192.168.1.34?) (85.197.216.186) + by mx1.hive.is with SMTP; 23 Feb 2006 13:01:41 -0000 +Subject: Re: Created Index is not used +From: Ragnar +To: Kjeld Peters +Cc: pgsql-performance@postgresql.org +In-Reply-To: <43FDAC27.7050305@profiling-company.de> +References: <43FDAC27.7050305@profiling-company.de> +Content-Type: text/plain +Date: Thu, 23 Feb 2006 13:03:26 +0000 +Message-Id: <1140699807.5728.42.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.4.1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.142 required=5 tests=[AWL=0.142] +X-Spam-Score: 0.142 +X-Spam-Level: +X-Archive-Number: 200602/364 +X-Sequence-Number: 17350 + +On fim, 2006-02-23 at 13:35 +0100, Kjeld Peters wrote: +> Select and update statements are quite slow on a large table with more +> than 600,000 rows. The table consists of 11 columns (nothing special). +> The column "id" (int8) is primary key and has a btree index on it. +> +> The following select statement takes nearly 500ms: +> +> SELECT * FROM table WHERE id = 600000; +> +> A prepending "EXPLAIN" to the statement reveals a seq scan: +> +> EXPLAIN SELECT * FROM table WHERE id = 600000; +> +> "Seq Scan on table (cost=0.00..15946.48 rows=2 width=74)" +> " Filter: (id = 600000)" + +> I tried a full vacuum and a reindex, but had no effect. Why is +> PostgreSQL not using the created index? + +try one of: + +SELECT * FROM table WHERE id = '600000'; +SELECT * FROM table WHERE id = 600000::int8; +PostgreSQL 8+ + +gnari + + + + +From pgsql-performance-owner@postgresql.org Thu Feb 23 10:09:11 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 724D49DC9F9 + for ; + Thu, 23 Feb 2006 10:09:10 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 59680-04 + for ; + Thu, 23 Feb 2006 10:09:14 -0400 (AST) +X-Greylist: delayed 01:33:15.577642 by SQLgrey- +Received: from server19320152131.serverpool.info + (server19320152131.serverpool.info [193.201.52.131]) + by postgresql.org (Postfix) with ESMTP id AB1869DC9A1 + for ; + Thu, 23 Feb 2006 10:09:07 -0400 (AST) +Received: from [192.168.0.83] (p548EE499.dip.t-dialin.net [84.142.228.153]) + by server19320152131.serverpool.info (Postfix) with ESMTP id + 2F74A190058; Thu, 23 Feb 2006 15:09:11 +0100 (CET) +Message-ID: <43FDC206.2090102@profiling-company.de> +Date: Thu, 23 Feb 2006 15:09:10 +0100 +From: Kjeld Peters +User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051019) +X-Accept-Language: de-DE, de, en-us, en +MIME-Version: 1.0 +To: Markus Schaber +Cc: pgsql-performance@postgresql.org +Subject: Re: Created Index is not used +References: <43FDAC27.7050305@profiling-company.de> + <43FDAE8A.60805@logix-tt.com> +In-Reply-To: <43FDAE8A.60805@logix-tt.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, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200602/366 +X-Sequence-Number: 17352 + +Hi Markus, + +first of all thanks for your quick reply! + +Markus Schaber wrote: +> Kjeld Peters wrote: +>>Select and update statements are quite slow on a large table with more +>>than 600,000 rows. The table consists of 11 columns (nothing special). +>>The column "id" (int8) is primary key and has a btree index on it. +>> +>>The following select statement takes nearly 500ms: +>> +>>SELECT * FROM table WHERE id = 600000; +> +> +> Known issue which is fixed in 8.X servers, postgreSQL sees your 600000 +> as int4 literal and does not grasp that the int8 index works for it. +> +> SELECT * FROM table WHERE id = 600000::int8; +> +> should do it. + +After I appended "::int8" to the query, selecting the table takes only +40-50ms. That's a great performance boost! + +> Btw, you should update to 7.4.12, there are importand bug fixes and it +> is upgradable "in place", without dumping and reloading the database. + +I guess I'll test an upgrade to version 8.1. + +Thanks again for your and Ragnar's help! + +Kjeld + +From pgsql-performance-owner@postgresql.org Thu Feb 23 10:38:26 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 95E149DC9A1 + for ; + Thu, 23 Feb 2006 10:38:25 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 62792-08 + for ; + Thu, 23 Feb 2006 10:38:28 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from yertle.kcilink.com (yertle.kcilink.com [65.205.34.180]) + by postgresql.org (Postfix) with ESMTP id A9E7A9DC806 + for ; + Thu, 23 Feb 2006 10:38:22 -0400 (AST) +Received: from [192.168.7.103] (host-103.int.kcilink.com [192.168.7.103]) + by yertle.kcilink.com (Postfix) with ESMTP id CAB0BB80D + for ; + Thu, 23 Feb 2006 09:38:26 -0500 (EST) +Mime-Version: 1.0 (Apple Message framework v746.2) +In-Reply-To: + <544485BC51F81A41AC1A72CFA69013655640AF@AZ18EV805.global.ds.honeywell.com> +References: + <544485BC51F81A41AC1A72CFA69013655640AF@AZ18EV805.global.ds.honeywell.com> +Content-Type: multipart/alternative; boundary=Apple-Mail-1--810451207 +Message-Id: <62FC5203-3162-4ABE-BF47-DFE0116AC520@khera.org> +From: Vivek Khera +Subject: Re: +Date: Thu, 23 Feb 2006 09:38:25 -0500 +To: Postgresql Performance +X-Mailer: Apple Mail (2.746.2) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.062 required=5 tests=[AWL=0.061, + HTML_MESSAGE=0.001] +X-Spam-Score: 0.062 +X-Spam-Level: +X-Archive-Number: 200602/367 +X-Sequence-Number: 17353 + + +--Apple-Mail-1--810451207 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset=US-ASCII; + delsp=yes; + format=flowed + + +On Feb 22, 2006, at 10:44 PM, Chethana, Rao ((IE10)) wrote: + +> That is what I wanted to know, how do I tune it? + +If there were a simple formula for doing it, it would already have +been written up as a program that runs once you install postgres. + +You have to monitor your usage, use your understanding of your +application, and the Postgres manual to see what things to adjust. +It differs if you are CPU bound or I/O bound. + +And please keep this on list. + + +--Apple-Mail-1--810451207 +Content-Transfer-Encoding: quoted-printable +Content-Type: text/html; + charset=ISO-8859-1 + +
On Feb 22, 2006, = +at 10:44 PM, Chethana, Rao ((IE10)) wrote:

That is what I wanted to know,=A0 how do I tune = +it?


If there = +were a simple formula for doing it, it would already have been written = +up as a program that runs once you install postgres.

You have to monitor your = +usage, use your understanding of your application, and the Postgres = +manual to see what things to adjust.=A0 =A0It differs if you are CPU = +bound or I/O bound.

And please keep this on = +list.

= + +--Apple-Mail-1--810451207-- + +From pgsql-performance-owner@postgresql.org Thu Feb 23 12:29:51 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 7266D9DC97E + for ; + Thu, 23 Feb 2006 12:29:50 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 99156-08 + for ; + Thu, 23 Feb 2006 12:29:47 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from bramble.mmrd.com (bramble.mmrd.com [65.217.53.66]) + by postgresql.org (Postfix) with ESMTP id C8B429DC809 + for ; + Thu, 23 Feb 2006 12:29:46 -0400 (AST) +Received: from thorn.mmrd.com (thorn.mmrd.com [172.25.10.100]) + by bramble.mmrd.com (8.12.8/8.12.8) with ESMTP id k1NHPqkB025903 + for ; Thu, 23 Feb 2006 12:25:53 -0500 +Received: from gnvex001.mmrd.com (gnvex001.mmrd.com [10.225.10.110]) + by thorn.mmrd.com (8.11.6/8.11.6) with ESMTP id k1NGTgC02623 + for ; Thu, 23 Feb 2006 11:29:42 -0500 +Received: from [10.225.105.30] (10.225.105.30 [10.225.105.30]) by + gnvex001.mmrd.com with SMTP (Microsoft Exchange Internet Mail + Service Version 5.5.2657.72) + id TWDBKR4C; Thu, 23 Feb 2006 11:29:40 -0500 +Subject: how to interpret/improve bad row estimates +From: Robert Treat +To: pgsql-performance@postgresql.org +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +X-Mailer: Ximian Evolution 1.0.8 +Date: 23 Feb 2006 11:29:32 -0500 +Message-Id: <1140712182.2190.297.camel@camel> +Mime-Version: 1.0 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.129 required=5 tests=[AWL=0.129] +X-Spam-Score: 0.129 +X-Spam-Level: +X-Archive-Number: 200602/368 +X-Sequence-Number: 17354 + +postgresql 8.1, I have two tables, bot hoth vacuumed and analyzed. on +msg307 I have altered the entityid and msgid columns statistics values +to 400. + + +dev20001=# explain analyze SELECT ewm.entity_id, m.agentname, m.filecreatedate AS versioninfo + FROM msg307 m join entity_watch_map ewm on (ewm.entity_id = m.entityid AND ewm.msgid = m.msgid AND ewm.msg_type = 307); + + QUERY PLAN +----------------------------------------------------------------------------------------------------------------------------------------------- + Nested Loop (cost=6.62..5227.40 rows=1 width=36) (actual time=0.583..962.346 rows=75322 loops=1) + -> Bitmap Heap Scan on entity_watch_map ewm (cost=6.62..730.47 rows=748 width=8) (actual time=0.552..7.017 rows=1264 loops=1) + Recheck Cond: (msg_type = 307) + -> Bitmap Index Scan on ewm_msg_type (cost=0.00..6.62 rows=748 width=0) (actual time=0.356..0.356 rows=1264 loops=1) + Index Cond: (msg_type = 307) + -> Index Scan using msg307_entityid_msgid_idx on msg307 m (cost=0.00..6.00 rows=1 width=40) (actual time=0.011..0.295 rows=60 loops=1264) + Index Cond: (("outer".entity_id = m.entityid) AND ("outer".msgid = m.msgid)) + Total runtime: 1223.469 ms +(8 rows) + + +I guess that the planner can not tell there is no correlation between +the distinctness of those two columns, and so makes a really bad +estimate on the indexscan, and pushes that estimate up into the nested +loop? (luckily in this case doing an index scan is generally a good +idea, so it works out, but it wouldn't always be a good idea) + +some pg_statistics information for those two columns +entityid: +starelid | 25580 +staattnum | 1 +stanullfrac | 0 +stawidth | 4 +stadistinct | 1266 +stakind1 | 1 +stakind2 | 2 +stakind3 | 3 +stakind4 | 0 +staop1 | 96 +staop2 | 97 +staop3 | 97 +staop4 | 0 +stanumbers1 | {0.00222976,0.00222976,0.00153048,0.00137216,0.00137216} +stanumbers2 | +stanumbers3 | {0.100312} +stanumbers4 | + +msgid: +starelid | 25580 +staattnum | 2 +stanullfrac | 0 +stawidth | 4 +stadistinct | 1272 +stakind1 | 1 +stakind2 | 2 +stakind3 | 3 +stakind4 | 0 +staop1 | 96 +staop2 | 97 +staop3 | 97 +staop4 | 0 +stanumbers1 | {0.00164923,0.00163604,0.00163604,0.00163604,0.00137216} +stanumbers2 | +stanumbers3 | {-0.0660856} +stanumbers4 | + + +is my interpretation of why i am seeing such bad estimates correct? I +don't really think it is, because looking at a similar scenario on a 7.3 +machine: + +------------------------------------------------------------------------------------------------------------------------------------------------------ + Merge Join (cost=1531.39..5350.90 rows=1 width=48) (actual time=118.44..899.37 rows=58260 loops=1) + Merge Cond: (("outer".entityid = "inner".entity_id) AND ("outer".msgid = "inner".msgid)) + -> Index Scan using msg307_entityid_msgid_idx on msg307 m (cost=0.00..3669.42 rows=58619 width=40) (actual time=0.31..390.01 rows=58619 loops=1) + -> Sort (cost=1531.39..1533.16 rows=709 width=8) (actual time=118.09..157.45 rows=58218 loops=1) + Sort Key: ewm.entity_id, ewm.msgid + -> Seq Scan on entity_watch_map ewm (cost=0.00..1497.80 rows=709 width=8) (actual time=0.14..114.74 rows=1157 loops=1) + Filter: (msg_type = 307) + Total runtime: 951.23 msec +(8 rows) + + +It still has the bad estimate at the nested loop stage, but it does seem +to have a better understanding of the # of rows it will return in the +index scan on msg307. This leads me to wonder if there something I could +do to improve the estimates on the 8.1 machine? + + +Robert Treat +-- +Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL + + +From pgsql-hackers-owner@postgresql.org Thu Feb 23 12:38:53 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 559DE9DCA1C; + Thu, 23 Feb 2006 12:38:52 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 05948-06; Thu, 23 Feb 2006 12:38:50 -0400 (AST) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id DEE619DC856; + Thu, 23 Feb 2006 12:38:49 -0400 (AST) +Received: from pop-savannah.atl.sa.earthlink.net + (pop-savannah.atl.sa.earthlink.net [207.69.195.69]) + by svr4.postgresql.org (Postfix) with ESMTP id A4FDE5AF038; + Thu, 23 Feb 2006 16:38:49 +0000 (GMT) +Received: from elwamui-rustique.atl.sa.earthlink.net ([209.86.224.48]) + by pop-savannah.atl.sa.earthlink.net with esmtp (Exim 3.36 #10) + id 1FCJUO-0001Od-00; Thu, 23 Feb 2006 11:38:48 -0500 +Message-ID: + <17961438.1140712728036.JavaMail.root@elwamui-rustique.atl.sa.earthlink.net> +Date: Thu, 23 Feb 2006 11:38:48 -0500 (GMT-05:00) +From: Ron Peacetree +Reply-To: Ron Peacetree +To: pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org +Subject: Looking for a tool to "*" pg tables as ERDs +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, score=0.479 required=5 tests=[DNS_FROM_RFC_ABUSE=0.479] +X-Spam-Score: 0.479 +X-Spam-Level: +X-Archive-Number: 200602/948 +X-Sequence-Number: 80086 + +Where "*" == +{print | save to PDF | save to format | display on screen} + +Anyone know of one? + +TiA +Ron + +From pgsql-hackers-owner@postgresql.org Thu Feb 23 12:48:10 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id C82889DCB8D; + Thu, 23 Feb 2006 12:48:09 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 06509-08; Thu, 23 Feb 2006 12:48:07 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.logix-tt.com (serval.logix-tt.com [213.239.221.42]) + by postgresql.org (Postfix) with ESMTP id F2C319DCA83; + Thu, 23 Feb 2006 12:48:06 -0400 (AST) +Received: from kingfisher.intern.logix-tt.com (Mea8d.m.pppool.de + [89.49.234.141]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logix-tt.com (Postfix) with ESMTP id 86C2C24407F; + Thu, 23 Feb 2006 17:48:04 +0100 (CET) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id F3E6F181B2EB2; + Thu, 23 Feb 2006 17:48:04 +0100 (CET) +Message-ID: <43FDE741.7070403@logix-tt.com> +Date: Thu, 23 Feb 2006 17:48:01 +0100 +From: Markus Schaber +Organization: Logical Tracking and Tracing International AG, Switzerland +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Ron Peacetree +Cc: pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Looking for a tool to "*" pg tables as ERDs +References: + <17961438.1140712728036.JavaMail.root@elwamui-rustique.atl.sa.earthlink.net> +In-Reply-To: + <17961438.1140712728036.JavaMail.root@elwamui-rustique.atl.sa.earthlink.net> +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.122 required=5 tests=[AWL=0.122] +X-Spam-Score: 0.122 +X-Spam-Level: +X-Archive-Number: 200602/949 +X-Sequence-Number: 80087 + +Hi, Ron, + +Ron Peacetree wrote: +> Where "*" == +> {print | save to PDF | save to format | display on screen} +> +> Anyone know of one? + +psql with fancy output formatting comes to my mind, or "COPY table TO +file" SQL command. + +HTH, +Markus +-- +Markus Schaber | Logical Tracking&Tracing International AG +Dipl. Inf. | Software Development GIS + +Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org + +From pgsql-hackers-owner@postgresql.org Thu Feb 23 12:59:40 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 77ABF9DC9FA + for ; + Thu, 23 Feb 2006 12:59:39 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 09544-08 + for ; + Thu, 23 Feb 2006 12:59:38 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from trolak.mydnsbox2.com (ns1.mydnsbox2.com [207.44.142.118]) + by postgresql.org (Postfix) with ESMTP id 063559DC9F9 + for ; + Thu, 23 Feb 2006 12:59:36 -0400 (AST) +Received: from [192.168.1.106] (68.143.134.146.nw.nuvox.net [68.143.134.146]) + (authenticated (0 bits)) + by trolak.mydnsbox2.com (8.11.6/8.11.6) with ESMTP id k1NHK8509317; + Thu, 23 Feb 2006 11:20:08 -0600 +Message-ID: <43FDE9F3.9000109@dunslane.net> +Date: Thu, 23 Feb 2006 11:59:31 -0500 +From: Andrew Dunstan +User-Agent: Mozilla Thunderbird 1.0.7-1.1.fc4 (X11/20050929) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Markus Schaber +CC: Ron Peacetree , pgsql-hackers@postgresql.org +Subject: Re: [PERFORM] Looking for a tool to "*" pg tables as ERDs +References: + <17961438.1140712728036.JavaMail.root@elwamui-rustique.atl.sa.earthlink.net> + <43FDE741.7070403@logix-tt.com> +In-Reply-To: <43FDE741.7070403@logix-tt.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, score=0.091 required=5 tests=[AWL=0.091] +X-Spam-Score: 0.091 +X-Spam-Level: +X-Archive-Number: 200602/952 +X-Sequence-Number: 80090 + + + + +Markus Schaber wrote: + +>Hi, Ron, +> +>Ron Peacetree wrote: +> +> +>>Where "*" == +>>{print | save to PDF | save to format | display on screen} +>> +>>Anyone know of one? +>> +>> +> +>psql with fancy output formatting comes to my mind, or "COPY table TO +>file" SQL command. +> +> +> +> + +How on earth can either of these have to do with producing an ERD? + +postgresql_autodoc might help: http://pgfoundry.org/projects/autodoc/ + +cheers + +andrew + + + + +From pgsql-performance-owner@postgresql.org Thu Feb 23 13:06:56 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id CD9C39DC856 + for ; + Thu, 23 Feb 2006 13:06:55 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18295-01 + for ; + Thu, 23 Feb 2006 13:06:53 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from yertle.kcilink.com (yertle.kcilink.com [65.205.34.180]) + by postgresql.org (Postfix) with ESMTP id 095A79DC806 + for ; + Thu, 23 Feb 2006 13:06:52 -0400 (AST) +Received: from [192.168.7.103] (host-103.int.kcilink.com [192.168.7.103]) + by yertle.kcilink.com (Postfix) with ESMTP id 86D73B80D + for ; + Thu, 23 Feb 2006 12:06:52 -0500 (EST) +Mime-Version: 1.0 (Apple Message framework v746.2) +In-Reply-To: + <17961438.1140712728036.JavaMail.root@elwamui-rustique.atl.sa.earthlink.net> +References: + <17961438.1140712728036.JavaMail.root@elwamui-rustique.atl.sa.earthlink.net> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <0FFE36E7-A61D-4DC3-A74D-D9549A44A1F6@khera.org> +Content-Transfer-Encoding: 7bit +From: Vivek Khera +Subject: Re: Looking for a tool to "*" pg tables as ERDs +Date: Thu, 23 Feb 2006 12:06:51 -0500 +To: Postgresql Performance +X-Mailer: Apple Mail (2.746.2) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.067 required=5 tests=[AWL=0.067] +X-Spam-Score: 0.067 +X-Spam-Level: +X-Archive-Number: 200602/371 +X-Sequence-Number: 17357 + + +On Feb 23, 2006, at 11:38 AM, Ron Peacetree wrote: + +> Where "*" == +> {print | save to PDF | save to format | display on screen} +> +> Anyone know of one? + +There's a perl module, GraphViz::DBI::General, which does a rather +nifty job of taking a schema and making a graphviz "dot" file from +it, which can then be processed into any of a bazillion formats. + +It basically makes a box for each table, with fields, and an arrow to +each FK referenced table. All layed out nicely. + +You may also want to investigate the SQLFairy < http:// +sqlfairy.sourceforge.net/ > if not for anything besides their awesome +logo. :-) + + + +From pgsql-hackers-owner@postgresql.org Thu Feb 23 13:20:21 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 019FE9DC84D + for ; + Thu, 23 Feb 2006 13:20:20 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 19096-08 + for ; + Thu, 23 Feb 2006 13:20:19 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.logix-tt.com (serval.logix-tt.com [213.239.221.42]) + by postgresql.org (Postfix) with ESMTP id 8CC1C9DC839 + for ; + Thu, 23 Feb 2006 13:20:18 -0400 (AST) +Received: from kingfisher.intern.logix-tt.com (Mea8d.m.pppool.de + [89.49.234.141]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logix-tt.com (Postfix) with ESMTP id 33C2924407F; + Thu, 23 Feb 2006 18:20:18 +0100 (CET) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id 8E77D181B2EB5; + Thu, 23 Feb 2006 18:20:19 +0100 (CET) +Message-ID: <43FDEED2.6010901@logix-tt.com> +Date: Thu, 23 Feb 2006 18:20:18 +0100 +From: Markus Schaber +Organization: Logical Tracking and Tracing International AG, Switzerland +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Andrew Dunstan +Cc: Ron Peacetree , + pgsql-hackers@postgresql.org +Subject: Re: [PERFORM] Looking for a tool to "*" pg tables as ERDs +References: + <17961438.1140712728036.JavaMail.root@elwamui-rustique.atl.sa.earthlink.net> + <43FDE741.7070403@logix-tt.com> <43FDE9F3.9000109@dunslane.net> +In-Reply-To: <43FDE9F3.9000109@dunslane.net> +X-Enigmail-Version: 0.93.0.0 +Content-Type: multipart/signed; micalg=pgp-ripemd160; + protocol="application/pgp-signature"; + boundary="------------enig555DE31B4944458B30136011" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.123 required=5 tests=[AWL=0.123] +X-Spam-Score: 0.123 +X-Spam-Level: +X-Archive-Number: 200602/953 +X-Sequence-Number: 80091 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig555DE31B4944458B30136011 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit + +Hi, Andrew, + +Andrew Dunstan wrote: + +> How on earth can either of these have to do with producing an ERD? + +Sorry, the ERD thing got lost in my mind while resolving the "*". + +Markus + +-- +Markus Schaber | Logical Tracking&Tracing International AG +Dipl. Inf. | Software Development GIS + +Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org + +--------------enig555DE31B4944458B30136011 +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.2 (GNU/Linux) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFD/e7SyHQIGEs7eeARA5a9AJ9bCMPgRISnwfJEHmZgHY8+VC854wCfS4eh +HrAg2cRCMUZotitPMzHZM+E= +=VC3A +-----END PGP SIGNATURE----- + +--------------enig555DE31B4944458B30136011-- + +From pgsql-performance-owner@postgresql.org Thu Feb 23 13:25:37 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id D73759DCB82 + for ; + Thu, 23 Feb 2006 13:25:28 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 20210-09 + for ; + Thu, 23 Feb 2006 13:25:27 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id BC48C9DCAD6 + for ; + Thu, 23 Feb 2006 13:25:25 -0400 (AST) +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 k1NHPMLf023301; + Thu, 23 Feb 2006 12:25:22 -0500 (EST) +To: "Jeremy Haile" +cc: pgsql-performance@postgresql.org +Subject: Re: Slow query +In-reply-to: <1140635770.1612.255019877@webmail.messagingengine.com> +References: <1140635770.1612.255019877@webmail.messagingengine.com> +Comments: In-reply-to "Jeremy Haile" + message dated "Wed, 22 Feb 2006 14:16:10 -0500" +Date: Thu, 23 Feb 2006 12:25:22 -0500 +Message-ID: <23300.1140715522@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.111 required=5 tests=[AWL=0.111] +X-Spam-Score: 0.111 +X-Spam-Level: +X-Archive-Number: 200602/372 +X-Sequence-Number: 17358 + +"Jeremy Haile" writes: +> I am running a query that joins against several large tables (~5 million +> rows each). The query takes an exteremely long time to run, and the +> explain output is a bit beyond my level of understanding. It is an +> auto-generated query, so the aliases are fairly ugly. + +Yah :-( + +> select distinct city4_.region_id as region1_29_, city4_1_.name as +> name29_, city4_.state_id as state2_30_ +> from registered_voters registered0_ +> inner join registered_voter_addresses addresses1_ on +> registered0_.registered_voter_id=addresses1_.registered_voter_id +> inner join registered_voter_addresses_regions regions2_ on +> addresses1_.address_id=regions2_.registered_voter_addresses_address_id +> inner join regions region3_ on +> regions2_.regions_region_id=region3_.region_id +> inner join cities city4_ on +> addresses1_.city_id=city4_.region_id +> inner join regions city4_1_ on +> city4_.region_id=city4_1_.region_id +> where region3_.region_id='093c44e8-f3b2-4c60-8be3-2b4d148f9f5a' +> order by city4_1_.name + +AFAICS the planner is doing about the best you can hope the machine to +do --- it's not making any serious estimation errors, and the plan is +pretty reasonable for the given query. The problem is that you are +forming a very large join result (4918204 rows) and then doing a +DISTINCT that reduces this to only 1124 rows ... but the damage of +computing that huge join has already been done. The machine is not +going to be able to think its way out of this one --- it's up to you +to think of a better formulation of the query. + +Offhand I'd try something involving joining just city4_/city4_1_ +(which should not need DISTINCT, I think) and then using WHERE +EXISTS(SELECT ... FROM the-other-tables) to filter out the cities +you don't want. The reason this can be a win is that the EXISTS +formulation will stop running the sub-select as soon as it's produced a +single row for the current city, rather than generating thousands of +similar rows that will be thrown away by DISTINCT as you have here. + +This assumes that the fraction of cities passing the query is +substantial, as it appears from the rowcounts in your EXPLAIN output. +If only a tiny fraction of them passed, then the time wasted in failing +EXISTS probes might eat up the savings. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Feb 23 14:55:05 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 333FF9DCD01 + for ; + Thu, 23 Feb 2006 14:55:04 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 50572-03 + for ; + Thu, 23 Feb 2006 14:55:03 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from gwmta.wicourts.gov (gwmta.wicourts.gov [165.219.244.99]) + by postgresql.org (Postfix) with ESMTP id 986AD9DCD00 + for ; + Thu, 23 Feb 2006 14:55:00 -0400 (AST) +Received: from Courts-MTA by gwmta.wicourts.gov + with Novell_GroupWise; Thu, 23 Feb 2006 12:54:59 -0600 +Message-Id: <43FDB09C.EE98.0025.0@wicourts.gov> +X-Mailer: Novell GroupWise Internet Agent 7.0 +Date: Thu, 23 Feb 2006 12:54:52 -0600 +From: "Kevin Grittner" +To: "Greg Stark" +Cc: +Subject: Re: Good News re count(*) in 8.1 +References: <43FC4384.EE98.0025.0@wicourts.gov> + <87irr6zq7j.fsf@stark.xeocode.com> +In-Reply-To: <87irr6zq7j.fsf@stark.xeocode.com> +Mime-Version: 1.0 +Content-Type: multipart/mixed; boundary="=__Part3D1F8DEC.1__=" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.057 required=5 tests=[AWL=0.057] +X-Spam-Score: 0.057 +X-Spam-Level: +X-Archive-Number: 200602/373 +X-Sequence-Number: 17359 + +--=__Part3D1F8DEC.1__= +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +Content-Disposition: inline + +>>> On Wed, Feb 22, 2006 at 9:52 pm, in message +<87irr6zq7j.fsf@stark.xeocode.com>, Greg Stark wrote: + + +> "Kevin Grittner" writes: +> +>> There have been several times that I have run a SELECT COUNT(*) on +an entire +>> table on all central machines. On identical hardware, with identical +data, +>> and equivalent query loads, the PostgreSQL databases have responded +with a +>> count in 50% to 70% of the time of the commercial product, in spite +of the +>> fact that the commercial product does a scan of a non- clustered +index while +>> PostgreSQL scans the data pages. +> +> I take it these are fairly narrow rows? The big benefit of index- +only scans +> come in when you're scanning extremely wide tables, often counting +rows +> matching some indexed criteria. + +I'm not sure what you would consider "fairly narrow rows" -- so see the +attached. This is the VACUUM ANALYZE VERBOSE output for the largest +table, from last night's regular maintenance run. + +-Kevin + + + +--=__Part3D1F8DEC.1__= +Content-Type: application/octet-stream; name="CaseHist-vacuum-analyze.txt" +Content-Transfer-Encoding: base64 +Content-Disposition: attachment; filename="CaseHist-vacuum-analyze.txt" + +SU5GTzogIHZhY3V1bWluZyAicHVibGljLkNhc2VIaXN0IgpJTkZPOiAgaW5kZXggIkNhc2VIaXN0 +X3BrZXkiIG5vdyBjb250YWlucyAxMzE4NTc0NTggcm93IHZlcnNpb25zIGluIDY2NjY1NiBwYWdl +cwpERVRBSUw6ICAxMDIyNCBpbmRleCByb3cgdmVyc2lvbnMgd2VyZSByZW1vdmVkLgowIGluZGV4 +IHBhZ2VzIGhhdmUgYmVlbiBkZWxldGVkLCAwIGFyZSBjdXJyZW50bHkgcmV1c2FibGUuCkNQVSA2 +MS44MXMvNjEuODd1IHNlYyBlbGFwc2VkIDk0Ni4xNyBzZWMuCklORk86ICBpbmRleCAiQ2FzZUhp +c3RfQ2FzZUhpc3RDaWJScHQiIG5vdyBjb250YWlucyAxMzE4NTc0NTggcm93IHZlcnNpb25zIGlu +IDgwODQ0MCBwYWdlcwpERVRBSUw6ICAxMDIyNCBpbmRleCByb3cgdmVyc2lvbnMgd2VyZSByZW1v +dmVkLgowIGluZGV4IHBhZ2VzIGhhdmUgYmVlbiBkZWxldGVkLCAwIGFyZSBjdXJyZW50bHkgcmV1 +c2FibGUuCkNQVSA1NC4zNXMvNjEuNzN1IHNlYyBlbGFwc2VkIDcyNS44OSBzZWMuCklORk86ICAi +Q2FzZUhpc3QiOiByZW1vdmVkIDEwMjI0IHJvdyB2ZXJzaW9ucyBpbiA0MTU2IHBhZ2VzCkRFVEFJ +TDogIENQVSAwLjY0cy8wLjMydSBzZWMgZWxhcHNlZCAyMy44NSBzZWMuCklORk86ICAiQ2FzZUhp +c3QiOiBmb3VuZCAxMDIyNCByZW1vdmFibGUsIDEzMTg1NzQ1OCBub25yZW1vdmFibGUgcm93IHZl +cnNpb25zIGluIDI1OTAzODAgcGFnZXMKREVUQUlMOiAgMCBkZWFkIHJvdyB2ZXJzaW9ucyBjYW5u +b3QgYmUgcmVtb3ZlZCB5ZXQuClRoZXJlIHdlcmUgODEyOTEgdW51c2VkIGl0ZW0gcG9pbnRlcnMu +CjAgcGFnZXMgYXJlIGVudGlyZWx5IGVtcHR5LgpDUFUgMTY0Ljc1cy8xNDEuNTR1IHNlYyBlbGFw +c2VkIDIzMjYuOTIgc2VjLgpJTkZPOiAgdmFjdXVtaW5nICJwZ190b2FzdC5wZ190b2FzdF8yNDU4 +OCIKSU5GTzogIGluZGV4ICJwZ190b2FzdF8yNDU4OF9pbmRleCIgbm93IGNvbnRhaW5zIDExNiBy +b3cgdmVyc2lvbnMgaW4gMiBwYWdlcwpERVRBSUw6ICAwIGluZGV4IHBhZ2VzIGhhdmUgYmVlbiBk +ZWxldGVkLCAwIGFyZSBjdXJyZW50bHkgcmV1c2FibGUuCkNQVSAwLjAwcy8wLjAwdSBzZWMgZWxh +cHNlZCAwLjAwIHNlYy4KSU5GTzogICJwZ190b2FzdF8yNDU4OCI6IGZvdW5kIDAgcmVtb3ZhYmxl +LCAxMTYgbm9ucmVtb3ZhYmxlIHJvdyB2ZXJzaW9ucyBpbiAyNSBwYWdlcwpERVRBSUw6ICAwIGRl +YWQgcm93IHZlcnNpb25zIGNhbm5vdCBiZSByZW1vdmVkIHlldC4KVGhlcmUgd2VyZSAzIHVudXNl +ZCBpdGVtIHBvaW50ZXJzLgowIHBhZ2VzIGFyZSBlbnRpcmVseSBlbXB0eS4KQ1BVIDAuMDBzLzAu +MDB1IHNlYyBlbGFwc2VkIDAuMDEgc2VjLgpJTkZPOiAgYW5hbHl6aW5nICJwdWJsaWMuQ2FzZUhp +c3QiCklORk86ICAiQ2FzZUhpc3QiOiBzY2FubmVkIDMwMDAgb2YgMjU5MDM4MCBwYWdlcywgY29u +dGFpbmluZyAxNTMxNTYgbGl2ZSByb3dzIGFuZCAwIGRlYWQgcm93czsgMzAwMCByb3dzIGluIHNh +bXBsZSwgMTMyMjQ0MDgwIGVzdGltYXRlZCB0b3RhbCByb3dzCg== + +--=__Part3D1F8DEC.1__=-- + +From pgsql-performance-owner@postgresql.org Thu Feb 23 15:57:09 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id DF4B59DC841 + for ; + Thu, 23 Feb 2006 15:57:08 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 59959-08 + for ; + Thu, 23 Feb 2006 15:57:09 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from outbound-smtp.firstam.com (outbound-smtp4.firstam.com + [69.87.54.9]) by postgresql.org (Postfix) with ESMTP id 551E89DCA83 + for ; + Thu, 23 Feb 2006 15:57:06 -0400 (AST) +Received: from 10.48.129.31 by outbound-smtp.firstam.com with ESMTP ( + Hello SMTP Relay); Thu, 23 Feb 2006 11:57:04 -0800 +X-Server-Uuid: A20F5341-692A-45C7-975F-AE726A98C579 +Received: from unknown (HELO pisgsna01smmx01.ana.firstamdata.com) ( + [172.17.88.35]) by FAEMSNA01SMXS02.FIRSTAM.COM with ESMTP; 23 Feb 2006 + 11:57:04 -0800 +Received: from pisgsna01sxch21.ana.firstamdata.com (Not + Verified[172.17.88.71]) by pisgsna01smmx01.ana.firstamdata.com with + NetIQ MailMarshal 6.0 Service Pack 1a (v6,0,3,33) id ; + Thu, 23 Feb 2006 11:57:04 -0800 +Received: from pisgsna01sxch01.ana.firstamdata.com ([172.17.88.70]) by + pisgsna01sxch21.ana.firstamdata.com with Microsoft + SMTPSVC(6.0.3790.1830); Thu, 23 Feb 2006 11:57:03 -0800 +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Subject: Re: 0ut of Memory Error during Vacuum Analyze and +Date: Thu, 23 Feb 2006 11:57:03 -0800 +Message-ID: + +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] 0ut of Memory Error during Vacuum Analyze and + Create Index +Thread-Index: AcYxwUxNDf47nAzFQwSLpwUs/PGr1AG14TOg +From: "Tomeh, Husam" +To: "Tom Lane" +cc: pgsql-performance@postgresql.org +X-OriginalArrivalTime: 23 Feb 2006 19:57:03.0912 (UTC) + FILETIME=[51313A80:01C638B3] +X-TMWD-Spam-Summary: SEV=1.1; DFV=A2006022307; IFV=2.0.6,4.0-7; RPD=4.00.0004; + RPDID=303030312E30413039303230322E34334645313336372E303038313A5343464D413534333432342D462D2F4E4553574B563534472F71554B6D71577A564237673D3D; + ENG=IBF; TS=20060223195704; CAT=NONE; CON=NONE; +X-WSS-ID: 6FE0CC1A36C639070-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, score=0.103 required=5 tests=[AWL=0.103] +X-Spam-Score: 0.103 +X-Spam-Level: +X-Archive-Number: 200602/374 +X-Sequence-Number: 17360 + +=20 +Thank for looking into this Tom. Here's the output from PostgreSQL log: + +*** Postgresql Log: + +TopMemoryContext: 32768 total in 4 blocks; 7232 free (9 chunks); 25536 +used +Operator class cache: 8192 total in 1 blocks; 4936 free (0 chunks); 3256 +used +TopTransactionContext: 8192 total in 1 blocks; 6816 free (0 chunks); +1376 used +MessageContext: 8192 total in 1 blocks; 7104 free (1 chunks); 1088 used +smgr relation table: 8192 total in 1 blocks; 2872 free (0 chunks); 5320 +used +Portal hash: 8192 total in 1 blocks; 3912 free (0 chunks); 4280 used +PortalMemory: 8192 total in 1 blocks; 8040 free (0 chunks); 152 used +PortalHeapMemory: 1077575324 total in 115158 blocks; 1860896 free +(115146 chunks); 1075714428 used +ExecutorState: 8192 total in 1 blocks; 7928 free (0 chunks); 264 used +ExprContext: 0 total in 0 blocks; 0 free (0 chunks); 0 used +Relcache by OID: 8192 total in 1 blocks; 3896 free (0 chunks); 4296 used +CacheMemoryContext: 516096 total in 6 blocks; 198480 free (2 chunks); +317616 used +mort_ht: 1024 total in 1 blocks; 328 free (0 chunks); 696 used +pg_depend_depender_index: 1024 total in 1 blocks; 256 free (0 chunks); +768 used +pg_depend_reference_index: 1024 total in 1 blocks; 256 free (0 chunks); +768 used +pg_index_indrelid_index: 1024 total in 1 blocks; 392 free (0 chunks); +632 used +pg_type_typname_nsp_index: 1024 total in 1 blocks; 328 free (0 chunks); +696 used +pg_type_oid_index: 1024 total in 1 blocks; 392 free (0 chunks); 632 used +pg_trigger_tgrelid_tgname_index: 1024 total in 1 blocks; 328 free (0 +chunks); 696 used +pg_statistic_relid_att_index: 1024 total in 1 blocks; 328 free (0 +chunks); 696 used +pg_auth_members_member_role_index: 1024 total in 1 blocks; 328 free (0 +chunks); 696 used +pg_auth_members_role_member_index: 1024 total in 1 blocks; 328 free (0 +chunks); 696 used +pg_rewrite_rel_rulename_index: 1024 total in 1 blocks; 328 free (0 +chunks); 696 used +pg_proc_proname_args_nsp_index: 1024 total in 1 blocks; 256 free (0 +chunks); 768 used +pg_proc_oid_index: 1024 total in 1 blocks; 392 free (0 chunks); 632 used +pg_operator_oprname_l_r_n_index: 1024 total in 1 blocks; 192 free (0 +chunks); 832 used +pg_operator_oid_index: 1024 total in 1 blocks; 392 free (0 chunks); 632 +used +pg_opclass_oid_index: 1024 total in 1 blocks; 392 free (0 chunks); 632 +used +pg_opclass_am_name_nsp_index: 1024 total in 1 blocks; 256 free (0 +chunks); 768 used +pg_namespace_oid_index: 1024 total in 1 blocks; 392 free (0 chunks); 632 +used +pg_namespace_nspname_index: 1024 total in 1 blocks; 392 free (0 chunks); +632 used +pg_language_oid_index: 1024 total in 1 blocks; 392 free (0 chunks); 632 +used +pg_language_name_index: 1024 total in 1 blocks; 392 free (0 chunks); 632 +used +pg_inherits_relid_seqno_index: 1024 total in 1 blocks; 328 free (0 +chunks); 696 used +pg_index_indexrelid_index: 1024 total in 1 blocks; 392 free (0 chunks); +632 used +pg_authid_oid_index: 1024 total in 1 blocks; 392 free (0 chunks); 632 +used +pg_authid_rolname_index: 1024 total in 1 blocks; 392 free (0 chunks); +632 used +pg_database_datname_index: 1024 total in 1 blocks; 392 free (0 chunks); +632 used +pg_conversion_oid_index: 1024 total in 1 blocks; 392 free (0 chunks); +632 used +pg_conversion_name_nsp_index: 1024 total in 1 blocks; 328 free (0 +chunks); 696 used +pg_conversion_default_index: 1024 total in 1 blocks; 192 free (0 +chunks); 832 used +pg_class_relname_nsp_index: 1024 total in 1 blocks; 328 free (0 chunks); +696 used +pg_class_oid_index: 1024 total in 1 blocks; 392 free (0 chunks); 632 +used +pg_cast_source_target_index: 1024 total in 1 blocks; 328 free (0 +chunks); 696 used +pg_attribute_relid_attnum_index: 1024 total in 1 blocks; 328 free (0 +chunks); 696 used +pg_attribute_relid_attnam_index: 1024 total in 1 blocks; 328 free (0 +chunks); 696 used +pg_amproc_opc_proc_index: 1024 total in 1 blocks; 256 free (0 chunks); +768 used +pg_amop_opr_opc_index: 1024 total in 1 blocks; 328 free (0 chunks); 696 +used +pg_amop_opc_strat_index: 1024 total in 1 blocks; 256 free (0 chunks); +768 used +pg_aggregate_fnoid_index: 1024 total in 1 blocks; 392 free (0 chunks); +632 used +MdSmgr: 8192 total in 1 blocks; 7504 free (0 chunks); 688 used +LockTable (locallock hash): 8192 total in 1 blocks; 3912 free (0 +chunks); 4280 used +Timezones: 47592 total in 2 blocks; 5968 free (0 chunks); 41624 used +ErrorContext: 8192 total in 1 blocks; 8176 free (4 chunks); 16 used +[2006-02-23 08:46:26 PST|[local]|mtrac|postgres] ERROR: out of memory +[2006-02-23 08:46:26 PST|[local]|mtrac|postgres] DETAIL: Failed on +request of size 134217728. + +------------------------- + +*** Stack trace: + +I'm not having luck generating a stack trace so far. Following the gdb +instructions, the create index statement never comes back with either +the I/O error or a success (created index). I'm still trying to figure +this out. Hopefully, the above from the server log may shed some light +on the problem. + +Thanks again, + +---- +=20 +=20 Husam Tomeh=20 + +-----Original Message----- +From: Tom Lane [mailto:tgl@sss.pgh.pa.us]=20 +Sent: Tuesday, February 14, 2006 3:49 PM +To: Tomeh, Husam +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] 0ut of Memory Error during Vacuum Analyze and +Create Index + +"Tomeh, Husam" writes: +> mtrac=3D# show maintenance_work_mem ; +> maintenance_work_mem +> ---------------------- +> 1048576 <=3D=3D=3D=3D=3D=3D +> (1 row) + +> mtrac=3D# +> mtrac=3D# +> mtrac=3D# create index mort_ht on mortgage(county_id,mtg_rec_dt); +> ERROR: out of memory +<=3D=3D=3D +> DETAIL: Failed on request of size 134217728. <=3D=3D=3D + +It would be useful to look at the detailed allocation info that this +(should have) put into the postmaster log. Also, if you could get +a stack trace back from the error, that would be even more useful. +To do that, +=09* start psql +=09* determine PID of connected backend (use pg_backend_pid()) +=09* in another window, as postgres user, +=09 gdb /path/to/postgres backend-PID +=09 gdb> break errfinish +=09 gdb> cont +=09* issue failing command in psql +=09* when breakpoint is reached, +=09 gdb> bt +=09 ... stack trace printed here ... +=09 gdb> q + +=09 regards, tom lane +********************************************************************** +This message contains confidential information intended only for the use = +of the addressee(s) named above and may contain information that is legal= +ly privileged. If you are not the addressee, or the person responsible f= +or delivering it to the addressee, you are hereby notified that reading, = +disseminating, distributing or copying this message is strictly prohibite= +d. If you have received this message by mistake, please immediately noti= +fy us by replying to the message and delete the original message immediat= +ely thereafter. + +Thank you. +=0D +=20 FADLD Tag +********************************************************************** + + +From pgsql-performance-owner@postgresql.org Thu Feb 23 16:45:48 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 584259DC819 + for ; + Thu, 23 Feb 2006 16:45:43 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 67112-08 + for ; + Thu, 23 Feb 2006 16:45:43 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 0B5389DCA20 + for ; + Thu, 23 Feb 2006 16:25:18 -0400 (AST) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 114BD56423; Thu, 23 Feb 2006 14:25:49 -0600 (CST) +Received: (hashcash-sendmail, from uid 1001); Thu, 23 Feb 2006 14:25:46 -0600 +Date: Thu, 23 Feb 2006 14:25:46 -0600 +From: "Jim C. Nasby" +To: Kevin Grittner +Cc: Greg Stark , pgsql-performance@postgresql.org +Subject: Re: Good News re count(*) in 8.1 +Message-ID: <20060223202546.GP86022@pervasive.com> +References: <43FC4384.EE98.0025.0@wicourts.gov> + <87irr6zq7j.fsf@stark.xeocode.com> + <43FDB09C.EE98.0025.0@wicourts.gov> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <43FDB09C.EE98.0025.0@wicourts.gov> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060223:kevin.grittner@wicourts.gov::xh/ZGsTrwfA5MQUp:0000000000 + 000000000000000000000000GzKf +X-Hashcash: 1:20:060223:gsstark@mit.edu::ZEY3sZmrp5ObUZ5E:00CNiW +X-Hashcash: + 1:20:060223:pgsql-performance@postgresql.org::c8Rojs172II20DVi:00000 + 00000000000000000000000009D4 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.105 required=5 tests=[AWL=0.105] +X-Spam-Score: 0.105 +X-Spam-Level: +X-Archive-Number: 200602/376 +X-Sequence-Number: 17362 + +On Thu, Feb 23, 2006 at 12:54:52PM -0600, Kevin Grittner wrote: +> >>> On Wed, Feb 22, 2006 at 9:52 pm, in message +> <87irr6zq7j.fsf@stark.xeocode.com>, Greg Stark wrote: +> +> +> > "Kevin Grittner" writes: +> > +> >> There have been several times that I have run a SELECT COUNT(*) on +> an entire +> >> table on all central machines. On identical hardware, with identical +> data, +> >> and equivalent query loads, the PostgreSQL databases have responded +> with a +> >> count in 50% to 70% of the time of the commercial product, in spite +> of the +> >> fact that the commercial product does a scan of a non- clustered +> index while +> >> PostgreSQL scans the data pages. +> > +> > I take it these are fairly narrow rows? The big benefit of index- +> only scans +> > come in when you're scanning extremely wide tables, often counting +> rows +> > matching some indexed criteria. +> +> I'm not sure what you would consider "fairly narrow rows" -- so see the +> attached. This is the VACUUM ANALYZE VERBOSE output for the largest +> table, from last night's regular maintenance run. + +Looks to be about 60 rows per page, somewhere around 140 bytes per row +(including overhead). Accounting for overhead and allowing for some +empty room, about 100 bytes of data per row, which isn't all that thin. +Not all that fat, either... The PK index is about 5 times smaller. IF +that ratio holds on the commercial product and they can't beat us with +an index scan.... :) +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Thu Feb 23 16:28:38 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 05E209DCA8A + for ; + Thu, 23 Feb 2006 16:28:37 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 65010-06 + for ; + Thu, 23 Feb 2006 16:28:38 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id CE3FE9DC99F + for ; + Thu, 23 Feb 2006 16:28:35 -0400 (AST) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 77DA456455; Thu, 23 Feb 2006 14:29:06 -0600 (CST) +Received: (hashcash-sendmail, from uid 1001); Thu, 23 Feb 2006 14:29:05 -0600 +Date: Thu, 23 Feb 2006 14:29:05 -0600 +From: "Jim C. Nasby" +To: Vivek Khera +Cc: Postgresql Performance +Subject: Re: +Message-ID: <20060223202905.GQ86022@pervasive.com> +References: + <544485BC51F81A41AC1A72CFA69013655640AF@AZ18EV805.global.ds.honeywell.com> + <62FC5203-3162-4ABE-BF47-DFE0116AC520@khera.org> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <62FC5203-3162-4ABE-BF47-DFE0116AC520@khera.org> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: 1:20:060223:vivek@khera.org::lQLI7ysWsVVBT9Xw:000Mni +X-Hashcash: + 1:20:060223:pgsql-performance@postgresql.org::yuOdj6M429SWipfv:00000 + 00000000000000000000000068Ze +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.105 required=5 tests=[AWL=0.105] +X-Spam-Score: 0.105 +X-Spam-Level: +X-Archive-Number: 200602/375 +X-Sequence-Number: 17361 + +On Thu, Feb 23, 2006 at 09:38:25AM -0500, Vivek Khera wrote: +> +> On Feb 22, 2006, at 10:44 PM, Chethana, Rao ((IE10)) wrote: +> +> >That is what I wanted to know, how do I tune it? +> +> If there were a simple formula for doing it, it would already have +> been written up as a program that runs once you install postgres. +> +> You have to monitor your usage, use your understanding of your +> application, and the Postgres manual to see what things to adjust. +> It differs if you are CPU bound or I/O bound. +> +> And please keep this on list. + +FWIW, had you included a bit more of the original post others might have +been able to provide advice... but now I have no idea what the original +question was (of course a blank subject doesn't help either... no idea +where that happened). + +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Thu Feb 23 18:42:14 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 90DC69DC819 + for ; + Thu, 23 Feb 2006 18:42:13 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 86250-02 + for ; + Thu, 23 Feb 2006 18:42:15 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from outbound-smtp.firstam.com (outbound-smtp7.firstam.com + [69.87.54.12]) by postgresql.org (Postfix) with ESMTP id E6A679DCA7F + for ; + Thu, 23 Feb 2006 18:42:10 -0400 (AST) +Received: from 10.48.129.31 by outbound-smtp.firstam.com with ESMTP ( + Hello SMTP Relay); Thu, 23 Feb 2006 14:42:08 -0800 +X-Server-Uuid: 784562B0-C2BD-4C7D-8289-6A1E69B096B7 +Received: from unknown (HELO pisgsna01smmx01.ana.firstamdata.com) ( + [172.17.88.35]) by FAEMSNA01SMXS01.firstam.com with ESMTP; 23 Feb 2006 + 14:42:08 -0800 +Received: from pisgsna01sxch21.ana.firstamdata.com (Not + Verified[172.17.88.71]) by pisgsna01smmx01.ana.firstamdata.com with + NetIQ MailMarshal 6.0 Service Pack 1a (v6,0,3,33) id ; + Thu, 23 Feb 2006 14:42:08 -0800 +Received: from pisgsna01sxch01.ana.firstamdata.com ([172.17.88.70]) by + pisgsna01sxch21.ana.firstamdata.com with Microsoft + SMTPSVC(6.0.3790.1830); Thu, 23 Feb 2006 14:42:07 -0800 +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Subject: Re: 0ut of Memory Error during Vacuum Analyze and +Date: Thu, 23 Feb 2006 14:42:07 -0800 +Message-ID: + +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] 0ut of Memory Error during Vacuum Analyze and +Thread-Index: AcYxwUxNDf47nAzFQwSLpwUs/PGr1AG14TOgAAw7MiA= +From: "Tomeh, Husam" +To: "Tom Lane" +cc: pgsql-performance@postgresql.org +X-OriginalArrivalTime: 23 Feb 2006 22:42:07.0832 (UTC) + FILETIME=[60637D80:01C638CA] +X-TMWD-Spam-Summary: SEV=1.1; DFV=A2006022308; IFV=2.0.6,4.0-7; RPD=4.00.0004; + RPDID=303030312E30413039303230322E34334645334131382E303034373A5343464D413534333432342D462D2F4E4553574B563534472F71554B6D71577A564237673D3D; + ENG=IBF; TS=20060223224209; CAT=NONE; CON=NONE; +X-WSS-ID: 6FE0E5CA2MC84483-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, score=0.106 required=5 tests=[AWL=0.106] +X-Spam-Score: 0.106 +X-Spam-Level: +X-Archive-Number: 200602/377 +X-Sequence-Number: 17363 + +=20 +What's more interesting is this: + +When I first connect to the database via "psql" and issue the "create +index" statement, of course, I get the "out of memory" error. If I +don't quit my current session and re-ran the same DDL statement again, +the index gets created successfully!.. However, if after my first +unsuccessful run, I exit my session and re-connect again, and then run +the DDL, it will fail again and get the same error. I have done that for +many times and appears to have a consistent pattern of behavior. Not +sure if that'll help, but I thought it may be an interesting observation +to think about. + +---- +=20 + Husam Tomeh + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Tomeh, +Husam +Sent: Thursday, February 23, 2006 11:57 AM +To: Tom Lane +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] 0ut of Memory Error during Vacuum Analyze and + +=20 +Thank for looking into this Tom. Here's the output from PostgreSQL log: + +*** Postgresql Log: + +TopMemoryContext: 32768 total in 4 blocks; 7232 free (9 chunks); 25536 +used +Operator class cache: 8192 total in 1 blocks; 4936 free (0 chunks); 3256 +used +TopTransactionContext: 8192 total in 1 blocks; 6816 free (0 chunks); +1376 used +MessageContext: 8192 total in 1 blocks; 7104 free (1 chunks); 1088 used +smgr relation table: 8192 total in 1 blocks; 2872 free (0 chunks); 5320 +used +Portal hash: 8192 total in 1 blocks; 3912 free (0 chunks); 4280 used +PortalMemory: 8192 total in 1 blocks; 8040 free (0 chunks); 152 used +PortalHeapMemory: 1077575324 total in 115158 blocks; 1860896 free +(115146 chunks); 1075714428 used +ExecutorState: 8192 total in 1 blocks; 7928 free (0 chunks); 264 used +ExprContext: 0 total in 0 blocks; 0 free (0 chunks); 0 used +Relcache by OID: 8192 total in 1 blocks; 3896 free (0 chunks); 4296 used +CacheMemoryContext: 516096 total in 6 blocks; 198480 free (2 chunks); +317616 used +mort_ht: 1024 total in 1 blocks; 328 free (0 chunks); 696 used +pg_depend_depender_index: 1024 total in 1 blocks; 256 free (0 chunks); +768 used +pg_depend_reference_index: 1024 total in 1 blocks; 256 free (0 chunks); +768 used +pg_index_indrelid_index: 1024 total in 1 blocks; 392 free (0 chunks); +632 used +pg_type_typname_nsp_index: 1024 total in 1 blocks; 328 free (0 chunks); +696 used +pg_type_oid_index: 1024 total in 1 blocks; 392 free (0 chunks); 632 used +pg_trigger_tgrelid_tgname_index: 1024 total in 1 blocks; 328 free (0 +chunks); 696 used +pg_statistic_relid_att_index: 1024 total in 1 blocks; 328 free (0 +chunks); 696 used +pg_auth_members_member_role_index: 1024 total in 1 blocks; 328 free (0 +chunks); 696 used +pg_auth_members_role_member_index: 1024 total in 1 blocks; 328 free (0 +chunks); 696 used +pg_rewrite_rel_rulename_index: 1024 total in 1 blocks; 328 free (0 +chunks); 696 used +pg_proc_proname_args_nsp_index: 1024 total in 1 blocks; 256 free (0 +chunks); 768 used +pg_proc_oid_index: 1024 total in 1 blocks; 392 free (0 chunks); 632 used +pg_operator_oprname_l_r_n_index: 1024 total in 1 blocks; 192 free (0 +chunks); 832 used +pg_operator_oid_index: 1024 total in 1 blocks; 392 free (0 chunks); 632 +used +pg_opclass_oid_index: 1024 total in 1 blocks; 392 free (0 chunks); 632 +used +pg_opclass_am_name_nsp_index: 1024 total in 1 blocks; 256 free (0 +chunks); 768 used +pg_namespace_oid_index: 1024 total in 1 blocks; 392 free (0 chunks); 632 +used +pg_namespace_nspname_index: 1024 total in 1 blocks; 392 free (0 chunks); +632 used +pg_language_oid_index: 1024 total in 1 blocks; 392 free (0 chunks); 632 +used +pg_language_name_index: 1024 total in 1 blocks; 392 free (0 chunks); 632 +used +pg_inherits_relid_seqno_index: 1024 total in 1 blocks; 328 free (0 +chunks); 696 used +pg_index_indexrelid_index: 1024 total in 1 blocks; 392 free (0 chunks); +632 used +pg_authid_oid_index: 1024 total in 1 blocks; 392 free (0 chunks); 632 +used +pg_authid_rolname_index: 1024 total in 1 blocks; 392 free (0 chunks); +632 used +pg_database_datname_index: 1024 total in 1 blocks; 392 free (0 chunks); +632 used +pg_conversion_oid_index: 1024 total in 1 blocks; 392 free (0 chunks); +632 used +pg_conversion_name_nsp_index: 1024 total in 1 blocks; 328 free (0 +chunks); 696 used +pg_conversion_default_index: 1024 total in 1 blocks; 192 free (0 +chunks); 832 used +pg_class_relname_nsp_index: 1024 total in 1 blocks; 328 free (0 chunks); +696 used +pg_class_oid_index: 1024 total in 1 blocks; 392 free (0 chunks); 632 +used +pg_cast_source_target_index: 1024 total in 1 blocks; 328 free (0 +chunks); 696 used +pg_attribute_relid_attnum_index: 1024 total in 1 blocks; 328 free (0 +chunks); 696 used +pg_attribute_relid_attnam_index: 1024 total in 1 blocks; 328 free (0 +chunks); 696 used +pg_amproc_opc_proc_index: 1024 total in 1 blocks; 256 free (0 chunks); +768 used +pg_amop_opr_opc_index: 1024 total in 1 blocks; 328 free (0 chunks); 696 +used +pg_amop_opc_strat_index: 1024 total in 1 blocks; 256 free (0 chunks); +768 used +pg_aggregate_fnoid_index: 1024 total in 1 blocks; 392 free (0 chunks); +632 used +MdSmgr: 8192 total in 1 blocks; 7504 free (0 chunks); 688 used +LockTable (locallock hash): 8192 total in 1 blocks; 3912 free (0 +chunks); 4280 used +Timezones: 47592 total in 2 blocks; 5968 free (0 chunks); 41624 used +ErrorContext: 8192 total in 1 blocks; 8176 free (4 chunks); 16 used +[2006-02-23 08:46:26 PST|[local]|mtrac|postgres] ERROR: out of memory +[2006-02-23 08:46:26 PST|[local]|mtrac|postgres] DETAIL: Failed on +request of size 134217728. + +------------------------- + +*** Stack trace: + +I'm not having luck generating a stack trace so far. Following the gdb +instructions, the create index statement never comes back with either +the I/O error or a success (created index). I'm still trying to figure +this out. Hopefully, the above from the server log may shed some light +on the problem. + +Thanks again, + +---- +=20 + Husam Tomeh=20 + +-----Original Message----- +From: Tom Lane [mailto:tgl@sss.pgh.pa.us]=20 +Sent: Tuesday, February 14, 2006 3:49 PM +To: Tomeh, Husam +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] 0ut of Memory Error during Vacuum Analyze and +Create Index + +"Tomeh, Husam" writes: +> mtrac=3D# show maintenance_work_mem ; +> maintenance_work_mem +> ---------------------- +> 1048576 <=3D=3D=3D=3D=3D=3D +> (1 row) + +> mtrac=3D# +> mtrac=3D# +> mtrac=3D# create index mort_ht on mortgage(county_id,mtg_rec_dt); +> ERROR: out of memory +<=3D=3D=3D +> DETAIL: Failed on request of size 134217728. <=3D=3D=3D + +It would be useful to look at the detailed allocation info that this +(should have) put into the postmaster log. Also, if you could get +a stack trace back from the error, that would be even more useful. +To do that, + * start psql + * determine PID of connected backend (use pg_backend_pid()) + * in another window, as postgres user, + gdb /path/to/postgres backend-PID + gdb> break errfinish + gdb> cont + * issue failing command in psql + * when breakpoint is reached, + gdb> bt + ... stack trace printed here ... + gdb> q + + regards, tom lane +********************************************************************** +This message contains confidential information intended only for the use +of the addressee(s) named above and may contain information that is +legally privileged. If you are not the addressee, or the person +responsible for delivering it to the addressee, you are hereby notified +that reading, disseminating, distributing or copying this message is +strictly prohibited. If you have received this message by mistake, +please immediately notify us by replying to the message and delete the +original message immediately thereafter. + +Thank you. + + + FADLD Tag +********************************************************************** + + +---------------------------(end of broadcast)--------------------------- +TIP 2: Don't 'kill -9' the postmaster + + +From pgsql-performance-owner@postgresql.org Thu Feb 23 18:47:03 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id C97E29DC819 + for ; + Thu, 23 Feb 2006 18:47:02 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 86250-05 + for ; + Thu, 23 Feb 2006 18:47:04 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 83D179DC849 + for ; + Thu, 23 Feb 2006 18:46:59 -0400 (AST) +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 k1NMkxW1026906; + Thu, 23 Feb 2006 17:46:59 -0500 (EST) +To: "Tomeh, Husam" +cc: pgsql-performance@postgresql.org +Subject: Re: 0ut of Memory Error during Vacuum Analyze and +In-reply-to: + +References: + +Comments: In-reply-to "Tomeh, Husam" + message dated "Thu, 23 Feb 2006 14:42:07 -0800" +Date: Thu, 23 Feb 2006 17:46:59 -0500 +Message-ID: <26905.1140734819@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.111 required=5 tests=[AWL=0.111] +X-Spam-Score: 0.111 +X-Spam-Level: +X-Archive-Number: 200602/378 +X-Sequence-Number: 17364 + +"Tomeh, Husam" writes: +> When I first connect to the database via "psql" and issue the "create +> index" statement, of course, I get the "out of memory" error. If I +> don't quit my current session and re-ran the same DDL statement again, +> the index gets created successfully!.. However, if after my first +> unsuccessful run, I exit my session and re-connect again, and then run +> the DDL, it will fail again and get the same error. I have done that for +> many times and appears to have a consistent pattern of behavior. + +Now that you know how to reproduce it, please have another go at getting +that stack trace. The palloc printout certainly looks like some kind of +memory-leak issue, but I can't tell more than that from it. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Feb 24 02:54:50 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 6E7D19DC9D6 + for ; + Fri, 24 Feb 2006 02:54:49 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 60460-07 + for ; + Fri, 24 Feb 2006 02:54:48 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.clickspace.com (router2.clickspace.com [65.110.166.227]) + by postgresql.org (Postfix) with ESMTP id 44B899DC89B + for ; + Fri, 24 Feb 2006 02:54:46 -0400 (AST) +Received: from [10.0.1.3] ([68.147.204.179]) + (authenticated user brendan@clickspace.com) by mail.clickspace.com + (using TLSv1/SSLv3 with cipher RC4-SHA (128 bits)); + Thu, 23 Feb 2006 23:54:44 -0700 +Mime-Version: 1.0 (Apple Message framework v746.2) +To: PostgreSQL Performance +Message-Id: <1831440F-F848-471D-ACE9-F84CE9F4E359@clickspace.com> +Content-Type: multipart/signed; micalg=sha1; boundary=Apple-Mail-2--751870699; + protocol="application/pkcs7-signature" +Cc: Tony Copping +Subject: Really really slow query. What's a better way? +From: Brendan Duddridge +Date: Thu, 23 Feb 2006 23:54:45 -0700 +X-Mailer: Apple Mail (2.746.2) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.107 required=5 tests=[AWL=0.106, + HTML_MESSAGE=0.001] +X-Spam-Score: 0.107 +X-Spam-Level: +X-Archive-Number: 200602/379 +X-Sequence-Number: 17365 + + +--Apple-Mail-2--751870699 +Content-Type: multipart/alternative; + boundary=Apple-Mail-1--751871314 + + +--Apple-Mail-1--751871314 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset=US-ASCII; + delsp=yes; + format=flowed + +Hi, + +We're executing a query that has the following plan and we're +wondering given the size of the data set, what's a better way to +write the query? It's been running since 2pm 2 days ago. + +explain DELETE FROM cds.cds_mspecxx WHERE ProdID not in (SELECT +stage.ProdID FROM cds_stage.cds_Catalog stage where stage.countryCode += 'us') and countryCode = 'us'; +QUERY PLAN +------------------------------------------------------------------------ +--------------------------- +Index Scan using pk_mspecxx on cds_mspecxx +(cost=53360.87..208989078645.48 rows=7377879 width=6) +Index Cond: ((countrycode)::text = 'us'::text) +Filter: (NOT (subplan)) +SubPlan +-> Materialize (cost=53360.87..77607.54 rows=1629167 width=12) +-> Seq Scan on cds_catalog stage (cost=0.00..43776.70 rows=1629167 +width=12) +Filter: ((countrycode)::text = 'us'::text) +(7 rows) + +Thanks, + +____________________________________________________________________ +Brendan Duddridge | CTO | 403-277-5591 x24 | brendan@clickspace.com + +ClickSpace Interactive Inc. +Suite L100, 239 - 10th Ave. SE +Calgary, AB T2G 0V9 + +http://www.clickspace.com + + +--Apple-Mail-1--751871314 +Content-Transfer-Encoding: quoted-printable +Content-Type: text/html; + charset=ISO-8859-1 + +Hi,

We're executing a query = +that has the following plan and we're wondering given the size of the = +data set, what's a better way to write the query? It's been running = +since 2pm 2 days ago.

explain DELETE FROM = +cds.cds_mspecxx WHERE ProdID not in (SELECT stage.ProdID FROM = +cds_stage.cds_Catalog stage where stage.countryCode =3D 'us') and = +countryCode =3D 'us';
QUERY PLAN=A0
-------------------------------------------------------= +--------------------------------------------
Index Scan using pk_mspecxx on cds_mspecxx = +(cost=3D53360.87..208989078645.48 rows=3D7377879 = +width=3D6)
Index Cond: ((countrycode)::text =3D = +'us'::text)
Filter: (NOT = +(subplan))
SubPlan
-> Materialize = +(cost=3D53360.87..77607.54 rows=3D1629167 width=3D12)
-> Seq Scan on cds_catalog stage = +(cost=3D0.00..43776.70 rows=3D1629167 width=3D12)
Filter: ((countrycode)::text =3D = +'us'::text)
(7 rows)

Thanks,
= +

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

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

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

= + +--Apple-Mail-1--751871314-- + +--Apple-Mail-2--751870699 +Content-Transfer-Encoding: base64 +Content-Type: application/pkcs7-signature; + name=smime.p7s +Content-Disposition: attachment; + filename=smime.p7s + +MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIGIDCCAtkw +ggJCoAMCAQICAw84ujANBgkqhkiG9w0BAQQFADBiMQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhh +d3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNvbmFsIEZyZWVt +YWlsIElzc3VpbmcgQ0EwHhcNMDUwNzI5MjAxMTQzWhcNMDYwNzI5MjAxMTQzWjBIMR8wHQYDVQQD +ExZUaGF3dGUgRnJlZW1haWwgTWVtYmVyMSUwIwYJKoZIhvcNAQkBFhZicmVuZGFuQGNsaWNrc3Bh +Y2UuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqWfMCdFgKzXroGNqJuU3eyDC +K/Gxts3mtmIdgcHGmUjRKdlBSfkmcCBUDPJIt4QQc91sY3h8Itg0EAsF+1yFECU6afn/1SEAHSDK +6Q86PclF58/Dux2FYNGpeIAw/lisZ2UCyIYoUiWtEDKCBq5jDuYzcGkFS5Csz+/rEL+BHTXQVqnS +nUdUaXu9xdZn4wgjB/n65UEYRqr0LGN53CGsFcA9uC+ViS7WyBtzJcP02LMNT+cAZ7TKHw4Q/ZeG +5ptPgQHLTD2wza3GMbPQ4fYK6aNPA+lVzslLSCjyQpg55gVyQQlV0k/5zU5Q5m48ZtqwOqN+fPYd +eIB7H5y1SFLd/wIDAQABozMwMTAhBgNVHREEGjAYgRZicmVuZGFuQGNsaWNrc3BhY2UuY29tMAwG +A1UdEwEB/wQCMAAwDQYJKoZIhvcNAQEEBQADgYEAT+6hGvStHoRO0OCHlJev31BpUlvPSpbYVKJN +i5kCMF164sSX7j0IRvcyU6DfUuW7samTluXJbANyuX1ZIpXulGen5EEc2NV7eU/rMz6ExklMShTh +++azcvmMjOzTuqXi3ZsIjwzBBhqCB0U++kYlMlHEYla2qKLFbXY6PiH0a8swggM/MIICqKADAgEC +AgENMA0GCSqGSIb3DQEBBQUAMIHRMQswCQYDVQQGEwJaQTEVMBMGA1UECBMMV2VzdGVybiBDYXBl +MRIwEAYDVQQHEwlDYXBlIFRvd24xGjAYBgNVBAoTEVRoYXd0ZSBDb25zdWx0aW5nMSgwJgYDVQQL +Ex9DZXJ0aWZpY2F0aW9uIFNlcnZpY2VzIERpdmlzaW9uMSQwIgYDVQQDExtUaGF3dGUgUGVyc29u +YWwgRnJlZW1haWwgQ0ExKzApBgkqhkiG9w0BCQEWHHBlcnNvbmFsLWZyZWVtYWlsQHRoYXd0ZS5j +b20wHhcNMDMwNzE3MDAwMDAwWhcNMTMwNzE2MjM1OTU5WjBiMQswCQYDVQQGEwJaQTElMCMGA1UE +ChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNvbmFs +IEZyZWVtYWlsIElzc3VpbmcgQ0EwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMSmPFVzVftO +ucqZWh5owHUEcJ3f6f+jHuy9zfVb8hp2vX8MOmHyv1HOAdTlUAow1wJjWiyJFXCO3cnwK4Vaqj9x +VsuvPAsH5/EfkTYkKhPPK9Xzgnc9A74r/rsYPge/QIACZNenprufZdHFKlSFD0gEf6e20TxhBEAe +ZBlyYLf7AgMBAAGjgZQwgZEwEgYDVR0TAQH/BAgwBgEB/wIBADBDBgNVHR8EPDA6MDigNqA0hjJo +dHRwOi8vY3JsLnRoYXd0ZS5jb20vVGhhd3RlUGVyc29uYWxGcmVlbWFpbENBLmNybDALBgNVHQ8E +BAMCAQYwKQYDVR0RBCIwIKQeMBwxGjAYBgNVBAMTEVByaXZhdGVMYWJlbDItMTM4MA0GCSqGSIb3 +DQEBBQUAA4GBAEiM0VCD6gsuzA2jZqxnD3+vrL7CF6FDlpSdf0whuPg2H6otnzYvwPQcUCCTcDz9 +reFhYsPZOhl+hLGZGwDFGguCdJ4lUJRix9sncVcljd2pnDmOjCBPZV+V2vf3h9bGCE6u9uo05RAa +WzVNd+NWIXiC3CEZNd4ksdMdRv9dX2VPMYIC5zCCAuMCAQEwaTBiMQswCQYDVQQGEwJaQTElMCMG +A1UEChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNv +bmFsIEZyZWVtYWlsIElzc3VpbmcgQ0ECAw84ujAJBgUrDgMCGgUAoIIBUzAYBgkqhkiG9w0BCQMx +CwYJKoZIhvcNAQcBMBwGCSqGSIb3DQEJBTEPFw0wNjAyMjQwNjU0NDZaMCMGCSqGSIb3DQEJBDEW +BBQr/4VMmsWuPP5+fhMQMmi87CMl5DB4BgkrBgEEAYI3EAQxazBpMGIxCzAJBgNVBAYTAlpBMSUw +IwYDVQQKExxUaGF3dGUgQ29uc3VsdGluZyAoUHR5KSBMdGQuMSwwKgYDVQQDEyNUaGF3dGUgUGVy +c29uYWwgRnJlZW1haWwgSXNzdWluZyBDQQIDDzi6MHoGCyqGSIb3DQEJEAILMWugaTBiMQswCQYD +VQQGEwJaQTElMCMGA1UEChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMj +VGhhd3RlIFBlcnNvbmFsIEZyZWVtYWlsIElzc3VpbmcgQ0ECAw84ujANBgkqhkiG9w0BAQEFAASC +AQBA5/j829ffqaCbrhBFqg3+ELdC1U3M0d3SdNf8ry6q4eXeJ8caE9ioCS7T4hf1826VlL/0JmTb +aMXDC+Hyr/TwSgJ4qLJojWHMtYfJhxETl5LBumFe+UjTwk3WtpVOlletq5fN6T1RdmQqYF7/x+ed +GCDvWpiZS7WNUkp3egeH7o28a4h6duY7ynYbyi02vno0rzrLMYn4wuCfTN+59t9f7XlHKCGGJvUH +xlmui3pkvPxp/gVj2At9fCP/3tLTSFCwqN5Uokjc+2UB79gqJ+zRagA3sUyKNdr234cc1LtxkNyV +4Gnt8B1EsH6B9RzfldhNTttMQoQ6CrCQFVRJxsVrAAAAAAAA + +--Apple-Mail-2--751870699-- + + +From pgsql-performance-owner@postgresql.org Fri Feb 24 03:01:34 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 9946E9DCD1B + for ; + Fri, 24 Feb 2006 03:01:31 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 63967-03 + for ; + Fri, 24 Feb 2006 03:01:30 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from houston.familyhealth.com.au (houston.au.fhnetwork.com + [203.22.197.21]) + by postgresql.org (Postfix) with ESMTP id AD37C9DCC07 + for ; + Fri, 24 Feb 2006 03:01:25 -0400 (AST) +Received: from houston.familyhealth.com.au (localhost [127.0.0.1]) + by houston.familyhealth.com.au (Postfix) with ESMTP id 78DBD2507D; + Fri, 24 Feb 2006 15:01:19 +0800 (WST) +Received: from [127.0.0.1] (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (Postfix) with ESMTP id 3B3332507C; + Fri, 24 Feb 2006 15:01:18 +0800 (WST) +Message-ID: <43FEB07A.7080209@familyhealth.com.au> +Date: Fri, 24 Feb 2006 15:06:34 +0800 +From: Christopher Kings-Lynne +User-Agent: Thunderbird 1.5 (Windows/20051201) +MIME-Version: 1.0 +To: Brendan Duddridge +Cc: PostgreSQL Performance , + Tony Copping +Subject: Re: Really really slow query. What's a better way? +References: <1831440F-F848-471D-ACE9-F84CE9F4E359@clickspace.com> +In-Reply-To: <1831440F-F848-471D-ACE9-F84CE9F4E359@clickspace.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-familyhealth-MailScanner-Information: Please contact the ISP for more + information +X-familyhealth-MailScanner: Found to be clean +X-familyhealth-MailScanner-From: chriskl@familyhealth.com.au +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.095 required=5 tests=[AWL=0.095] +X-Spam-Score: 0.095 +X-Spam-Level: +X-Archive-Number: 200602/380 +X-Sequence-Number: 17366 + +how about something like: + +DELETE FROM cds.cds_mspecxx WHERE NOT EXISTS (SELECT 1 FROM +cds_stage.cds_Catalog stage where stage.countryCode = 'us' and +stage.ProdId=cds.cds_mspecxx.ProdId) and countryCode = 'us'; + +Run explain on it first to see how it will be planned. Both tables +should have an index over (countryCode, ProdId) I think. + +Chris + +Brendan Duddridge wrote: +> Hi, +> +> We're executing a query that has the following plan and we're wondering +> given the size of the data set, what's a better way to write the query? +> It's been running since 2pm 2 days ago. +> +> explain DELETE FROM cds.cds_mspecxx WHERE ProdID not in (SELECT +> stage.ProdID FROM cds_stage.cds_Catalog stage where stage.countryCode = +> 'us') and countryCode = 'us'; +> QUERY PLAN +> --------------------------------------------------------------------------------------------------- +> Index Scan using pk_mspecxx on cds_mspecxx +> (cost=53360.87..208989078645.48 rows=7377879 width=6) +> Index Cond: ((countrycode)::text = 'us'::text) +> Filter: (NOT (subplan)) +> SubPlan +> -> Materialize (cost=53360.87..77607.54 rows=1629167 width=12) +> -> Seq Scan on cds_catalog stage (cost=0.00..43776.70 rows=1629167 width=12) +> Filter: ((countrycode)::text = 'us'::text) +> (7 rows) +> +> Thanks, +> * +> *____________________________________________________________________ +> *Brendan Duddridge* | CTO | 403-277-5591 x24 | brendan@clickspace.com +> +> * +> *ClickSpace Interactive Inc. +> Suite L100, 239 - 10th Ave. SE +> Calgary, AB T2G 0V9 +> +> http://www.clickspace.com +> + + +From pgsql-performance-owner@postgresql.org Fri Feb 24 03:24:03 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id BAF669DC89B + for ; + Fri, 24 Feb 2006 03:24:02 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 64249-07 + for ; + Fri, 24 Feb 2006 03:24:02 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.clickspace.com (router2.clickspace.com [65.110.166.227]) + by postgresql.org (Postfix) with ESMTP id 01E719DC840 + for ; + Fri, 24 Feb 2006 03:23:59 -0400 (AST) +Received: from [10.0.1.3] ([68.147.204.179]) + (authenticated user brendan@clickspace.com) by mail.clickspace.com + (using TLSv1/SSLv3 with cipher RC4-SHA (128 bits)); + Fri, 24 Feb 2006 00:23:59 -0700 +In-Reply-To: <43FEB07A.7080209@familyhealth.com.au> +References: <1831440F-F848-471D-ACE9-F84CE9F4E359@clickspace.com> + <43FEB07A.7080209@familyhealth.com.au> +Mime-Version: 1.0 (Apple Message framework v746.2) +Content-Type: multipart/signed; micalg=sha1; boundary=Apple-Mail-3--750115871; + protocol="application/pkcs7-signature" +Message-Id: <1E4DF43B-6BF9-4F16-AD27-2326288F6B8E@clickspace.com> +Cc: PostgreSQL Performance , + Tony Copping +From: Brendan Duddridge +Subject: Re: Really really slow query. What's a better way? +Date: Fri, 24 Feb 2006 00:24:00 -0700 +To: Christopher Kings-Lynne +X-Mailer: Apple Mail (2.746.2) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.108 required=5 tests=[AWL=0.108] +X-Spam-Score: 0.108 +X-Spam-Level: +X-Archive-Number: 200602/381 +X-Sequence-Number: 17367 + + +--Apple-Mail-3--750115871 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset=US-ASCII; + delsp=yes; + format=flowed + +Thanks Chris for the very quick response! + +Just after posting this message, we tried explain on the same format +as you just posted: + +explain DELETE FROM cds.cds_mspecxx WHERE not exists (SELECT 'X' FROM +cds_stage.cds_Catalog stage where stage.countryCode = 'us' and +stage.prodid = cds.cds_mspecxx.prodid) and countryCode = 'us'; +QUERY PLAN +------------------------------------------------------------------------ +---------------------- +Bitmap Heap Scan on cds_mspecxx (cost=299654.85..59555205.23 +rows=7377879 width=6) +Recheck Cond: ((countrycode)::text = 'us'::text) +Filter: (NOT (subplan)) +-> Bitmap Index Scan on pk_mspecxx (cost=0.00..299654.85 +rows=14755759 width=0) +Index Cond: ((countrycode)::text = 'us'::text) +SubPlan +-> Index Scan using pk_catalog on cds_catalog stage (cost=0.00..7.97 +rows=2 width=0) +Index Cond: (((prodid)::text = ($0)::text) AND ((countrycode)::text = +'us'::text)) +(8 rows) + +Seems way better. I'm not sure it can get any faster though. Not sure +if having the indexes as (countryCode, ProdId) or (ProdId, +countryCode) would make any kind of difference though. Would it? + +Thanks! + +____________________________________________________________________ +Brendan Duddridge | CTO | 403-277-5591 x24 | brendan@clickspace.com + +ClickSpace Interactive Inc. +Suite L100, 239 - 10th Ave. SE +Calgary, AB T2G 0V9 + +http://www.clickspace.com + +On Feb 24, 2006, at 12:06 AM, Christopher Kings-Lynne wrote: + +> how about something like: +> +> DELETE FROM cds.cds_mspecxx WHERE NOT EXISTS (SELECT 1 FROM +> cds_stage.cds_Catalog stage where stage.countryCode = 'us' and +> stage.ProdId=cds.cds_mspecxx.ProdId) and countryCode = 'us'; +> +> Run explain on it first to see how it will be planned. Both tables +> should have an index over (countryCode, ProdId) I think. +> +> Chris +> +> Brendan Duddridge wrote: +>> Hi, +>> We're executing a query that has the following plan and we're +>> wondering given the size of the data set, what's a better way to +>> write the query? It's been running since 2pm 2 days ago. +>> explain DELETE FROM cds.cds_mspecxx WHERE ProdID not in (SELECT +>> stage.ProdID FROM cds_stage.cds_Catalog stage where +>> stage.countryCode = 'us') and countryCode = 'us'; +>> QUERY PLAN +>> --------------------------------------------------------------------- +>> ------------------------------ +>> Index Scan using pk_mspecxx on cds_mspecxx +>> (cost=53360.87..208989078645.48 rows=7377879 width=6) +>> Index Cond: ((countrycode)::text = 'us'::text) +>> Filter: (NOT (subplan)) +>> SubPlan +>> -> Materialize (cost=53360.87..77607.54 rows=1629167 width=12) +>> -> Seq Scan on cds_catalog stage (cost=0.00..43776.70 rows=1629167 +>> width=12) +>> Filter: ((countrycode)::text = 'us'::text) +>> (7 rows) +>> Thanks, +>> * +>> *____________________________________________________________________ +>> *Brendan Duddridge* | CTO | 403-277-5591 x24 | +>> brendan@clickspace.com +>> * +>> *ClickSpace Interactive Inc. +>> Suite L100, 239 - 10th Ave. SE +>> Calgary, AB T2G 0V9 +>> http://www.clickspace.com +> +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 5: don't forget to increase your free space map settings +> + + +--Apple-Mail-3--750115871 +Content-Transfer-Encoding: base64 +Content-Type: application/pkcs7-signature; + name=smime.p7s +Content-Disposition: attachment; + filename=smime.p7s + +MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIGIDCCAtkw +ggJCoAMCAQICAw84ujANBgkqhkiG9w0BAQQFADBiMQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhh +d3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNvbmFsIEZyZWVt +YWlsIElzc3VpbmcgQ0EwHhcNMDUwNzI5MjAxMTQzWhcNMDYwNzI5MjAxMTQzWjBIMR8wHQYDVQQD +ExZUaGF3dGUgRnJlZW1haWwgTWVtYmVyMSUwIwYJKoZIhvcNAQkBFhZicmVuZGFuQGNsaWNrc3Bh +Y2UuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqWfMCdFgKzXroGNqJuU3eyDC +K/Gxts3mtmIdgcHGmUjRKdlBSfkmcCBUDPJIt4QQc91sY3h8Itg0EAsF+1yFECU6afn/1SEAHSDK +6Q86PclF58/Dux2FYNGpeIAw/lisZ2UCyIYoUiWtEDKCBq5jDuYzcGkFS5Csz+/rEL+BHTXQVqnS +nUdUaXu9xdZn4wgjB/n65UEYRqr0LGN53CGsFcA9uC+ViS7WyBtzJcP02LMNT+cAZ7TKHw4Q/ZeG +5ptPgQHLTD2wza3GMbPQ4fYK6aNPA+lVzslLSCjyQpg55gVyQQlV0k/5zU5Q5m48ZtqwOqN+fPYd +eIB7H5y1SFLd/wIDAQABozMwMTAhBgNVHREEGjAYgRZicmVuZGFuQGNsaWNrc3BhY2UuY29tMAwG +A1UdEwEB/wQCMAAwDQYJKoZIhvcNAQEEBQADgYEAT+6hGvStHoRO0OCHlJev31BpUlvPSpbYVKJN +i5kCMF164sSX7j0IRvcyU6DfUuW7samTluXJbANyuX1ZIpXulGen5EEc2NV7eU/rMz6ExklMShTh +++azcvmMjOzTuqXi3ZsIjwzBBhqCB0U++kYlMlHEYla2qKLFbXY6PiH0a8swggM/MIICqKADAgEC +AgENMA0GCSqGSIb3DQEBBQUAMIHRMQswCQYDVQQGEwJaQTEVMBMGA1UECBMMV2VzdGVybiBDYXBl +MRIwEAYDVQQHEwlDYXBlIFRvd24xGjAYBgNVBAoTEVRoYXd0ZSBDb25zdWx0aW5nMSgwJgYDVQQL +Ex9DZXJ0aWZpY2F0aW9uIFNlcnZpY2VzIERpdmlzaW9uMSQwIgYDVQQDExtUaGF3dGUgUGVyc29u +YWwgRnJlZW1haWwgQ0ExKzApBgkqhkiG9w0BCQEWHHBlcnNvbmFsLWZyZWVtYWlsQHRoYXd0ZS5j +b20wHhcNMDMwNzE3MDAwMDAwWhcNMTMwNzE2MjM1OTU5WjBiMQswCQYDVQQGEwJaQTElMCMGA1UE +ChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNvbmFs +IEZyZWVtYWlsIElzc3VpbmcgQ0EwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMSmPFVzVftO +ucqZWh5owHUEcJ3f6f+jHuy9zfVb8hp2vX8MOmHyv1HOAdTlUAow1wJjWiyJFXCO3cnwK4Vaqj9x +VsuvPAsH5/EfkTYkKhPPK9Xzgnc9A74r/rsYPge/QIACZNenprufZdHFKlSFD0gEf6e20TxhBEAe +ZBlyYLf7AgMBAAGjgZQwgZEwEgYDVR0TAQH/BAgwBgEB/wIBADBDBgNVHR8EPDA6MDigNqA0hjJo +dHRwOi8vY3JsLnRoYXd0ZS5jb20vVGhhd3RlUGVyc29uYWxGcmVlbWFpbENBLmNybDALBgNVHQ8E +BAMCAQYwKQYDVR0RBCIwIKQeMBwxGjAYBgNVBAMTEVByaXZhdGVMYWJlbDItMTM4MA0GCSqGSIb3 +DQEBBQUAA4GBAEiM0VCD6gsuzA2jZqxnD3+vrL7CF6FDlpSdf0whuPg2H6otnzYvwPQcUCCTcDz9 +reFhYsPZOhl+hLGZGwDFGguCdJ4lUJRix9sncVcljd2pnDmOjCBPZV+V2vf3h9bGCE6u9uo05RAa +WzVNd+NWIXiC3CEZNd4ksdMdRv9dX2VPMYIC5zCCAuMCAQEwaTBiMQswCQYDVQQGEwJaQTElMCMG +A1UEChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNv +bmFsIEZyZWVtYWlsIElzc3VpbmcgQ0ECAw84ujAJBgUrDgMCGgUAoIIBUzAYBgkqhkiG9w0BCQMx +CwYJKoZIhvcNAQcBMBwGCSqGSIb3DQEJBTEPFw0wNjAyMjQwNzI0MDFaMCMGCSqGSIb3DQEJBDEW +BBSEoR4OHIhai/WGQUSt0VJsjEir8DB4BgkrBgEEAYI3EAQxazBpMGIxCzAJBgNVBAYTAlpBMSUw +IwYDVQQKExxUaGF3dGUgQ29uc3VsdGluZyAoUHR5KSBMdGQuMSwwKgYDVQQDEyNUaGF3dGUgUGVy +c29uYWwgRnJlZW1haWwgSXNzdWluZyBDQQIDDzi6MHoGCyqGSIb3DQEJEAILMWugaTBiMQswCQYD +VQQGEwJaQTElMCMGA1UEChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMj +VGhhd3RlIFBlcnNvbmFsIEZyZWVtYWlsIElzc3VpbmcgQ0ECAw84ujANBgkqhkiG9w0BAQEFAASC +AQCTA2IOStKyzQqVvZiFLpZ79GU0Qx4CSe3k+4vhXYPdgklsFLfATaIcwRa7a0nUHHakCh06RhY4 +moUi78Zwxj2gpVi6ByhM6usTLZUNAc6od4+gQA9k7jroKWmIh/PsPpCdhRJWdlW6GES/Z7uFEAfX +hOoM7dwXC/nzdVWuI0NverFOkbpILeiKp5B4FrUyVsEZP4oWJixrEN5EGS47e36O2niOuDu9pT2N +cmpDW8RsqK8wIWjICrTbQf1TeQQTTSI4wqfvUQeEmiajxhBE5hceKL+kVzx+3flwL1Mtt8tXzfhB +WY/8Z/oMzp/sEUKE+agL1Wz80vEcI+tLNxbdxZvtAAAAAAAA + +--Apple-Mail-3--750115871-- + + +From pgsql-performance-owner@postgresql.org Tue Feb 28 22:50:41 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 91D459DCD00 + for ; + Fri, 24 Feb 2006 10:13:41 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 29668-03 + for ; + Fri, 24 Feb 2006 10:13:39 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id 65D8E9DC822 + for ; + Fri, 24 Feb 2006 10:13:33 -0400 (AST) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 5F78E30BAC; Fri, 24 Feb 2006 15:13:37 +0100 (MET) +From: "jcfischer" +X-Newsgroups: pgsql.performance +Subject: nested query on last n rows of huge table +Date: 24 Feb 2006 06:13:31 -0800 +Organization: http://groups.google.com +Lines: 35 +Message-ID: <1140790410.923941.261250@p10g2000cwp.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; de; + rv:1.8.0.1) Gecko/20060111 + Firefox/1.5.0.1,gzip(gfe),gzip(gfe) +Complaints-To: groups-abuse@google.com +Injection-Info: p10g2000cwp.googlegroups.com; posting-host=195.186.55.199; + posting-account=y8Yb_A0AAAAqh4VDa55BdDUMWbuhwj4N +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200602/448 +X-Sequence-Number: 17434 + +Hi list + +I'm fairly new to Postgres so bear with me. Googling and searching the +list, I didn't find anything that resembled my problem. + +I have a large table with ca. 10 million inserts per day (fairly simple +data: timestam, a couple of id's and a varchar message) + +I run a query every couple of minutes that looks at the new entries +since the last run and retrieves them for further processing (using a +WHERE eventtime > '2006-02-24 14:00:00' ) to limit to the most recent +entries + +These queries run around 40-50 seconds (largely due to some LIKE %msg% +threwn in for good measure). Postgres performs a seq table scan on +those queries :-( + +My idea is to limit the search to only the last n entries because I +found that a + +SELECT * from table ORDER eventtime DESC limit 1000 + +is very fast. Because the inserts are in chronolgical order, I can +store the sequential id of the highest row from the last query and +subtract that from the current high row count to determine that number. + +Is there a way to limit the expensive query to only those last 1000 (or +whatever) results? + +I have tried to nest SELECTS but my SQL-fu is to limited to get +anything through the SQL processor :-) + +thanks +Jens-Christian Fischer + + +From pgsql-performance-owner@postgresql.org Tue Feb 28 22:51:21 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id D6F379DCBB3 + for ; + Fri, 24 Feb 2006 10:26:45 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 30908-02 + for ; + Fri, 24 Feb 2006 10:26:49 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id 18D169DCBA4 + for ; + Fri, 24 Feb 2006 10:26:42 -0400 (AST) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 3144730BAC; Fri, 24 Feb 2006 15:26:47 +0100 (MET) +From: "jcfischer" +X-Newsgroups: pgsql.performance +Subject: Re: nested query on last n rows of huge table +Date: 24 Feb 2006 06:26:40 -0800 +Organization: http://groups.google.com +Lines: 46 +Message-ID: <1140791200.791076.26200@t39g2000cwt.googlegroups.com> +References: <1140790410.923941.261250@p10g2000cwp.googlegroups.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset="iso-8859-1" +X-Complaints-To: groups-abuse@google.com +In-Reply-To: <1140790410.923941.261250@p10g2000cwp.googlegroups.com> +User-Agent: G2/0.2 +X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; de; + rv:1.8.0.1) Gecko/20060111 + Firefox/1.5.0.1,gzip(gfe),gzip(gfe) +Complaints-To: groups-abuse@google.com +Injection-Info: t39g2000cwt.googlegroups.com; posting-host=195.186.55.199; + posting-account=y8Yb_A0AAAAqh4VDa55BdDUMWbuhwj4N +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200602/449 +X-Sequence-Number: 17435 + +sorry: Postgres 8.0.2 server. The EXPLAIN ANALYZE for the query looks +like this: + +explain analyze select +syslog.logs.eventtime,assets.hosts.name,syslog.processes.name as +process +from +syslog.logs,assets.hosts,assets.ipaddrs,assets.macaddrs,syslog.processes +where msg like '%session opened for user root%' +and syslog.logs.assets_ipaddr_id = assets.ipaddrs.id +and assets.ipaddrs.macaddr_id = assets.macaddrs.id +and assets.macaddrs.host_id = assets.hosts.id +and syslog.processes.id = syslog.logs.process_id and +eventtime > timestamp '2006-02-24 15:05:00' + +Nested Loop (cost=0.00..328832.34 rows=2 width=254) (actual +time=49389.924..49494.665 rows=45 loops=1) + -> Nested Loop (cost=0.00..328826.32 rows=1 width=90) (actual +time=49365.709..49434.500 rows=45 loops=1) + -> Nested Loop (cost=0.00..328820.30 rows=1 width=90) (actual +time=49327.211..49360.043 rows=45 loops=1) + -> Nested Loop (cost=0.00..328814.27 rows=1 width=90) +(actual time=49327.183..49344.281 rows=45 loops=1) + -> Seq Scan on logs (cost=0.00..328809.04 rows=1 +width=16) (actual time=49314.928..49331.451 rows=45 loops=1) + Filter: (((msg)::text ~~ '%session opened for +user root%'::text) AND (eventtime > '2006-02-24 15:05:00'::timestamp +without time zone)) + -> Index Scan using "pk_syslog.processes" on +processes (cost=0.00..5.21 rows=1 width=82) (actual time=0.278..0.280 +rows=1 loops=45) + Index Cond: (processes.id = +"outer".process_id) + -> Index Scan using "pk_assets.ipaddrs" on ipaddrs +(cost=0.00..6.01 rows=1 width=8) (actual time=0.344..0.346 rows=1 +loops=45) + Index Cond: ("outer".assets_ipaddr_id = ipaddrs.id) + -> Index Scan using "pk_assets.macaddrs" on macaddrs +(cost=0.00..6.01 rows=1 width=8) (actual time=1.648..1.650 rows=1 +loops=45) + Index Cond: ("outer".macaddr_id = macaddrs.id) + -> Index Scan using "pk_assets.hosts" on hosts (cost=0.00..6.01 +rows=1 width=172) (actual time=1.330..1.331 rows=1 loops=45) + Index Cond: ("outer".host_id = hosts.id) +Total runtime: 49494.830 ms + + +From pgsql-performance-owner@postgresql.org Fri Feb 24 10:30:01 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id CA35E9DC822 + for ; + Fri, 24 Feb 2006 10:30:00 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28893-07 + for ; + Fri, 24 Feb 2006 10:30:04 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from candle.pha.pa.us (candle.pha.pa.us [70.90.9.53]) + by postgresql.org (Postfix) with ESMTP id 101399DC816 + for ; + Fri, 24 Feb 2006 10:29:57 -0400 (AST) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id k1OETwD07991; + Fri, 24 Feb 2006 09:29:58 -0500 (EST) +From: Bruce Momjian +Message-Id: <200602241429.k1OETwD07991@candle.pha.pa.us> +Subject: Re: Reliability recommendations +In-Reply-To: <87r764wjg4.fsf@wolfe.cbbrowne.com> +To: Christopher Browne +Date: Fri, 24 Feb 2006 09:29:58 -0500 (EST) +CC: pgsql-performance@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL121 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.378 required=5 tests=[AWL=-0.122, RAZOR2_CHECK=0.5] +X-Spam-Score: 0.378 +X-Spam-Level: +X-Archive-Number: 200602/382 +X-Sequence-Number: 17368 + +Christopher Browne wrote: +> After takin a swig o' Arrakan spice grog, jd@commandprompt.com ("Joshua D. Drake") belched out: +> > Jeremy Haile wrote: +> >> We are a small company looking to put together the most cost effective +> >> solution for our production database environment. Currently in +> >> production Postgres 8.1 is running on this machine: +> >> +> >> Dell 2850 +> >> 2 x 3.0 Ghz Xeon 800Mhz FSB 2MB Cache +> >> 4 GB DDR2 400 Mhz +> >> 2 x 73 GB 10K SCSI RAID 1 (for xlog and OS) +> >> 4 x 146 GB 10K SCSI RAID 10 (for postgres data) +> >> Perc4ei controller +> >> +> >> The above is a standard Dell box with nothing added or modified beyond +> >> the options available directly through Dell. +> +> > You should probably review the archives for PostgreSQL user +> > experience with Dell's before you purchase one. +> +> Hear, hear! We found Dell servers were big-time underperformers. +> +> Generic hardware put together with generally the same brand names of +> components (e.g. - for SCSI controllers and such) would generally play +> much better. +> +> For the cheapo desktop boxes they obviously have to buy the "cheapest +> hardware available this week;" it sure seems as though they engage in +> the same sort of thing with the "server class" hardware. +> +> I don't think anyone has been able to forcibly point out any +> completely precise shortcoming; just that they underperform what the +> specs suggest they ought to be able to provide. + +Dell often says part X is included, but part X is not the exact same as +part X sold by the original manufacturer. To hit a specific price +point, Dell is willing to strip thing out of commodity hardware, and +often does so even when performance suffers. For many people, this is +unacceptable. + +-- + Bruce Momjian http://candle.pha.pa.us + SRA OSS, Inc. http://www.sraoss.com + + + If your life is a hard drive, Christ can be your backup. + + +From pgsql-performance-owner@postgresql.org Fri Feb 24 11:10:16 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 3EA859DC816 + for ; + Fri, 24 Feb 2006 11:10:16 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37188-02 + for ; + Fri, 24 Feb 2006 11:10:20 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from moonunit2.moonview.localnet (wsip-68-15-5-150.sd.sd.cox.net + [68.15.5.150]) by postgresql.org (Postfix) with ESMTP id DB7A89DC80A + for ; + Fri, 24 Feb 2006 11:10:13 -0400 (AST) +Received: from [192.168.0.3] (moonunit3.moonview.localnet [192.168.0.3]) + by moonunit2.moonview.localnet (8.13.1/8.13.1) with ESMTP id + k1OFBDXJ026177 + for ; Fri, 24 Feb 2006 07:11:13 -0800 +Message-ID: <43FF2095.6050505@modgraph-usa.com> +Date: Fri, 24 Feb 2006 07:04:53 -0800 +From: "Craig A. James" +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +CC: pgsql-performance@postgresql.org +Subject: Re: Reliability recommendations +References: <200602241429.k1OETwD07991@candle.pha.pa.us> +In-Reply-To: <200602241429.k1OETwD07991@candle.pha.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.191 required=5 tests=[AWL=0.002, + MISSING_HEADERS=0.189] +X-Spam-Score: 0.191 +X-Spam-Level: +X-Archive-Number: 200602/383 +X-Sequence-Number: 17369 + +Bruce Momjian wrote: +> Dell often says part X is included, but part X is not the exact same as +> part X sold by the original manufacturer. To hit a specific price +> point, Dell is willing to strip thing out of commodity hardware, and +> often does so even when performance suffers. For many people, this is +> unacceptable. + +I find this strains credibility, that this major manufacturer of PC's would do something deceptive that hurts performance, when it would be easily detected and widely reported. Can anyone cite a specific instances where this has happened? Such as, "I bought Dell model XYZ, which was advertised to have these parts and these specs, but in fact had these other parts and here are the actual specs." + +Dell seems to take quite a beating in this forum, and I don't recall seeing any other manufacturer blasted this way. Is it that they are deceptive, or simply that their "servers" are designed to be office servers, not database servers? + +There's nothing wrong with Dell designing their servers for a different market than ours; they need to go for the profits, and that may not include us. But it's not fair for us to claim Dell is being deceptive unless we have concrete evidence. + +Craig + + +From pgsql-performance-owner@postgresql.org Fri Feb 24 11:14:30 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id B07399DC822 + for ; + Fri, 24 Feb 2006 11:14:29 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37577-01 + for ; + Fri, 24 Feb 2006 11:14:31 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.mi8.com (d01gw02.mi8.com [63.240.6.46]) + by postgresql.org (Postfix) with ESMTP id AC2579DC820 + for ; + Fri, 24 Feb 2006 11:14:24 -0400 (AST) +Received: from 172.16.1.26 by mail.mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D2)); Fri, 24 Feb 2006 10:14:21 -0500 +X-Server-Uuid: 7829E76E-BB9E-4995-8473-3C0929DF7DD1 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.175]) by + D01HOST01.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Fri, 24 Feb + 2006 10:14:21 -0500 +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.105]) with Microsoft Exchange Server HTTP-DAV ; Fri, 24 Feb + 2006 15:14:20 +0000 +User-Agent: Microsoft-Entourage/11.2.1.051004 +Date: Fri, 24 Feb 2006 07:14:20 -0800 +Subject: Re: Reliability recommendations +From: "Luke Lonergan" +To: "Bruce Momjian" , + "Christopher Browne" +cc: pgsql-performance@postgresql.org +Message-ID: +Thread-Topic: [PERFORM] Reliability recommendations +Thread-Index: AcY5Tu051lElMhjHSsadVf3PiYjSzwABg8Yf +In-Reply-To: <200602241429.k1OETwD07991@candle.pha.pa.us> +MIME-Version: 1.0 +X-OriginalArrivalTime: 24 Feb 2006 15:14:21.0183 (UTC) + FILETIME=[FD07F0F0:01C63954] +X-WSS-ID: 6FE1FD472XS17450566-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, score=1.349 required=5 tests=[AWL=0.096, + RCVD_NUMERIC_HELO=1.253] +X-Spam-Score: 1.349 +X-Spam-Level: * +X-Archive-Number: 200602/384 +X-Sequence-Number: 17370 + +Bruce, + +On 2/24/06 6:29 AM, "Bruce Momjian" wrote: + +> Christopher Browne wrote: +>> After takin a swig o' Arrakan spice grog, jd@commandprompt.com ("Joshua D. +>> Drake") belched out: + +Always more fun to read drunken posts :-) + +>>>> Dell 2850 +>>>> 2 x 3.0 Ghz Xeon 800Mhz FSB 2MB Cache +>>>> 4 GB DDR2 400 Mhz +>>>> 2 x 73 GB 10K SCSI RAID 1 (for xlog and OS) +>>>> 4 x 146 GB 10K SCSI RAID 10 (for postgres data) +>>>> Perc4ei controller + +> Dell often says part X is included, but part X is not the exact same as +> part X sold by the original manufacturer. To hit a specific price +> point, Dell is willing to strip thing out of commodity hardware, and +> often does so even when performance suffers. For many people, this is +> unacceptable. + +I'll register the contrarian's point of view on this: we just had a customer +(an airline) buy the exact machines that Jeremy lists here, including the +Perc4 controller (an LSI MPT RAID controller). + +Besides the complete lack of real RAID 10 support, the machines are actually +performing very well in hardware RAID5 mode. They are running Redhat 4 +linux, and we did have to tune the I/O readahead to get the performance we +needed - about 250MB/s on 2 banks of RAID5, not bad at all for only 4 active +disks. + +I think the build quality and the fit/finish/features of their chassis were +all pretty good. + +So, if you want RAID5, these machines work for me. The lack of RAID 10 +could knock them out of contention for people. + +The problem with their RAID10 is actually hidden from view BTW. You can +configure the controller with a "spanning" and other options that sound like +RAID10, but in actuality it's spanning pairs of RAID1 disks, which does not +provide the performance benefit of RAID10 (see James Thornton's post here: +http://openacs.org/forums/message-view?message_id=178447), the important bit +of which says: + +"RAID-10 on PERC 2/SC, 2/DC, 3/SC, 3/DCL, 3/DC, 3/QC, 4/Di, and CERC +ATA100/4ch controllers is implemented as RAID Level 1-Concatenated. RAID-1 +Concatenated is a RAID-1 array that spans across more than a single pair of +array disks. This combines the advantages of concatenation with the +redundancy of RAID-1. No striping is involved in this RAID type. Also, +RAID-1 Concatenated can be implemented on hardware that supports only RAID-1 +by creating multiple RAID-1 virtual disks, upgrading the virtual disks to +dynamic disks, and then using spanning to concatenate all of the RAID-1 +virtual disks into one large dynamic volume. In a concatenation (spanned +volume), when an array disk in a concatenated or spanned volume fails, the +entire volume becomes unavailable." + +- Luke + + + +From pgsql-performance-owner@postgresql.org Fri Feb 24 11:41:22 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 7D8419DC98C + for ; + Fri, 24 Feb 2006 11:41:21 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 41543-04 + for ; + Fri, 24 Feb 2006 11:41:26 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.Mi8.com (d01gw01.mi8.com [63.240.6.47]) + by postgresql.org (Postfix) with ESMTP id 1DFD19DC816 + for ; + Fri, 24 Feb 2006 11:41:18 -0400 (AST) +Received: from 172.16.1.112 by mail.Mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D1)); Fri, 24 Feb 2006 10:41:13 -0500 +X-Server-Uuid: 241911D6-425B-44B9-A073-E3FE0F8FC774 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.175]) by + D01SMTP02.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Fri, 24 Feb + 2006 10:41:12 -0500 +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.105]) with Microsoft Exchange Server HTTP-DAV ; Fri, 24 Feb + 2006 15:41:12 +0000 +User-Agent: Microsoft-Entourage/11.2.1.051004 +Date: Fri, 24 Feb 2006 07:41:12 -0800 +Subject: Re: Reliability recommendations +From: "Luke Lonergan" +To: "Luke Lonergan" , + "Bruce Momjian" , + "Christopher Browne" +cc: pgsql-performance@postgresql.org +Message-ID: +Thread-Topic: [PERFORM] Reliability recommendations +Thread-Index: AcY5Tu051lElMhjHSsadVf3PiYjSzwABg8YfAADwNdc= +In-Reply-To: +MIME-Version: 1.0 +X-OriginalArrivalTime: 24 Feb 2006 15:41:12.0694 (UTC) + FILETIME=[BD910160:01C63958] +X-WSS-ID: 6FE1F69331W11063204-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, score=1.35 required=5 tests=[AWL=0.097, + RCVD_NUMERIC_HELO=1.253] +X-Spam-Score: 1.35 +X-Spam-Level: * +X-Archive-Number: 200602/385 +X-Sequence-Number: 17371 + +Bruce, + +On 2/24/06 7:14 AM, "Luke Lonergan" wrote: + +> So, if you want RAID5, these machines work for me. The lack of RAID 10 +> could knock them out of contention for people. + +Sorry in advance for the double post, but there's some more information on +this, which altogether demonstrates why people get frustrated with Dell IMO. + +Later on in the article I cited, the same person who listed Dell's technical +description of their strange, not really RAID10 support, he mentions that he +called LSI directly to find out the real scoop. He says that they (LSI) +told him that the LSI controller does support real RAID10, so he concluded +that the Dell could do it too. + +However, Dell's documentation seems unambiguous to me, and matches our +direct experience. Also, more online documentation from Dell reinforces +this. See their definition of both RAID10 and spanning in this +backgrounder: +http://support.dell.com/support/edocs/storage/RAID/RAIDbk0.pdf. Seems that +they are clear about what striping and spanning do, and what RAID10 does, +making their delineation of the standard RAID10 support versus what some of +their controllers do (all of the PERC 4 series) pretty clear. + +So, I'd conclude at this point that Dell seems to have implemented a RAID +BIOS that does not allow true RAID10 or RAID50 on their embedded LSI +adapters, which could otherwise support RAID10/50. They have done this +intentionally, for some reason unknown to me and it seems to some people at +LSI as well. + +- Luke + + + +From pgsql-performance-owner@postgresql.org Fri Feb 24 12:27:43 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 05B9E9DC820 + for ; + Fri, 24 Feb 2006 12:27:43 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 46305-10 + for ; + Fri, 24 Feb 2006 12:27:41 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from yertle.kcilink.com (yertle.kcilink.com [65.205.34.180]) + by postgresql.org (Postfix) with ESMTP id 88D349DC816 + for ; + Fri, 24 Feb 2006 12:27:40 -0400 (AST) +Received: from [192.168.7.103] (host-103.int.kcilink.com [192.168.7.103]) + by yertle.kcilink.com (Postfix) with ESMTP id D0EC1B80D + for ; + Fri, 24 Feb 2006 11:27:38 -0500 (EST) +Mime-Version: 1.0 (Apple Message framework v746.2) +In-Reply-To: <200602241429.k1OETwD07991@candle.pha.pa.us> +References: <200602241429.k1OETwD07991@candle.pha.pa.us> +Content-Type: multipart/signed; micalg=sha1; boundary=Apple-Mail-6--717499401; + protocol="application/pkcs7-signature" +Message-Id: <30917816-5D5E-4161-A21A-64DF2990777F@khera.org> +From: Vivek Khera +Subject: Re: Reliability recommendations +Date: Fri, 24 Feb 2006 11:27:37 -0500 +To: Postgresql Performance +X-Mailer: Apple Mail (2.746.2) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.067 required=5 tests=[AWL=0.067] +X-Spam-Score: 0.067 +X-Spam-Level: +X-Archive-Number: 200602/386 +X-Sequence-Number: 17372 + + +--Apple-Mail-6--717499401 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset=US-ASCII; + delsp=yes; + format=flowed + + +On Feb 24, 2006, at 9:29 AM, Bruce Momjian wrote: + +> Dell often says part X is included, but part X is not the exact +> same as +> part X sold by the original manufacturer. To hit a specific price +> point, Dell is willing to strip thing out of commodity hardware, and +> often does so even when performance suffers. For many people, this is +> unacceptable. + +The last dell box I bought, a PE1850, came with a PERC 4e/Si card, +which I believe is the same as the card the OP was looking at. It is +very fast in RAID1 with two U320 disks. + +For real DB work, I'd look more to a dual channel card and have 1/2 +of each mirror pair on opposing channels. Dell can configure that +for you, I'm sure. + +I think the well tossed-around notion of Dells being underperforming +needs to be re-evaluated with the EM64T Xeon based systems. They are +quite fast. I haven't put a very large db with extreme loads on any +of these systems, but the simple benchmarking I did on them shows +them to be acceptable performers. The high-end RAID cards they sell +these days do not seem to me to be skimpy. + +Now if they'd only get on the Opteron bandwagon.... + + +--Apple-Mail-6--717499401 +Content-Transfer-Encoding: base64 +Content-Type: application/pkcs7-signature; + name=smime.p7s +Content-Disposition: attachment; + filename=smime.p7s + +MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIGhzCCAz8w +ggKooAMCAQICAQ0wDQYJKoZIhvcNAQEFBQAwgdExCzAJBgNVBAYTAlpBMRUwEwYDVQQIEwxXZXN0 +ZXJuIENhcGUxEjAQBgNVBAcTCUNhcGUgVG93bjEaMBgGA1UEChMRVGhhd3RlIENvbnN1bHRpbmcx +KDAmBgNVBAsTH0NlcnRpZmljYXRpb24gU2VydmljZXMgRGl2aXNpb24xJDAiBgNVBAMTG1RoYXd0 +ZSBQZXJzb25hbCBGcmVlbWFpbCBDQTErMCkGCSqGSIb3DQEJARYccGVyc29uYWwtZnJlZW1haWxA +dGhhd3RlLmNvbTAeFw0wMzA3MTcwMDAwMDBaFw0xMzA3MTYyMzU5NTlaMGIxCzAJBgNVBAYTAlpB +MSUwIwYDVQQKExxUaGF3dGUgQ29uc3VsdGluZyAoUHR5KSBMdGQuMSwwKgYDVQQDEyNUaGF3dGUg +UGVyc29uYWwgRnJlZW1haWwgSXNzdWluZyBDQTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA +xKY8VXNV+065yplaHmjAdQRwnd/p/6Me7L3N9VvyGna9fww6YfK/Uc4B1OVQCjDXAmNaLIkVcI7d +yfArhVqqP3FWy688Cwfn8R+RNiQqE88r1fOCdz0Dviv+uxg+B79AgAJk16emu59l0cUqVIUPSAR/ +p7bRPGEEQB5kGXJgt/sCAwEAAaOBlDCBkTASBgNVHRMBAf8ECDAGAQH/AgEAMEMGA1UdHwQ8MDow +OKA2oDSGMmh0dHA6Ly9jcmwudGhhd3RlLmNvbS9UaGF3dGVQZXJzb25hbEZyZWVtYWlsQ0EuY3Js +MAsGA1UdDwQEAwIBBjApBgNVHREEIjAgpB4wHDEaMBgGA1UEAxMRUHJpdmF0ZUxhYmVsMi0xMzgw +DQYJKoZIhvcNAQEFBQADgYEASIzRUIPqCy7MDaNmrGcPf6+svsIXoUOWlJ1/TCG4+DYfqi2fNi/A +9BxQIJNwPP2t4WFiw9k6GX6EsZkbAMUaC4J0niVQlGLH2ydxVyWN3amcOY6MIE9lX5Xa9/eH1sYI +Tq726jTlEBpbNU1341YheILcIRk13iSx0x1G/11fZU8wggNAMIICqaADAgECAgMOah8wDQYJKoZI +hvcNAQEEBQAwYjELMAkGA1UEBhMCWkExJTAjBgNVBAoTHFRoYXd0ZSBDb25zdWx0aW5nIChQdHkp +IEx0ZC4xLDAqBgNVBAMTI1RoYXd0ZSBQZXJzb25hbCBGcmVlbWFpbCBJc3N1aW5nIENBMB4XDTA1 +MDQwNTIwMzEzMloXDTA2MDQwNTIwMzEzMlowgYoxHzAdBgNVBAMTFlRoYXd0ZSBGcmVlbWFpbCBN +ZW1iZXIxHjAcBgkqhkiG9w0BCQEWD3ZpdmVrQGtoZXJhLm9yZzEgMB4GCSqGSIb3DQEJARYRa2hl +cmFAa2NpbGluay5jb20xJTAjBgkqhkiG9w0BCQEWFnZpdmVrQG1haWxlcm1haWxlci5jb20wggEi +MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDdo7hywGcY0VvK6WqqXXV77MS/t/4X3WkCaCXo +RSl2W58GP4P21hodPn7hlIxUoDOW7x9O+FbqTgE2Ejqr6yA00Mm90tGPFgjFjqPGAqg7xk6IDcv9 +uTyMia/FKEHSIynM6zqokXY8JklvdbJOiByE/8VeyEXOANWiflo8o4+GHnhMKpA9982YTXUqeKU6 +mMQVaLCBRjTDc7j2XkMC/UNcp2HMyDQdTqYVnhLxbvbLX8CNDBY/7OWFlB9evru46SpGWhe4lhv5 +DSgE2RdCKvDytzxRDvP49L8V0TnFjAVeC1C1Pj0/KQsoL/AP4APplROiD4QaUhshQl28pXxJtfbl +AgMBAAGjVzBVMEUGA1UdEQQ+MDyBD3ZpdmVrQGtoZXJhLm9yZ4ERa2hlcmFAa2NpbGluay5jb22B +FnZpdmVrQG1haWxlcm1haWxlci5jb20wDAYDVR0TAQH/BAIwADANBgkqhkiG9w0BAQQFAAOBgQAr +CWop3h28qPwofzLrkoT410J4d7Bqk6FLeVlKZfg/wXlS1MTqYMNcCm4x+JsJbjwsO0fb2elFIuGq +1razoSzPpgi89itydvUT0U0U/u+AkZA5rW4AptTpMZ70YW5u9wzkcvmifqZmcfbaaeGdZfruzUXZ +6qvdXDpNb3ZHeQw6PjGCAucwggLjAgEBMGkwYjELMAkGA1UEBhMCWkExJTAjBgNVBAoTHFRoYXd0 +ZSBDb25zdWx0aW5nIChQdHkpIEx0ZC4xLDAqBgNVBAMTI1RoYXd0ZSBQZXJzb25hbCBGcmVlbWFp +bCBJc3N1aW5nIENBAgMOah8wCQYFKw4DAhoFAKCCAVMwGAYJKoZIhvcNAQkDMQsGCSqGSIb3DQEH +ATAcBgkqhkiG9w0BCQUxDxcNMDYwMjI0MTYyNzM4WjAjBgkqhkiG9w0BCQQxFgQU595hQU7VoQz0 +PElDyEdBnFvflqEweAYJKwYBBAGCNxAEMWswaTBiMQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhh +d3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNvbmFsIEZyZWVt +YWlsIElzc3VpbmcgQ0ECAw5qHzB6BgsqhkiG9w0BCRACCzFroGkwYjELMAkGA1UEBhMCWkExJTAj +BgNVBAoTHFRoYXd0ZSBDb25zdWx0aW5nIChQdHkpIEx0ZC4xLDAqBgNVBAMTI1RoYXd0ZSBQZXJz +b25hbCBGcmVlbWFpbCBJc3N1aW5nIENBAgMOah8wDQYJKoZIhvcNAQEBBQAEggEAeXoEB5xVVsIO +hftaNmqIsvXJADkk3PDqb7Nua09tIhgs88RxYfNcVtEZxYHp78E33GcoNrruus5w7ehxkKoTw19Q +mPhYWj9KSsjQezH23V/4tpNwfOkmbjNyXSXqeBbmYr9x8DY3rM//e74/HmrJfoF7xaVb1JyLp6Uo +hdtGoO61LFGlN9S60Wa1OyRdjLP5QckVwv538n3qgz4hFGvrPFT5s3zrY04w9Aing+8PlYJyvSBT +rDXPkFpyPwyVxhzM55iS1oYBl470FfPXQSqkP5PRTZ1KIX0k7SZbYey9x3lNRLuDOhhchS+SO0rT +jMUlhN1Up46rIpMNErKq51FBsAAAAAAAAA== + +--Apple-Mail-6--717499401-- + +From pgsql-performance-owner@postgresql.org Fri Feb 24 12:32:26 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 0AF719DC816 + for ; + Fri, 24 Feb 2006 12:32:26 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 47763-04 + for ; + Fri, 24 Feb 2006 12:32:24 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id D86BD9DC801 + for ; + Fri, 24 Feb 2006 12:32:23 -0400 (AST) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Fri, 24 Feb 2006 16:32:22 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 24 Feb 2006 10:32:22 -0600 +Subject: Re: Reliability recommendations +From: Scott Marlowe +To: Vivek Khera +Cc: Postgresql Performance +In-Reply-To: <30917816-5D5E-4161-A21A-64DF2990777F@khera.org> +References: <200602241429.k1OETwD07991@candle.pha.pa.us> + <30917816-5D5E-4161-A21A-64DF2990777F@khera.org> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1140798742.18756.13.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Fri, 24 Feb 2006 10:32:22 -0600 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.155 required=5 tests=[AWL=0.154, + UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 0.155 +X-Spam-Level: +X-Archive-Number: 200602/387 +X-Sequence-Number: 17373 + +On Fri, 2006-02-24 at 10:27, Vivek Khera wrote: +> On Feb 24, 2006, at 9:29 AM, Bruce Momjian wrote: +> +> > Dell often says part X is included, but part X is not the exact +> > same as +> > part X sold by the original manufacturer. To hit a specific price +> > point, Dell is willing to strip thing out of commodity hardware, and +> > often does so even when performance suffers. For many people, this is +> > unacceptable. +> +> The last dell box I bought, a PE1850, came with a PERC 4e/Si card, +> which I believe is the same as the card the OP was looking at. It is +> very fast in RAID1 with two U320 disks. + +My bad experiences were with the 2600 series machines. We now have some +2800 and they're much better than the 2600/2650s I've used in the past. + +That said, I've not tried to do anything too high end with them, like +RAID 1+0 or anything. + +My past experience has been that Intel and SuperMicro make much better +"white boxes" you can get from almost any halfway decent local +supplier. They're faster, more reliable, and the parts are easy to get. + +From pgsql-performance-owner@postgresql.org Fri Feb 24 12:40:29 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id EC0029DC87B + for ; + Fri, 24 Feb 2006 12:40:28 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 47763-09 + for ; + Fri, 24 Feb 2006 12:40:27 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from yertle.kcilink.com (yertle.kcilink.com [65.205.34.180]) + by postgresql.org (Postfix) with ESMTP id 90DE39DC80C + for ; + Fri, 24 Feb 2006 12:40:26 -0400 (AST) +Received: from [192.168.7.103] (host-103.int.kcilink.com [192.168.7.103]) + by yertle.kcilink.com (Postfix) with ESMTP id 43B8DB80D + for ; + Fri, 24 Feb 2006 11:40:26 -0500 (EST) +Mime-Version: 1.0 (Apple Message framework v746.2) +In-Reply-To: <1140798742.18756.13.camel@state.g2switchworks.com> +References: <200602241429.k1OETwD07991@candle.pha.pa.us> + <30917816-5D5E-4161-A21A-64DF2990777F@khera.org> + <1140798742.18756.13.camel@state.g2switchworks.com> +Content-Type: multipart/signed; micalg=sha1; boundary=Apple-Mail-7--716731798; + protocol="application/pkcs7-signature" +Message-Id: +From: Vivek Khera +Subject: Re: Reliability recommendations +Date: Fri, 24 Feb 2006 11:40:25 -0500 +To: Postgresql Performance +X-Mailer: Apple Mail (2.746.2) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.068 required=5 tests=[AWL=0.068] +X-Spam-Score: 0.068 +X-Spam-Level: +X-Archive-Number: 200602/388 +X-Sequence-Number: 17374 + + +--Apple-Mail-7--716731798 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset=US-ASCII; + delsp=yes; + format=flowed + + +On Feb 24, 2006, at 11:32 AM, Scott Marlowe wrote: + +> My bad experiences were with the 2600 series machines. We now have +> some +> 2800 and they're much better than the 2600/2650s I've used in the +> past. + +Yes, the 2450 and 2650 were CRAP disk performers. I haven't any 2850 +to compare, just an 1850. + + +--Apple-Mail-7--716731798 +Content-Transfer-Encoding: base64 +Content-Type: application/pkcs7-signature; + name=smime.p7s +Content-Disposition: attachment; + filename=smime.p7s + +MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIGhzCCAz8w +ggKooAMCAQICAQ0wDQYJKoZIhvcNAQEFBQAwgdExCzAJBgNVBAYTAlpBMRUwEwYDVQQIEwxXZXN0 +ZXJuIENhcGUxEjAQBgNVBAcTCUNhcGUgVG93bjEaMBgGA1UEChMRVGhhd3RlIENvbnN1bHRpbmcx +KDAmBgNVBAsTH0NlcnRpZmljYXRpb24gU2VydmljZXMgRGl2aXNpb24xJDAiBgNVBAMTG1RoYXd0 +ZSBQZXJzb25hbCBGcmVlbWFpbCBDQTErMCkGCSqGSIb3DQEJARYccGVyc29uYWwtZnJlZW1haWxA +dGhhd3RlLmNvbTAeFw0wMzA3MTcwMDAwMDBaFw0xMzA3MTYyMzU5NTlaMGIxCzAJBgNVBAYTAlpB +MSUwIwYDVQQKExxUaGF3dGUgQ29uc3VsdGluZyAoUHR5KSBMdGQuMSwwKgYDVQQDEyNUaGF3dGUg +UGVyc29uYWwgRnJlZW1haWwgSXNzdWluZyBDQTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA +xKY8VXNV+065yplaHmjAdQRwnd/p/6Me7L3N9VvyGna9fww6YfK/Uc4B1OVQCjDXAmNaLIkVcI7d +yfArhVqqP3FWy688Cwfn8R+RNiQqE88r1fOCdz0Dviv+uxg+B79AgAJk16emu59l0cUqVIUPSAR/ +p7bRPGEEQB5kGXJgt/sCAwEAAaOBlDCBkTASBgNVHRMBAf8ECDAGAQH/AgEAMEMGA1UdHwQ8MDow +OKA2oDSGMmh0dHA6Ly9jcmwudGhhd3RlLmNvbS9UaGF3dGVQZXJzb25hbEZyZWVtYWlsQ0EuY3Js +MAsGA1UdDwQEAwIBBjApBgNVHREEIjAgpB4wHDEaMBgGA1UEAxMRUHJpdmF0ZUxhYmVsMi0xMzgw +DQYJKoZIhvcNAQEFBQADgYEASIzRUIPqCy7MDaNmrGcPf6+svsIXoUOWlJ1/TCG4+DYfqi2fNi/A +9BxQIJNwPP2t4WFiw9k6GX6EsZkbAMUaC4J0niVQlGLH2ydxVyWN3amcOY6MIE9lX5Xa9/eH1sYI +Tq726jTlEBpbNU1341YheILcIRk13iSx0x1G/11fZU8wggNAMIICqaADAgECAgMOah8wDQYJKoZI +hvcNAQEEBQAwYjELMAkGA1UEBhMCWkExJTAjBgNVBAoTHFRoYXd0ZSBDb25zdWx0aW5nIChQdHkp +IEx0ZC4xLDAqBgNVBAMTI1RoYXd0ZSBQZXJzb25hbCBGcmVlbWFpbCBJc3N1aW5nIENBMB4XDTA1 +MDQwNTIwMzEzMloXDTA2MDQwNTIwMzEzMlowgYoxHzAdBgNVBAMTFlRoYXd0ZSBGcmVlbWFpbCBN +ZW1iZXIxHjAcBgkqhkiG9w0BCQEWD3ZpdmVrQGtoZXJhLm9yZzEgMB4GCSqGSIb3DQEJARYRa2hl +cmFAa2NpbGluay5jb20xJTAjBgkqhkiG9w0BCQEWFnZpdmVrQG1haWxlcm1haWxlci5jb20wggEi +MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDdo7hywGcY0VvK6WqqXXV77MS/t/4X3WkCaCXo +RSl2W58GP4P21hodPn7hlIxUoDOW7x9O+FbqTgE2Ejqr6yA00Mm90tGPFgjFjqPGAqg7xk6IDcv9 +uTyMia/FKEHSIynM6zqokXY8JklvdbJOiByE/8VeyEXOANWiflo8o4+GHnhMKpA9982YTXUqeKU6 +mMQVaLCBRjTDc7j2XkMC/UNcp2HMyDQdTqYVnhLxbvbLX8CNDBY/7OWFlB9evru46SpGWhe4lhv5 +DSgE2RdCKvDytzxRDvP49L8V0TnFjAVeC1C1Pj0/KQsoL/AP4APplROiD4QaUhshQl28pXxJtfbl +AgMBAAGjVzBVMEUGA1UdEQQ+MDyBD3ZpdmVrQGtoZXJhLm9yZ4ERa2hlcmFAa2NpbGluay5jb22B +FnZpdmVrQG1haWxlcm1haWxlci5jb20wDAYDVR0TAQH/BAIwADANBgkqhkiG9w0BAQQFAAOBgQAr +CWop3h28qPwofzLrkoT410J4d7Bqk6FLeVlKZfg/wXlS1MTqYMNcCm4x+JsJbjwsO0fb2elFIuGq +1razoSzPpgi89itydvUT0U0U/u+AkZA5rW4AptTpMZ70YW5u9wzkcvmifqZmcfbaaeGdZfruzUXZ +6qvdXDpNb3ZHeQw6PjGCAucwggLjAgEBMGkwYjELMAkGA1UEBhMCWkExJTAjBgNVBAoTHFRoYXd0 +ZSBDb25zdWx0aW5nIChQdHkpIEx0ZC4xLDAqBgNVBAMTI1RoYXd0ZSBQZXJzb25hbCBGcmVlbWFp +bCBJc3N1aW5nIENBAgMOah8wCQYFKw4DAhoFAKCCAVMwGAYJKoZIhvcNAQkDMQsGCSqGSIb3DQEH +ATAcBgkqhkiG9w0BCQUxDxcNMDYwMjI0MTY0MDI1WjAjBgkqhkiG9w0BCQQxFgQU0H7eIN5wS0Pf +vpIQcEHmYr7dKQUweAYJKwYBBAGCNxAEMWswaTBiMQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhh +d3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNvbmFsIEZyZWVt +YWlsIElzc3VpbmcgQ0ECAw5qHzB6BgsqhkiG9w0BCRACCzFroGkwYjELMAkGA1UEBhMCWkExJTAj +BgNVBAoTHFRoYXd0ZSBDb25zdWx0aW5nIChQdHkpIEx0ZC4xLDAqBgNVBAMTI1RoYXd0ZSBQZXJz +b25hbCBGcmVlbWFpbCBJc3N1aW5nIENBAgMOah8wDQYJKoZIhvcNAQEBBQAEggEAdfLhH6QtCCfA +HOI5owt4teAEq4zqWg4ZN951/pfX/82HW4NVVrpuHHcAu+Yklgp28yqGQGN4kkGqIOBr5RQJFrL5 +Kru9ZVnyEcVBoCRGkT4WBpSF9cprtlYrldOhHWq/MVfi7qp0mER+I35SjlACqVgbSRwJB5w4CkAo +PprBB+7QkOmtvbdE2nCqyId9iPhN9APGaWMKEMAX9Q6frsmBjojxn7w4+NUexrZFHbM4bbxUZ6cx +SwRGDnGjTxcKNzJbApGwcOvkdiwqx3FqAQnViLEpt4u7yYiSfz1e3j8Y5aj/Ql4G8vLFpX+4XYN8 +GHdeboiSYa7QTg2MqYyqn9w/pwAAAAAAAA== + +--Apple-Mail-7--716731798-- + +From pgsql-performance-owner@postgresql.org Fri Feb 24 12:51:31 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 18A3B9DC816 + for ; + Fri, 24 Feb 2006 12:51:31 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 49870-10 + for ; + Fri, 24 Feb 2006 12:51:29 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id CCFFF9DC870 + for ; + Fri, 24 Feb 2006 12:51:28 -0400 (AST) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Fri, 24 Feb 2006 16:51:28 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 24 Feb 2006 10:51:28 -0600 +Subject: Re: Reliability recommendations +From: Scott Marlowe +To: Vivek Khera +Cc: Postgresql Performance +In-Reply-To: +References: <200602241429.k1OETwD07991@candle.pha.pa.us> + <30917816-5D5E-4161-A21A-64DF2990777F@khera.org> + <1140798742.18756.13.camel@state.g2switchworks.com> + +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1140799888.18756.16.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Fri, 24 Feb 2006 10:51:28 -0600 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.155 required=5 tests=[AWL=0.154, + UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 0.155 +X-Spam-Level: +X-Archive-Number: 200602/389 +X-Sequence-Number: 17375 + +On Fri, 2006-02-24 at 10:40, Vivek Khera wrote: +> On Feb 24, 2006, at 11:32 AM, Scott Marlowe wrote: +> +> > My bad experiences were with the 2600 series machines. We now have +> > some +> > 2800 and they're much better than the 2600/2650s I've used in the +> > past. +> +> Yes, the 2450 and 2650 were CRAP disk performers. I haven't any 2850 +> to compare, just an 1850. +> +And the real problem with the 2650s we have now is that under very heavy +load, they just lock up. all of them, latest BIOS updates, etc... +nothing makes them stable. Some things make them a little less dodgy, +but they are never truly reliable. Something the Intel and Supermicro +white boxes have always been for me. + +I don't want support from a company like Dell, I want a reliable +machine. + +From pgsql-performance-owner@postgresql.org Fri Feb 24 16:06:32 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 6213F9DC823 + for ; + Fri, 24 Feb 2006 16:06:31 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 93459-01 + for ; + Fri, 24 Feb 2006 16:06:31 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from mail.gmx.net (mail.gmx.de [213.165.64.20]) + by postgresql.org (Postfix) with SMTP id 6B93E9DC814 + for ; + Fri, 24 Feb 2006 16:06:28 -0400 (AST) +Received: (qmail invoked by alias); 24 Feb 2006 20:06:27 -0000 +Received: from 201-24-233-176.ctame704.dsl.brasiltelecom.net.br (EHLO + servidor) [201.24.233.176] + by mail.gmx.net (mp032) with SMTP; 24 Feb 2006 21:06:27 +0100 +X-Authenticated: #15924888 +Subject: Re: Creating a correct and real benchmark +From: Marcos +To: Chris +Cc: pgsql-performance@postgresql.org +In-Reply-To: <43FA5D20.2080805@gmail.com> +References: <1140432636.1170.6.camel@servidor> + <43FA5D20.2080805@gmail.com> +Content-Type: text/plain +Date: Fri, 24 Feb 2006 17:06:20 +0000 +Message-Id: <1140800780.3309.4.camel@servidor> +Mime-Version: 1.0 +X-Mailer: Evolution 2.4.1 FreeBSD GNOME Team Port +Content-Transfer-Encoding: 7bit +X-Y-GMX-Trusted: 0 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.135 required=5 tests=[AWL=0.135] +X-Spam-Score: 0.135 +X-Spam-Level: +X-Archive-Number: 200602/392 +X-Sequence-Number: 17378 + +Thanks for advises :-D. + +Marcos + + +From pgsql-performance-owner@postgresql.org Fri Feb 24 13:14:20 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 660529DC816 + for ; + Fri, 24 Feb 2006 13:14:19 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 52586-09 + for ; + Fri, 24 Feb 2006 13:14:18 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from hosting.commandprompt.com (128.commandprompt.com + [207.173.200.128]) + by postgresql.org (Postfix) with ESMTP id 836589DC801 + for ; + Fri, 24 Feb 2006 13:14:15 -0400 (AST) +Received: from [192.168.1.100] (or-67-76-146-141.sta.sprint-hsd.net + [67.76.146.141]) (authenticated bits=0) + by hosting.commandprompt.com (8.13.4/8.13.4) with ESMTP id + k1OH2K20031255; Fri, 24 Feb 2006 09:02:21 -0800 +Message-ID: <43FF403D.8090305@commandprompt.com> +Date: Fri, 24 Feb 2006 09:19:57 -0800 +From: "Joshua D. Drake" +User-Agent: Thunderbird 1.5 (X11/20051201) +MIME-Version: 1.0 +To: "Craig A. James" +CC: pgsql-performance@postgresql.org +Subject: Re: Reliability recommendations +References: <200602241429.k1OETwD07991@candle.pha.pa.us> + <43FF2095.6050505@modgraph-usa.com> +In-Reply-To: <43FF2095.6050505@modgraph-usa.com> +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]); + Fri, 24 Feb 2006 09:02:22 -0800 (PST) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.089 required=5 tests=[AWL=0.089] +X-Spam-Score: 0.089 +X-Spam-Level: +X-Archive-Number: 200602/390 +X-Sequence-Number: 17376 + + +> I find this strains credibility, that this major manufacturer of PC's +> would do something deceptive that hurts performance, when it would be +> easily detected and widely reported. Can anyone cite a specific +> instances where this has happened? Such as, "I bought Dell model XYZ, +> which was advertised to have these parts and these specs, but in fact +> had these other parts and here are the actual specs." +I can :) + +Feb 20 07:33:52 master kernel: [4294682.803000] Vendor: MegaRAID +Model: LD 0 RAID1 51G Rev: 196T +Feb 20 07:33:52 master kernel: [4294682.803000] Type: +Direct-Access ANSI SCSI revision: 02 +Feb 20 07:33:52 master kernel: [4294682.818000] tg3.c:v3.31 (June 8, 2005) +Feb 20 07:33:52 master kernel: [4294682.818000] ACPI: PCI Interrupt +0000:0a:01.0[A] -> GSI 17 (level, low) -> IRQ 17 +Feb 20 07:33:52 master kernel: [4294683.510000] eth0: Tigon3 +[partno(BCM95700A6) rev 7104 PHY(5411)] (PCI:66MHz:64-bit) +10/100/1000BaseT Ethernet 00:0f:1f:6e:01:f +Feb 20 07:33:52 master kernel: [4294683.510000] eth0: RXcsums[1] +LinkChgREG[1] MIirq[1] ASF[0] Split[0] WireSpeed[0] TSOcap[0] +Feb 20 07:33:52 master kernel: [4294683.510000] eth0: dma_rwctrl[76ff000f] +Feb 20 07:33:52 master kernel: [4294683.510000] ACPI: PCI Interrupt +0000:0a:02.0[A] -> GSI 18 (level, low) -> IRQ 18 +Feb 20 07:33:52 master kernel: [4294684.203000] eth1: Tigon3 +[partno(BCM95700A6) rev 7104 PHY(5411)] (PCI:66MHz:64-bit) +10/100/1000BaseT Ethernet 00:0f:1f:6e:01:f +Feb 20 07:33:52 master kernel: [4294684.203000] eth1: RXcsums[1] +LinkChgREG[1] MIirq[1] ASF[0] Split[0] WireSpeed[0] TSOcap[0] +Feb 20 07:33:52 master kernel: [4294684.203000] eth1: dma_rwctrl[76ff000f] +Feb 20 07:33:52 master kernel: [4294686.228000] SCSI device sda: +106168320 512-byte hdwr sectors (54358 MB) +Feb 20 07:33:52 master kernel: [4294686.228000] SCSI device sda: +106168320 512-byte hdwr sectors (54358 MB) +Feb 20 07:33:52 master kernel: [4294686.228000] +/dev/scsi/host0/bus2/target0/lun0: p1 p2 < p5 > p3 +Feb 20 07:33:52 master kernel: [4294686.243000] Attached scsi disk sda +at scsi0, channel 2, id 0, lun 0 +Feb 20 07:33:52 master kernel: [4294686.578000] ACPI: CPU0 (power +states: C1[C1]) +Feb 20 07:33:52 master kernel: [4294686.655000] Attempting manual resume +Feb 20 07:33:52 master kernel: [4294686.659000] swsusp: Suspend +partition has wrong signature? +Feb 20 07:33:52 master kernel: [4294686.671000] kjournald starting. +Commit interval 5 seconds +Feb 20 07:33:52 master kernel: [4294686.671000] EXT3-fs: mounted +filesystem with ordered data mode. +Feb 20 07:33:52 master kernel: [4294687.327000] md: md driver 0.90.1 +MAX_MD_DEVS=256, MD_SB_DISKS=27 +Feb 20 07:33:52 master kernel: [4294688.633000] Adding 3903784k swap on +/dev/sda5. Priority:-1 extents:1 +Feb 20 07:33:52 master kernel: [4294688.705000] EXT3 FS on sda3, +internal journal +Feb 20 07:33:52 master kernel: [4294692.533000] lp: driver loaded but no +devices found +Feb 20 07:33:52 master kernel: [4294692.557000] mice: PS/2 mouse device +common for all mice +Feb 20 07:33:52 master kernel: [4294695.263000] device-mapper: +4.4.0-ioctl (2005-01-12) initialised: dm-devel@redhat.com +Feb 20 07:33:52 master kernel: [4294695.479000] kjournald starting. +Commit interval 5 seconds +Feb 20 07:33:52 master kernel: [4294695.479000] EXT3 FS on sda1, +internal journal +Feb 20 07:33:52 master kernel: [4294695.479000] EXT3-fs: mounted +filesystem with ordered data mode. +Feb 20 07:33:52 master kernel: [4294695.805000] Linux agpgart interface +v0.101 (c) Dave Jones +Feb 20 07:33:52 master kernel: [4294696.071000] piix4_smbus +0000:00:0f.0: Found 0000:00:0f.0 device +Feb 20 07:33:52 master kernel: [4294696.584000] pci_hotplug: PCI Hot +Plug PCI Core version: 0.5 + + +processor : 0 +vendor_id : GenuineIntel +cpu family : 15 +model : 2 +model name : Intel(R) Xeon(TM) MP CPU 2.20GHz +stepping : 6 +cpu MHz : 2194.056 +cache size : 512 KB +fdiv_bug : no +hlt_bug : no +f00f_bug : no +coma_bug : no +fpu : yes +fpu_exception : yes +cpuid level : 2 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge +mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe cid xtpr +bogomips : 4325.37 + + + +This machine... if you run it in raid 5 will only get 7-9 megabytes a +second READ! performance. That is with 6 SCSI drives. +If you run it in RAID 10 you get a more reasonable 50-55 megabytes per +second. + +I don't have it sitting in front of me or I would give you an exact +model number. + +This machine also uses the serverworks chipset which is known to be a +catastrophe. + +Joshua D. Drake + + + + +> +> Dell seems to take quite a beating in this forum, and I don't recall +> seeing any other manufacturer blasted this way. Is it that they are +> deceptive, or simply that their "servers" are designed to be office +> servers, not database servers? +> +> There's nothing wrong with Dell designing their servers for a +> different market than ours; they need to go for the profits, and that +> may not include us. But it's not fair for us to claim Dell is being +> deceptive unless we have concrete evidence. +> +> Craig +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 3: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faq + + +-- +The PostgreSQL Company - Command Prompt, Inc. 1.503.667.4564 +PostgreSQL Replication, Consulting, Custom Development, 24x7 support +Managed Services, Shared and Dedicated Hosting +Co-Authors: PLphp, PLperl - http://www.commandprompt.com/ + + +From pgsql-performance-owner@postgresql.org Fri Feb 24 16:03:47 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 03E019DC809 + for ; + Fri, 24 Feb 2006 16:03:47 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 92311-06 + for ; + Fri, 24 Feb 2006 16:03:47 -0400 (AST) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 425019DCAC2 + for ; + Fri, 24 Feb 2006 16:03:44 -0400 (AST) +Received: from asmail001.abovesecurity.com (asmail001.abovesecurity.com + [206.162.148.235]) + by svr4.postgresql.org (Postfix) with ESMTP id 928A35AF091 + for ; + Fri, 24 Feb 2006 20:03:43 +0000 (GMT) +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.181 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: quoted-printable +Subject: Schema vs Independant Databases, ACLS,Overhead,pg_hba.conf +Date: Fri, 24 Feb 2006 15:03:36 -0500 +Message-ID: +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Importance: normal +Thread-Topic: Schema vs Independant Databases, ACLS,Overhead,pg_hba.conf +Thread-Index: AcY5fWU3JxFyHTk2SueBB9/l4c3o1Q== +From: "Eric Lauzon" +To: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200602/391 +X-Sequence-Number: 17377 + +Hello all, + +I have this small set of questions that i have been looking to ask and +here it comes. + +Lets imagin we have a setup where we have multiple databases instances +on one server, +and we are starting to use more and more cross databases queries [query +unions] using dblink [multiple context but=20 +using the same templated database schema]. Most of the operations +performed on those instance +do not need to be done in the same context , but as requirement comes +for more and more inter context +data analysis we are starting to see some issue with the current +databases layout. + +Thats where we asked our self what we could do. Without mutch changes it +wouldn't be so hard to merge +lets say 4 context into one [4 database using the same template into 1] +, and we are sure that those cross databases +query would get major speed improvement. + +But now we have some issues arround having 1 database context for whats +is actualy contained in 4 separated ones. + +Having one context implies either 1 database with 4 SCHEMA OR 1 database +with 1 schema [still trying to see where we want to go] + +The first issue we have is with pg_hba Acls where you can't define +specific ACLS for SCHEMA , where +if we want to have a first line of defense against data segregation we +must + 1.Create "ala context" users for schema and per schema defined +acls ...[hard to manage and a bit out of Security Logic] + or + 2.Just create as many user as needed and implement underlying +acls ..[also hard to manage and out of Security Logic] + +Now that the issue is that we can't implement a per connection user/ACL +pair , would it be a good idea to implement +Schema ACLS and mabey pg_hba.conf Schema acls=20 + + +I mean=20 +NOW: +local database user auth-method [auth-option] +=09 +Could be : +local database/or database.schema user auth-method [auth-option] + ^^^ + database could be considered as database.public + +Now if we would have that kind of acces Control to postresql i would +like to know what is the=20 +benefices of using multiple schema in a single database in term of +Postgresql Backend management=20 +[file on disk,Index Management,Maintenance Management],beside the +possibilites to do quick and=20 +efficient cross databases querys,=20 +[Note those cross databases queries are not done by a users that need +per Schema/Databases=20 +ACLS but by a "superior user" so we do not need to consider that for +this issue] + +Is it really more efficient of having 4 schema in one databaes , 1 +database with one schema or having 4 databases? +I think i can have some of those answers i think but i want behind the +scene point of view on those. + +Thanks you all in advance, have a nice week-end + +-elz + +AVERTISSEMENT CONCERNANT LA CONFIDENTIALITE=20 + +Le present message est a l'usage exclusif du ou des destinataires = +mentionnes ci-dessus. Son contenu est confidentiel et peut etre = +assujetti au secret professionnel. Si vous avez recu le present message = +par erreur, veuillez nous en aviser immediatement et le detruire en vous = +abstenant d'en faire une copie, d'en divulguer le contenu ou d'y donner = +suite. + +CONFIDENTIALITY NOTICE + +This communication is intended for the exclusive use of the addressee = +identified above. Its content is confidential and may contain privileged = +information. If you have received this communication by error, please = +notify the sender and delete the message without copying or disclosing = +it. + +From pgsql-performance-owner@postgresql.org Fri Feb 24 19:18:10 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 179269DCA94 + for ; + Fri, 24 Feb 2006 19:18:09 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18388-03 + for ; + Fri, 24 Feb 2006 19:18:11 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from moonunit2.moonview.localnet (wsip-68-15-5-150.sd.sd.cox.net + [68.15.5.150]) by postgresql.org (Postfix) with ESMTP id DFE479DCA20 + for ; + Fri, 24 Feb 2006 19:18:06 -0400 (AST) +Received: from [192.168.0.3] (moonunit3.moonview.localnet [192.168.0.3]) + by moonunit2.moonview.localnet (8.13.1/8.13.1) with ESMTP id + k1ONJ6ec027351; Fri, 24 Feb 2006 15:19:06 -0800 +Message-ID: <43FF92EB.7060704@modgraph-usa.com> +Date: Fri, 24 Feb 2006 15:12:43 -0800 +From: "Craig A. James" +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "Joshua D. Drake" +CC: pgsql-performance@postgresql.org +Subject: Re: Reliability recommendations +References: <200602241429.k1OETwD07991@candle.pha.pa.us> + <43FF2095.6050505@modgraph-usa.com> + <43FF403D.8090305@commandprompt.com> +In-Reply-To: <43FF403D.8090305@commandprompt.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, score=0.101 required=5 tests=[AWL=0.101] +X-Spam-Score: 0.101 +X-Spam-Level: +X-Archive-Number: 200602/393 +X-Sequence-Number: 17379 + +Joshua D. Drake wrote: +>> I find this strains credibility, that this major manufacturer of PC's +>> would do something deceptive that hurts performance, when it would be +>> easily detected and widely reported. Can anyone cite a specific +>> instances where this has happened? Such as, "I bought Dell model XYZ, +>> which was advertised to have these parts and these specs, but in fact +>> had these other parts and here are the actual specs." +> +> I can :) +> +> Feb 20 07:33:52 master kernel: [4294682.803000] Vendor: MegaRAID +> Model: LD 0 RAID1 51G Rev: 196T +> --- snip --- +> This machine... if you run it in raid 5 will only get 7-9 megabytes a +> second READ! performance. That is with 6 SCSI drives. +> If you run it in RAID 10 you get a more reasonable 50-55 megabytes per +> second. + +But you don't say how this machine was advertised. Are there components in that list that were not as advertised? Was the machine advertised as capable of RAID 5? Were performance figures published for RAID 5? + +If Dell advertised that the machine could do what you asked, then you're right -- they screwed you. But if it was designed for and advertised to a different market, then I've made my point: People are blaming Dell for something that's not their fault. + +Craig + +From pgsql-performance-owner@postgresql.org Fri Feb 24 19:59:14 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 217C39DCBD4 + for ; + Fri, 24 Feb 2006 19:59:14 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 22213-05 + for ; + Fri, 24 Feb 2006 19:59:16 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id EDA1C9DCB6F + for ; + Fri, 24 Feb 2006 19:59:11 -0400 (AST) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Fri, 24 Feb 2006 23:59:14 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 24 Feb 2006 17:59:14 -0600 +Subject: Re: Reliability recommendations +From: Scott Marlowe +To: "Craig A. James" +Cc: "Joshua D. Drake" , pgsql-performance@postgresql.org +In-Reply-To: <43FF92EB.7060704@modgraph-usa.com> +References: <200602241429.k1OETwD07991@candle.pha.pa.us> + <43FF2095.6050505@modgraph-usa.com> + <43FF403D.8090305@commandprompt.com> + <43FF92EB.7060704@modgraph-usa.com> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1140825554.18756.26.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Fri, 24 Feb 2006 17:59:14 -0600 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.152 required=5 tests=[AWL=0.151, + UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 0.152 +X-Spam-Level: +X-Archive-Number: 200602/394 +X-Sequence-Number: 17380 + +On Fri, 2006-02-24 at 17:12, Craig A. James wrote: +> Joshua D. Drake wrote: +> >> I find this strains credibility, that this major manufacturer of PC's +> >> would do something deceptive that hurts performance, when it would be +> >> easily detected and widely reported. Can anyone cite a specific +> >> instances where this has happened? Such as, "I bought Dell model XYZ, +> >> which was advertised to have these parts and these specs, but in fact +> >> had these other parts and here are the actual specs." +> > +> > I can :) +> > +> > Feb 20 07:33:52 master kernel: [4294682.803000] Vendor: MegaRAID +> > Model: LD 0 RAID1 51G Rev: 196T +> > --- snip --- +> > This machine... if you run it in raid 5 will only get 7-9 megabytes a +> > second READ! performance. That is with 6 SCSI drives. +> > If you run it in RAID 10 you get a more reasonable 50-55 megabytes per +> > second. +> +> But you don't say how this machine was advertised. Are there components in that list that were not as advertised? Was the machine advertised as capable of RAID 5? Were performance figures published for RAID 5? +> +> If Dell advertised that the machine could do what you asked, then you're right -- they screwed you. But if it was designed for and advertised to a different market, then I've made my point: People are blaming Dell for something that's not their fault. + +IT was advertised as a rackmount server with dual processors and a RAID +controller with 6 drive bays. I would expect such a machine to perform +well in both RAID 5 and RAID 1+0 configurations. + +It certainly didn't do what we expected of a machine with the specs it +had. For the same price, form factor and basic setup, i.e. dual P-IV 2 +to 4 gig ram, 5 or 6 drive bays, I'd expect the same thing. They were +crap. Honestly. Did you see the post where I mentioned that under +heavy I/O load they lock up about once every month or so. They all do, +every one I've ever seen. Some take more time than others, but they all +eventually lock up while running. + +I was pretty much agnostic as to which servers we bought at my last job, +until someone started ordering from Dell and we got 2600 series +machines. No one should have to live with these things. + +From pgsql-performance-owner@postgresql.org Fri Feb 24 20:07:06 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 0B6659DCB0F + for ; + Fri, 24 Feb 2006 20:07:06 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25810-03 + for ; + Fri, 24 Feb 2006 20:07:08 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.mi8.com (d01gw02.mi8.com [63.240.6.46]) + by postgresql.org (Postfix) with ESMTP id 8B8A09DCABD + for ; + Fri, 24 Feb 2006 20:07:03 -0400 (AST) +Received: from 172.16.1.112 by mail.mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D2)); Fri, 24 Feb 2006 19:06:57 -0500 +X-Server-Uuid: 7829E76E-BB9E-4995-8473-3C0929DF7DD1 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.175]) by + D01SMTP02.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Fri, 24 Feb + 2006 19:06:57 -0500 +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.106]) with Microsoft Exchange Server HTTP-DAV ; Sat, 25 Feb + 2006 00:06:57 +0000 +User-Agent: Microsoft-Entourage/11.2.1.051004 +Date: Fri, 24 Feb 2006 16:06:57 -0800 +Subject: Re: Reliability recommendations +From: "Luke Lonergan" +To: "Joshua D. Drake" , + "Craig A. James" +cc: pgsql-performance@postgresql.org +Message-ID: +Thread-Topic: [PERFORM] Reliability recommendations +Thread-Index: AcY5Zdlzm6d/hZFPS4eebfXvfIH5OAAOYq4M +In-Reply-To: <43FF403D.8090305@commandprompt.com> +MIME-Version: 1.0 +X-OriginalArrivalTime: 25 Feb 2006 00:06:57.0653 (UTC) + FILETIME=[64924A50:01C6399F] +X-WSS-ID: 6FE1402B2XS17674002-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, score=1.326 required=5 tests=[AWL=0.073, + RCVD_NUMERIC_HELO=1.253] +X-Spam-Score: 1.326 +X-Spam-Level: * +X-Archive-Number: 200602/395 +X-Sequence-Number: 17381 + +Joshua, + +On 2/24/06 9:19 AM, "Joshua D. Drake" wrote: + +> This machine... if you run it in raid 5 will only get 7-9 megabytes a +> second READ! performance. That is with 6 SCSI drives. +> If you run it in RAID 10 you get a more reasonable 50-55 megabytes per +> second. +> +> I don't have it sitting in front of me or I would give you an exact +> model number. +> +> This machine also uses the serverworks chipset which is known to be a +> catastrophe. + +I'd be more shocked if this weren't also true of nearly all SCSI HW RAID +adapters of this era. If you had ordered an HP DL380 server you'd get about +the same performance. + +BTW - I don't think there's anything reasonable about 50-55 MB/s from 6 +disks, I'd put the minimum for this era machine at 5 x 30 = 150MB/s. + +- Luke + + + +From pgsql-performance-owner@postgresql.org Fri Feb 24 20:18:53 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 2189D9DC871 + for ; + Fri, 24 Feb 2006 20:18:53 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 23956-10 + for ; + Fri, 24 Feb 2006 20:18:55 -0400 (AST) +X-Greylist: whitelisted by SQLgrey- +Received: from smtp2-g19.free.fr (smtp2-g19.free.fr [212.27.42.28]) + by postgresql.org (Postfix) with ESMTP id A7DCB9DC848 + for ; + Fri, 24 Feb 2006 20:18:50 -0400 (AST) +Received: from [127.0.0.1] (rue92-4-82-236-4-82.fbx.proxad.net [82.236.4.82]) + by smtp2-g19.free.fr (Postfix) with ESMTP id C28526CFA6 + for ; + Sat, 25 Feb 2006 01:18:53 +0100 (CET) +Message-ID: <43FFA26C.5020802@free.fr> +Date: Sat, 25 Feb 2006 01:18:52 +0100 +From: Philippe Marzin +User-Agent: Thunderbird 1.5 (Windows/20051201) +MIME-Version: 1.0 +CC: pgsql-performance@postgresql.org +Subject: Re: Reliability recommendations +References: +In-Reply-To: +Content-Type: multipart/alternative; + boundary="------------060601010405050704090007" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.19 required=5 tests=[HTML_MESSAGE=0.001, + MISSING_HEADERS=0.189] +X-Spam-Score: 0.19 +X-Spam-Level: +X-Archive-Number: 200602/396 +X-Sequence-Number: 17382 + +This is a multi-part message in MIME format. +--------------060601010405050704090007 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: quoted-printable + +Do you have a hw reference that runs that fast (5 x 30 =3D 150MB/s) ? + + +Luke Lonergan a =E9crit : +> Joshua, +> +> On 2/24/06 9:19 AM, "Joshua D. Drake" wrote: +> +> =20 +>> This machine... if you run it in raid 5 will only get 7-9 megabytes a +>> second READ! performance. That is with 6 SCSI drives. +>> If you run it in RAID 10 you get a more reasonable 50-55 megabytes per= + +>> second. +>> +>> I don't have it sitting in front of me or I would give you an exact +>> model number. +>> +>> This machine also uses the serverworks chipset which is known to be a +>> catastrophe. +>> =20 +> +> I'd be more shocked if this weren't also true of nearly all SCSI HW RAI= +D +> adapters of this era. If you had ordered an HP DL380 server you'd get = +about +> the same performance. +> +> BTW - I don't think there's anything reasonable about 50-55 MB/s from 6= + +> disks, I'd put the minimum for this era machine at 5 x 30 =3D 150MB/s. +> +> - Luke +> +> +> +> ---------------------------(end of broadcast)--------------------------= +- +> TIP 1: if posting/reading through Usenet, please send an appropriate +> subscribe-nomail command to majordomo@postgresql.org so that you= +r +> message can get through to the mailing list cleanly +> +> +> +> =20 + +--------------060601010405050704090007 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit + + + + + + + + +Do you have a hw reference that runs that fast (5 x 30 = 150MB/s) ?
+
+
+Luke Lonergan a écrit : +
+
Joshua,
+
+On 2/24/06 9:19 AM, "Joshua D. Drake" <jd@commandprompt.com> wrote:
+
+  
+
+
This machine... if you run it in raid 5 will only get 7-9 megabytes a
+second READ! performance. That is with 6 SCSI drives.
+If you run it in RAID 10 you get a more reasonable 50-55 megabytes per
+second.
+
+I don't have it sitting in front of me or I would give you an exact
+model number.
+
+This machine also uses the serverworks chipset which is known to be a
+catastrophe.
+    
+
+

+I'd be more shocked if this weren't also true of nearly all SCSI HW RAID
+adapters of this era.  If you had ordered an HP DL380 server you'd get about
+the same performance.
+
+BTW - I don't think there's anything reasonable about 50-55 MB/s from 6
+disks, I'd put the minimum for this era machine at 5 x 30 = 150MB/s.
+
+- 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
+
+
+
+  
+
+ + + +--------------060601010405050704090007-- + + +From pgsql-performance-owner@postgresql.org Fri Feb 24 20:33:54 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 0FEB09DC848 + for ; + Fri, 24 Feb 2006 20:33:54 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25452-09 + for ; + Fri, 24 Feb 2006 20:33:57 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from linda-3.paradise.net.nz (bm-3a.paradise.net.nz + [203.96.152.182]) + by postgresql.org (Postfix) with ESMTP id 071069DC814 + for ; + Fri, 24 Feb 2006 20:33:51 -0400 (AST) +Received: from smtp-1.paradise.net.nz + (tclsnelb1-src-1.paradise.net.nz [203.96.152.172]) by + linda-3.paradise.net.nz (Paradise.net.nz) with ESMTP id + <0IV7008GGW77AH@linda-3.paradise.net.nz> for + pgsql-performance@postgresql.org; Sat, 25 Feb 2006 13:33:27 +1300 (NZDT) +Received: from [192.168.1.11] + (218-101-28-207.dsl.clear.net.nz [218.101.28.207]) by + smtp-1.paradise.net.nz (Postfix) with ESMTP id 16F761424D09; + Sat, 25 Feb 2006 13:29:58 +1300 (NZDT) +Date: Sat, 25 Feb 2006 13:29:55 +1300 +From: Mark Kirkwood +Subject: Re: Reliability recommendations +In-reply-to: +To: Luke Lonergan +Cc: "Joshua D. Drake" , + "Craig A. James" , + pgsql-performance@postgresql.org +Message-id: <43FFA503.5070700@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/20051106) +References: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.195 required=5 tests=[AWL=0.195] +X-Spam-Score: 0.195 +X-Spam-Level: +X-Archive-Number: 200602/397 +X-Sequence-Number: 17383 + +Luke Lonergan wrote: + +> +> I'd be more shocked if this weren't also true of nearly all SCSI HW RAID +> adapters of this era. If you had ordered an HP DL380 server you'd get about +> the same performance. +> +> BTW - I don't think there's anything reasonable about 50-55 MB/s from 6 +> disks, I'd put the minimum for this era machine at 5 x 30 = 150MB/s. +> + +He was quoting for 6 disk RAID 10 - I'm thinking 3 x 30MB/s = 90MB/s is +probably more correct? Having aid that, your point is still completely +correct - the performance @55MB/s is poor (e.g. my *ata* system with 2 +disk RAID0 does reads @110MB/s). + +cheers + +Mark + +From pgsql-performance-owner@postgresql.org Fri Feb 24 20:49:52 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 560109DC814 + for ; + Fri, 24 Feb 2006 20:49:49 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 27630-08 + for ; + Fri, 24 Feb 2006 20:49:52 -0400 (AST) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 0F1A89DCABD + for ; + Fri, 24 Feb 2006 20:49:47 -0400 (AST) +Received: from host54a.simplicato.com (host54a.simplicato.com [207.99.47.54]) + by svr4.postgresql.org (Postfix) with ESMTP id 461D65AF09B + for ; + Sat, 25 Feb 2006 00:49:51 +0000 (GMT) +Received: from localhost (localhost.simplicato.com [127.0.0.1]) + by host54a.simplicato.com (Postfix) with ESMTP id 3B6AC6C07A5; + Fri, 24 Feb 2006 19:49:43 -0500 (EST) +Received: from host54a.simplicato.com ([127.0.0.1]) + by localhost (host54a.simplicato.com [127.0.0.1]) (amavisd-new, + port 10024) + with ESMTP id 68203-01; Fri, 24 Feb 2006 19:49:43 -0500 (EST) +Received: from [192.168.1.173] (66.237.43.131.ptr.us.xo.net [66.237.43.131]) + by host54a.simplicato.com (Postfix) with ESMTP id 6C95D6C066E; + Fri, 24 Feb 2006 19:49:42 -0500 (EST) +In-Reply-To: <43FFA503.5070700@paradise.net.nz> +References: + <43FFA503.5070700@paradise.net.nz> +Mime-Version: 1.0 (Apple Message framework v746.2) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <125CA0A8-6142-4DF5-822E-CF0B0C46B4C1@hi5.com> +Cc: Luke Lonergan , + "Joshua D. Drake" , + "Craig A. James" , + pgsql-performance@postgresql.org +Content-Transfer-Encoding: 7bit +From: Dan Gorman +Subject: Re: Reliability recommendations +Date: Fri, 24 Feb 2006 16:47:23 -0800 +To: Mark Kirkwood +X-Mailer: Apple Mail (2.746.2) +X-Virus-Scanned: by amavisd-new at simplicato.com +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.306 required=5 tests=[DNS_FROM_AHBL_RHSBL=0.306] +X-Spam-Score: 0.306 +X-Spam-Level: +X-Archive-Number: 200602/398 +X-Sequence-Number: 17384 + +All, + +Was that sequential reads? If so, yeah you'll get 110MB/s? How big +was the datafile size? 8MB? Yeah, you'll get 110MB/s. 2GB? No, they +can't sustain that. There are so many details missing from this test +that it's hard to have any context around it :) + +I was getting about 40-50MB/s on a PV with 14 disks on a RAID10 in +real world usage. (random IO and fully saturating a Dell 1850 with 4 +concurrent threads (to peg the cpu on selects) and raw data files) + +Best Regards, +Dan Gorman + +On Feb 24, 2006, at 4:29 PM, Mark Kirkwood wrote: + +> Luke Lonergan wrote: +> +>> I'd be more shocked if this weren't also true of nearly all SCSI +>> HW RAID +>> adapters of this era. If you had ordered an HP DL380 server you'd +>> get about +>> the same performance. +>> BTW - I don't think there's anything reasonable about 50-55 MB/s +>> from 6 +>> disks, I'd put the minimum for this era machine at 5 x 30 = 150MB/s. +> +> He was quoting for 6 disk RAID 10 - I'm thinking 3 x 30MB/s = 90MB/ +> s is probably more correct? Having aid that, your point is still +> completely correct - the performance @55MB/s is poor (e.g. my *ata* +> system with 2 disk RAID0 does reads @110MB/s). +> +> cheers +> +> Mark +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 4: Have you searched our list archives? +> +> http://archives.postgresql.org + + +From pgsql-performance-owner@postgresql.org Fri Feb 24 21:18:40 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 2F7C29DC848 + for ; + Fri, 24 Feb 2006 21:18:39 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 35471-02 + for ; + Fri, 24 Feb 2006 21:18:42 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from linda-4.paradise.net.nz (bm-4a.paradise.net.nz + [203.96.152.183]) + by postgresql.org (Postfix) with ESMTP id A06B69DC814 + for ; + Fri, 24 Feb 2006 21:18:32 -0400 (AST) +Received: from smtp-1.paradise.net.nz + (tclsnelb1-src-1.paradise.net.nz [203.96.152.172]) by + linda-4.paradise.net.nz (Paradise.net.nz) with ESMTP id + <0IV70079JYAZZI@linda-4.paradise.net.nz> for + pgsql-performance@postgresql.org; Sat, 25 Feb 2006 14:18:35 +1300 (NZDT) +Received: from [192.168.1.11] + (218-101-28-207.dsl.clear.net.nz [218.101.28.207]) by + smtp-1.paradise.net.nz (Postfix) with ESMTP id 8C496695F1; + Sat, 25 Feb 2006 14:18:34 +1300 (NZDT) +Date: Sat, 25 Feb 2006 14:18:31 +1300 +From: Mark Kirkwood +Subject: Re: Reliability recommendations +In-reply-to: <125CA0A8-6142-4DF5-822E-CF0B0C46B4C1@hi5.com> +To: Dan Gorman +Cc: Luke Lonergan , + "Joshua D. Drake" , + "Craig A. James" , + pgsql-performance@postgresql.org +Message-id: <43FFB067.2070406@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/20051106) +References: + <43FFA503.5070700@paradise.net.nz> + <125CA0A8-6142-4DF5-822E-CF0B0C46B4C1@hi5.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.194 required=5 tests=[AWL=0.194] +X-Spam-Score: 0.194 +X-Spam-Level: +X-Archive-Number: 200602/399 +X-Sequence-Number: 17385 + +Dan Gorman wrote: +> All, +> +> Was that sequential reads? If so, yeah you'll get 110MB/s? How big was +> the datafile size? 8MB? Yeah, you'll get 110MB/s. 2GB? No, they can't +> sustain that. There are so many details missing from this test that +> it's hard to have any context around it :) +> + +Actually they can. Datafile size was 8G, machine had 2G RAM (i.e. +datafile 4 times memory). The test was for a sequential read with 8K +blocks. I believe this is precisely the type of test that the previous +posters were referring to - while clearly, its not a real-world measure, +we are comparing like to like, and as such terrible results on such a +simple test are indicative of something 'not right'. + +regards + +Mark + +P.s. FWIW - I'm quoting a test from a few years ago - the (same) machine +now has 4 RAID0 ata disks and does 175MB/s on the same test.... + + + + +From pgsql-performance-owner@postgresql.org Fri Feb 24 23:42:36 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 057559DC8A2 + for ; + Fri, 24 Feb 2006 23:42:35 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 56356-02 + for ; + Fri, 24 Feb 2006 23:42:40 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from candle.pha.pa.us (candle.pha.pa.us [70.90.9.53]) + by postgresql.org (Postfix) with ESMTP id 53F169DCA35 + for ; + Fri, 24 Feb 2006 23:42:33 -0400 (AST) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id k1P3gdj15861; + Fri, 24 Feb 2006 22:42:39 -0500 (EST) +From: Bruce Momjian +Message-Id: <200602250342.k1P3gdj15861@candle.pha.pa.us> +Subject: Re: +In-Reply-To: <20060223202905.GQ86022@pervasive.com> +To: "Jim C. Nasby" +Date: Fri, 24 Feb 2006 22:42:39 -0500 (EST) +CC: Vivek Khera , + Postgresql Performance +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, score=0.387 required=5 tests=[AWL=-0.113, RAZOR2_CHECK=0.5] +X-Spam-Score: 0.387 +X-Spam-Level: +X-Archive-Number: 200602/400 +X-Sequence-Number: 17386 + + +See the FAQ. + +--------------------------------------------------------------------------- + +Jim C. Nasby wrote: +> On Thu, Feb 23, 2006 at 09:38:25AM -0500, Vivek Khera wrote: +> > +> > On Feb 22, 2006, at 10:44 PM, Chethana, Rao ((IE10)) wrote: +> > +> > >That is what I wanted to know, how do I tune it? +> > +> > If there were a simple formula for doing it, it would already have +> > been written up as a program that runs once you install postgres. +> > +> > You have to monitor your usage, use your understanding of your +> > application, and the Postgres manual to see what things to adjust. +> > It differs if you are CPU bound or I/O bound. +> > +> > And please keep this on list. +> +> FWIW, had you included a bit more of the original post others might have +> been able to provide advice... but now I have no idea what the original +> question was (of course a blank subject doesn't help either... no idea +> where that happened). +> +> -- +> Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +> Pervasive Software http://pervasive.com work: 512-231-6117 +> vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: Don't 'kill -9' the postmaster +> + +-- + Bruce Momjian http://candle.pha.pa.us + SRA OSS, Inc. http://www.sraoss.com + + + If your life is a hard drive, Christ can be your backup. + + +From pgsql-performance-owner@postgresql.org Sat Feb 25 00:42:05 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 3848D9DCBF3 + for ; + Sat, 25 Feb 2006 00:42:05 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 64718-04 + for ; + Sat, 25 Feb 2006 00:42:03 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.Mi8.com (d01gw01.mi8.com [63.240.6.47]) + by postgresql.org (Postfix) with ESMTP id 4049B9DCAE3 + for ; + Sat, 25 Feb 2006 00:42:01 -0400 (AST) +Received: from 172.16.1.112 by mail.Mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D1)); Fri, 24 Feb 2006 23:41:54 -0500 +X-Server-Uuid: 241911D6-425B-44B9-A073-E3FE0F8FC774 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.175]) by + D01SMTP02.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Fri, 24 Feb + 2006 23:41:54 -0500 +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.105]) with Microsoft Exchange Server HTTP-DAV ; Sat, 25 Feb + 2006 04:41:53 +0000 +User-Agent: Microsoft-Entourage/11.2.1.051004 +Date: Fri, 24 Feb 2006 20:41:52 -0800 +Subject: Re: Reliability recommendations +From: "Luke Lonergan" +To: "Dan Gorman" , + "Mark Kirkwood" +cc: "Joshua D. Drake" , + "Craig A. James" , + pgsql-performance@postgresql.org +Message-ID: +Thread-Topic: [PERFORM] Reliability recommendations +Thread-Index: AcY5pWS53OX+vf3vQguwzrvbaAMBzAAIGc8V +In-Reply-To: <125CA0A8-6142-4DF5-822E-CF0B0C46B4C1@hi5.com> +MIME-Version: 1.0 +X-OriginalArrivalTime: 25 Feb 2006 04:41:54.0577 (UTC) + FILETIME=[CD812010:01C639C5] +X-WSS-ID: 6FE13F9831W11329475-01-01 +Content-Type: text/plain; + charset=utf-7 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=1.351 required=5 tests=[AWL=0.098, + RCVD_NUMERIC_HELO=1.253] +X-Spam-Score: 1.351 +X-Spam-Level: * +X-Archive-Number: 200602/401 +X-Sequence-Number: 17387 + +Dan, + +On 2/24/06 4:47 PM, "Dan Gorman" wrote: + +> Was that sequential reads? If so, yeah you'll get 110MB/s? How big +> was the datafile size? 8MB? Yeah, you'll get 110MB/s. 2GB? No, they +> can't sustain that. There are so many details missing from this test +> that it's hard to have any context around it :) +> +> I was getting about 40-50MB/s on a PV with 14 disks on a RAID10 in +> real world usage. (random IO and fully saturating a Dell 1850 with 4 +> concurrent threads (to peg the cpu on selects) and raw data files) + +OK, how about some proof? + +In a synthetic test that writes 32GB of sequential 8k pages on a machine +with 16GB of RAM: +========================= Write test results ============================== +time bash -c "dd if=/dev/zero of=/dbfast1/llonergan/bigfile bs=8k +count=2000000 && sync" & +time bash -c "dd if=/dev/zero of=/dbfast3/llonergan/bigfile bs=8k +count=2000000 && sync" & + +2000000++0 records in +2000000++0 records out +2000000++0 records in +2000000++0 records out + +real 1m0.046s +user 0m0.270s +sys 0m30.008s + +real 1m0.047s +user 0m0.287s +sys 0m30.675s + +So that's 32,000 MB written in 60.05 seconds, which is 533MB/s sustained +with two threads. + +Now to read the same files in parallel: +========================= Read test results ============================== +sync +time dd of=/dev/null if=/dbfast1/llonergan/bigfile bs=8k & +time dd of=/dev/null if=/dbfast3/llonergan/bigfile bs=8k & + +2000000++0 records in +2000000++0 records out + +real 0m39.849s +user 0m0.282s +sys 0m22.294s +2000000++0 records in +2000000++0 records out + +real 0m40.410s +user 0m0.251s +sys 0m22.515s + +And that's 32,000MB in 40.4 seconds, or 792MB/s sustained from disk (not +memory). + +These are each RAID5 arrays of 8 internal SATA disks on 3Ware HW RAID +controllers. + +Now for real usage, let's run a simple sequential scan query on 123,434 MB +of data in a single table on 4 of these machines in parallel. All tables +are distributed evenly by Bizgres MPP over all 8 filesystems: + +============= Bizgres MPP sequential scan results ========================= + +[llonergan@salerno]$ !psql +psql -p 9999 -U mppdemo1 demo +Welcome to psql 8.1.1 (server 8.1.3), the PostgreSQL interactive terminal. + +Type: \copyright for distribution terms + \h for help with SQL commands + \? for help with psql commands + \g or terminate with semicolon to execute query + \q to quit + +demo=# \timing +Timing is on. +demo=# select version(); + +version +---------------------------------------------------------------------------- +---------------------------------------------------------------------------- +----- + PostgreSQL 8.1.3 (Bizgres MPP 2.1) on x86_64-unknown-linux-gnu, compiled by +GCC gcc (GCC) 3.4.4 20050721 (Red Hat 3.4.4-2) compiled on Feb 23 2006 +11:34:06 +(1 row) + +Time: 0.570 ms +demo=# select relname,8*relpages/128 as MB from pg_class order by relpages +desc limit 6; + relname | mb +--------------------------------++-------- + lineitem | 123434 + orders | 24907 + partsupp | 14785 + part | 3997 + customer | 3293 + supplier | 202 +(6 rows) + +Time: 1.824 ms +demo=# select count(*) from lineitem; + count +----------- + 600037902 +(1 row) + +Time: 60300.960 ms + +So that's 123,434 MB of data scanned in 60.3 seconds, or 2,047 MB/s on 4 +machines, which uses 512MB/s of disk bandwidth on each machine. + +Now let's do a query that uses a this big table (a two way join) using all 4 +machines: +============= Bizgres MPP Query results ========================= +demo=# select +demo-# sum(l_extendedprice* (1 - l_discount)) as revenue +demo-# from +demo-# lineitem, +demo-# part +demo-# where +demo-# ( +demo(# p_partkey = l_partkey +demo(# and p_brand = 'Brand#42' +demo(# and p_container in ('SM CASE', 'SM BOX', 'SM PACK', +'SM PKG') +demo(# and l_quantity >= 7 and l_quantity <= 7 ++ 10 +demo(# and p_size between 1 and 5 +demo(# and l_shipmode in ('AIR', 'AIR REG') +demo(# and l_shipinstruct = 'DELIVER IN PERSON' +demo(# ) +demo-# or +demo-# ( +demo(# p_partkey = l_partkey +demo(# and p_brand = 'Brand#15' +demo(# and p_container in ('MED BAG', 'MED BOX', 'MED PKG', +'MED PACK') +demo(# and l_quantity >= 14 and l_quantity <= 14 ++ 10 +demo(# and p_size between 1 and 10 +demo(# and l_shipmode in ('AIR', 'AIR REG') +demo(# and l_shipinstruct = 'DELIVER IN PERSON' +demo(# ) +demo-# or +demo-# ( +demo(# p_partkey = l_partkey +demo(# and p_brand = 'Brand#53' +demo(# and p_container in ('LG CASE', 'LG BOX', 'LG PACK', +'LG PKG') +demo(# and l_quantity >= 22 and l_quantity <= 22 ++ 10 +demo(# and p_size between 1 and 15 +demo(# and l_shipmode in ('AIR', 'AIR REG') +demo(# and l_shipinstruct = 'DELIVER IN PERSON' +demo(# ); + revenue +---------------- + 356492404.3164 +(1 row) + +Time: 114908.149 ms + + +And now a 6-way join among 4 tables in this same schema: + +demo=# SELECT +demo-# +s.s_acctbal,s.s_name,n.n_name,p.p_partkey,p.p_mfgr,s.s_address,s.s_phone,s.s +_comment +demo-# FROM +demo-# supplier s,partsupp ps,nation n,region r, +demo-# part p, ( +demo(# SELECT p_partkey, min(ps_supplycost) as +min_ps_cost from part, partsupp , +demo(# supplier,nation, region +demo(# WHERE +demo(# p_partkey=ps_partkey +demo(# and s_suppkey = ps_suppkey +demo(# and s_nationkey = n_nationkey +demo(# and n_regionkey = r_regionkey +demo(# and r_name = 'EUROPE' +demo(# GROUP BY +demo(# p_partkey +demo(# ) g +demo-# WHERE +demo-# p.p_partkey = ps.ps_partkey +demo-# and g.p_partkey = p.p_partkey +demo-# and g. min_ps_cost = ps.ps_supplycost +demo-# and s.s_suppkey = ps.ps_suppkey +demo-# and p.p_size = 15 +demo-# and p.p_type like '%BRASS' +demo-# and s.s_nationkey = n.n_nationkey +demo-# and n.n_regionkey = r.r_regionkey +demo-# and r.r_name = 'EUROPE' +demo-# ORDER BY +demo-# s. s_acctbal desc,n.n_name,s.s_name,p.p_partkey +demo-# LIMIT 100; + s_acctbal | s_name | n_name | +p_partkey | p_mfgr | + s_address | s_phone | +s_comment + +-----------++---------------------------++---------------------------++-------- +---++---------------------------++------ +------------------------------------++-----------------++--------------------- +-------------------------------------- +------------------------------------------- + 9999.70 | Supplier#000239544 | UNITED KINGDOM | +6739531 | Manufacturer#4 | 1UCMu +3TLyUThghoeZ8arg6cV3Mr | 33-509-584-9496 | carefully ironic +asymptotes cajole quickly. slyly silent a +ccounts sleep. fl +... +... + 9975.53 | Supplier#000310136 | ROMANIA | +10810115 | Manufacturer#5 | VNWON +A5Sr B | 29-977-903-6199 | pending deposits +wake permanently; final accounts sleep ab +out the pending deposits. +(100 rows) + +Time: 424981.813 ms + + +- Luke + + + +From pgsql-performance-owner@postgresql.org Sat Feb 25 02:11:00 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id EB7F89DC80E + for ; + Sat, 25 Feb 2006 02:10:59 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 78750-01 + for ; + Sat, 25 Feb 2006 02:10:59 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from linda-5.paradise.net.nz (bm-5a.paradise.net.nz + [203.96.152.184]) + by postgresql.org (Postfix) with ESMTP id AF5F39DCA80 + for ; + Sat, 25 Feb 2006 02:10:57 -0400 (AST) +Received: from smtp-3.paradise.net.nz + (tclsnelb1-src-1.paradise.net.nz [203.96.152.172]) by + linda-5.paradise.net.nz (Paradise.net.nz) with ESMTP id + <0IV8006DPBU9Z6@linda-5.paradise.net.nz> for + pgsql-performance@postgresql.org; Sat, 25 Feb 2006 19:10:57 +1300 (NZDT) +Received: from [192.168.1.11] + (218-101-28-236.dsl.clear.net.nz [218.101.28.236]) by + smtp-3.paradise.net.nz (Postfix) with ESMTP id 8E5CCD43E4E; + Sat, 25 Feb 2006 19:10:56 +1300 (NZDT) +Date: Sat, 25 Feb 2006 19:10:55 +1300 +From: Mark Kirkwood +Subject: Re: Reliability recommendations +In-reply-to: +To: Luke Lonergan +Cc: Dan Gorman , "Joshua D. Drake" , + "Craig A. James" , + pgsql-performance@postgresql.org +Message-id: <43FFF4EF.6060601@paradise.net.nz> +MIME-version: 1.0 +Content-type: text/plain; charset=UTF-7 +Content-transfer-encoding: 7bit +X-Accept-Language: en-us, en +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20051106) +References: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.193 required=5 tests=[AWL=0.193] +X-Spam-Score: 0.193 +X-Spam-Level: +X-Archive-Number: 200602/402 +X-Sequence-Number: 17388 + +Luke Lonergan wrote: + +> +> OK, how about some proof? +> +> In a synthetic test that writes 32GB of sequential 8k pages on a machine +> with 16GB of RAM: +> ========================= Write test results ============================== +> time bash -c "dd if=/dev/zero of=/dbfast1/llonergan/bigfile bs=8k +> count=2000000 && sync" & +> time bash -c "dd if=/dev/zero of=/dbfast3/llonergan/bigfile bs=8k +> count=2000000 && sync" & +> +> 2000000 records in +> 2000000 records out +> 2000000 records in +> 2000000 records out +> +> real 1m0.046s +> user 0m0.270s +> sys 0m30.008s +> +> real 1m0.047s +> user 0m0.287s +> sys 0m30.675s +> +> So that's 32,000 MB written in 60.05 seconds, which is 533MB/s sustained +> with two threads. +> + +Well, since this is always fun (2G memory, 3Ware 7506, 4xPATA), writing: + +$ dd if=/dev/zero of=/data0/dump/bigfile bs=8k count=500000 +500000+0 records in +500000+0 records out +4096000000 bytes transferred in 32.619208 secs (125570185 bytes/sec) + +> Now to read the same files in parallel: +> ========================= Read test results ============================== +> sync +> time dd of=/dev/null if=/dbfast1/llonergan/bigfile bs=8k & +> time dd of=/dev/null if=/dbfast3/llonergan/bigfile bs=8k & +> +> 2000000 records in +> 2000000 records out +> +> real 0m39.849s +> user 0m0.282s +> sys 0m22.294s +> 2000000 records in +> 2000000 records out +> +> real 0m40.410s +> user 0m0.251s +> sys 0m22.515s +> +> And that's 32,000MB in 40.4 seconds, or 792MB/s sustained from disk (not +> memory). +> + +Reading: + +$ dd of=/dev/null if=/data0/dump/bigfile bs=8k count=500000 +500000+0 records in +500000+0 records out +4096000000 bytes transferred in 24.067298 secs (170189442 bytes/sec) + +Ok - didn't quite get my quoted 175MB/s, (FWIW if bs=32k I get exactly +175MB/s). + +Hmmm - a bit humbled by Luke's machinery :-), however, mine is probably +competitive on (MB/s)/$.... + + +It would be interesting to see what Dan's system would do on a purely +sequential workload - as 40-50MB of purely random IO is high. + +Cheers + +Mark + +From pgsql-performance-owner@postgresql.org Sat Feb 25 02:23:04 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 8A63A9DCAD2 + for ; + Sat, 25 Feb 2006 02:23:03 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 77809-05 + for ; + Sat, 25 Feb 2006 02:23:03 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.Mi8.com (d01gw01.mi8.com [63.240.6.47]) + by postgresql.org (Postfix) with ESMTP id 57B7E9DCAAA + for ; + Sat, 25 Feb 2006 02:23:00 -0400 (AST) +Received: from 172.16.1.112 by mail.Mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D1)); Sat, 25 Feb 2006 01:22:51 -0500 +X-Server-Uuid: 241911D6-425B-44B9-A073-E3FE0F8FC774 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.175]) by + D01SMTP02.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Sat, 25 Feb + 2006 01:22:51 -0500 +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 ; Sat, 25 Feb + 2006 06:22:50 +0000 +User-Agent: Microsoft-Entourage/11.2.1.051004 +Date: Fri, 24 Feb 2006 22:22:49 -0800 +Subject: Re: Reliability recommendations +From: "Luke Lonergan" +To: "Mark Kirkwood" +cc: "Dan Gorman" , "Joshua D. Drake" , + "Craig A. James" , + pgsql-performance@postgresql.org +Message-ID: +Thread-Topic: [PERFORM] Reliability recommendations +Thread-Index: AcY50+Y4JREnwqXHEdqbDgANk63kWA== +In-Reply-To: <43FFF4EF.6060601@paradise.net.nz> +MIME-Version: 1.0 +X-OriginalArrivalTime: 25 Feb 2006 06:22:51.0356 (UTC) + FILETIME=[E7A041C0:01C639D3] +X-WSS-ID: 6FE1283131W11352612-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, score=1.351 required=5 tests=[AWL=0.098, + RCVD_NUMERIC_HELO=1.253] +X-Spam-Score: 1.351 +X-Spam-Level: * +X-Archive-Number: 200602/403 +X-Sequence-Number: 17389 + +Mark, + +On 2/24/06 10:10 PM, "Mark Kirkwood" wrote: + +> Well, since this is always fun (2G memory, 3Ware 7506, 4xPATA), writing: +> +> $ dd if=/dev/zero of=/data0/dump/bigfile bs=8k count=500000 +> 500000 records in +> 500000 records out +> 4096000000 bytes transferred in 32.619208 secs (125570185 bytes/sec) + +> Reading: +> +> $ dd of=/dev/null if=/data0/dump/bigfile bs=8k count=500000 +> 500000 records in +> 500000 records out +> 4096000000 bytes transferred in 24.067298 secs (170189442 bytes/sec) + +Not bad at all! I have one of these cards in my home machine running WinXP +and it's not nearly this fast. + +> Hmmm - a bit humbled by Luke's machinery :-), however, mine is probably +> competitive on (MB/s)/$.... + +Not sure - the machines I cite are about $10K each. The machine you tested +was probably about $1500 a few years ago (my guess), and with a 5:1 ratio in +speed versus about a 6:1 ratio in price, we're not too far off in MB/s/$ +after all :-) + +> It would be interesting to see what Dan's system would do on a purely +> sequential workload - as 40-50MB of purely random IO is high. + +Yeah - that is really high if the I/O is really random. I'd normally expect +maybe 500-600 iops / second and if each IO is 8KB, that would be 4MB/s. The +I/O is probably not really completely random, or it's random over cachable +bits of the occupied disk area. + +- Luke + + + +From pgsql-performance-owner@postgresql.org Sat Feb 25 02:28:20 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id ABCB19DC84D + for ; + Sat, 25 Feb 2006 02:28:19 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 75145-09 + for ; + Sat, 25 Feb 2006 02:28:19 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from linda-2.paradise.net.nz (bm-2a.paradise.net.nz + [203.96.152.181]) + by postgresql.org (Postfix) with ESMTP id 795679DC80E + for ; + Sat, 25 Feb 2006 02:28:17 -0400 (AST) +Received: from smtp-3.paradise.net.nz + (tclsnelb1-src-1.paradise.net.nz [203.96.152.172]) by + linda-2.paradise.net.nz (Paradise.net.nz) with ESMTP id + <0IV800B5DCN56B@linda-2.paradise.net.nz> for + pgsql-performance@postgresql.org; Sat, 25 Feb 2006 19:28:17 +1300 (NZDT) +Received: from [192.168.1.11] + (218-101-28-236.dsl.clear.net.nz [218.101.28.236]) by + smtp-3.paradise.net.nz (Postfix) with ESMTP id 65499672D81; + Sat, 25 Feb 2006 19:28:16 +1300 (NZDT) +Date: Sat, 25 Feb 2006 19:28:15 +1300 +From: Mark Kirkwood +Subject: Re: Reliability recommendations +In-reply-to: +To: Luke Lonergan +Cc: Dan Gorman , "Joshua D. Drake" , + "Craig A. James" , + pgsql-performance@postgresql.org +Message-id: <43FFF8FF.8050101@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/20051106) +References: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.192 required=5 tests=[AWL=0.192] +X-Spam-Score: 0.192 +X-Spam-Level: +X-Archive-Number: 200602/404 +X-Sequence-Number: 17390 + +Luke Lonergan wrote: +> Mark, +> +>>Hmmm - a bit humbled by Luke's machinery :-), however, mine is probably +>>competitive on (MB/s)/$.... +> +> +> Not sure - the machines I cite are about $10K each. The machine you tested +> was probably about $1500 a few years ago (my guess), and with a 5:1 ratio in +> speed versus about a 6:1 ratio in price, we're not too far off in MB/s/$ +> after all :-) +> + +Wow - that is remarkable performance for $10K! + +Cheers + +Mark + +From pgsql-performance-owner@postgresql.org Sat Feb 25 07:25:00 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 62EF89DC81C + for ; + Sat, 25 Feb 2006 07:24:59 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 63777-02 + for ; + Sat, 25 Feb 2006 07:25:01 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smtpauth02.mail.atl.earthlink.net + (smtpauth02.mail.atl.earthlink.net [209.86.89.62]) + by postgresql.org (Postfix) with ESMTP id D6A0C9DC819 + for ; + Sat, 25 Feb 2006 07:24:56 -0400 (AST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=ECzGSzbSgsarucUzL2KSJ7sNcPy2RSvQ6YJ7kZ8qwL/b3FB5Te/cUByHN9NWh/sG; + 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 [71.243.43.186] (helo=ron-6d52adff2a6.earthlink.net) + by smtpauth02.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1FCxXn-00034J-6p; Sat, 25 Feb 2006 06:24:59 -0500 +Message-Id: <7.0.1.0.2.20060225055917.03da49f8@earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 7.0.1.0 +Date: Sat, 25 Feb 2006 06:24:55 -0500 +To: "Luke Lonergan" , + pgsql-performance@postgresql.org +From: Ron +Subject: Re: Reliability recommendations +In-Reply-To: +References: <125CA0A8-6142-4DF5-822E-CF0B0C46B4C1@hi5.com> + +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bcd1e7200161cb12d078261b5d480d94d0350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 71.243.43.186 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.473 required=5 tests=[AWL=-0.006, + DNS_FROM_RFC_ABUSE=0.479] +X-Spam-Score: 0.473 +X-Spam-Level: +X-Archive-Number: 200602/405 +X-Sequence-Number: 17391 + +At 11:41 PM 2/24/2006, Luke Lonergan wrote: +>Dan, +> +>On 2/24/06 4:47 PM, "Dan Gorman" wrote: +> +> > Was that sequential reads? If so, yeah you'll get 110MB/s? How big +> > was the datafile size? 8MB? Yeah, you'll get 110MB/s. 2GB? No, they +> > can't sustain that. There are so many details missing from this test +> > that it's hard to have any context around it :) +> > +> > I was getting about 40-50MB/s on a PV with 14 disks on a RAID10 in +> > real world usage. (random IO and fully saturating a Dell 1850 with 4 +> > concurrent threads (to peg the cpu on selects) and raw data files) +> +>OK, how about some proof? +> +>In a synthetic test that writes 32GB of sequential 8k pages on a machine +>with 16GB of RAM: +>========================= Write test results ============================== +>time bash -c "dd if=/dev/zero of=/dbfast1/llonergan/bigfile bs=8k +>count=2000000 && sync" & +>time bash -c "dd if=/dev/zero of=/dbfast3/llonergan/bigfile bs=8k +>count=2000000 && sync" & +> +>2000000++0 records in +>2000000++0 records out +>2000000++0 records in +>2000000++0 records out +> +>real 1m0.046s +>user 0m0.270s +>sys 0m30.008s +> +>real 1m0.047s +>user 0m0.287s +>sys 0m30.675s +> +>So that's 32,000 MB written in 60.05 seconds, which is 533MB/s sustained +>with two threads. +> +>Now to read the same files in parallel: +>========================= Read test results ============================== +>sync +>time dd of=/dev/null if=/dbfast1/llonergan/bigfile bs=8k & +>time dd of=/dev/null if=/dbfast3/llonergan/bigfile bs=8k & +> +>2000000++0 records in +>2000000++0 records out +> +>real 0m39.849s +>user 0m0.282s +>sys 0m22.294s +>2000000++0 records in +>2000000++0 records out +> +>real 0m40.410s +>user 0m0.251s +>sys 0m22.515s +> +>And that's 32,000MB in 40.4 seconds, or 792MB/s sustained from disk (not +>memory). +> +>These are each RAID5 arrays of 8 internal SATA disks on 3Ware HW RAID +>controllers. + +Impressive IO rates. A more detailed HW list would help put them in context. + +Which 3Ware? The 9550SX? How much cache on it (AFAIK, the only +options are 128MB and 256MB?)? + +Which HDs? + +What CPUs (looks like Opterons, but which flavor?) and mainboard? + +What's CPU utilization when hammering the physical IO subsystem this hard? + + +>Now for real usage, let's run a simple sequential scan query on 123,434 MB +>of data in a single table on 4 of these machines in parallel. All tables +>are distributed evenly by Bizgres MPP over all 8 filesystems: +> +>============= Bizgres MPP sequential scan results ========================= +> +>[llonergan@salerno0 +AH4]$ !psql +>psql -p 9999 -U mppdemo1 demo +>Welcome to psql 8.1.1 (server 8.1.3), the PostgreSQL interactive terminal. +> +>Type: +AFw-copyright for distribution terms +> +AFw-h for help with SQL commands +> +AFw? for help with psql commands +> +AFw-g or terminate with semicolon to execute query +> +AFw-q to quit +> +>demo=# +AFw-timing +>Timing is on. +>demo=# select version(); +> +>version +>---------------------------------------------------------------------------- +>---------------------------------------------------------------------------- +>----- +> PostgreSQL 8.1.3 (Bizgres MPP 2.1) on x86_64-unknown-linux-gnu, compiled by +>GCC gcc (GCC) 3.4.4 20050721 (Red Hat 3.4.4-2) compiled on Feb 23 2006 +>11:34:06 +>(1 row) +> +>Time: 0.570 ms +>demo=# select relname,8*relpages/128 as MB from pg_class order by relpages +>desc limit 6; +> relname | mb +>--------------------------------++-------- +> lineitem | 123434 +> orders | 24907 +> partsupp | 14785 +> part | 3997 +> customer | 3293 +> supplier | 202 +>(6 rows) +> +>Time: 1.824 ms +>demo=# select count(*) from lineitem; +> count +>----------- +> 600037902 +>(1 row) +> +>Time: 60300.960 ms +> +>So that's 123,434 MB of data scanned in 60.3 seconds, or 2,047 MB/s on 4 +>machines, which uses 512MB/s of disk bandwidth on each machine. +> +>Now let's do a query that uses a this big table (a two way join) using all 4 +>machines: +>============= Bizgres MPP Query results ========================= +>demo=# select +>demo-# sum(l_extendedprice* (1 - l_discount)) as revenue +>demo-# from +>demo-# lineitem, +>demo-# part +>demo-# where +>demo-# ( +>demo(# p_partkey = l_partkey +>demo(# and p_brand = 'Brand#42' +>demo(# and p_container in ('SM CASE', 'SM BOX', 'SM PACK', +>'SM PKG') +>demo(# and l_quantity >= 7 and l_quantity <= 7 ++ 10 +>demo(# and p_size between 1 and 5 +>demo(# and l_shipmode in ('AIR', 'AIR REG') +>demo(# and l_shipinstruct = 'DELIVER IN PERSON' +>demo(# ) +>demo-# or +>demo-# ( +>demo(# p_partkey = l_partkey +>demo(# and p_brand = 'Brand#15' +>demo(# and p_container in ('MED BAG', 'MED BOX', 'MED PKG', +>'MED PACK') +>demo(# and l_quantity >= 14 and l_quantity <= 14 ++ 10 +>demo(# and p_size between 1 and 10 +>demo(# and l_shipmode in ('AIR', 'AIR REG') +>demo(# and l_shipinstruct = 'DELIVER IN PERSON' +>demo(# ) +>demo-# or +>demo-# ( +>demo(# p_partkey = l_partkey +>demo(# and p_brand = 'Brand#53' +>demo(# and p_container in ('LG CASE', 'LG BOX', 'LG PACK', +>'LG PKG') +>demo(# and l_quantity >= 22 and l_quantity <= 22 ++ 10 +>demo(# and p_size between 1 and 15 +>demo(# and l_shipmode in ('AIR', 'AIR REG') +>demo(# and l_shipinstruct = 'DELIVER IN PERSON' +>demo(# ); +> revenue +>---------------- +> 356492404.3164 +>(1 row) +> +>Time: 114908.149 ms +Hmmm. ~115secs @ ~500MBps => ~57.5GB of data manipulated. + + +>And now a 6-way join among 4 tables in this same schema: +> +>demo=# SELECT +>demo-# +>s.s_acctbal,s.s_name,n.n_name,p.p_partkey,p.p_mfgr,s.s_address,s.s_phone,s.s +>_comment +>demo-# FROM +>demo-# supplier s,partsupp ps,nation n,region r, +>demo-# part p, ( +>demo(# SELECT p_partkey, min(ps_supplycost) as +>min_ps_cost from part, partsupp , +>demo(# supplier,nation, region +>demo(# WHERE +>demo(# p_partkey=ps_partkey +>demo(# and s_suppkey = ps_suppkey +>demo(# and s_nationkey = n_nationkey +>demo(# and n_regionkey = r_regionkey +>demo(# and r_name = 'EUROPE' +>demo(# GROUP BY +>demo(# p_partkey +>demo(# ) g +>demo-# WHERE +>demo-# p.p_partkey = ps.ps_partkey +>demo-# and g.p_partkey = p.p_partkey +>demo-# and g. min_ps_cost = ps.ps_supplycost +>demo-# and s.s_suppkey = ps.ps_suppkey +>demo-# and p.p_size = 15 +>demo-# and p.p_type like '%BRASS' +>demo-# and s.s_nationkey = n.n_nationkey +>demo-# and n.n_regionkey = r.r_regionkey +>demo-# and r.r_name = 'EUROPE' +>demo-# ORDER BY +>demo-# s. s_acctbal desc,n.n_name,s.s_name,p.p_partkey +>demo-# LIMIT 100; +> s_acctbal | s_name | n_name | +>p_partkey | p_mfgr | +> s_address | s_phone | +>s_comment +> +>-----------++---------------------------++---------------------------++-------- +>---++---------------------------++------ +>------------------------------------++-----------------++--------------------- +>-------------------------------------- +>------------------------------------------- +> 9999.70 | Supplier#000239544 | UNITED KINGDOM | +>6739531 | Manufacturer#4 | 1UCMu +>3TLyUThghoeZ8arg6cV3Mr | 33-509-584-9496 | carefully ironic +>asymptotes cajole quickly. slyly silent a +>ccounts sleep. fl +>... +>... +> 9975.53 | Supplier#000310136 | ROMANIA | +>10810115 | Manufacturer#5 | VNWON +>A5Sr B | 29-977-903-6199 | pending deposits +>wake permanently; final accounts sleep ab +>out the pending deposits. +>(100 rows) +> +>Time: 424981.813 ms +...and this implies ~425secs @ ~500MBps => 212.5GB + +What are the IO rates during these joins? + +How much data is being handled to complete these joins? + +How much data is being exchanged between these machines to complete the joins? + +What is the connectivity between these 4 machines? + +Putting these numbers in context may help the advocacy effort +considerably as well as help us improve things even further. ;-) + +TiA, +Ron + + + +From pgsql-performance-owner@postgresql.org Sat Feb 25 07:56:37 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 302999DC9E0 + for ; + Sat, 25 Feb 2006 07:56:37 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 66958-01 + for ; + Sat, 25 Feb 2006 07:56:39 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smtpauth07.mail.atl.earthlink.net + (smtpauth07.mail.atl.earthlink.net [209.86.89.67]) + by postgresql.org (Postfix) with ESMTP id 895D49DC951 + for ; + Sat, 25 Feb 2006 07:56:34 -0400 (AST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=l0yqXtCyDQ/KllgHFCLukR6f3L6Asf+6etDH1QWPKcIcCdJRfA0VHBnuKqq5A5LU; + 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 [71.243.43.186] (helo=ron-6d52adff2a6.earthlink.net) + by smtpauth07.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1FCy2O-0003HM-La; Sat, 25 Feb 2006 06:56:36 -0500 +Message-Id: <7.0.1.0.2.20060225063934.00adfec0@earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 7.0.1.0 +Date: Sat, 25 Feb 2006 06:56:33 -0500 +To: "Luke Lonergan" , + pgsql-performance@postgresql.org +From: Ron +Subject: Re: Reliability recommendations +In-Reply-To: +References: <43FFF4EF.6060601@paradise.net.nz> + +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bc190db5a84933826e883da3a6fb6a2d6a350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 71.243.43.186 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.473 required=5 tests=[AWL=-0.006, + DNS_FROM_RFC_ABUSE=0.479] +X-Spam-Score: 0.473 +X-Spam-Level: +X-Archive-Number: 200602/406 +X-Sequence-Number: 17392 + +At 01:22 AM 2/25/2006, Luke Lonergan wrote: +>Mark, +> +>On 2/24/06 10:10 PM, "Mark Kirkwood" wrote: +> +> > Well, since this is always fun (2G memory, 3Ware 7506, 4xPATA), writing: +> > +> > $ dd if=/dev/zero of=/data0/dump/bigfile bs=8k count=500000 +> > 500000 records in +> > 500000 records out +> > 4096000000 bytes transferred in 32.619208 secs (125570185 bytes/sec) +> +> > Reading: +> > +> > $ dd of=/dev/null if=/data0/dump/bigfile bs=8k count=500000 +> > 500000 records in +> > 500000 records out +> > 4096000000 bytes transferred in 24.067298 secs (170189442 bytes/sec) +> +>Not bad at all! I have one of these cards in my home machine running WinXP +>and it's not nearly this fast. +> +> > Hmmm - a bit humbled by Luke's machinery :-), however, mine is probably +> > competitive on (MB/s)/$.... +> +>Not sure - the machines I cite are about $10K each. The machine you tested +>was probably about $1500 a few years ago (my guess), and with a 5:1 ratio in +>speed versus about a 6:1 ratio in price, we're not too far off in MB/s/$ +>after all :-) +> +> > It would be interesting to see what Dan's system would do on a purely +> > sequential workload - as 40-50MB of purely random IO is high. +> +>Yeah - that is really high if the I/O is really random. I'd normally expect +>maybe 500-600 iops / second and if each IO is 8KB, that would be 4MB/s. The +>I/O is probably not really completely random, or it's random over cachable +>bits of the occupied disk area. +Side note: the new WD 150GB Raptors (10Krpm 1.5Gbps SATA w/ NCQ +support) have benched at ~1000 IOps _per drive_ + +http://www.storagereview.com/articles/200601/WD1500ADFD_4.html + +(Now if we can just get WD to make a 300GB Raptor, increase that +wimpy 16MB buffer, and implement 6Gbps SATA...;-) ) + +An array of these things plugged into a PCI-E <-> SATA RAID +controller with 1-2GB of cache should set a new bar for performance +as well as making that performance more resilient than ever to +variations in usage patterns. + + + + + +From pgsql-performance-owner@postgresql.org Sat Feb 25 11:50:21 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 327879DD206 + for ; + Sat, 25 Feb 2006 11:50:10 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 04112-02 + for ; + Sat, 25 Feb 2006 11:50:14 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.Mi8.com (d01gw01.mi8.com [63.240.6.47]) + by postgresql.org (Postfix) with ESMTP id 3F9EC9DD07D + for ; + Sat, 25 Feb 2006 11:50:02 -0400 (AST) +Received: from 172.16.1.112 by mail.Mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D1)); Sat, 25 Feb 2006 10:49:53 -0500 +X-Server-Uuid: 241911D6-425B-44B9-A073-E3FE0F8FC774 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.175]) by + D01SMTP02.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Sat, 25 Feb + 2006 10:49:53 -0500 +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 ; Sat, 25 Feb + 2006 15:49:52 +0000 +User-Agent: Microsoft-Entourage/11.2.1.051004 +Date: Sat, 25 Feb 2006 07:49:51 -0800 +Subject: Re: Reliability recommendations +From: "Luke Lonergan" +To: "Ron" , + pgsql-performance@postgresql.org +Message-ID: +Thread-Topic: [PERFORM] Reliability recommendations +Thread-Index: AcY5/iDeWoYsFgWERASdh6+tS202CQAJPwJU +In-Reply-To: <7.0.1.0.2.20060225055917.03da49f8@earthlink.net> +MIME-Version: 1.0 +X-OriginalArrivalTime: 25 Feb 2006 15:49:53.0382 (UTC) + FILETIME=[1E557060:01C63A23] +X-WSS-ID: 681EA32B31W11489157-01-01 +Content-Type: multipart/mixed; + boundary=B_3223698593_18201262 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=1.352 required=5 tests=[AWL=0.099, + RCVD_NUMERIC_HELO=1.253] +X-Spam-Score: 1.352 +X-Spam-Level: * +X-Archive-Number: 200602/407 +X-Sequence-Number: 17393 + +> 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_3223698593_18201262 +Content-Type: text/plain; + charset=iso-8859-1 +Content-Transfer-Encoding: quoted-printable + +Ron, + +On 2/25/06 3:24 AM, "Ron" wrote: + +>> These are each RAID5 arrays of 8 internal SATA disks on 3Ware HW RAID +>> controllers. +>=20 +> Impressive IO rates. A more detailed HW list would help put them in cont= +ext. +>=20 +> Which 3Ware? The 9550SX? How much cache on it (AFAIK, the only +> options are 128MB and 256MB?)? +>=20 +> Which HDs? +>=20 +> What CPUs (looks like Opterons, but which flavor?) and mainboard? +>=20 +> What's CPU utilization when hammering the physical IO subsystem this hard= +? + +OK. There are four machines. Each machine has: +Qty 2 of 3Ware 9550SX/PCIX/128MB cache SATAII RAID controllers +Qty 2 of AMD Opteron 250 CPUs (2.4 GHz) +Qty 16 of 1GB PC3200 RAM (16GB total) +Qty 1 of Tyan 2882S Motherboard +Qty 16 Western Digital 400GB Raid Edition 2 SATA disks +Cost: About $10,000 each + +They are connected together using a Netgear 48 port Gigabit Ethernet switch +and copper CAT6 cables. +Cost: About $1,500 + +Total of all machines: +8 CPUs +64GB RAM +64 Disks +20TB storage in RAID5 +Total HW cost: About $45,000. + +CPU utilization is apparently (adding up usr+system and dividing by real): +Writing at 2,132MB/s: 51% +Reading at 3,168MB/s: 56% + +>> revenue +>> ---------------- +>> 356492404.3164 +>> (1 row) +>>=20 +>> Time: 114908.149 ms +> Hmmm. ~115secs @ ~500MBps =3D> ~57.5GB of data manipulated. + +Actually, this query sequential scans all of both lineitem and part, so it=B9= +s +accessing 127.5GB of data, and performing the work of the hash join, in +about double the scan time. That=B9s possible because we=B9re using all 8 CPUs= +, +4 network interfaces and the 64 disks while we are performing the query: + + Aggregate (cost=3D3751996.97..3751996.99 rows=3D1 width=3D22) + -> Gather Motion (cost=3D3751996.97..3751996.99 rows=3D1 width=3D22) + -> Aggregate (cost=3D3751996.97..3751996.99 rows=3D1 width=3D22) + -> Hash Join (cost=3D123440.49..3751993.62 rows=3D1339 +width=3D22) + Hash Cond: ("outer".l_partkey =3D "inner".p_partkey) + Join Filter: ((("inner".p_brand =3D 'Brand#42'::bpchar) +AND (("inner".p_container =3D 'SM CASE'::bpchar) OR ("inner".p_container =3D 'S= +M +BOX'::bpchar) OR ("inner".p_container =3D 'SM PACK'::bpchar) OR +("inner".p_container =3D 'SM PKG'::bpchar)) AND ("outer".l_quantity >=3D +7::numeric) AND ("outer".l_quantity <=3D 17::numeric) AND ("inner".p_size <=3D +5)) OR (("inner".p_brand =3D 'Brand#15'::bpchar) AND (("inner".p_container =3D +'MED BAG'::bpchar) OR ("inner".p_container =3D 'MED BOX'::bpchar) OR +("inner".p_container =3D 'MED PKG'::bpchar) OR ("inner".p_container =3D 'MED +PACK'::bpchar)) AND ("outer".l_quantity >=3D 14::numeric) AND +("outer".l_quantity <=3D 24::numeric) AND ("inner".p_size <=3D 10)) OR +(("inner".p_brand =3D 'Brand#53'::bpchar) AND (("inner".p_container =3D 'LG +CASE'::bpchar) OR ("inner".p_container =3D 'LG BOX'::bpchar) OR +("inner".p_container =3D 'LG PACK'::bpchar) OR ("inner".p_container =3D 'LG +PKG'::bpchar)) AND ("outer".l_quantity >=3D 22::numeric) AND +("outer".l_quantity <=3D 32::numeric) AND ("inner".p_size <=3D 15))) + -> Redistribute Motion (cost=3D0.00..3340198.25 +rows=3D2611796 width=3D36) + Hash Key: l_partkey + -> Seq Scan on lineitem (cost=3D0.00..3287962.32 +rows=3D2611796 width=3D36) + Filter: (((l_shipmode =3D 'AIR'::bpchar) OR +(l_shipmode =3D 'AIR REG'::bpchar)) AND (l_shipinstruct =3D 'DELIVER IN +PERSON'::bpchar)) + -> Hash (cost=3D95213.75..95213.75 rows=3D2500296 +width=3D36) + -> Seq Scan on part (cost=3D0.00..95213.75 +rows=3D2500296 width=3D36) + Filter: (p_size >=3D 1) +(13 rows) +=20 +>> Time: 424981.813 ms +> ...and this implies ~425secs @ ~500MBps =3D> 212.5GB + +I've attached this explain plan because it's large. Same thing applies as +in previous, all of the involved tables are scanned, and in this case we've +got all manner of CPU work being performed: sorts, hashes, aggregations,... + +> What are the IO rates during these joins? + +They burst then disappear during the progression of the queries. These are +now CPU bound because the I/O available to each CPU is so fast. + +> How much data is being handled to complete these joins? + +See above, basically all of it because there are no indexes. +=20 +> How much data is being exchanged between these machines to complete the j= +oins? + +Good question, you can infer it from reading the EXPLAIN plans, but the +stats are not what they appear - generally multiply them by 8. +=20 +> What is the connectivity between these 4 machines? + +See above. +=20 +> Putting these numbers in context may help the advocacy effort +> considerably as well as help us improve things even further. ;-) + +Thanks! (bait bait) I can safely say that there have never been query +speeds with Postgres this fast, not even close. (bait bait) + +What's next is a machine 4 or maybe 8 times this fast. + +Explain for second query is attached, compressed with gzip (it=B9s kinda +huge). + +- Luke + + + +--B_3223698593_18201262 +Content-Type: application/octet-stream; + name=q2-explain.txt.gz +Content-Disposition: attachment; + filename=q2-explain.txt.gz +Content-Transfer-Encoding: base64 + +H4sICKd7AEQAA3EyLWV4cGxhaW4udHh0AN1ZW2/bNhh9968gAgxJgJYgxasMeEDaZR26NOsS +9GFPhmKriVBH0iQFrffQ3z5SlHWzfJNlW+15cAgCIQ+/G88nAnB4/P3p+u4f8PHm6vYIm4HB +658OA3DjPXsJABeTIE5GmCCKLQyRhDAf2yAKvsYjDL560+RpZGF2OVDWeP0rAO+c5MmNwIcg +8QK/zSIGH9zo0QV/uvMhiGE8diaT5MGZvQI+9Me+8+y+SqfNKIThOHSi5Is7LxbQXFofpAy9 +0H0Q7b2OQbrSHseqM/vDiZ/A+8DLTW1jTIQNZZmd2JadQbrm28CfDsHFWfCSuNFZSkp7VJEB +I3Dm+b6e9YvZtStqpnfu1IuTyHtQC9bCI+UsIGMZZyyhIFXO2EZrdygxN9YtmG3+N03v1o0T +dwpugiBcRwu3oWWQeul3b6bsqQ2bmTAexy9hmJk1M3aYT269+A4WtmyJBFV/q0chYuvNDApj +F3x3W2F1ANeooj2plgjX4lpRz3KsFNZ53rXaptnPz54/VpvpIy57ejbX8612S8uT+y+4nzg+ +UA7XzPWSyikLiyKIEISEcM64Gma2RAhJ9ZMHcuvdU7MuOy8fVn3H221UbGduhnLESGkzi0D7 +QJsamG3r0dN58NRPuyanhZSIScgohBLZTB2fLIqmxbkUi2ThexMxKOX7+ntpV6RedZRBPWfm +/eeCz0EEpq4znQWTLyB2PrvJvOHMwpbYJpDl8YwJtXnXhy4YvouCl/Dq8TFyHxXXnBC3sSKE +NSHJhFBD0eCEDTfuHqya5NYpSRmU5FvHwbKMfjqnznC5bFXYEcYxxOwU7Aya61v3t+OuqMtv +iinlDApV7NVQSAvSk/i0jELUL27fkuWOR6NRTnFpc6jqJKSICEtCap3aWgYrxFhJDNcF8tEp +rpRWh9dV+9IuazIuuLombQizgeHJCCEsI0mPzrFg+iYKnOnEUaq4eodZkFg9pFwQX8q0jDHW +jKVhzDkXvSBs0H1jfxzUEzFtmTwleyqJSKm6DBBdlDeG1NjYXvbkDOWstKClUlL/ZoRxjwLF +YF16Yohwz+kbNKbqgj2ufRnrG3mDprT1x0rqLqVtVMz28iQbOlqTxzj/NNWn/F2FoisuuaS/ +dOul1JT5ugMWVbTfDqiXVJPV+vdHyGqDuj9MCC354wc6kUH+/TNKXzNUjTq//nT318fr8+Hw +IZw8OdFJukfCKLeVUFNXL+HIpgSKLNS1XmAUncDA1e5x06PPIdDU6FRDUKouUnXa6DC2Wnpi +Q1j3+FTJ6cWQZwmQf+AjHXmoZP2uTd9o1lr3mJ0vf+Ho/HwGeTpehONYf2MdAdXzg6vb39Kp +ZB66l8Nh4n5LwPfv4PyXN3dX9/fnZuZyp0eoRp0eb6vUMccbHxKrKlr3XPq39kK0jflWSUPW +ekWDJr0WNeo1v4VeW6fKcwGVhZNsmaIrbqXoMPdSh3dFgySgTYJm5xfEFbppo3LSG11wU70u +B4P/AWxN+JcCIwAA + +--B_3223698593_18201262-- + + +From pgsql-performance-owner@postgresql.org Sat Feb 25 12:03:09 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 8C6819DD622 + for ; + Sat, 25 Feb 2006 12:03:05 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 04483-07 + for ; + Sat, 25 Feb 2006 12:03:03 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx1.surnet.cl (mx1.surnet.cl [216.155.73.180]) + by postgresql.org (Postfix) with ESMTP id C11C59DD620 + for ; + Sat, 25 Feb 2006 12:03:02 -0400 (AST) +Received: from unknown (HELO cluster.surnet.cl) ([216.155.73.165]) + by mx1.surnet.cl with ESMTP; 25 Feb 2006 13:24:38 -0300 +X-IronPort-AV: i="4.02,145,1139194800"; + d="scan'208"; a="41167004:sNHT29330812" +Received: from alvh.no-ip.org (201.221.201.125) by cluster.surnet.cl (7.0.043) + (authenticated as alvherre@surnet.cl) + id 43A978FD0083DCB1; Sat, 25 Feb 2006 13:03:01 -0300 +Received: by alvh.no-ip.org (Postfix, from userid 1000) + id EE32EC2C2DD; Sat, 25 Feb 2006 13:03:00 -0300 (CLST) +Date: Sat, 25 Feb 2006 13:03:00 -0300 +From: Alvaro Herrera +To: Eric Lauzon +Cc: pgsql-performance@postgresql.org +Subject: Re: Schema vs Independant Databases, ACLS,Overhead,pg_hba.conf +Message-ID: <20060225160300.GD4756@surnet.cl> +Mail-Followup-To: Eric Lauzon , + pgsql-performance@postgresql.org +References: +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: + +User-Agent: Mutt/1.5.11+cvs20060126 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=1.577 required=5 tests=[AWL=-0.342, + DNS_FROM_RFC_ABUSE=0.479, DNS_FROM_RFC_POST=1.44] +X-Spam-Score: 1.577 +X-Spam-Level: * +X-Archive-Number: 200602/408 +X-Sequence-Number: 17394 + +Eric Lauzon wrote: + +Hi, + +> Now that the issue is that we can't implement a per connection user/ACL +> pair , would it be a good idea to implement +> Schema ACLS and mabey pg_hba.conf Schema acls + +This is certainly possible to do using GRANT and REVOKE on the schemas; +no need to fool with pg_hba.conf. You can of course create groups/roles +to simplify the assignment of privileges, as needed. + +Apart from the much more efficient queries (i.e. using cross-schema +queries instead of dblink), I don't think you're going to see much +change in performance, because most things like WAL and shared buffers +are shared among all databases anyway. You'd save a bit by not having +multiple copies of system caches (pg_class cache, etc), but I wouldn't +know if that's going to be very noticeable next to the primary +improvement. + +-- +Alvaro Herrera http://www.CommandPrompt.com/ +The PostgreSQL Company - Command Prompt, Inc. + +From pgsql-performance-owner@postgresql.org Mon Feb 27 06:03:03 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id CF2119DC9E3 + for ; + Mon, 27 Feb 2006 06:03:02 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 92318-06 + for ; + Mon, 27 Feb 2006 06:03:03 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from bilbao.pandasoftware.es (unknown [62.14.249.71]) + by postgresql.org (Postfix) with ESMTP id CB4989DC9DD + for ; + Mon, 27 Feb 2006 06:02:58 -0400 (AST) +Received: from escorpexh05.pandasoftware.local (escorpext02 [192.168.100.182]) + by bilbao.pandasoftware.es (Postfix) with ESMTP id AB9301B3708 + for ; + Mon, 27 Feb 2006 11:02:39 +0100 (CET) +Received: from ESCORPEXH03.pandasoftware.local ([172.16.0.70]) by + escorpexh05.pandasoftware.local with Microsoft + SMTPSVC(6.0.3790.211); Mon, 27 Feb 2006 11:02:59 +0100 +Received: escorpexh03.pandasoftware.local 172.16.0.73 from 172.16.128.4 + 172.16.128.4 via HTTP with MS-WebStorage 6.5.6944 +Received: from pndsoft by escorpexh03.pandasoftware.local; + 27 Feb 2006 11:03:43 +0100 +Subject: fsync and battery-backed caches +From: Javier Somoza +To: pgsql-performance@postgresql.org +Content-Type: multipart/alternative; boundary="=-CXS6MWlqw4nzwTflLotv" +Message-Id: <1141034594.1556.15.camel@pndsoft> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Mon, 27 Feb 2006 11:03:14 +0100 +X-OriginalArrivalTime: 27 Feb 2006 10:02:59.0817 (UTC) + FILETIME=[FD4EF590:01C63B84] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=2.502 required=5 tests=[HTML_MESSAGE=0.001, + RAZOR2_CF_RANGE_51_100=0.5, RAZOR2_CF_RANGE_E8_51_100=1.5, + RAZOR2_CHECK=0.5, UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 2.502 +X-Spam-Level: ** +X-Archive-Number: 200602/409 +X-Sequence-Number: 17395 + + +--=-CXS6MWlqw4nzwTflLotv +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: quoted-printable + + + Hi all + + Is it secure to disable fsync havin battery-backed disk cache? + =20 + Thx + + +Javier Somoza +Oficina de Direcci=F3n Estrat=E9gica +mailto:jsomoza@pandasoftware.es + +Panda Software +Buenos Aires, 12 +48001 BILBAO - ESPA=D1A +Tel=E9fono: 902 24 365 4 +Fax: 94 424 46 97 +http://www.pandasoftware.es +Panda Software, una de las principales compa=F1=EDas desarrolladoras de +soluciones de protecci=F3n contra virus e intrusos, presenta su nueva +familia de soluciones. Todos los usuarios de ordenadores, desde las +redes m=E1s grandes a los dom=E9sticos, disponen ahora de nuevos productos +con excelentes tecnolog=EDas de seguridad. M=E1s informaci=F3n en: +http://www.pandasoftware.es/productos + + =20 + +=A1Prot=E9jase ahora contra virus e intrusos! Pruebe gratis nuestros +productos en http://www.pandasoftware.es/descargas/ + + =20 + =20 + =20 + =20 + =20 + =20 + =20 + =20 + +--=-CXS6MWlqw4nzwTflLotv +Content-Type: text/html; charset=utf-8 + + + + + + + + +
+        Hi all
+
+        Is it secure to disable fsync havin battery-backed disk cache?
+               
+        Thx
+
+
+ + + + +
+Javier Somoza
+Oficina de Dirección Estratégica

+mailto:jsomoza@pandasoftware.es
+
+Panda Software
+Buenos Aires, 12
+48001 BILBAO - ESPAÑA
+Teléfono: 902 24 365 4
+Fax:  94 424 46 97

+http://www.pandasoftware.es
+Panda Software, una de las principales compañías desarrolladoras de soluciones de protección contra virus e intrusos, presenta su nueva familia de soluciones. Todos los usuarios de ordenadores, desde las redes más grandes a los domésticos, disponen ahora de nuevos productos con excelentes tecnologías de seguridad. Más información en: http://www.pandasoftware.es/productos +
    +
    +
+¡Protéjase ahora contra virus e intrusos! Pruebe gratis nuestros productos en http://www.pandasoftware.es/descargas/ +
    +
      +
      +
      +
    +
    +
    +
    +
    +
    +
    +
+
+ + + + +--=-CXS6MWlqw4nzwTflLotv-- + +From pgsql-performance-owner@postgresql.org Mon Feb 27 06:13:10 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id D428C9DC9A8 + for ; + Mon, 27 Feb 2006 06:13:09 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 93836-05 + for ; + Mon, 27 Feb 2006 06:13:11 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from service-web.de (p15093784.pureserver.info [217.160.106.224]) + by postgresql.org (Postfix) with ESMTP id CAB179DC825 + for ; + Mon, 27 Feb 2006 06:13:07 -0400 (AST) +Received: from [10.100.1.50] (074-016-066-080.eggenet.de [80.66.16.74]) + by service-web.de (Postfix) with ESMTP id 5463920002A; + Mon, 27 Feb 2006 11:13:09 +0100 (CET) +Message-ID: <4402D0A9.7080705@wildenhain.de> +Date: Mon, 27 Feb 2006 11:12:57 +0100 +From: Tino Wildenhain +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050929) +X-Accept-Language: de-DE, de, en-us, en +MIME-Version: 1.0 +To: Javier Somoza +Cc: pgsql-performance@postgresql.org +Subject: Re: fsync and battery-backed caches +References: <1141034594.1556.15.camel@pndsoft> +In-Reply-To: <1141034594.1556.15.camel@pndsoft> +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, score=0.103 required=5 tests=[AWL=0.103] +X-Spam-Score: 0.103 +X-Spam-Level: +X-Archive-Number: 200602/410 +X-Sequence-Number: 17396 + +Javier Somoza schrieb: +> +> Hi all +> +> Is it secure to disable fsync havin battery-backed disk cache? +> +> Thx +> +No. fsync moves the data from OS memory cache to disk-adaptor +cache which is required to benefit from battery backup. + +If this data is written to the plates immediately depends on settings +of your disk adaptor card. + +Regards +Tino + +From pgsql-performance-owner@postgresql.org Mon Feb 27 08:08:22 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id E5F819DC9B9 + for ; + Mon, 27 Feb 2006 08:08:21 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 10821-08 + for ; + Mon, 27 Feb 2006 08:08:24 -0400 (AST) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id D1B8E9DC825 + for ; + Mon, 27 Feb 2006 08:08:19 -0400 (AST) +Received: from office1.i-free.ru (office1.i-free.ru [81.222.216.82]) + by svr4.postgresql.org (Postfix) with ESMTP id 9E98F5AF0AE + for ; + Mon, 27 Feb 2006 12:08:22 +0000 (GMT) +Received: from [192.168.0.250] (helo=deepcore.i-free.ru) + by office1.i-free.ru with smtp (Exim 3.36 #1 (Debian)) + id 1FDhAo-0004II-00 + for ; Mon, 27 Feb 2006 15:08:18 +0300 +Date: Mon, 27 Feb 2006 15:08:19 +0300 +From: Evgeny Gridasov +To: pgsql-performance@postgresql.org +Subject: wal sync method +Message-Id: <20060227150819.48e48a85.eugrid@fpm.kubsu.ru> +In-Reply-To: <5709.1128146518@sss.pgh.pa.us> +References: + <1128015863.11474.9.camel@noodles> <5709.1128146518@sss.pgh.pa.us> +X-Mailer: Sylpheed version 2.2.0 (GTK+ 2.6.2; i686-pc-linux-gnu) +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.1 required=5 tests=[AWL=0.100] +X-Spam-Score: 0.1 +X-Spam-Level: +X-Archive-Number: 200602/411 +X-Sequence-Number: 17397 + +Hi everybody! + +Which wal sync method is the fastest under linux 2.6.x? +I'm using RAID-10 (JFS filesystem), 2xXEON, 4 Gb RAM. + +I've tried to switch to open_sync which seems to work +faster than default fdatasync, but is it crash-safe? + +-- +Evgeny Gridasov +Software Engineer +I-Free, Russia + +From pgsql-performance-owner@postgresql.org Mon Feb 27 08:28:41 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 34EB59DC825 + for ; + Mon, 27 Feb 2006 08:28:41 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 10163-10 + for ; + Mon, 27 Feb 2006 08:28:43 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from bilbao.pandasoftware.es (unknown [62.14.249.71]) + by postgresql.org (Postfix) with ESMTP id 06F789DC81A + for ; + Mon, 27 Feb 2006 08:28:36 -0400 (AST) +Received: from escorpexh05.pandasoftware.local (escorpext02 [192.168.100.182]) + by bilbao.pandasoftware.es (Postfix) with ESMTP + id C71BE1B382E; Mon, 27 Feb 2006 13:28:16 +0100 (CET) +Received: from ESCORPEXH03.pandasoftware.local ([172.16.0.70]) by + escorpexh05.pandasoftware.local with Microsoft + SMTPSVC(6.0.3790.211); Mon, 27 Feb 2006 13:28:35 +0100 +Received: escorpexh03.pandasoftware.local 172.16.0.73 from 172.16.128.4 + 172.16.128.4 via HTTP with MS-WebStorage 6.5.6944 +Received: from pndsoft by escorpexh03.pandasoftware.local; + 27 Feb 2006 13:29:19 +0100 +Subject: Re: wal sync method +From: Javier Somoza +To: Evgeny Gridasov +Cc: pgsql-performance@postgresql.org +In-Reply-To: <20060227150819.48e48a85.eugrid@fpm.kubsu.ru> +References: + <1128015863.11474.9.camel@noodles> <5709.1128146518@sss.pgh.pa.us> + <20060227150819.48e48a85.eugrid@fpm.kubsu.ru> +Content-Type: multipart/alternative; boundary="=-h+pnIo7DFRbKVIrlmZMe" +Message-Id: <1141043359.1556.44.camel@pndsoft> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Mon, 27 Feb 2006 13:29:19 +0100 +X-OriginalArrivalTime: 27 Feb 2006 12:28:35.0832 (UTC) + FILETIME=[54610F80:01C63B99] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=2.582 required=5 tests=[AWL=0.080, + HTML_MESSAGE=0.001, RAZOR2_CF_RANGE_51_100=0.5, + RAZOR2_CF_RANGE_E8_51_100=1.5, RAZOR2_CHECK=0.5, + UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 2.582 +X-Spam-Level: ** +X-Archive-Number: 200602/412 +X-Sequence-Number: 17398 + + +--=-h+pnIo7DFRbKVIrlmZMe +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: quoted-printable + + + + + Hi Evgeny + + Im also testing what fsync method to use and using this program +(http://archives.postgresql.org/pgsql-performance/2003-12/msg00191.php) + a bit modified and i get this results: + + write 0.000036 + write & fsync 0.006796 + write & fdatasync 0.001001 + write (O_FSYNC) 0.005761 + write (O_DSYNC) 0.005894 + + So fdatasync faster for me?=20 + + +> Hi everybody! +>=20 +> Which wal sync method is the fastest under linux 2.6.x? +> I'm using RAID-10 (JFS filesystem), 2xXEON, 4 Gb RAM. +>=20 +> I've tried to switch to open_sync which seems to work=20 +> faster than default fdatasync, but is it crash-safe? + + + + +Javier Somoza +Oficina de Direcci=F3n Estrat=E9gica +mailto:jsomoza@pandasoftware.es + +Panda Software +Buenos Aires, 12 +48001 BILBAO - ESPA=D1A +Tel=E9fono: 902 24 365 4 +Fax: 94 424 46 97 +http://www.pandasoftware.es +Panda Software, una de las principales compa=F1=EDas desarrolladoras de +soluciones de protecci=F3n contra virus e intrusos, presenta su nueva +familia de soluciones. Todos los usuarios de ordenadores, desde las +redes m=E1s grandes a los dom=E9sticos, disponen ahora de nuevos productos +con excelentes tecnolog=EDas de seguridad. M=E1s informaci=F3n en: +http://www.pandasoftware.es/productos + + =20 + +=A1Prot=E9jase ahora contra virus e intrusos! Pruebe gratis nuestros +productos en http://www.pandasoftware.es/descargas/ + + =20 + =20 + =20 + =20 + =20 + =20 + =20 + =20 + +--=-h+pnIo7DFRbKVIrlmZMe +Content-Type: text/html; charset=utf-8 + + + + + + + + +
+
+
+        Hi Evgeny
+
+        Im also testing what fsync method to use and using this program (http://archives.postgresql.org/pgsql-performance/2003-12/msg00191.php)
+        a bit modified and i get this results:
+
+                write                          0.000036
+                write & fsync             0.006796
+                write & fdatasync      0.001001
+                write (O_FSYNC)        0.005761
+                write (O_DSYNC)        0.005894
+
+        So fdatasync faster for me?
+
+
+
Hi everybody!
+
+Which wal sync method is the fastest under linux 2.6.x?
+I'm using RAID-10 (JFS filesystem), 2xXEON, 4 Gb RAM.
+
+I've tried to switch to open_sync which seems to work 
+faster than default fdatasync, but is it crash-safe?
+
+
+
+

+
+
+
+
+Javier Somoza
+Oficina de Dirección Estratégica

+mailto:jsomoza@pandasoftware.es
+
+Panda Software
+Buenos Aires, 12
+48001 BILBAO - ESPAÑA
+Teléfono: 902 24 365 4
+Fax:  94 424 46 97

+http://www.pandasoftware.es
+Panda Software, una de las principales compañías desarrolladoras de soluciones de protección contra virus e intrusos, presenta su nueva familia de soluciones. Todos los usuarios de ordenadores, desde las redes más grandes a los domésticos, disponen ahora de nuevos productos con excelentes tecnologías de seguridad. Más información en: http://www.pandasoftware.es/productos +
    +
    +
+¡Protéjase ahora contra virus e intrusos! Pruebe gratis nuestros productos en http://www.pandasoftware.es/descargas/ +
    +
      +
      +
      +
    +
    +
    +
    +
    +
    +
    +
+
+
+ + + +--=-h+pnIo7DFRbKVIrlmZMe-- + +From pgsql-performance-owner@postgresql.org Mon Feb 27 08:42:54 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 41AEE9DC80C + for ; + Mon, 27 Feb 2006 08:42:54 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 14828-05 + for ; + Mon, 27 Feb 2006 08:42:57 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from bilbao.pandasoftware.es (unknown [62.14.249.71]) + by postgresql.org (Postfix) with ESMTP id 0E5BA9DCAC4 + for ; + Mon, 27 Feb 2006 08:42:49 -0400 (AST) +Received: from escorpexh05.pandasoftware.local (escorpext02 [192.168.100.182]) + by bilbao.pandasoftware.es (Postfix) with ESMTP id 966AC1B34AF + for ; + Mon, 27 Feb 2006 13:42:32 +0100 (CET) +Received: from ESCORPEXH03.pandasoftware.local ([172.16.0.70]) by + escorpexh05.pandasoftware.local with Microsoft + SMTPSVC(6.0.3790.211); Mon, 27 Feb 2006 13:42:52 +0100 +Received: escorpexh03.pandasoftware.local 172.16.0.73 from 172.16.128.4 + 172.16.128.4 via HTTP with MS-WebStorage 6.5.6944 +Received: from pndsoft by escorpexh03.pandasoftware.local; + 27 Feb 2006 13:43:36 +0100 +Subject: Setting the shared buffers +From: Javier Somoza +To: pgsql-performance@postgresql.org +Content-Type: multipart/alternative; boundary="=-XxeEkJty47c36Sq500Bz" +Message-Id: <1141044216.1556.54.camel@pndsoft> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Mon, 27 Feb 2006 13:43:36 +0100 +X-OriginalArrivalTime: 27 Feb 2006 12:42:52.0852 (UTC) + FILETIME=[5333EF40:01C63B9B] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=2.598 required=5 tests=[AWL=0.096, + HTML_MESSAGE=0.001, RAZOR2_CF_RANGE_51_100=0.5, + RAZOR2_CF_RANGE_E8_51_100=1.5, RAZOR2_CHECK=0.5, + UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 2.598 +X-Spam-Level: ** +X-Archive-Number: 200602/413 +X-Sequence-Number: 17399 + + +--=-XxeEkJty47c36Sq500Bz +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: quoted-printable + + + Hi, + + How should i set this configuration? Depending on the +memory? + And then is it necessary to perform a benchmarking test? + + What did you do? + + Thx! + =20 + + +Javier Somoza +Oficina de Direcci=F3n Estrat=E9gica +mailto:jsomoza@pandasoftware.es + +Panda Software +Buenos Aires, 12 +48001 BILBAO - ESPA=D1A +Tel=E9fono: 902 24 365 4 +Fax: 94 424 46 97 +http://www.pandasoftware.es +Panda Software, una de las principales compa=F1=EDas desarrolladoras de +soluciones de protecci=F3n contra virus e intrusos, presenta su nueva +familia de soluciones. Todos los usuarios de ordenadores, desde las +redes m=E1s grandes a los dom=E9sticos, disponen ahora de nuevos productos +con excelentes tecnolog=EDas de seguridad. M=E1s informaci=F3n en: +http://www.pandasoftware.es/productos + + =20 + +=A1Prot=E9jase ahora contra virus e intrusos! Pruebe gratis nuestros +productos en http://www.pandasoftware.es/descargas/ + + =20 + =20 + =20 + =20 + =20 + =20 + =20 + =20 + +--=-XxeEkJty47c36Sq500Bz +Content-Type: text/html; charset=utf-8 + + + + + + + + +
+            Hi,
+
+            How should i set this configuration? Depending on the memory?
+            And then is it necessary to perform a benchmarking test?
+
+            What did you do?
+
+            Thx!
+           
+
+
+ + + + +
+Javier Somoza
+Oficina de Dirección Estratégica

+mailto:jsomoza@pandasoftware.es
+
+Panda Software
+Buenos Aires, 12
+48001 BILBAO - ESPAÑA
+Teléfono: 902 24 365 4
+Fax:  94 424 46 97

+http://www.pandasoftware.es
+Panda Software, una de las principales compañías desarrolladoras de soluciones de protección contra virus e intrusos, presenta su nueva familia de soluciones. Todos los usuarios de ordenadores, desde las redes más grandes a los domésticos, disponen ahora de nuevos productos con excelentes tecnologías de seguridad. Más información en: http://www.pandasoftware.es/productos +
    +
    +
+¡Protéjase ahora contra virus e intrusos! Pruebe gratis nuestros productos en http://www.pandasoftware.es/descargas/ +
    +
      +
      +
      +
    +
    +
    +
    +
    +
    +
    +
+
+ + + + +--=-XxeEkJty47c36Sq500Bz-- + +From pgsql-performance-owner@postgresql.org Mon Feb 27 09:17:35 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 9C39F9DC9D3 + for ; + Mon, 27 Feb 2006 09:17:34 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 19537-06 + for ; + Mon, 27 Feb 2006 09:17:37 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.192]) + by postgresql.org (Postfix) with ESMTP id 465129DCB50 + for ; + Mon, 27 Feb 2006 09:17:32 -0400 (AST) +Received: by zproxy.gmail.com with SMTP id 8so885968nzo + for ; + Mon, 27 Feb 2006 05:17:35 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; + b=I3ZyR9iZtxHXTNyuFRjBNjRuZ3E0mcvt5O0/OvTQgg2TTpcHOAdA9cAQUBnEYKI3fZ3b42/sv41ogmz+uH9IekGAfZstx8hrjyV1VFODBrzpVlWYz4vDyhg3KMkosiDzEw36ZpwIAP8CFYyJ+QL+a+GGoAtcohloAUOoxAdZM60= +Received: by 10.65.183.8 with SMTP id k8mr456711qbp; + Mon, 27 Feb 2006 05:17:35 -0800 (PST) +Received: by 10.65.216.18 with HTTP; Mon, 27 Feb 2006 05:17:35 -0800 (PST) +Message-ID: +Date: Mon, 27 Feb 2006 14:17:35 +0100 +From: "Claus Guttesen" +To: "Javier Somoza" +Subject: Re: Setting the shared buffers +Cc: pgsql-performance@postgresql.org +In-Reply-To: <1141044216.1556.54.camel@pndsoft> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_1305_376649.1141046255574" +References: <1141044216.1556.54.camel@pndsoft> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.001 required=5 tests=[HTML_MESSAGE=0.001] +X-Spam-Score: 0.001 +X-Spam-Level: +X-Archive-Number: 200602/414 +X-Sequence-Number: 17400 + +------=_Part_1305_376649.1141046255574 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +> +> How should i set this configuration? Depending on the memory? +> And then is it necessary to perform a benchmarking test? + + +I've set it to 'shared_buffers =3D 12288' with 8 GB RAM on postgresql 7.4.9= +, +FreeBSD 6.0. There is no exact size, depends on type of workload, server-OS +etc. Adjust it up and down and see if your performance changes. + +regards +Claus + +------=_Part_1305_376649.1141046255574 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +
  = +          How should i set thi= +s configuration? Depending on the memory?
+            And then= + is it necessary to perform a benchmarking test?

I've = +set it to 'shared_buffers =3D 12288' with 8 GB RAM on postgresql 7.4.9, Fre= +eBSD 6.0. There is no exact size, depends on type of workload, server-OS et= +c. Adjust it up and down and see if your performance changes. +

regards
Claus

+ +------=_Part_1305_376649.1141046255574-- + +From pgsql-performance-owner@postgresql.org Mon Feb 27 09:31:37 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 81C849DC81A + for ; + Mon, 27 Feb 2006 09:31:36 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 22173-08 + for ; + Mon, 27 Feb 2006 09:31:39 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.ecircle.de (mail.ecircle.de [195.140.186.200]) + by postgresql.org (Postfix) with ESMTP id 9C91F9DC80C + for ; + Mon, 27 Feb 2006 09:31:33 -0400 (AST) +Received: from deimos.muc.ecircle.de (deimos.muc.ecircle.de [192.168.1.4]) + by mail.ecircle.de (READY) with ESMTP id E0B2E55C006 + for ; + Mon, 27 Feb 2006 14:31:36 +0100 (CET) +Received: from [192.168.1.110] ([192.168.1.110]) by deimos.muc.ecircle.de with + Microsoft SMTPSVC(5.0.2195.6713); Mon, 27 Feb 2006 14:31:36 +0100 +Subject: neverending vacuum +From: Csaba Nagy +To: postgres performance list +Content-Type: text/plain +Message-Id: <1141047092.6846.256.camel@coppola.muc.ecircle.de> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Mon, 27 Feb 2006 14:31:33 +0100 +Content-Transfer-Encoding: 7bit +X-OriginalArrivalTime: 27 Feb 2006 13:31:36.0757 (UTC) + FILETIME=[21FC6E50:01C63BA2] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.105 required=5 tests=[AWL=0.105] +X-Spam-Score: 0.105 +X-Spam-Level: +X-Archive-Number: 200602/415 +X-Sequence-Number: 17401 + +Hi all, + +Short story: + +I have a quite big table (about 200 million records, and ~2-3 million +updates/~1 million inserts/few thousand deletes per day). I started a +vacuum on it on friday evening, and it still runs now (monday +afternoon). I used "vacuum verbose", and the output looks like: + +INFO: vacuuming "public.big_table" +INFO: index "pk_big_table" now contains 223227480 row versions in +1069776 pages +DETAIL: 711140 index row versions were removed. +80669 index pages have been deleted, 80669 are currently reusable. +CPU 14.56s/46.42u sec elapsed 13987.65 sec. +INFO: index "idx_big_table_1" now contains 223229722 row versions in +740108 pages +DETAIL: 711140 index row versions were removed. +58736 index pages have been deleted, 58733 are currently reusable. +CPU 12.90s/94.97u sec elapsed 10052.12 sec. +INFO: index "idx_big_table_2" now contains 16779341 row versions in +55831 pages +DETAIL: 125895 index row versions were removed. +369 index pages have been deleted, 337 are currently reusable. +CPU 1.39s/5.81u sec elapsed 763.25 sec. +INFO: index "idx_big_table_3" now contains 472945 row versions in 2536 +pages +DETAIL: 5328 index row versions were removed. +595 index pages have been deleted, 595 are currently reusable. +CPU 0.06s/0.20u sec elapsed 35.36 sec. +INFO: index "idx_big_table_4" now contains 471419 row versions in 2537 +pages +DETAIL: 5318 index row versions were removed. +591 index pages have been deleted, 591 are currently reusable. +CPU 0.08s/0.21u sec elapsed 36.18 sec. +INFO: "big_table": removed 2795984 row versions in 413228 pages +DETAIL: CPU 22.19s/26.92u sec elapsed 5095.57 sec. +INFO: index "pk_big_table" now contains 221069840 row versions in +1069780 pages +DETAIL: 2162406 index row versions were removed. +90604 index pages have been deleted, 80609 are currently reusable. +CPU 7.77s/15.92u sec elapsed 13576.07 sec. +INFO: index "idx_big_table_1" now contains 221087391 row versions in +740109 pages +DETAIL: 2162406 index row versions were removed. +66116 index pages have been deleted, 58647 are currently reusable. +CPU 6.34s/23.22u sec elapsed 10592.02 sec. +INFO: index "idx_big_table_2" now contains 16782762 row versions in +55831 pages +DETAIL: 21 index row versions were removed. +355 index pages have been deleted, 323 are currently reusable. +CPU 0.24s/0.78u sec elapsed 651.89 sec. +INFO: index "idx_big_table_3" now contains 482084 row versions in 2536 +pages +DETAIL: 525 index row versions were removed. +561 index pages have been deleted, 561 are currently reusable. +CPU 0.04s/0.10u sec elapsed 36.80 sec. +INFO: index "idx_big_table_4" now contains 480575 row versions in 2537 +pages +DETAIL: 525 index row versions were removed. +558 index pages have been deleted, 558 are currently reusable. +CPU 0.07s/0.17u sec elapsed 39.37 sec. +INFO: "big_table": removed 2795985 row versions in 32975 pages +DETAIL: CPU 0.96s/0.30u sec elapsed 232.51 sec. +INFO: index "pk_big_table" now contains 218297352 row versions in +1069780 pages +DETAIL: 2795309 index row versions were removed. +103434 index pages have been deleted, 80489 are currently reusable. +CPU 10.40s/18.63u sec elapsed 14420.05 sec. +INFO: index "idx_big_table_1" now contains 218310055 row versions in +740109 pages +DETAIL: 2795309 index row versions were removed. +75674 index pages have been deleted, 58591 are currently reusable. +CPU 6.46s/23.33u sec elapsed 10495.41 sec. +INFO: index "idx_big_table_2" now contains 16782885 row versions in +55831 pages +DETAIL: 29 index row versions were removed. +354 index pages have been deleted, 322 are currently reusable. +CPU 0.24s/0.72u sec elapsed 653.09 sec. +INFO: index "idx_big_table_3" now contains 491320 row versions in 2536 +pages +DETAIL: 451 index row versions were removed. +529 index pages have been deleted, 529 are currently reusable. +CPU 0.02s/0.13u sec elapsed 36.83 sec. +INFO: index "idx_big_table_4" now contains 489798 row versions in 2537 +pages +DETAIL: 451 index row versions were removed. +522 index pages have been deleted, 522 are currently reusable. +CPU 0.03s/0.13u sec elapsed 36.50 sec. +INFO: "big_table": removed 2795957 row versions in 32947 pages +DETAIL: CPU 0.93s/0.28u sec elapsed 216.91 sec. +INFO: index "pk_big_table" now contains 215519688 row versions in +1069780 pages +DETAIL: 2793693 index row versions were removed. +115142 index pages have been deleted, 80428 are currently reusable. +CPU 7.97s/16.05u sec elapsed 14921.06 sec. +INFO: index "idx_big_table_1" now contains 215523269 row versions in +740109 pages +DETAIL: 2793693 index row versions were removed. +83819 index pages have been deleted, 58576 are currently reusable. +CPU 8.62s/34.15u sec elapsed 9607.76 sec. +INFO: index "idx_big_table_2" now contains 16780518 row versions in +55831 pages +DETAIL: 2385 index row versions were removed. +362 index pages have been deleted, 322 are currently reusable. +CPU 0.20s/0.73u sec elapsed 701.77 sec. +INFO: index "idx_big_table_3" now contains 492309 row versions in 2536 +pages +DETAIL: 1097 index row versions were removed. +520 index pages have been deleted, 520 are currently reusable. +CPU 0.06s/0.19u sec elapsed 39.09 sec. +INFO: index "idx_big_table_4" now contains 490789 row versions in 2537 +pages +DETAIL: 1090 index row versions were removed. +515 index pages have been deleted, 515 are currently reusable. +CPU 0.05s/0.17u sec elapsed 40.08 sec. +INFO: "big_table": removed 2795966 row versions in 33760 pages +DETAIL: CPU 1.40s/0.47u sec elapsed 273.16 sec. +INFO: index "pk_big_table" now contains 212731896 row versions in +1069780 pages +DETAIL: 2791935 index row versions were removed. +127577 index pages have been deleted, 80406 are currently reusable. +CPU 7.78s/16.26u sec elapsed 14241.76 sec. +INFO: index "idx_big_table_1" now contains 212738938 row versions in +740109 pages +DETAIL: 2791935 index row versions were removed. +93049 index pages have been deleted, 58545 are currently reusable. +CPU 9.57s/32.24u sec elapsed 9782.60 sec. +INFO: index "idx_big_table_2" now contains 16772407 row versions in +55831 pages +DETAIL: 8234 index row versions were removed. +390 index pages have been deleted, 322 are currently reusable. +CPU 0.22s/0.82u sec elapsed 658.90 sec. +INFO: index "idx_big_table_3" now contains 496310 row versions in 2536 +pages +DETAIL: 1719 index row versions were removed. +501 index pages have been deleted, 501 are currently reusable. +CPU 0.05s/0.19u sec elapsed 36.78 sec. +INFO: index "idx_big_table_4" now contains 494804 row versions in 2537 +pages +DETAIL: 1716 index row versions were removed. +497 index pages have been deleted, 497 are currently reusable. +CPU 0.02s/0.18u sec elapsed 36.32 sec. +INFO: "big_table": removed 2795961 row versions in 36659 pages +DETAIL: CPU 1.04s/0.60u sec elapsed 253.21 sec. +INFO: index "pk_big_table" now contains 209952007 row versions in +1069780 pages +DETAIL: 2791879 index row versions were removed. +140136 index pages have been deleted, 80292 are currently reusable. +CPU 9.00s/15.42u sec elapsed 14884.36 sec. +INFO: index "idx_big_table_1" now contains 209966255 row versions in +740109 pages +DETAIL: 2791879 index row versions were removed. +102429 index pages have been deleted, 58476 are currently reusable. +CPU 7.78s/21.55u sec elapsed 11868.99 sec. +INFO: index "idx_big_table_2" now contains 16772692 row versions in +55831 pages +DETAIL: 107 index row versions were removed. +391 index pages have been deleted, 322 are currently reusable. +CPU 0.29s/0.94u sec elapsed 804.51 sec. +INFO: index "idx_big_table_3" now contains 506561 row versions in 2536 +pages +DETAIL: 1741 index row versions were removed. +460 index pages have been deleted, 460 are currently reusable. +CPU 0.06s/0.20u sec elapsed 70.12 sec. +INFO: index "idx_big_table_4" now contains 505063 row versions in 2537 +pages +DETAIL: 1741 index row versions were removed. +453 index pages have been deleted, 453 are currently reusable. +CPU 0.07s/0.15u sec elapsed 67.72 sec. +INFO: "big_table": removed 2795955 row versions in 33272 pages +DETAIL: CPU 0.95s/0.30u sec elapsed 436.58 sec. +INFO: index "pk_big_table" now contains 207177253 row versions in +1069780 pages +DETAIL: 2793516 index row versions were removed. +153135 index pages have been deleted, 80210 are currently reusable. +CPU 9.73s/16.60u sec elapsed 16165.25 sec. +INFO: index "idx_big_table_1" now contains 207181989 row versions in +740109 pages +DETAIL: 2793516 index row versions were removed. +112028 index pages have been deleted, 58454 are currently reusable. +CPU 6.60s/19.69u sec elapsed 10805.05 sec. +INFO: index "idx_big_table_2" now contains 16772703 row versions in +55831 pages +DETAIL: 16 index row versions were removed. +391 index pages have been deleted, 322 are currently reusable. +CPU 0.38s/1.10u sec elapsed 618.92 sec. +INFO: index "idx_big_table_3" now contains 508312 row versions in 2536 +pages +DETAIL: 1860 index row versions were removed. +447 index pages have been deleted, 447 are currently reusable. +CPU 0.05s/0.15u sec elapsed 39.21 sec. +INFO: index "idx_big_table_4" now contains 506796 row versions in 2537 +pages +DETAIL: 1860 index row versions were removed. +441 index pages have been deleted, 441 are currently reusable. +CPU 0.06s/0.16u sec elapsed 37.47 sec. +INFO: "big_table": removed 2796014 row versions in 33014 pages +DETAIL: CPU 0.64s/0.22u sec elapsed 231.78 sec. +INFO: index "pk_big_table" now contains 204387243 row versions in +1069780 pages +DETAIL: 2795393 index row versions were removed. +166053 index pages have been deleted, 80186 are currently reusable. +CPU 10.27s/19.48u sec elapsed 14750.33 sec. +INFO: index "idx_big_table_1" now contains 204393784 row versions in +740109 pages +DETAIL: 2795393 index row versions were removed. +121640 index pages have been deleted, 58403 are currently reusable. +CPU 7.23s/19.34u sec elapsed 10932.43 sec. +INFO: index "idx_big_table_2" now contains 16772967 row versions in +55831 pages +DETAIL: 7 index row versions were removed. +389 index pages have been deleted, 320 are currently reusable. +CPU 0.32s/0.85u sec elapsed 744.28 sec. +INFO: index "idx_big_table_3" now contains 513406 row versions in 2536 +pages +DETAIL: 507 index row versions were removed. +429 index pages have been deleted, 429 are currently reusable. +CPU 0.04s/0.16u sec elapsed 47.37 sec. +INFO: index "idx_big_table_4" now contains 511904 row versions in 2537 +pages +DETAIL: 507 index row versions were removed. +422 index pages have been deleted, 422 are currently reusable. +CPU 0.06s/0.14u sec elapsed 44.98 sec. +INFO: "big_table": removed 2795974 row versions in 32926 pages +DETAIL: CPU 1.14s/0.36u sec elapsed 287.30 sec. + + +Now the question: + +I wonder why the repeated infos about all the steps ? Is vacuum in some +kind of loop here ? + + +Now the long story and why the long vacuum is a problem for me: + +I have a postgres 8.1.3 (actually it's a non-released CVS version from +the 8.1 stable branch somewhere after 8.1.3 was released) installation +where I have a quite big table which is also frequently updated. + +The big problem is that I can't run vacuum on it, because it won't +finish in the maintenance time window I can allocate for it. + +I would let vacuum run on it as long as it's finished, but then I get a +huge performance hit on other tables, which are heavily +inserted/deleted, and must be vacuumed very frequently. +The long running vacuum on the big table will prevent effective vacuum +on those, they will get quickly too big, the system will slow down, the +big vacuum will be even slower, and so on. +One of these (normally small) tables is particularly a problem, as it +has a query running on it frequently (several times per second) which +requires a full table scan and can't be accelerated by any indexing. And +top that with the fact that it has a high insert/delete ratio when the +system is busy... I can't afford any long running transaction in busy +times on this system. + +So, after a clean dump/reload of this system coupled with migration to +8.1, I thought that vacuuming the big table will be possible over night +(it has about 200 million records, and ~2-3 million updates/~1 million +inserts/few thousand deletes per day). +But to my surprise it was not enough, and it affected very negatively +other maintenance tasks too, so I had to cancel nightly vacuuming for +it. + +So I scheduled the vacuum over the weekend, when we have only light +activity on this system. But it did not finish over the weekend +either... and again it affected all other activities too much. I had to +kill the vacuum (on monday) in the last few weeks, as it was stopping +business. + +So we started to suspect that there is some concurrency problem with +either our hardware or OS, and moved the server to another machine with +the same hardware, same OS (debian linux), all the same settings but a +different file system (XFS instead of ext3). + +We actually have seen a significant overall performance boost from this +simple move... But the vacuum still didn't finish over the weekend, it +just didn't affect anymore the other tasks, which finished slightly +slower than when running alone. The vacuum itself wouldn't be a problem +performance-wise, except it is a long running transaction, and it +affects other table's vacuuming schedule, as mentioned above. Business +hours are coming, and I will have to kill the vacuum again... + +Cheers, +Csaba. + + + +From pgsql-performance-owner@postgresql.org Mon Feb 27 10:31:52 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id DA9D99DCB62 + for ; + Mon, 27 Feb 2006 10:31:51 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34241-05 + for ; + Mon, 27 Feb 2006 10:31:55 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx2.surnet.cl (mx2.surnet.cl [216.155.73.181]) + by postgresql.org (Postfix) with ESMTP id 6BD469DCB4C + for ; + Mon, 27 Feb 2006 10:31:49 -0400 (AST) +Received: from unknown (HELO cluster.surnet.cl) ([216.155.73.165]) + by mx2.surnet.cl with ESMTP; 27 Feb 2006 11:52:45 -0300 +X-IronPort-AV: i="3.99,385,1131332400"; + d="scan'208"; a="31826432:sNHT22548868" +Received: from alvh.no-ip.org (201.220.123.141) by cluster.surnet.cl (7.0.043) + (authenticated as alvherre@surnet.cl) + id 43A978FD00866C1C; Mon, 27 Feb 2006 11:31:53 -0300 +Received: by alvh.no-ip.org (Postfix, from userid 1000) + id 34262C3A397; Mon, 27 Feb 2006 11:31:53 -0300 (CLST) +Date: Mon, 27 Feb 2006 11:31:53 -0300 +From: Alvaro Herrera +To: Csaba Nagy +Cc: postgres performance list +Subject: Re: neverending vacuum +Message-ID: <20060227143153.GC5755@surnet.cl> +Mail-Followup-To: Csaba Nagy , + postgres performance list +References: <1141047092.6846.256.camel@coppola.muc.ecircle.de> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1141047092.6846.256.camel@coppola.muc.ecircle.de> +User-Agent: Mutt/1.5.11+cvs20060126 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=1.731 required=5 tests=[AWL=-0.188, + DNS_FROM_RFC_ABUSE=0.479, DNS_FROM_RFC_POST=1.44] +X-Spam-Score: 1.731 +X-Spam-Level: * +X-Archive-Number: 200602/416 +X-Sequence-Number: 17402 + +Csaba Nagy wrote: + +> I have a quite big table (about 200 million records, and ~2-3 million +> updates/~1 million inserts/few thousand deletes per day). I started a +> vacuum on it on friday evening, and it still runs now (monday +> afternoon). I used "vacuum verbose", and the output looks like: +> +> [vacuums list all the indexes noting how many tuples it cleaned, then +> "restarts" and lists all the indexes again, then again ... ad nauseam] + +What happens is this: the vacuum commands scans the heap and notes which +tuples need to be removed. It needs to remember them in memory, but +memory is limited; it uses the maintenance_work_mem GUC setting to +figure out how much to use. Within this memory it needs to store the +TIDs (absolute location) of tuples that need to be deleted. When the +memory is filled, it stops scanning the heap and scans the first index, +looking for pointers to any of the tuples that were deleted in the heap. +Eventually it finds them all and goes to the next index: scan, delete +pointers. Next index. And so on, until all the indexes are done. + +At this point, the first pass is done. Vacuum must then continue +scanning the heap for the next set of TIDs, until it finds enough to +fill maintenance_work_mem. Scan the indexes to clean them. Start +again. And again. + +So one very effective way of speeding this process up is giving the +vacuum process lots of memory, because it will have to do fewer passes +at each index. How much do you have? + +-- +Alvaro Herrera http://www.CommandPrompt.com/ +PostgreSQL Replication, Consulting, Custom Development, 24x7 support + +From pgsql-performance-owner@postgresql.org Tue Feb 28 22:51:29 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 97B079DCB4C + for ; + Mon, 27 Feb 2006 10:48:08 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 36304-02 + for ; + Mon, 27 Feb 2006 10:48:12 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id A37759DCB7C + for ; + Mon, 27 Feb 2006 10:48:05 -0400 (AST) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 9349430C21; Mon, 27 Feb 2006 15:48:09 +0100 (MET) +From: "Nik" +X-Newsgroups: pgsql.performance +Subject: Large Table With Only a Few Rows +Date: 27 Feb 2006 06:48:02 -0800 +Organization: http://groups.google.com +Lines: 122 +Message-ID: <1141051682.534005.194130@v46g2000cwv.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.8.0.1) Gecko/20060111 + Firefox/1.5.0.1,gzip(gfe),gzip(gfe) +Complaints-To: groups-abuse@google.com +Injection-Info: v46g2000cwv.googlegroups.com; posting-host=128.8.215.134; + posting-account=IbeoPg0AAADFgBNlhrpbQJcn64xCVhww +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.152 required=5 tests=[AWL=0.152] +X-Spam-Score: 0.152 +X-Spam-Level: +X-Archive-Number: 200602/450 +X-Sequence-Number: 17436 + +I have a table that has only a few records in it at the time, and they +get deleted every few seconds and new records are inserted. Table never +has more than 5-10 records in it. + +However, I noticed a deteriorating performance in deletes and inserts +on it. So I performed vacuum analyze on it three times (twice in a row, +and once two days later). In the statistics it says that the table size +is 863Mb, toast table size is 246Mb, and indexes size is 134Mb, even +though the table has only 5-10 rows in it it. I was wondering how can I +reclaim all this space and improve the performance? + +Here are the outputs of my vacuum sessions: + +----------------------02/24/06 4:30PM---------------------- +INFO: vacuuming "incidents.php_sessions" +INFO: index "php_sessions_pkey" now contains 16 row versions in 17151 +pages +DETAIL: 878643 index row versions were removed. +16967 index pages have been deleted, 8597 are currently reusable. +CPU 3.35s/3.67u sec elapsed 25.96 sec. +INFO: "php_sessions": removed 878689 row versions in 107418 pages +DETAIL: CPU 17.53s/11.23u sec elapsed 88.22 sec. +INFO: "php_sessions": found 878689 removable, 14 nonremovable row +versions in 110472 pages +DETAIL: 10 dead row versions cannot be removed yet. +There were 87817 unused item pointers. +0 pages are entirely empty. +CPU 23.87s/16.57u sec elapsed 124.54 sec. +INFO: vacuuming "pg_toast.pg_toast_47206" +INFO: index "pg_toast_47206_index" now contains 550 row versions in +11927 pages +DETAIL: 1415130 index row versions were removed. +11901 index pages have been deleted, 6522 are currently reusable. +CPU 1.45s/2.15u sec elapsed 20.62 sec. +INFO: "pg_toast_47206": removed 1415130 row versions in 353787 pages +DETAIL: CPU 56.92s/32.12u sec elapsed 592.18 sec. +INFO: "pg_toast_47206": found 1415130 removable, 114 nonremovable row +versions in 353815 pages +DETAIL: 114 dead row versions cannot be removed yet. +There were 0 unused item pointers. +0 pages are entirely empty. +CPU 87.42s/43.06u sec elapsed 939.62 sec. +INFO: analyzing "incidents.php_sessions" +INFO: "php_sessions": scanned 3000 of 110479 pages, containing 0 live +rows and 16 dead rows; 0 rows in sample, 0 estimated total rows + +Total query runtime: 1064249 ms. + + +----------------------02/24/06 5:00PM---------------------- +INFO: vacuuming "incidents.php_sessions" +INFO: index "php_sessions_pkey" now contains 4 row versions in 17151 +pages +DETAIL: 783 index row versions were removed. +17137 index pages have been deleted, 17129 are currently reusable. +CPU 0.31s/0.20u sec elapsed 13.89 sec. +INFO: "php_sessions": removed 784 row versions in 87 pages +DETAIL: CPU 0.00s/0.01u sec elapsed 0.01 sec. +INFO: "php_sessions": found 784 removable, 3 nonremovable row versions +in 110479 pages +DETAIL: 0 dead row versions cannot be removed yet. +There were 966202 unused item pointers. +0 pages are entirely empty. +CPU 1.21s/0.79u sec elapsed 15.82 sec. +INFO: vacuuming "pg_toast.pg_toast_47206" +INFO: index "pg_toast_47206_index" now contains 310 row versions in +11927 pages +DETAIL: 1830 index row versions were removed. +11922 index pages have been deleted, 11915 are currently reusable. +CPU 0.18s/0.12u sec elapsed 11.39 sec. +INFO: "pg_toast_47206": removed 1830 row versions in 465 pages +DETAIL: CPU 0.12s/0.04u sec elapsed 0.25 sec. +INFO: "pg_toast_47206": found 1830 removable, 30 nonremovable row +versions in 354141 pages +DETAIL: 20 dead row versions cannot be removed yet. +There were 1414680 unused item pointers. +0 pages are entirely empty. +CPU 16.07s/4.46u sec elapsed 200.87 sec. +INFO: "pg_toast_47206": truncated 354141 to 312 pages +DETAIL: CPU 8.32s/2.57u sec elapsed 699.85 sec. +INFO: analyzing "incidents.php_sessions" +INFO: "php_sessions": scanned 3000 of 110479 pages, containing 0 live +rows and 0 dead rows; 0 rows in sample, 0 estimated total rows + +Total query runtime: 924084 ms. + + +----------------------02/26/06 9:30AM---------------------- +INFO: vacuuming "incidents.php_sessions" +INFO: index "php_sessions_pkey" now contains 1 row versions in 17151 +pages +DETAIL: 46336 index row versions were removed. +17140 index pages have been deleted, 16709 are currently reusable. +CPU 0.20s/0.18u sec elapsed 13.96 sec. +INFO: "php_sessions": removed 46343 row versions in 4492 pages +DETAIL: CPU 0.25s/0.31u sec elapsed 2.42 sec. +INFO: "php_sessions": found 46343 removable, 1 nonremovable row +versions in 110479 pages +DETAIL: 0 dead row versions cannot be removed yet. +There were 948998 unused item pointers. +0 pages are entirely empty. +CPU 1.07s/0.90u sec elapsed 17.45 sec. +INFO: vacuuming "pg_toast.pg_toast_47206" +INFO: index "pg_toast_47206_index" now contains 50 row versions in +11927 pages +DETAIL: 125250 index row versions were removed. +11923 index pages have been deleted, 11446 are currently reusable. +CPU 0.25s/0.12u sec elapsed 11.79 sec. +INFO: "pg_toast_47206": removed 125250 row versions in 31316 pages +DETAIL: CPU 2.35s/1.79u sec elapsed 15.68 sec. +INFO: "pg_toast_47206": found 125250 removable, 32 nonremovable row +versions in 31436 pages +DETAIL: 30 dead row versions cannot be removed yet. +There were 456 unused item pointers. +0 pages are entirely empty. +CPU 4.39s/2.20u sec elapsed 37.92 sec. +INFO: analyzing "incidents.php_sessions" +INFO: "php_sessions": scanned 3000 of 110479 pages, containing 0 live +rows and 0 dead rows; 0 rows in sample, 0 estimated total rows + +Total query runtime: 55517 ms. + + +From pgsql-performance-owner@postgresql.org Mon Feb 27 11:03:45 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 758829DCBC4 + for ; + Mon, 27 Feb 2006 11:03:44 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37378-04 + for ; + Mon, 27 Feb 2006 11:03:48 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.ecircle.de (mail.ecircle.de [195.140.186.200]) + by postgresql.org (Postfix) with ESMTP id 785B59DCB4C + for ; + Mon, 27 Feb 2006 11:03:42 -0400 (AST) +Received: from deimos.muc.ecircle.de (deimos.muc.ecircle.de [192.168.1.4]) + by mail.ecircle.de (READY) with ESMTP id 1FE3855C008; + Mon, 27 Feb 2006 16:03:47 +0100 (CET) +Received: from [192.168.1.110] ([192.168.1.110]) by deimos.muc.ecircle.de with + Microsoft SMTPSVC(5.0.2195.6713); Mon, 27 Feb 2006 16:03:46 +0100 +Subject: Re: neverending vacuum +From: Csaba Nagy +To: Alvaro Herrera +Cc: postgres performance list +In-Reply-To: <20060227143153.GC5755@surnet.cl> +References: <1141047092.6846.256.camel@coppola.muc.ecircle.de> + <20060227143153.GC5755@surnet.cl> +Content-Type: text/plain +Message-Id: <1141052619.6846.263.camel@coppola.muc.ecircle.de> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Mon, 27 Feb 2006 16:03:40 +0100 +Content-Transfer-Encoding: 7bit +X-OriginalArrivalTime: 27 Feb 2006 15:03:46.0585 (UTC) + FILETIME=[02053890:01C63BAF] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.105 required=5 tests=[AWL=0.105] +X-Spam-Score: 0.105 +X-Spam-Level: +X-Archive-Number: 200602/417 +X-Sequence-Number: 17403 + +> So one very effective way of speeding this process up is giving the +> vacuum process lots of memory, because it will have to do fewer passes +> at each index. How much do you have? + +OK, this is my problem... it is left at default (16 megabyte ?). This +must be a mistake in configuration, on other similar boxes I set this to +262144 (256 megabyte). The box has 4 Gbyte memory. + +Thanks for the explanation - you were right on the spot, it will likely +solve the problem. + +Cheers, +Csaba. + + + + +From pgsql-performance-owner@postgresql.org Mon Feb 27 13:06:53 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 01C249DCA5E + for ; + Mon, 27 Feb 2006 13:06:52 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 56615-01 + for ; + Mon, 27 Feb 2006 13:06:51 -0400 (AST) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 5931D9DCA1C + for ; + Mon, 27 Feb 2006 13:06:50 -0400 (AST) +Received: from smtp1.clb.oleane.net (smtp1.clb.oleane.net [213.56.31.17]) + by svr4.postgresql.org (Postfix) with ESMTP id 026455AF04C + for ; + Mon, 27 Feb 2006 17:06:49 +0000 (GMT) +Received: from smtp1.clb.oleane.net (localhost [127.0.0.1]) + by smtp1.clb.oleane.net (antivirus) with ESMTP id k1RH6hES027901 + for ; Mon, 27 Feb 2006 18:06:43 +0100 +Received: from [192.168.8.219] ([62.160.127.238]) (authenticated) + by smtp1.clb.oleane.net with ESMTP id k1RH6dfp027703 + for ; Mon, 27 Feb 2006 18:06:39 +0100 +Message-ID: <44033246.9030808@elios-informatique.fr> +Date: Mon, 27 Feb 2006 18:09:26 +0100 +From: Jamal Ghaffour +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050716) +X-Accept-Language: fr, en +MIME-Version: 1.0 +To: postgres performance list +Subject: The trigger can be specified to fire on time condition? +Content-Type: multipart/mixed; boundary="------------010204020204050203090106" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.08 required=5 tests=[AWL=0.080] +X-Spam-Score: 0.08 +X-Spam-Level: +X-Archive-Number: 200602/418 +X-Sequence-Number: 17404 + +This is a multi-part message in MIME format. +--------------010204020204050203090106 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Hi All, +I ' m using the postgresql datbase to stores cookies. Theses cookies +become invalid after 30 mn and have to be deleted. i have defined a +procedure that will +delete all invalid cookies, but i don't know how to call it in loop way +(for example each hour). +I think that it possible because this behaivor is the same of the +autovaccum procedure that handle the vaccum process every time (60s in +default way). +After reading the documentation, it seems that triggers can't handle +this stuff . +how can i resolve the problem ? + + +Thanks + +--------------010204020204050203090106 +Content-Type: text/x-vcard; charset=utf-8; + name="Jamal.Ghaffour.vcf" +Content-Transfer-Encoding: 7bit +Content-Disposition: attachment; + filename="Jamal.Ghaffour.vcf" + +begin:vcard +fn:Jamal Ghaffour +n:Ghaffour;Jamal +org:ELIOS Informatique +adr;quoted-printable:;;1, sq de ch=C3=AAne Germain,;CESSON SEVIGNE;;35510;FRANCE +email;internet:Jamal.Ghaffour@elios-informatique.fr +tel;work:(+33) 2.99.63.85.30 +tel;fax:(+33) 2.99.63.85.93 +tel;home:(+33) 2 99 36 73 96 +tel;cell:(+33) 6.21.85.15.91 +url:http://www.elios-informatique.fr +version:2.1 +end:vcard + + +--------------010204020204050203090106-- + +From pgsql-performance-owner@postgresql.org Mon Feb 27 13:10:11 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 2EF619DCA1C + for ; + Mon, 27 Feb 2006 13:10:11 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 56438-08 + for ; + Mon, 27 Feb 2006 13:10:09 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx1.surnet.cl (mx1.surnet.cl [216.155.73.180]) + by postgresql.org (Postfix) with ESMTP id 6A8C19DCA5E + for ; + Mon, 27 Feb 2006 13:10:08 -0400 (AST) +Received: from unknown (HELO cluster.surnet.cl) ([216.155.73.165]) + by mx1.surnet.cl with ESMTP; 27 Feb 2006 14:32:19 -0300 +X-IronPort-AV: i="4.02,150,1139194800"; + d="scan'208"; a="42000940:sNHT18416052" +Received: from alvh.no-ip.org (201.220.123.141) by cluster.surnet.cl (7.0.043) + (authenticated as alvherre@surnet.cl) + id 43A978FD0086CA42; Mon, 27 Feb 2006 14:10:07 -0300 +Received: by alvh.no-ip.org (Postfix, from userid 1000) + id 72840C3A397; Mon, 27 Feb 2006 14:10:07 -0300 (CLST) +Date: Mon, 27 Feb 2006 14:10:07 -0300 +From: Alvaro Herrera +To: Jamal Ghaffour +Cc: postgres performance list +Subject: Re: The trigger can be specified to fire on time condition? +Message-ID: <20060227171007.GD6490@surnet.cl> +Mail-Followup-To: Jamal Ghaffour , + postgres performance list +References: <44033246.9030808@elios-informatique.fr> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <44033246.9030808@elios-informatique.fr> +User-Agent: Mutt/1.5.11+cvs20060126 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=1.724 required=5 tests=[AWL=-0.195, + DNS_FROM_RFC_ABUSE=0.479, DNS_FROM_RFC_POST=1.44] +X-Spam-Score: 1.724 +X-Spam-Level: * +X-Archive-Number: 200602/419 +X-Sequence-Number: 17405 + +Jamal Ghaffour wrote: +> Hi All, +> I ' m using the postgresql datbase to stores cookies. Theses cookies +> become invalid after 30 mn and have to be deleted. i have defined a +> procedure that will +> delete all invalid cookies, but i don't know how to call it in loop way +> (for example each hour). +> I think that it possible because this behaivor is the same of the +> autovaccum procedure that handle the vaccum process every time (60s in +> default way). +> After reading the documentation, it seems that triggers can't handle +> this stuff . +> how can i resolve the problem ? + +Use your system's crontab! (On Windows, "scheduled tasks" or whatever). + +-- +Alvaro Herrera http://www.CommandPrompt.com/ +The PostgreSQL Company - Command Prompt, Inc. + +From pgsql-performance-owner@postgresql.org Mon Feb 27 13:26:06 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 7CB6E9DCA1C + for ; + Mon, 27 Feb 2006 13:26:06 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 58769-07 + for ; + Mon, 27 Feb 2006 13:26:05 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id 006AF9DC8A5 + for ; + Mon, 27 Feb 2006 13:26:03 -0400 (AST) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 8CF2C30C21; Mon, 27 Feb 2006 18:26:03 +0100 (MET) +From: Chris Browne +X-Newsgroups: pgsql.performance +Subject: Re: Large Table With Only a Few Rows +Date: Mon, 27 Feb 2006 12:25:26 -0500 +Organization: cbbrowne Computing Inc +Lines: 36 +Message-ID: <60slq4zpbt.fsf@dba2.int.libertyrms.com> +References: <1141051682.534005.194130@v46g2000cwv.googlegroups.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@news.hub.org +User-Agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4.19 (linux) +Cancel-Lock: sha1:hvduhIutAzqnJYM6xKEEfoBgG9k= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.289 required=5 tests=[AWL=0.289] +X-Spam-Score: 0.289 +X-Spam-Level: +X-Archive-Number: 200602/420 +X-Sequence-Number: 17406 + +"Nik" writes: +> I have a table that has only a few records in it at the time, and they +> get deleted every few seconds and new records are inserted. Table never +> has more than 5-10 records in it. +> +> However, I noticed a deteriorating performance in deletes and inserts +> on it. So I performed vacuum analyze on it three times (twice in a row, +> and once two days later). In the statistics it says that the table size +> is 863Mb, toast table size is 246Mb, and indexes size is 134Mb, even +> though the table has only 5-10 rows in it it. I was wondering how can I +> reclaim all this space and improve the performance? + +You need to run VACUUM ANALYZE on this table very frequently. + +Based on what you describe, "very frequently" should be on the order +of at least once per minute. + +Schedule a cron job specifically to vacuum this table, with a cron +entry like the following: + +* * * * * /usr/local/bin/vacuumdb -z -t my_table -p 5432 my_database + +Of course, you need to bring it back down to size, first. + +You could run CLUSTER on the table to bring it back down to size; +that's probably the fastest way... + + cluster my_table_pk on my_table; + +VACUUM FULL would also do the job, but probably not as quickly. +-- +(reverse (concatenate 'string "gro.gultn" "@" "enworbbc")) +http://cbbrowne.com/info/sgml.html +"Now they can put you in jail if they *THINK* you're gonna commit a +crime. Let me say that again, because it sounds vaguely important" +--george carlin + +From pgsql-performance-owner@postgresql.org Mon Feb 27 14:04:07 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 747C89DC807 + for ; + Mon, 27 Feb 2006 14:04:06 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 64996-02 + for ; + Mon, 27 Feb 2006 14:04:05 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id E38749DCB83 + for ; + Mon, 27 Feb 2006 14:04:02 -0400 (AST) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 1F89F30C21; Mon, 27 Feb 2006 19:04:03 +0100 (MET) +From: Chris Browne +X-Newsgroups: pgsql.performance +Subject: Re: The trigger can be specified to fire on time condition? +Date: Mon, 27 Feb 2006 12:30:53 -0500 +Organization: cbbrowne Computing Inc +Lines: 17 +Message-ID: <60oe0szp2q.fsf@dba2.int.libertyrms.com> +References: <44033246.9030808@elios-informatique.fr> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@news.hub.org +User-Agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4.19 (linux) +Cancel-Lock: sha1:94oLrN4Hcf9g33FKFCYoEapg1Z0= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.288 required=5 tests=[AWL=0.288] +X-Spam-Score: 0.288 +X-Spam-Level: +X-Archive-Number: 200602/421 +X-Sequence-Number: 17407 + +Jamal.Ghaffour@elios-informatique.fr (Jamal Ghaffour) writes: +> Hi All, I ' m using the postgresql datbase to stores cookies. Theses +> cookies become invalid after 30 mn and have to be deleted. i have +> defined a procedure that will delete all invalid cookies, but i +> don't know how to call it in loop way (for example each hour). I +> think that it possible because this behaivor is the same of the +> autovaccum procedure that handle the vaccum process every time (60s +> in default way). After reading the documentation, it seems that +> triggers can't handle this stuff . how can i resolve the problem ? + +Time-based event scheduling is done using cron, external to the +database. +-- +output = reverse("gro.mca" "@" "enworbbc") +http://cbbrowne.com/info/sgml.html +"Even in the area of anticompetitive conduct, Microsoft is mainly an +imitator." -- Ralph Nader (1998/11/11) + +From pgsql-performance-owner@postgresql.org Mon Feb 27 14:34:27 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 1CAF49DC9A5 + for ; + Mon, 27 Feb 2006 14:34:26 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 72166-02 + for ; + Mon, 27 Feb 2006 14:34:24 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.201]) + by postgresql.org (Postfix) with ESMTP id D23029DC9A6 + for ; + Mon, 27 Feb 2006 14:34:22 -0400 (AST) +Received: by wproxy.gmail.com with SMTP id i23so906175wra + for ; + Mon, 27 Feb 2006 10:34:23 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:subject:cc:in-reply-to:mime-version:content-type:references; + b=f/jtmXIUcwVMSvmHWdRly9kUpHoN0uBIKtH0jgqdg0O4cxZoXMRE6WkMvQJYqL7uAS6lQJI3NAUxM8dZGMjwRAvglyBCkUbqJMej5HQESrI9QrTDtf1l48eDtDB1TFOWjSByAFbzKIfwS6LmL1Mpj1B4bGmNUQw8Q2fyBLwIv1k= +Received: by 10.64.179.19 with SMTP id b19mr3627317qbf; + Mon, 27 Feb 2006 10:34:20 -0800 (PST) +Received: by 10.64.232.2 with HTTP; Mon, 27 Feb 2006 10:34:12 -0800 (PST) +Message-ID: +Date: Mon, 27 Feb 2006 18:34:12 +0000 +From: "Peter Childs" +Subject: Re: Large Table With Only a Few Rows +Cc: pgsql-performance@postgresql.org +In-Reply-To: <60slq4zpbt.fsf@dba2.int.libertyrms.com> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_8744_10163819.1141065252724" +References: <1141051682.534005.194130@v46g2000cwv.googlegroups.com> + <60slq4zpbt.fsf@dba2.int.libertyrms.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.647 required=5 tests=[AWL=0.457, + HTML_MESSAGE=0.001, MISSING_HEADERS=0.189] +X-Spam-Score: 0.647 +X-Spam-Level: +X-Archive-Number: 200602/422 +X-Sequence-Number: 17408 + +------=_Part_8744_10163819.1141065252724 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +On 27/02/06, Chris Browne wrote: +> +> "Nik" writes: +> > I have a table that has only a few records in it at the time, and they +> > get deleted every few seconds and new records are inserted. Table never +> > has more than 5-10 records in it. +> > +> > However, I noticed a deteriorating performance in deletes and inserts +> > on it. So I performed vacuum analyze on it three times (twice in a row, +> > and once two days later). In the statistics it says that the table size +> > is 863Mb, toast table size is 246Mb, and indexes size is 134Mb, even +> > though the table has only 5-10 rows in it it. I was wondering how can I +> > reclaim all this space and improve the performance? +> +> You need to run VACUUM ANALYZE on this table very frequently. +> +> Based on what you describe, "very frequently" should be on the order +> of at least once per minute. +> +> Schedule a cron job specifically to vacuum this table, with a cron +> entry like the following: +> +> * * * * * /usr/local/bin/vacuumdb -z -t my_table -p 5432 my_database +> +> Of course, you need to bring it back down to size, first. +> +> You could run CLUSTER on the table to bring it back down to size; +> that's probably the fastest way... +> +> cluster my_table_pk on my_table; +> +> VACUUM FULL would also do the job, but probably not as quickly. +> -- +> (reverse (concatenate 'string "gro.gultn" "@" "enworbbc")) +> http://cbbrowne.com/info/sgml.html +> "Now they can put you in jail if they *THINK* you're gonna commit a +> crime. Let me say that again, because it sounds vaguely important" +> --george carlin +> +> ---------------------------(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 +> + +You probably want to do one or two other things. + +1> Switch on autovacuum. + +2> improve the setting of max_fsm_pages in your postgresql.conf a restart +will be required. + +if you do a "vacuum verbose;" the last couple of lines should tell you how +much free space is about against how much free space the database can +actuall remember to use. + +INFO: free space map contains 5464 pages in 303 relations +DETAIL: A total of 9760 page slots are in use (including overhead). +9760 page slots are required to track all free space. +Current limits are: 40000 page slots, 1000 relations, using 299 KB. + +if the required page slots (9760 in my case) goes above the current limit +(40000 in my case) you will need to do a vacuum full to reclaim the free +space. (cluster of the relevent tables may work. + +If you run Vacuum Verbose regullally you can check you are vacuuming often +enough and that your free space map is big enough to hold your free space. + +Peter Childs + +------=_Part_8744_10163819.1141065252724 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +

On 27/02/06, Chris Browne <cbbrowne@= +acm.org> wrote:
+"Nik" <XLPizza@gmail.com<= +/a>> writes:
> I have a table that has only a few records in it at= + the time, and they
> get deleted every few seconds and new records a= +re inserted. Table never +
> has more than 5-10 records in it.
>
> However, I notic= +ed a deteriorating performance in deletes and inserts
> on it. So I p= +erformed vacuum analyze on it three times (twice in a row,
> and once= + two days later). In the statistics it says that the table size +
> is 863Mb, toast table size is 246Mb, and indexes size is 134Mb, ev= +en
> though the table has only 5-10 rows in it it. I was wondering ho= +w can I
> reclaim all this space and improve the performance?
+
You need to run VACUUM ANALYZE on this table very frequently.

Ba= +sed on what you describe, "very frequently" should be on the orde= +r
of at least once per minute.

Schedule a cron job specifically t= +o vacuum this table, with a cron +
entry like the following:

* * * * * /usr/local/bin/vacuumdb -z -= +t my_table -p 5432 my_database

Of course, you need to bring it back = +down to size, first.

You could run CLUSTER on the table to bring it = +back down to size; +
that's probably the fastest way...

   cluster my_table= +_pk on my_table;

VACUUM FULL would also do the job, but probably not= + as quickly.
--
(reverse (concatenate 'string "gro.gultn" &= +quot;@" "enworbbc")) +
http://cbbrowne.com/info= +/sgml.html
"Now they can put you in jail if they *THINK* you're= + gonna commit a
crime.  Let me say that again, because it soun= +ds vaguely important" +
--george carlin

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

+You probably want to do one or two other things.
+
+1> Switch on autovacuum.
+
+2> improve the setting of max_fsm_pages in your postgresql.conf a restar= +t will be required.
+
+if you do a "vacuum verbose;" the last couple of lines should tel= +l you +how much free space is about against how much free space the database +can actuall remember to use.
+
+INFO:  free space map contains 5464 pages in 303 relations
+DETAIL:  A total of 9760 page slots are in use (including overhead). +9760 page slots are required to track all free space.
+Current limits are:  40000 page slots, 1000 relations, using 299 KB. +
+if the required page slots (9760 in my case) goes above the current +limit (40000 in my case) you will need to do a vacuum full to reclaim +the free space. (cluster of the relevent tables may work.
+
+If you run Vacuum Verbose regullally you can check you are vacuuming +often enough and that your free space map is big enough to hold your +free space.
+
+Peter Childs
+
+ +------=_Part_8744_10163819.1141065252724-- + +From pgsql-performance-owner@postgresql.org Mon Feb 27 20:22:26 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 52F139DC800 + for ; + Mon, 27 Feb 2006 20:22:25 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 39001-06 + for ; + Mon, 27 Feb 2006 20:22:28 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 1E9259DC8AA + for ; + Mon, 27 Feb 2006 20:22:22 -0400 (AST) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 2B1C75645D; Mon, 27 Feb 2006 18:22:26 -0600 (CST) +Received: (hashcash-sendmail, from uid 1001); Mon, 27 Feb 2006 18:22:23 -0600 +Date: Mon, 27 Feb 2006 18:22:23 -0600 +From: "Jim C. Nasby" +To: Tino Wildenhain +Cc: Javier Somoza , pgsql-performance@postgresql.org +Subject: Re: fsync and battery-backed caches +Message-ID: <20060228002223.GW82012@pervasive.com> +References: <1141034594.1556.15.camel@pndsoft> + <4402D0A9.7080705@wildenhain.de> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <4402D0A9.7080705@wildenhain.de> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060228:tino@wildenhain.de::jfHX0Y3fAICZPhhb:0000000000000000000 + 000000000000000000000000AGSr +X-Hashcash: + 1:20:060228:jsomoza@pandasoftware.es::M7gJzIgtYVyEhNeP:0000000000000 + 0000000000000000000000002qCl +X-Hashcash: + 1:20:060228:pgsql-performance@postgresql.org::d9YObfzMqiiHPeUN:00000 + 00000000000000000000000099Cg +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.105 required=5 tests=[AWL=0.105] +X-Spam-Score: 0.105 +X-Spam-Level: +X-Archive-Number: 200602/423 +X-Sequence-Number: 17409 + +On Mon, Feb 27, 2006 at 11:12:57AM +0100, Tino Wildenhain wrote: +> Javier Somoza schrieb: +> > +> > Hi all +> > +> > Is it secure to disable fsync havin battery-backed disk cache? +> > +> > Thx +> > +> No. fsync moves the data from OS memory cache to disk-adaptor +> cache which is required to benefit from battery backup. + +More importantly, in guarantees that data is committed to non-volatile +storage in such a way that PostgreSQL can recover from a crash without +corruption. + +If you have a battery-backed controller and turn on write caching you +shouldn't see much effect from fsync anyway. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Mon Feb 27 21:06:17 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id DCB689DC850 + for ; + Mon, 27 Feb 2006 21:06:15 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 44058-09 + for ; + Mon, 27 Feb 2006 21:06:18 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from candle.pha.pa.us (candle.pha.pa.us [70.90.9.53]) + by postgresql.org (Postfix) with ESMTP id 3C0549DC823 + for ; + Mon, 27 Feb 2006 21:06:13 -0400 (AST) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id k1S16DK16068; + Mon, 27 Feb 2006 20:06:13 -0500 (EST) +From: Bruce Momjian +Message-Id: <200602280106.k1S16DK16068@candle.pha.pa.us> +Subject: Re: fsync and battery-backed caches +In-Reply-To: <20060228002223.GW82012@pervasive.com> +To: "Jim C. Nasby" +Date: Mon, 27 Feb 2006 20:06:13 -0500 (EST) +CC: Tino Wildenhain , + Javier Somoza , pgsql-performance@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL121 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.393 required=5 tests=[AWL=-0.107, RAZOR2_CHECK=0.5] +X-Spam-Score: 0.393 +X-Spam-Level: +X-Archive-Number: 200602/424 +X-Sequence-Number: 17410 + +Jim C. Nasby wrote: +> On Mon, Feb 27, 2006 at 11:12:57AM +0100, Tino Wildenhain wrote: +> > Javier Somoza schrieb: +> > > +> > > Hi all +> > > +> > > Is it secure to disable fsync havin battery-backed disk cache? +> > > +> > > Thx +> > > +> > No. fsync moves the data from OS memory cache to disk-adaptor +> > cache which is required to benefit from battery backup. +> +> More importantly, in guarantees that data is committed to non-volatile +> storage in such a way that PostgreSQL can recover from a crash without +> corruption. +> +> If you have a battery-backed controller and turn on write caching you +> shouldn't see much effect from fsync anyway. + +We do mention battery-backed cache in our docs: + + http://www.postgresql.org/docs/8.1/static/wal.html + +If it is unclear, please let us know. + +-- + Bruce Momjian http://candle.pha.pa.us + SRA OSS, Inc. http://www.sraoss.com + + + If your life is a hard drive, Christ can be your backup. + + +From pgsql-performance-owner@postgresql.org Mon Feb 27 21:14:13 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id A66F79DC9F2 + for ; + Mon, 27 Feb 2006 21:14:12 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 46764-09 + for ; + Mon, 27 Feb 2006 21:14:15 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from candle.pha.pa.us (candle.pha.pa.us [70.90.9.53]) + by postgresql.org (Postfix) with ESMTP id E26039DC9B7 + for ; + Mon, 27 Feb 2006 21:14:09 -0400 (AST) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id k1S1EAQ17159; + Mon, 27 Feb 2006 20:14:10 -0500 (EST) +From: Bruce Momjian +Message-Id: <200602280114.k1S1EAQ17159@candle.pha.pa.us> +Subject: Re: wal sync method +In-Reply-To: <1141043359.1556.44.camel@pndsoft> +To: Javier Somoza +Date: Mon, 27 Feb 2006 20:14:10 -0500 (EST) +CC: Evgeny Gridasov , pgsql-performance@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL121 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=1.393 required=5 tests=[AWL=-1.107, + RAZOR2_CF_RANGE_51_100=0.5, RAZOR2_CF_RANGE_E8_51_100=1.5, + RAZOR2_CHECK=0.5] +X-Spam-Score: 1.393 +X-Spam-Level: * +X-Archive-Number: 200602/425 +X-Sequence-Number: 17411 + + +Use whichever sync method is fastest for you. They are all reliable, +except turning fsync off. + +--------------------------------------------------------------------------- + +Javier Somoza wrote: +> +> +> +> Hi Evgeny +> +> Im also testing what fsync method to use and using this program +> (http://archives.postgresql.org/pgsql-performance/2003-12/msg00191.php) +> a bit modified and i get this results: +> +> write 0.000036 +> write & fsync 0.006796 +> write & fdatasync 0.001001 +> write (O_FSYNC) 0.005761 +> write (O_DSYNC) 0.005894 +> +> So fdatasync faster for me? +> +> +> > Hi everybody! +> > +> > Which wal sync method is the fastest under linux 2.6.x? +> > I'm using RAID-10 (JFS filesystem), 2xXEON, 4 Gb RAM. +> > +> > I've tried to switch to open_sync which seems to work +> > faster than default fdatasync, but is it crash-safe? +> +> +> +> +> Javier Somoza +> Oficina de Direcci?n Estrat?gica +> mailto:jsomoza@pandasoftware.es +> +> Panda Software +> Buenos Aires, 12 +> 48001 BILBAO - ESPA?A +> Tel?fono: 902 24 365 4 +> Fax: 94 424 46 97 +> http://www.pandasoftware.es +> Panda Software, una de las principales compa??as desarrolladoras de +> soluciones de protecci?n contra virus e intrusos, presenta su nueva +> familia de soluciones. Todos los usuarios de ordenadores, desde las +> redes m?s grandes a los dom?sticos, disponen ahora de nuevos productos +> con excelentes tecnolog?as de seguridad. M?s informaci?n en: +> http://www.pandasoftware.es/productos +> +> +> +> ?Prot?jase ahora contra virus e intrusos! Pruebe gratis nuestros +> productos en http://www.pandasoftware.es/descargas/ +> +> +> +> +> +> +> +> +> + +-- + Bruce Momjian http://candle.pha.pa.us + SRA OSS, Inc. http://www.sraoss.com + + + If your life is a hard drive, Christ can be your backup. + + +From pgsql-general-owner@postgresql.org Mon Feb 27 23:45:11 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id C37D59DCC49 + for ; + Mon, 27 Feb 2006 23:45:10 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 01566-04 + for ; + Mon, 27 Feb 2006 23:45:15 -0400 (AST) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id A5F909DCC17 + for ; + Mon, 27 Feb 2006 23:45:08 -0400 (AST) +Received: from AZ18CN851.global.ds.honeywell.com (tmpnat1.honeywell.com + [199.64.0.252]) + by svr4.postgresql.org (Postfix) with ESMTP id 55AE65AF0AC + for ; + Tue, 28 Feb 2006 03:45:14 +0000 (GMT) +Received: from IE10EV801.global.ds.honeywell.com ([199.63.32.162]) by + AZ18CN851.global.ds.honeywell.com with Microsoft + SMTPSVC(6.0.3790.1830); Mon, 27 Feb 2006 20:45:10 -0700 +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: rotate records +Date: Tue, 28 Feb 2006 09:14:59 +0530 +Message-ID: + +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [GENERAL] rotate records +Thread-Index: AcY6Oug6c6jr1ptgSNi+jTj/nJI56AB3F7lgAABfsCA= +From: "Jeevanandam, Kathirvel (IE10)" +To: +X-OriginalArrivalTime: 28 Feb 2006 03:45:11.0351 (UTC) + FILETIME=[60434C70:01C63C19] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200602/1161 +X-Sequence-Number: 91826 + +Hi all, + +I am facing performance issues even with less than 3000 records, I am +using Triggers/SPs in all the tables. What could be the problem. +Any idea it is good to use triggers w.r.t performance? + +Regards, +Jeeva.K + +From pgsql-general-owner@postgresql.org Tue Feb 28 01:04:11 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 25E099DC948 + for ; + Tue, 28 Feb 2006 01:04:11 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 24928-10 + for ; + Tue, 28 Feb 2006 01:04:09 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from service-web.de (p15093784.pureserver.info [217.160.106.224]) + by postgresql.org (Postfix) with ESMTP id 809089DC80C + for ; + Tue, 28 Feb 2006 01:04:08 -0400 (AST) +Received: from [192.168.178.99] (p548B3E77.dip0.t-ipconnect.de + [84.139.62.119]) + by service-web.de (Postfix) with ESMTP id 22F1B20002A; + Tue, 28 Feb 2006 06:04:09 +0100 (CET) +Message-ID: <4403D9C5.20301@wildenhain.de> +Date: Tue, 28 Feb 2006 06:04:05 +0100 +From: Tino Wildenhain +User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: de-DE, de, en-us, en +MIME-Version: 1.0 +To: "Jeevanandam, Kathirvel (IE10)" +Cc: pgsql-general@postgresql.org +Subject: triggers, performance Was: Re: rotate records +References: + +In-Reply-To: + +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.128 required=5 tests=[AWL=0.128] +X-Spam-Score: 0.128 +X-Spam-Level: +X-Archive-Number: 200602/1164 +X-Sequence-Number: 91829 + +Jeevanandam, Kathirvel (IE10) schrieb: +> Hi all, +> +> I am facing performance issues even with less than 3000 records, I am +> using Triggers/SPs in all the tables. What could be the problem. +> Any idea it is good to use triggers w.r.t performance? + +Much to general. What triggers? (what are they doing, when are +they invoked...?). Please provide much greater details with +your request or nobody can help. + +Regards +Tino + +PS: and try not to steal threads + +From pgsql-general-owner@postgresql.org Tue Feb 28 00:58:37 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 4C6A89DCAAB + for ; + Tue, 28 Feb 2006 00:58:36 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 24367-02 + for ; + Tue, 28 Feb 2006 00:58:35 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from wolff.to (wolff.to [66.93.197.194]) + by postgresql.org (Postfix) with SMTP id 8CEAD9DC80C + for ; + Tue, 28 Feb 2006 00:58:33 -0400 (AST) +Received: (qmail 14953 invoked by uid 500); 28 Feb 2006 05:08:31 -0000 +Date: Mon, 27 Feb 2006 23:08:31 -0600 +From: Bruno Wolff III +To: "Jeevanandam, Kathirvel \(IE10\)" +Cc: pgsql-general@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: rotate records +Message-ID: <20060228050831.GA12351@wolff.to> +Mail-Followup-To: "Jeevanandam, + Kathirvel (IE10)" , + pgsql-performance@postgresql.org +References: + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: + +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.098 required=5 tests=[AWL=0.098] +X-Spam-Score: 0.098 +X-Spam-Level: +X-Archive-Number: 200602/1162 +X-Sequence-Number: 91827 + +On Tue, Feb 28, 2006 at 09:14:59 +0530, + "Jeevanandam, Kathirvel (IE10)" wrote: +> Hi all, + +Please don't hijack existing threads to start new ones. This can cause +people to miss your question and messes up the archives. + +Performance questions should generally be posted to the performance list. +I have redirected followups to there. + +> +> I am facing performance issues even with less than 3000 records, I am +> using Triggers/SPs in all the tables. What could be the problem. +> Any idea it is good to use triggers w.r.t performance? + +A common cause of this kind of thing is not running vacuum often enough +leaving you with a lot of dead tuples. + +You should probably start by doing a vacuum full analyse and then showing +the list some problem query sources along with explain analyse output +for them. + +> +> Regards, +> Jeeva.K +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 4: Have you searched our list archives? +> +> http://archives.postgresql.org + +From pgsql-performance-owner@postgresql.org Tue Feb 28 22:51:33 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id D84D39DCA2D + for ; + Tue, 28 Feb 2006 01:54:51 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 32026-04 + for ; + Tue, 28 Feb 2006 01:54:51 -0400 (AST) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id B870F9DC9ED + for ; + Tue, 28 Feb 2006 01:54:49 -0400 (AST) +Received: from az18cn848.global.ds.honeywell.com (tmpnat1.honeywell.com + [199.64.0.252]) + by svr4.postgresql.org (Postfix) with ESMTP id 35F0F5AF02B + for ; + Tue, 28 Feb 2006 05:54:50 +0000 (GMT) +Received: from IE10EV801.global.ds.honeywell.com ([199.63.32.162]) by + az18cn848.global.ds.honeywell.com with Microsoft + SMTPSVC(6.0.3790.1830); Mon, 27 Feb 2006 22:54:48 -0700 +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: triggers, performance Was: Re: [GENERAL] rotate records +Date: Tue, 28 Feb 2006 11:24:34 +0530 +Message-ID: + +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: triggers, performance Was: Re: [GENERAL] rotate records +Thread-Index: AcY8JGp93J4auRAKTKuPfRW8c8nooAABcw5g +From: "Jeevanandam, Kathirvel (IE10)" +To: "Tino Wildenhain" +Cc: +X-OriginalArrivalTime: 28 Feb 2006 05:54:48.0544 (UTC) + FILETIME=[7BD4C600:01C63C2B] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200602/451 +X-Sequence-Number: 17437 + +I am using triggers for all the events (insert,delete,update) please +find the details below. + +trg_delpointtable BEFORE DELETE ON pointtable FOR EACH ROW EXECUTE +PROCEDURE pp_delpointtable() + +trg_insdelpoints AFTER DELETE ON pointtable FOR EACH ROW EXECUTE +PROCEDURE pp_insdelpoints() + +trgins_pointtable AFTER INSERT ON pointtable FOR EACH ROW EXECUTE +PROCEDURE pp_inspointtable() + +trupd_pointtable AFTER UPDATE ON pointtable FOR EACH ROW EXECUTE +PROCEDURE pp_updpointtable() + + +Basically, this each trigger modifies the content of other dependent +tables. + +Best Regards, +Jeeva.K + +-----Original Message----- +From: Tino Wildenhain [mailto:tino@wildenhain.de]=20 +Sent: Tuesday, February 28, 2006 10:34 AM +To: Jeevanandam, Kathirvel (IE10) +Cc: pgsql-general@postgresql.org +Subject: triggers, performance Was: Re: [GENERAL] rotate records + +Jeevanandam, Kathirvel (IE10) schrieb: +> Hi all, +>=20 +> I am facing performance issues even with less than 3000 records, I am +> using Triggers/SPs in all the tables. What could be the problem. +> Any idea it is good to use triggers w.r.t performance? + +Much to general. What triggers? (what are they doing, when are +they invoked...?). Please provide much greater details with +your request or nobody can help. + +Regards +Tino + +PS: and try not to steal threads + +From pgsql-performance-owner@postgresql.org Tue Feb 28 04:18:58 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id DF1E09DC881 + for ; + Tue, 28 Feb 2006 04:18:57 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 52176-10 + for ; + Tue, 28 Feb 2006 04:18:58 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from bilbao.pandasoftware.es (unknown [62.14.249.71]) + by postgresql.org (Postfix) with ESMTP id C8C2B9DC832 + for ; + Tue, 28 Feb 2006 04:18:53 -0400 (AST) +Received: from escorpexh05.pandasoftware.local (escorpext02 [192.168.100.182]) + by bilbao.pandasoftware.es (Postfix) with ESMTP + id 17E1A1B3609; Tue, 28 Feb 2006 09:18:32 +0100 (CET) +Received: from ESCORPEXH03.pandasoftware.local ([172.16.0.70]) by + escorpexh05.pandasoftware.local with Microsoft + SMTPSVC(6.0.3790.211); Tue, 28 Feb 2006 09:18:52 +0100 +Received: escorpexh03.pandasoftware.local 172.16.0.73 from 172.16.3.16 + 172.16.3.16 via HTTP with MS-WebStorage 6.5.6944 +Received: from pndsoft by escorpexh03.pandasoftware.local; + 28 Feb 2006 09:19:36 +0100 +Subject: Re: fsync and battery-backed caches +From: Javier Somoza +To: Bruce Momjian +Cc: "Jim C. Nasby" , + Tino Wildenhain , pgsql-performance@postgresql.org +In-Reply-To: <200602280106.k1S16DK16068@candle.pha.pa.us> +References: <200602280106.k1S16DK16068@candle.pha.pa.us> +Content-Type: multipart/alternative; boundary="=-P6PHUsQ2bd+SYl9D3G8K" +Message-Id: <1141114775.1555.7.camel@pndsoft> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Tue, 28 Feb 2006 09:19:36 +0100 +X-OriginalArrivalTime: 28 Feb 2006 08:18:52.0431 (UTC) + FILETIME=[9BFD41F0:01C63C3F] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=2.605 required=5 tests=[AWL=0.103, + HTML_MESSAGE=0.001, RAZOR2_CF_RANGE_51_100=0.5, + RAZOR2_CF_RANGE_E8_51_100=1.5, RAZOR2_CHECK=0.5, + UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 2.605 +X-Spam-Level: ** +X-Archive-Number: 200602/427 +X-Sequence-Number: 17413 + + +--=-P6PHUsQ2bd+SYl9D3G8K +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: quoted-printable + + + Yeah, i saw it. It says full-page-writes can be disabled +without problems. + But i wanted to confirm fsync cannot be disabled although i +have battery. + + Thanks!! :-) + + + +> We do mention battery-backed cache in our docs: +>=20 +> http://www.postgresql.org/docs/8.1/static/wal.html +>=20 +> If it is unclear, please let us know. + +Javier Somoza +Oficina de Direcci=F3n Estrat=E9gica +mailto:jsomoza@pandasoftware.es + +Panda Software +Buenos Aires, 12 +48001 BILBAO - ESPA=D1A +Tel=E9fono: 902 24 365 4 +Fax: 94 424 46 97 +http://www.pandasoftware.es +Panda Software, una de las principales compa=F1=EDas desarrolladoras de +soluciones de protecci=F3n contra virus e intrusos, presenta su nueva +familia de soluciones. Todos los usuarios de ordenadores, desde las +redes m=E1s grandes a los dom=E9sticos, disponen ahora de nuevos productos +con excelentes tecnolog=EDas de seguridad. M=E1s informaci=F3n en: +http://www.pandasoftware.es/productos + + =20 + +=A1Prot=E9jase ahora contra virus e intrusos! Pruebe gratis nuestros +productos en http://www.pandasoftware.es/descargas/ + + =20 + =20 + =20 + =20 + =20 + =20 + =20 + =20 + +--=-P6PHUsQ2bd+SYl9D3G8K +Content-Type: text/html; charset=utf-8 + + + + + + + + +
+            Yeah, i saw it. It says full-page-writes can be disabled without problems.
+            But i wanted to confirm fsync cannot be disabled although i have battery.
+
+            Thanks!!   :-) +
+
+
We do mention battery-backed cache in our docs:
+
+	http://www.postgresql.org/docs/8.1/static/wal.html
+
+If it is unclear, please let us know.
+
+

+
+
+
+
+Javier Somoza
+Oficina de Dirección Estratégica

+mailto:jsomoza@pandasoftware.es
+
+Panda Software
+Buenos Aires, 12
+48001 BILBAO - ESPAÑA
+Teléfono: 902 24 365 4
+Fax:  94 424 46 97

+http://www.pandasoftware.es
+Panda Software, una de las principales compañías desarrolladoras de soluciones de protección contra virus e intrusos, presenta su nueva familia de soluciones. Todos los usuarios de ordenadores, desde las redes más grandes a los domésticos, disponen ahora de nuevos productos con excelentes tecnologías de seguridad. Más información en: http://www.pandasoftware.es/productos +
    +
    +
+¡Protéjase ahora contra virus e intrusos! Pruebe gratis nuestros productos en http://www.pandasoftware.es/descargas/ +
    +
      +
      +
      +
    +
    +
    +
    +
    +
    +
    +
+
+
+ + + +--=-P6PHUsQ2bd+SYl9D3G8K-- + +From pgsql-performance-owner@postgresql.org Tue Feb 28 05:45:13 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 3B9B89DC941 + for ; + Tue, 28 Feb 2006 05:45:13 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 66481-03 + for ; + Tue, 28 Feb 2006 05:45:14 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from bilbao.pandasoftware.es (unknown [62.14.249.71]) + by postgresql.org (Postfix) with ESMTP id E9EF69DC93C + for ; + Tue, 28 Feb 2006 05:45:10 -0400 (AST) +Received: from escorpexh05.pandasoftware.local (escorpext02 [192.168.100.182]) + by bilbao.pandasoftware.es (Postfix) with ESMTP id AE9F81B3642 + for ; + Tue, 28 Feb 2006 10:44:41 +0100 (CET) +Received: from ESCORPEXH03.pandasoftware.local ([172.16.0.70]) by + escorpexh05.pandasoftware.local with Microsoft + SMTPSVC(6.0.3790.211); Tue, 28 Feb 2006 10:45:01 +0100 +Received: escorpexh03.pandasoftware.local 172.16.0.73 from 172.16.3.16 + 172.16.3.16 via HTTP with MS-WebStorage 6.5.6944 +Received: from pndsoft by escorpexh03.pandasoftware.local; + 28 Feb 2006 10:45:45 +0100 +Subject: Different disks for xlogs and data +From: Javier Somoza +To: pgsql-performance@postgresql.org +In-Reply-To: <4402D475.9020505@wildenhain.de> +References: <1141034594.1556.15.camel@pndsoft> + <4402D0A9.7080705@wildenhain.de> <1141035368.1556.22.camel@pndsoft> + <4402D475.9020505@wildenhain.de> +Content-Type: multipart/alternative; boundary="=-8k5uspHUYOrOsiH3wgSS" +Message-Id: <1141119945.1555.16.camel@pndsoft> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Tue, 28 Feb 2006 10:45:45 +0100 +X-OriginalArrivalTime: 28 Feb 2006 09:45:02.0038 (UTC) + FILETIME=[A550AF60:01C63C4B] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=1.358 required=5 tests=[AWL=1.356, + HTML_MESSAGE=0.001, UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 1.358 +X-Spam-Level: * +X-Archive-Number: 200602/428 +X-Sequence-Number: 17414 + + +--=-8k5uspHUYOrOsiH3wgSS +Content-Type: text/plain +Content-Transfer-Encoding: 7bit + + + + Hi, + + is interesting to do it when using RAID 1+0? + + Thx + + + +--=-8k5uspHUYOrOsiH3wgSS +Content-Type: text/html; charset=utf-8 + + + + + + + + +
+
+	Hi,
+
+	is interesting to do it when using RAID 1+0?
+
+	Thx
+
+
+ + + +--=-8k5uspHUYOrOsiH3wgSS-- + +From pgsql-performance-owner@postgresql.org Tue Feb 28 08:10:37 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 9D2F29DCBF4 + for ; + Tue, 28 Feb 2006 08:10:36 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 89067-07 + for ; + Tue, 28 Feb 2006 08:10:39 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from bilbao.pandasoftware.es (unknown [62.14.249.71]) + by postgresql.org (Postfix) with ESMTP id EE2FA9DCBDD + for ; + Tue, 28 Feb 2006 08:10:33 -0400 (AST) +Received: from escorpexh05.pandasoftware.local (escorpext02 [192.168.100.182]) + by bilbao.pandasoftware.es (Postfix) with ESMTP id D03D81B3748 + for ; + Tue, 28 Feb 2006 13:10:03 +0100 (CET) +Received: from ESCORPEXH03.pandasoftware.local ([172.16.0.70]) by + escorpexh05.pandasoftware.local with Microsoft + SMTPSVC(6.0.3790.211); Tue, 28 Feb 2006 13:10:21 +0100 +Received: escorpexh03.pandasoftware.local 172.16.0.73 from 172.16.3.16 + 172.16.3.16 via HTTP with MS-WebStorage 6.5.6944 +Received: from pndsoft by escorpexh03.pandasoftware.local; + 28 Feb 2006 13:11:05 +0100 +Subject: vacuum, analyze and reindex +From: Javier Somoza +To: pgsql-performance@postgresql.org +Content-Type: multipart/alternative; boundary="=-QO1J/z6tDBQ7dsbbZ1QI" +Message-Id: <1141128665.1555.33.camel@pndsoft> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Tue, 28 Feb 2006 13:11:05 +0100 +X-OriginalArrivalTime: 28 Feb 2006 12:10:21.0236 (UTC) + FILETIME=[F25CB740:01C63C5F] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=1.134 required=5 tests=[AWL=1.132, + HTML_MESSAGE=0.001, UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 1.134 +X-Spam-Level: * +X-Archive-Number: 200602/429 +X-Sequence-Number: 17415 + + +--=-QO1J/z6tDBQ7dsbbZ1QI +Content-Type: text/plain +Content-Transfer-Encoding: 7bit + + + + Hi all + + I've a question about vacuuming, ... + + Vacuum: cleans out obsolete and deleted registers... + Analyze: update statistics for the planner + Reindex: rebuild indexes + + I think the correct order to perform the database +maintenance for performance is: + + 1 - Vacuum + 2 - Reindex + 3 - Analyze + + So the planner is updated with the updated indexes. + + + The autovacuum daemon does vacuum and analyze. Not reindex. + So, no way to perform it in that order. + + What do you think? + How often do you reindex your tables? + + Thx all + +--=-QO1J/z6tDBQ7dsbbZ1QI +Content-Type: text/html; charset=utf-8 + + + + + + + + +
+
+            Hi all
+
+            I've a question about vacuuming, ...
+
+            Vacuum: cleans out obsolete and deleted registers...
+            Analyze:  update statistics for the planner
+            Reindex:  rebuild indexes
+
+            I think the correct order to perform the database maintenance for performance is:
+
+            1 - Vacuum
+            2 - Reindex
+            3 - Analyze
+
+            So the planner is updated with the updated indexes.
+
+
+            The autovacuum daemon does vacuum and analyze. Not reindex.
+            So, no way to perform it in that order.
+
+            What do you think?
+            How often do you reindex your tables?
+
+            Thx all + + + +--=-QO1J/z6tDBQ7dsbbZ1QI-- + +From pgsql-performance-owner@postgresql.org Tue Feb 28 09:38:11 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id A1DFF9DCA3B + for ; + Tue, 28 Feb 2006 09:38:10 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 00508-07 + for ; + Tue, 28 Feb 2006 09:38:12 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id 738A99DC8A3 + for ; + Tue, 28 Feb 2006 09:38:06 -0400 (AST) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 3847D30C22; Tue, 28 Feb 2006 14:38:10 +0100 (MET) +From: Christopher Browne +X-Newsgroups: pgsql.performance +Subject: Re: vacuum, analyze and reindex +Date: Tue, 28 Feb 2006 08:34:01 -0500 +Organization: cbbrowne Computing Inc +Lines: 41 +Message-ID: <87mzgbsj3q.fsf@wolfe.cbbrowne.com> +References: <1141128665.1555.33.camel@pndsoft> +Mime-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Complaints-To: usenet@news.hub.org +X-message-flag: Outlook is rather hackable, isn't it? +X-Home-Page: http://www.cbbrowne.com/info/ +X-Affero: http://svcs.affero.net/rm.php?r=cbbrowne +User-Agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4.19 (linux) +Cancel-Lock: sha1:WQXF/N2TwnOziEX/N7aLpOxfL4Q= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.692 required=5 tests=[AWL=-0.121, INFO_TLD=0.813] +X-Spam-Score: 0.692 +X-Spam-Level: +X-Archive-Number: 200602/430 +X-Sequence-Number: 17416 + +Centuries ago, Nostradamus foresaw when jsomoza@pandasoftware.es (Javier Somoza) would write: +> ����������� Hi all +> ����������� I've a question about vacuuming, ... +> ����������� Vacuum: cleans out obsolete and deleted registers... +> ����������� Analyze:� update statistics for the planner +> ����������� Reindex:� rebuild indexes +> ����������� I think the correct order to perform the database maintenance for performance is: +> ����������� 1 - Vacuum +> ����������� 2 - Reindex +> ����������� 3 - Analyze +> ����������� So the planner is updated with the updated indexes. + +There is a misunderstanding there. The planner isn't aware of +"updates" to the indexes; it is aware of how they are defined. + +ANALYZE doesn't calculate index-specific things; it calculates +statistical distributions for the contents of each column. As soon as +it runs, the planner will be better able to choose from the available +indexes. If you add another index, the planner will, without another +ANALYZE, be able to choose that index, if it is useful to do so, based +on the existing statistical distributions. + +> ����������� The autovacuum daemon does vacuum and analyze. Not reindex. +> ����������� So, no way to perform it in that order. +> ����������� What do you think? +> ����������� How often do you reindex your tables? + +If tables are being vacuumed frequently enough, the answer to that can +be "almost never." + +Back in the days of 7.2, there were conditions where indexes could +bloat mercilessly, so that heavily updated tables needed a reindex +every so often. But if you're running a reasonably modern version, +that shouldn't be necessary. +-- +wm(X,Y):-write(X),write('@'),write(Y). wm('cbbrowne','gmail.com'). +http://linuxfinances.info/info/slony.html +Rules of the Evil Overlord #219. "I will be selective in the hiring of +assassins. Anyone who attempts to strike down the hero the first +instant his back is turned will not even be considered for the job." + + +From pgsql-performance-owner@postgresql.org Tue Feb 28 09:41:03 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 56EAA9DCA45 + for ; + Tue, 28 Feb 2006 09:41:02 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 03882-07 + for ; + Tue, 28 Feb 2006 09:41:05 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smtpauth02.mail.atl.earthlink.net + (smtpauth02.mail.atl.earthlink.net [209.86.89.62]) + by postgresql.org (Postfix) with ESMTP id E31CA9DCA3B + for ; + Tue, 28 Feb 2006 09:40:59 -0400 (AST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=l/wevGclsI6ZyqOoKIiEv6nEWT9pwUwxfoKrNN7zR8Vu4A0R+Aj4fvHqYZEjOtFh; + 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 [71.243.43.186] (helo=ron-6d52adff2a6.earthlink.net) + by smtpauth02.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1FE565-00010A-9U; Tue, 28 Feb 2006 08:41:01 -0500 +Message-Id: <7.0.1.0.2.20060228072910.038dacc0@earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 7.0.1.0 +Date: Tue, 28 Feb 2006 08:40:56 -0500 +To: Javier Somoza , pgsql-performance@postgresql.org +From: Ron +Subject: Re: Different disks for xlogs and data +In-Reply-To: <1141119945.1555.16.camel@pndsoft> +References: <1141034594.1556.15.camel@pndsoft> + <4402D0A9.7080705@wildenhain.de> + <1141035368.1556.22.camel@pndsoft> <4402D475.9020505@wildenhain.de> + <1141119945.1555.16.camel@pndsoft> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bc75f67d460039329ef6317ba634b61c91350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 71.243.43.186 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.473 required=5 tests=[AWL=-0.006, + DNS_FROM_RFC_ABUSE=0.479] +X-Spam-Score: 0.473 +X-Spam-Level: +X-Archive-Number: 200602/431 +X-Sequence-Number: 17417 + +At 04:45 AM 2/28/2006, Javier Somoza wrote: + +>Hi, +>is interesting to do it (use different HD sets AKA "LUNs" for xlogs +>than for data) when using RAID 1+0? + +If "interesting" means "this increases performance", this is not a +simple question. + +Regardless of what RAID level you use, under the proper circumstances +it can boost performance to put xlog on a dedicated set of spindles. + +If you have a large enough pool of HDs so that you can maximize the +performance of any LUN you create, then it is always good to put xlog +on its own LUN. + +In the "perfect" world, each table or set of tables that tends to be +accessed for the same query, which obviously includes xlog, would be +on its own LUN; and each LUN would contain enough HDs to maximize performance. + +Most people can't afford and/or fit that many HDs into their set up. + +If you have a small number of HDs, and "small" depends on the +specifics of your DB and the HDs you are using, you may get better +performance by leaving everything together on one set of HDs. + +Once you have more than whatever is a "small" number of HDs for your +DB and set of disks, _usually_, but not always, one of the best first +tables to move to different HD's is xlog. + +The best way to find out what will get the most performance from your +specific HW and DB is to test, test, test. Start by putting +everything on 1 RAID 5 set. Test. Then (if you have enough HDs) put +everything on 1 RAID 1+0 set. Test again. If performance is "good +enough", and only you know what that is for your DB, then STOP and +just use whichever works best for you. It's possible to spend far +more money in man hours of effort than it is worth trying to get a +few extra percents of performance. + +If you have the need and the budget to tweak things further, then +start worrying about the more complicated stuff. + +As a rule of thumb, figure each 7200rpm HD does ~50MBps and each +15Krpm (or 10Krpm WD Raptor) does ~75MBps. So a 8 HD RAID 5 set of +7200rpm HDs does ~(8-1= 7)*50= ~350MBps. A RAID 10 set made of the +same 8 HDs should do ~4*50= 200MBps. (=If and only if= the rest of +your HW let's the RAID set push data at that speed.). Also, note +that RAID 5 writes are often 2/3 - 4/5 the speed of RAID 5 reads. + +If we pull 1 HD from the 8 HD RAID 5 set above and dedicate it to +xlog, then xlog will always get ~50MBps bandwidth. OTOH, in the +original RAID 5 configuration xlog was probably sharing between 2/3 +and 4/5 of ~350MBps bandwidth. Say ~233-280MBps. Which results in +higher overall performance for you DB? Only testing by you on your +DB can tell. + +Hope this helps, +Ron + + + + + + + + + +From pgsql-hackers-owner@postgresql.org Tue Feb 28 11:44:17 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 0FEA49DCAEE; + Tue, 28 Feb 2006 11:44:16 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 51931-07; Tue, 28 Feb 2006 11:44:20 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from gwmta.wicourts.gov (gwmta.wicourts.gov [165.219.244.99]) + by postgresql.org (Postfix) with ESMTP id 5BDED9DCABF; + Tue, 28 Feb 2006 11:44:12 -0400 (AST) +Received: from Courts-MTA by gwmta.wicourts.gov + with Novell_GroupWise; Tue, 28 Feb 2006 09:44:17 -0600 +Message-Id: <44041B68.EE98.0025.0@wicourts.gov> +X-Mailer: Novell GroupWise Internet Agent 7.0 +Date: Tue, 28 Feb 2006 09:44:08 -0600 +From: "Kevin Grittner" +To: , +Subject: temporary indexes +Mime-Version: 1.0 +Content-Type: multipart/mixed; boundary="=__Part9FBAD2D8.0__=" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.072 required=5 tests=[AWL=0.072] +X-Spam-Score: 0.072 +X-Spam-Level: +X-Archive-Number: 200602/1194 +X-Sequence-Number: 80332 + +--=__Part9FBAD2D8.0__= +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +Content-Disposition: inline + +Just a "wouldn't it be nice if" sort of feature request. I'm not sure +how practical it is. + +Someone in our organization wrote a data fix query, which has sort of +odd logic, but it does what they need. The problem is that it ran for +14 hours in a test against a copy of the data. I looked at it and +figured it could do better with an extra index. The index took five +minutes to build, and the run time for the query dropped to five +minutes. The index is not needed for production, so it was then +dropped. + +It struck me that it would be outstanding if the planner could +recognize this sort of situation, and build a temporary index based on +the snapshot of the data visible to the transaction. It seems to me +that the obvious downside of this would be the explosion in the number +of permutations the planner would need to examine -- based not just on +what indexes ARE there, but which ones it could build. At a minimum, +there would need to be a cost threshold below which it would not even +consider the option. (In this case, as long as the optimizer spent less +than 13 hours and 50 minutes considering its options, we would have come +out ahead.) + +I'm not sure the details of this particular incident are that relevant, +but I've attached the query and the two plans. + +-Kevin + + +--=__Part9FBAD2D8.0__= +Content-Type: application/octet-stream; name="datafix-Action.txt" +Content-Transfer-Encoding: base64 +Content-Disposition: attachment; filename="datafix-Action.txt" + +YmlnYmlyZD0+IFxkICJBY3Rpb24iCiAgICAgICAgICAgVGFibGUgInB1YmxpYy5BY3Rpb24iCiAg +ICBDb2x1bW4gICAgfCAgICAgIFR5cGUgICAgICB8IE1vZGlmaWVycwotLS0tLS0tLS0tLS0tLSst +LS0tLS0tLS0tLS0tLS0tKy0tLS0tLS0tLS0tCiBhY3Rpb25TZXFObyAgfCAiQWN0aW9uU2VxTm9U +IiB8IG5vdCBudWxsCiBqdXJ5WWVhciAgICAgfCAiSnVyeVllYXJUIiAgICB8IG5vdCBudWxsCiBj +b3VudHlObyAgICAgfCAiQ291bnR5Tm9UIiAgICB8IG5vdCBudWxsCiBhY3Rpb25Db2RlICAgfCAi +QWN0aW9uQ29kZVQiICB8IG5vdCBudWxsCiBzdGFydERhdGUgICAgfCAiRGF0ZVQiICAgICAgICB8 +IG5vdCBudWxsCiBiYWlsaWZmTm8gICAgfCAiQmFpbGlmZk5vVCIgICB8CiBjYXNlTm8gICAgICAg +fCAiQ2FzZU5vVCIgICAgICB8CiBjdG9mY05vICAgICAgfCAiQ3RvZmNOb1QiICAgICB8CiBlZmZE +YXRlICAgICAgfCAiRGF0ZVQiICAgICAgICB8CiBlbmREYXRlICAgICAgfCAiRGF0ZVQiICAgICAg +ICB8CiBqdXJvcklkICAgICAgfCAiSnVyb3JJZFQiICAgICB8CiBwYW5lbElkICAgICAgfCAiUGFu +ZWxJZFQiICAgICB8CiBwb29sSWQgICAgICAgfCAiUG9vbElkVCIgICAgICB8CiBjb21tZW50cyAg +ICAgfCAiVGV4dFQiICAgICAgICB8CiBkYXRlSW5zZXJ0ZWQgfCAiRGF0ZVQiICAgICAgICB8CiB0 +aW1lSW5zZXJ0ZWQgfCAiVGltZVQiICAgICAgICB8CkluZGV4ZXM6CiAgICAiQWN0aW9uX3BrZXki +IFBSSU1BUlkgS0VZLCBidHJlZSAoImNvdW50eU5vIiwgImFjdGlvblNlcU5vIiwgImp1cnlZZWFy +IikKICAgICJBY3Rpb25fanVyb3IiIGJ0cmVlICgiY291bnR5Tm8iLCAianVyeVllYXIiLCAianVy +b3JJZCIsICJhY3Rpb25TZXFObyIsICJhY3Rpb25Db2RlIikKCg== + +--=__Part9FBAD2D8.0__= +Content-Type: application/octet-stream; name="datafix-plan1.txt" +Content-Transfer-Encoding: base64 +Content-Disposition: attachment; filename="datafix-plan1.txt" + +IE1lcmdlIEpvaW4gIChjb3N0PTE2MDEzMDczMjQuMDIuLjE2MDk3Mzc1OTkuMzAgcm93cz0xNDY0 +Mjkgd2lkdGg9MTgyKQogICBNZXJnZSBDb25kOiAoKCJvdXRlciIuIj9jb2x1bW4xNj8iID0gImlu +bmVyIi4iP2NvbHVtbjg/IikgQU5EICgib3V0ZXIiLiI/Y29sdW1uMTc/IiA9ICJpbm5lciIuIj9j +b2x1bW45PyIpKQogICBKb2luIEZpbHRlcjogKCgoImlubmVyIi4ic3RhcnREYXRlIik6OmRhdGUg +PCAoIm91dGVyIi4ic3RhcnREYXRlIik6OmRhdGUpIEFORCAoTk9UIChzdWJwbGFuKSkpCiAgIC0+ +ICBTb3J0ICAoY29zdD0xNjAxMDA3MjUyLjMyLi4xNjAxMDA4MTE5LjczIHJvd3M9MzQ2OTYzIHdp +ZHRoPTE1NCkKICAgICAgICAgU29ydCBLZXk6ICgiQWN0aW9uIi4ianVyb3JJZCIpOjppbnRlZ2Vy +LCAoIkFjdGlvbiIuImp1cnlZZWFyIik6OmJwY2hhcgogICAgICAgICAtPiAgSW5kZXggU2NhbiB1 +c2luZyAiQWN0aW9uX3BrZXkiIG9uICJBY3Rpb24iICAoY29zdD0wLjAwLi4xNjAwOTU5MDU5LjA4 +IHJvd3M9MzQ2OTYzIHdpZHRoPTE1NCkKICAgICAgICAgICAgICAgSW5kZXggQ29uZDogKCgiY291 +bnR5Tm8iKTo6c21hbGxpbnQgPSA0MCkKICAgICAgICAgICAgICAgRmlsdGVyOiAoKCgiYWN0aW9u +Q29kZSIpOjpicGNoYXIgPD4gJ0FQT09MJzo6YnBjaGFyKSBBTkQgKCgiYWN0aW9uQ29kZSIpOjpi +cGNoYXIgPD4gJ1JQT09MJzo6YnBjaGFyKSBBTkQgKCgiYWN0aW9uQ29kZSIpOjpicGNoYXIgPD4g +J0FQQU4nOjpicGNoYXIpIEFORCAoKCJhY3Rpb25Db2RlIik6OmJwY2hhciA8PiAnUlBBTic6OmJw +Y2hhcikgQU5EICgoImFjdGlvbkNvZGUiKTo6YnBjaGFyIDw+ICdNUE9PTCc6OmJwY2hhcikgQU5E +ICgoImFjdGlvbkNvZGUiKTo6YnBjaGFyIDw+ICdNUEFOJzo6YnBjaGFyKSBBTkQgKCgiYWN0aW9u +Q29kZSIpOjpicGNoYXIgPD4gJ1BSJzo6YnBjaGFyKSBBTkQgKCgiYWN0aW9uQ29kZSIpOjpicGNo +YXIgPD4gJ0pQUCc6OmJwY2hhcikgQU5EICgoImFjdGlvbkNvZGUiKTo6YnBjaGFyIDw+ICdNRlJP +TSc6OmJwY2hhcikgQU5EICgoImFjdGlvbkNvZGUiKTo6YnBjaGFyIDw+ICdNTkVYVCc6OmJwY2hh +cikgQU5EIChzdWJwbGFuKSBBTkQgKCgoInBvb2xJZCIgSVMgTlVMTCkgQU5EIChzdWJwbGFuKSkg +T1IgKCgicGFuZWxJZCIgSVMgTlVMTCkgQU5EIChzdWJwbGFuKSkpKQogICAgICAgICAgICAgICBT +dWJQbGFuCiAgICAgICAgICAgICAgICAgLT4gIEluZGV4IFNjYW4gdXNpbmcgIkFjdGlvbl9wa2V5 +IiBvbiAiQWN0aW9uIiBhMSAgKGNvc3Q9MC4wMC4uNDM2LjgxIHJvd3M9MSB3aWR0aD0wKQogICAg +ICAgICAgICAgICAgICAgICAgIEluZGV4IENvbmQ6ICgoKCJjb3VudHlObyIpOjpzbWFsbGludCA9 +IDQwKSBBTkQgKCgiY291bnR5Tm8iKTo6c21hbGxpbnQgPSAoJDApOjpzbWFsbGludCkgQU5EICgo +ImFjdGlvblNlcU5vIik6OmludGVnZXIgPCAoJDMpOjppbnRlZ2VyKSBBTkQgKCgianVyeVllYXIi +KTo6YnBjaGFyID0gKCQxKTo6YnBjaGFyKSkKICAgICAgICAgICAgICAgICAgICAgICBGaWx0ZXI6 +ICgoKCJqdXJvcklkIik6OmludGVnZXIgPSAoJDIpOjppbnRlZ2VyKSBBTkQgKCgoImFjdGlvbkNv +ZGUiKTo6YnBjaGFyID0gJ0FQQU4nOjpicGNoYXIpIE9SICgoImFjdGlvbkNvZGUiKTo6YnBjaGFy +ID0gJ01QQU4nOjpicGNoYXIpKSkKICAgICAgICAgICAgICAgICAtPiAgSW5kZXggU2NhbiB1c2lu +ZyAiQWN0aW9uX3BrZXkiIG9uICJBY3Rpb24iIGExICAoY29zdD0wLjAwLi40MzYuODEgcm93cz0x +IHdpZHRoPTApCiAgICAgICAgICAgICAgICAgICAgICAgSW5kZXggQ29uZDogKCgoImNvdW50eU5v +Iik6OnNtYWxsaW50ID0gNDApIEFORCAoKCJjb3VudHlObyIpOjpzbWFsbGludCA9ICgkMCk6OnNt +YWxsaW50KSBBTkQgKCgiYWN0aW9uU2VxTm8iKTo6aW50ZWdlciA8ICgkMyk6OmludGVnZXIpIEFO +RCAoKCJqdXJ5WWVhciIpOjpicGNoYXIgPSAoJDEpOjpicGNoYXIpKQogICAgICAgICAgICAgICAg +ICAgICAgIEZpbHRlcjogKCgoImp1cm9ySWQiKTo6aW50ZWdlciA9ICgkMik6OmludGVnZXIpIEFO +RCAoKCgiYWN0aW9uQ29kZSIpOjpicGNoYXIgPSAnQVBPT0wnOjpicGNoYXIpIE9SICgoImFjdGlv +bkNvZGUiKTo6YnBjaGFyID0gJ01QT09MJzo6YnBjaGFyKSkpCiAgICAgICAgICAgICAgICAgLT4g +IEluZGV4IFNjYW4gdXNpbmcgIkp1cnlDb250cm9sX3BrZXkiIG9uICJKdXJ5Q29udHJvbCIgamMg +IChjb3N0PTAuMDAuLjMuNzMgcm93cz0xIHdpZHRoPTApCiAgICAgICAgICAgICAgICAgICAgICAg +SW5kZXggQ29uZDogKCgoImNvdW50eU5vIik6OnNtYWxsaW50ID0gNDApIEFORCAoKCJjb3VudHlO +byIpOjpzbWFsbGludCA9ICgkMCk6OnNtYWxsaW50KSkKICAgICAgICAgICAgICAgICAgICAgICBG +aWx0ZXI6ICgoImp1cnlZZWFyIik6OmJwY2hhciA9ICgkMSk6OmJwY2hhcikKICAgLT4gIFNvcnQg +IChjb3N0PTMwMDA3MS42OS4uMzAwOTk0LjU0IHJvd3M9MzY5MTM3IHdpZHRoPTUwKQogICAgICAg +ICBTb3J0IEtleTogKGEyLiJqdXJvcklkIik6OmludGVnZXIsIChhMi4ianVyeVllYXIiKTo6YnBj +aGFyCiAgICAgICAgIC0+ICBCaXRtYXAgSGVhcCBTY2FuIG9uICJBY3Rpb24iIGEyICAoY29zdD0x +NDYxMy41Ni4uMjU4MDA1Ljg2IHJvd3M9MzY5MTM3IHdpZHRoPTUwKQogICAgICAgICAgICAgICBS +ZWNoZWNrIENvbmQ6ICgoImNvdW50eU5vIik6OnNtYWxsaW50ID0gNDApCiAgICAgICAgICAgICAg +IEZpbHRlcjogKCgoImFjdGlvbkNvZGUiKTo6YnBjaGFyID0gJ0FQT09MJzo6YnBjaGFyKSBPUiAo +KCJhY3Rpb25Db2RlIik6OmJwY2hhciA9ICdSUE9PTCc6OmJwY2hhcikgT1IgKCgiYWN0aW9uQ29k +ZSIpOjpicGNoYXIgPSAnQVBBTic6OmJwY2hhcikgT1IgKCgiYWN0aW9uQ29kZSIpOjpicGNoYXIg +PSAnUlBBTic6OmJwY2hhcikgT1IgKCgiYWN0aW9uQ29kZSIpOjpicGNoYXIgPSAnTVBPT0wnOjpi +cGNoYXIpIE9SICgoImFjdGlvbkNvZGUiKTo6YnBjaGFyID0gJ01QQU4nOjpicGNoYXIpKQogICAg +ICAgICAgICAgICAtPiAgQml0bWFwIEluZGV4IFNjYW4gb24gIkFjdGlvbl9wa2V5IiAgKGNvc3Q9 +MC4wMC4uMTQ2MTMuNTYgcm93cz0xODI0NDQ3IHdpZHRoPTApCiAgICAgICAgICAgICAgICAgICAg +IEluZGV4IENvbmQ6ICgoImNvdW50eU5vIik6OnNtYWxsaW50ID0gNDApCiAgIFN1YlBsYW4KICAg +ICAtPiAgSW5kZXggU2NhbiB1c2luZyAiQWN0aW9uX3BrZXkiIG9uICJBY3Rpb24iIGEzICAoY29z +dD0wLjAwLi45LjU3IHJvd3M9MSB3aWR0aD0xNzYpCiAgICAgICAgICAgSW5kZXggQ29uZDogKCgo +ImNvdW50eU5vIik6OnNtYWxsaW50ID0gNDApIEFORCAoKCJjb3VudHlObyIpOjpzbWFsbGludCA9 +ICgkMCk6OnNtYWxsaW50KSBBTkQgKCgiY291bnR5Tm8iKTo6c21hbGxpbnQgPSAoJDUpOjpzbWFs +bGludCkgQU5EICgoImp1cnlZZWFyIik6OmJwY2hhciA9ICgkMSk6OmJwY2hhcikgQU5EICgoImp1 +cnlZZWFyIik6OmJwY2hhciA9ICgkNik6OmJwY2hhcikpCiAgICAgICAgICAgRmlsdGVyOiAoKCgi +anVyb3JJZCIpOjppbnRlZ2VyID0gKCQyKTo6aW50ZWdlcikgQU5EICgoKCJhY3Rpb25Db2RlIik6 +OmJwY2hhciA9ICdBUE9PTCc6OmJwY2hhcikgT1IgKCgiYWN0aW9uQ29kZSIpOjpicGNoYXIgPSAn +UlBPT0wnOjpicGNoYXIpIE9SICgoImFjdGlvbkNvZGUiKTo6YnBjaGFyID0gJ0FQQU4nOjpicGNo +YXIpIE9SICgoImFjdGlvbkNvZGUiKTo6YnBjaGFyID0gJ1JQQU4nOjpicGNoYXIpIE9SICgoImFj +dGlvbkNvZGUiKTo6YnBjaGFyID0gJ01QT09MJzo6YnBjaGFyKSBPUiAoKCJhY3Rpb25Db2RlIik6 +OmJwY2hhciA9ICdNUEFOJzo6YnBjaGFyKSkgQU5EICgoInN0YXJ0RGF0ZSIpOjpkYXRlIDwgKCQ0 +KTo6ZGF0ZSkgQU5EICgoImp1cm9ySWQiKTo6aW50ZWdlciA9ICgkNyk6OmludGVnZXIpIEFORCAo +KCJzdGFydERhdGUiKTo6ZGF0ZSA+PSAoJDgpOjpkYXRlKSBBTkQgKCgoInN0YXJ0RGF0ZSIpOjpk +YXRlID4gKCQ4KTo6ZGF0ZSkgT1IgKCgiYWN0aW9uU2VxTm8iKTo6aW50ZWdlciA+ICgkOSk6Omlu +dGVnZXIpKSkKKDI5IHJvd3MpCgo= + +--=__Part9FBAD2D8.0__= +Content-Type: application/octet-stream; name="datafix-plan2.txt" +Content-Transfer-Encoding: base64 +Content-Disposition: attachment; filename="datafix-plan2.txt" + +IE1lcmdlIEpvaW4gIChjb3N0PTIwMjYzNzQ5LjY3Li4yMzQwMDAzNi4yMSByb3dzPTE0NTkxNCB3 +aWR0aD0xODIpCiAgIE1lcmdlIENvbmQ6ICgoIm91dGVyIi4iP2NvbHVtbjE2PyIgPSAiaW5uZXIi +LiI/Y29sdW1uOD8iKSBBTkQgKCJvdXRlciIuIj9jb2x1bW4xNz8iID0gImlubmVyIi4iP2NvbHVt +bjk/IikpCiAgIEpvaW4gRmlsdGVyOiAoKCgiaW5uZXIiLiJzdGFydERhdGUiKTo6ZGF0ZSA8ICgi +b3V0ZXIiLiJzdGFydERhdGUiKTo6ZGF0ZSkgQU5EIChOT1QgKHN1YnBsYW4pKSkKICAgLT4gIFNv +cnQgIChjb3N0PTIwMDA3MjMwLjg4Li4yMDAwODA5Ni43NiByb3dzPTM0NjM1MiB3aWR0aD0xNTQp +CiAgICAgICAgIFNvcnQgS2V5OiAoIkFjdGlvbiIuImp1cm9ySWQiKTo6aW50ZWdlciwgKCJBY3Rp +b24iLiJqdXJ5WWVhciIpOjpicGNoYXIKICAgICAgICAgLT4gIEluZGV4IFNjYW4gdXNpbmcgIkFj +dGlvbl9wa2V5IiBvbiAiQWN0aW9uIiAgKGNvc3Q9MC4wMC4uMTk5NTkxMjYuMjcgcm93cz0zNDYz +NTIgd2lkdGg9MTU0KQogICAgICAgICAgICAgICBJbmRleCBDb25kOiAoKCJjb3VudHlObyIpOjpz +bWFsbGludCA9IDQwKQogICAgICAgICAgICAgICBGaWx0ZXI6ICgoKCJhY3Rpb25Db2RlIik6OmJw +Y2hhciA8PiAnQVBPT0wnOjpicGNoYXIpIEFORCAoKCJhY3Rpb25Db2RlIik6OmJwY2hhciA8PiAn +UlBPT0wnOjpicGNoYXIpIEFORCAoKCJhY3Rpb25Db2RlIik6OmJwY2hhciA8PiAnQVBBTic6OmJw +Y2hhcikgQU5EICgoImFjdGlvbkNvZGUiKTo6YnBjaGFyIDw+ICdSUEFOJzo6YnBjaGFyKSBBTkQg +KCgiYWN0aW9uQ29kZSIpOjpicGNoYXIgPD4gJ01QT09MJzo6YnBjaGFyKSBBTkQgKCgiYWN0aW9u +Q29kZSIpOjpicGNoYXIgPD4gJ01QQU4nOjpicGNoYXIpIEFORCAoKCJhY3Rpb25Db2RlIik6OmJw +Y2hhciA8PiAnUFInOjpicGNoYXIpIEFORCAoKCJhY3Rpb25Db2RlIik6OmJwY2hhciA8PiAnSlBQ +Jzo6YnBjaGFyKSBBTkQgKCgiYWN0aW9uQ29kZSIpOjpicGNoYXIgPD4gJ01GUk9NJzo6YnBjaGFy +KSBBTkQgKCgiYWN0aW9uQ29kZSIpOjpicGNoYXIgPD4gJ01ORVhUJzo6YnBjaGFyKSBBTkQgKHN1 +YnBsYW4pIEFORCAoKCgicG9vbElkIiBJUyBOVUxMKSBBTkQgKHN1YnBsYW4pKSBPUiAoKCJwYW5l +bElkIiBJUyBOVUxMKSBBTkQgKHN1YnBsYW4pKSkpCiAgICAgICAgICAgICAgIFN1YlBsYW4KICAg +ICAgICAgICAgICAgICAtPiAgSW5kZXggU2NhbiB1c2luZyAiQWN0aW9uX2p1cm9yIiBvbiAiQWN0 +aW9uIiBhMSAgKGNvc3Q9MC4wMC4uMy41MyByb3dzPTEgd2lkdGg9MCkKICAgICAgICAgICAgICAg +ICAgICAgICBJbmRleCBDb25kOiAoKCgiY291bnR5Tm8iKTo6c21hbGxpbnQgPSA0MCkgQU5EICgo +ImNvdW50eU5vIik6OnNtYWxsaW50ID0gKCQwKTo6c21hbGxpbnQpIEFORCAoKCJqdXJ5WWVhciIp +OjpicGNoYXIgPSAoJDEpOjpicGNoYXIpIEFORCAoKCJqdXJvcklkIik6OmludGVnZXIgPSAoJDIp +OjppbnRlZ2VyKSBBTkQgKCgiYWN0aW9uU2VxTm8iKTo6aW50ZWdlciA8ICgkMyk6OmludGVnZXIp +KQogICAgICAgICAgICAgICAgICAgICAgIEZpbHRlcjogKCgoImFjdGlvbkNvZGUiKTo6YnBjaGFy +ID0gJ0FQQU4nOjpicGNoYXIpIE9SICgoImFjdGlvbkNvZGUiKTo6YnBjaGFyID0gJ01QQU4nOjpi +cGNoYXIpKQogICAgICAgICAgICAgICAgIC0+ICBJbmRleCBTY2FuIHVzaW5nICJBY3Rpb25fanVy +b3IiIG9uICJBY3Rpb24iIGExICAoY29zdD0wLjAwLi4zLjUzIHJvd3M9MSB3aWR0aD0wKQogICAg +ICAgICAgICAgICAgICAgICAgIEluZGV4IENvbmQ6ICgoKCJjb3VudHlObyIpOjpzbWFsbGludCA9 +IDQwKSBBTkQgKCgiY291bnR5Tm8iKTo6c21hbGxpbnQgPSAoJDApOjpzbWFsbGludCkgQU5EICgo +Imp1cnlZZWFyIik6OmJwY2hhciA9ICgkMSk6OmJwY2hhcikgQU5EICgoImp1cm9ySWQiKTo6aW50 +ZWdlciA9ICgkMik6OmludGVnZXIpIEFORCAoKCJhY3Rpb25TZXFObyIpOjppbnRlZ2VyIDwgKCQz +KTo6aW50ZWdlcikpCiAgICAgICAgICAgICAgICAgICAgICAgRmlsdGVyOiAoKCgiYWN0aW9uQ29k +ZSIpOjpicGNoYXIgPSAnQVBPT0wnOjpicGNoYXIpIE9SICgoImFjdGlvbkNvZGUiKTo6YnBjaGFy +ID0gJ01QT09MJzo6YnBjaGFyKSkKICAgICAgICAgICAgICAgICAtPiAgSW5kZXggU2NhbiB1c2lu +ZyAiSnVyeUNvbnRyb2xfcGtleSIgb24gIkp1cnlDb250cm9sIiBqYyAgKGNvc3Q9MC4wMC4uMy43 +MyByb3dzPTEgd2lkdGg9MCkKICAgICAgICAgICAgICAgICAgICAgICBJbmRleCBDb25kOiAoKCgi +Y291bnR5Tm8iKTo6c21hbGxpbnQgPSA0MCkgQU5EICgoImNvdW50eU5vIik6OnNtYWxsaW50ID0g +KCQwKTo6c21hbGxpbnQpKQogICAgICAgICAgICAgICAgICAgICAgIEZpbHRlcjogKCgianVyeVll +YXIiKTo6YnBjaGFyID0gKCQxKTo6YnBjaGFyKQogICAtPiAgU29ydCAgKGNvc3Q9MjU2NTE4Ljc5 +Li4yNTc0NDAuMDEgcm93cz0zNjg0ODcgd2lkdGg9NTApCiAgICAgICAgIFNvcnQgS2V5OiAoYTIu +Imp1cm9ySWQiKTo6aW50ZWdlciwgKGEyLiJqdXJ5WWVhciIpOjpicGNoYXIKICAgICAgICAgLT4g +IEJpdG1hcCBIZWFwIFNjYW4gb24gIkFjdGlvbiIgYTIgIChjb3N0PTE0NjUxNS45Ny4uMjE0NTMx +Ljc1IHJvd3M9MzY4NDg3IHdpZHRoPTUwKQogICAgICAgICAgICAgICBSZWNoZWNrIENvbmQ6ICgo +KCgoImNvdW50eU5vIik6OnNtYWxsaW50ID0gNDApIEFORCAoKCJhY3Rpb25Db2RlIik6OmJwY2hh +ciA9ICdBUE9PTCc6OmJwY2hhcikpIE9SICgoKCJjb3VudHlObyIpOjpzbWFsbGludCA9IDQwKSBB +TkQgKCgiYWN0aW9uQ29kZSIpOjpicGNoYXIgPSAnUlBPT0wnOjpicGNoYXIpKSBPUiAoKCgiY291 +bnR5Tm8iKTo6c21hbGxpbnQgPSA0MCkgQU5EICgoImFjdGlvbkNvZGUiKTo6YnBjaGFyID0gJ0FQ +QU4nOjpicGNoYXIpKSBPUiAoKCgiY291bnR5Tm8iKTo6c21hbGxpbnQgPSA0MCkgQU5EICgoImFj +dGlvbkNvZGUiKTo6YnBjaGFyID0gJ1JQQU4nOjpicGNoYXIpKSBPUiAoKCgiY291bnR5Tm8iKTo6 +c21hbGxpbnQgPSA0MCkgQU5EICgoImFjdGlvbkNvZGUiKTo6YnBjaGFyID0gJ01QT09MJzo6YnBj +aGFyKSkgT1IgKCgoImNvdW50eU5vIik6OnNtYWxsaW50ID0gNDApIEFORCAoKCJhY3Rpb25Db2Rl +Iik6OmJwY2hhciA9ICdNUEFOJzo6YnBjaGFyKSkpIEFORCAoKCJjb3VudHlObyIpOjpzbWFsbGlu +dCA9IDQwKSkKICAgICAgICAgICAgICAgLT4gIEJpdG1hcEFuZCAgKGNvc3Q9MTQ2NTE1Ljk3Li4x +NDY1MTUuOTcgcm93cz00OTMxMyB3aWR0aD0wKQogICAgICAgICAgICAgICAgICAgICAtPiAgQml0 +bWFwT3IgIChjb3N0PTEzMTkxMi40MC4uMTMxOTEyLjQwIHJvd3M9Mzk3Njg3IHdpZHRoPTApCiAg +ICAgICAgICAgICAgICAgICAgICAgICAgIC0+ICBCaXRtYXAgSW5kZXggU2NhbiBvbiAiQWN0aW9u +X2p1cm9yIiAgKGNvc3Q9MC4wMC4uMjE5ODUuNDAgcm93cz0xNTkwNTQgd2lkdGg9MCkKICAgICAg +ICAgICAgICAgICAgICAgICAgICAgICAgICAgSW5kZXggQ29uZDogKCgoImNvdW50eU5vIik6OnNt +YWxsaW50ID0gNDApIEFORCAoKCJhY3Rpb25Db2RlIik6OmJwY2hhciA9ICdBUE9PTCc6OmJwY2hh +cikpCiAgICAgICAgICAgICAgICAgICAgICAgICAgIC0+ICBCaXRtYXAgSW5kZXggU2NhbiBvbiAi +QWN0aW9uX2p1cm9yIiAgKGNvc3Q9MC4wMC4uMjE5ODUuNDAgcm93cz0xNTU5OSB3aWR0aD0wKQog +ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBJbmRleCBDb25kOiAoKCgiY291bnR5Tm8i +KTo6c21hbGxpbnQgPSA0MCkgQU5EICgoImFjdGlvbkNvZGUiKTo6YnBjaGFyID0gJ1JQT09MJzo6 +YnBjaGFyKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgLT4gIEJpdG1hcCBJbmRleCBTY2Fu +IG9uICJBY3Rpb25fanVyb3IiICAoY29zdD0wLjAwLi4yMTk4NS40MCByb3dzPTE0MDIzNSB3aWR0 +aD0wKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBJbmRleCBDb25kOiAoKCgiY291 +bnR5Tm8iKTo6c21hbGxpbnQgPSA0MCkgQU5EICgoImFjdGlvbkNvZGUiKTo6YnBjaGFyID0gJ0FQ +QU4nOjpicGNoYXIpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAtPiAgQml0bWFwIEluZGV4 +IFNjYW4gb24gIkFjdGlvbl9qdXJvciIgIChjb3N0PTAuMDAuLjIxOTg1LjQwIHJvd3M9NTE2MDIg +d2lkdGg9MCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgSW5kZXggQ29uZDogKCgo +ImNvdW50eU5vIik6OnNtYWxsaW50ID0gNDApIEFORCAoKCJhY3Rpb25Db2RlIik6OmJwY2hhciA9 +ICdSUEFOJzo6YnBjaGFyKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgLT4gIEJpdG1hcCBJ +bmRleCBTY2FuIG9uICJBY3Rpb25fanVyb3IiICAoY29zdD0wLjAwLi4yMTk4NS40MCByb3dzPTE1 +NTk5IHdpZHRoPTApCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEluZGV4IENvbmQ6 +ICgoKCJjb3VudHlObyIpOjpzbWFsbGludCA9IDQwKSBBTkQgKCgiYWN0aW9uQ29kZSIpOjpicGNo +YXIgPSAnTVBPT0wnOjpicGNoYXIpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAtPiAgQml0 +bWFwIEluZGV4IFNjYW4gb24gIkFjdGlvbl9qdXJvciIgIChjb3N0PTAuMDAuLjIxOTg1LjQwIHJv +d3M9MTU1OTkgd2lkdGg9MCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgSW5kZXgg +Q29uZDogKCgoImNvdW50eU5vIik6OnNtYWxsaW50ID0gNDApIEFORCAoKCJhY3Rpb25Db2RlIik6 +OmJwY2hhciA9ICdNUEFOJzo6YnBjaGFyKSkKICAgICAgICAgICAgICAgICAgICAgLT4gIEJpdG1h +cCBJbmRleCBTY2FuIG9uICJBY3Rpb25fcGtleSIgIChjb3N0PTAuMDAuLjE0NjAzLjMyIHJvd3M9 +MTgyMTIzMyB3aWR0aD0wKQogICAgICAgICAgICAgICAgICAgICAgICAgICBJbmRleCBDb25kOiAo +KCJjb3VudHlObyIpOjpzbWFsbGludCA9IDQwKQogICBTdWJQbGFuCiAgICAgLT4gIEluZGV4IFNj +YW4gdXNpbmcgIkFjdGlvbl9qdXJvciIgb24gIkFjdGlvbiIgYTMgIChjb3N0PTAuMDAuLjMuNTYg +cm93cz0xIHdpZHRoPTE3NikKICAgICAgICAgICBJbmRleCBDb25kOiAoKCgiY291bnR5Tm8iKTo6 +c21hbGxpbnQgPSA0MCkgQU5EICgoImNvdW50eU5vIik6OnNtYWxsaW50ID0gKCQwKTo6c21hbGxp +bnQpIEFORCAoKCJjb3VudHlObyIpOjpzbWFsbGludCA9ICgkNSk6OnNtYWxsaW50KSBBTkQgKCgi +anVyeVllYXIiKTo6YnBjaGFyID0gKCQxKTo6YnBjaGFyKSBBTkQgKCgianVyeVllYXIiKTo6YnBj +aGFyID0gKCQ2KTo6YnBjaGFyKSBBTkQgKCgianVyb3JJZCIpOjppbnRlZ2VyID0gKCQyKTo6aW50 +ZWdlcikgQU5EICgoImp1cm9ySWQiKTo6aW50ZWdlciA9ICgkNyk6OmludGVnZXIpKQogICAgICAg +ICAgIEZpbHRlcjogKCgoKCJhY3Rpb25Db2RlIik6OmJwY2hhciA9ICdBUE9PTCc6OmJwY2hhcikg +T1IgKCgiYWN0aW9uQ29kZSIpOjpicGNoYXIgPSAnUlBPT0wnOjpicGNoYXIpIE9SICgoImFjdGlv +bkNvZGUiKTo6YnBjaGFyID0gJ0FQQU4nOjpicGNoYXIpIE9SICgoImFjdGlvbkNvZGUiKTo6YnBj +aGFyID0gJ1JQQU4nOjpicGNoYXIpIE9SICgoImFjdGlvbkNvZGUiKTo6YnBjaGFyID0gJ01QT09M +Jzo6YnBjaGFyKSBPUiAoKCJhY3Rpb25Db2RlIik6OmJwY2hhciA9ICdNUEFOJzo6YnBjaGFyKSkg +QU5EICgoInN0YXJ0RGF0ZSIpOjpkYXRlIDwgKCQ0KTo6ZGF0ZSkgQU5EICgoInN0YXJ0RGF0ZSIp +OjpkYXRlID49ICgkOCk6OmRhdGUpIEFORCAoKCgic3RhcnREYXRlIik6OmRhdGUgPiAoJDgpOjpk +YXRlKSBPUiAoKCJhY3Rpb25TZXFObyIpOjppbnRlZ2VyID4gKCQ5KTo6aW50ZWdlcikpKQooNDIg +cm93cykKCg== + +--=__Part9FBAD2D8.0__= +Content-Type: application/octet-stream; name="datafix.qry" +Content-Transfer-Encoding: base64 +Content-Disposition: attachment; filename="datafix.qry" + +VVBEQVRFICJBY3Rpb24iCiAgU0VUICJwb29sSWQiICA9IGEyLiJwb29sSWQiLAogICAgICAicGFu +ZWxJZCIgPSBhMi4icGFuZWxJZCIKICBGUk9NICJBY3Rpb24iIGEyCiAgV0hFUkUgIkFjdGlvbiIu +ImFjdGlvbkNvZGUiIG5vdCBpbgogICAgICAoJ0FQT09MJywnUlBPT0wnLCdBUEFOJywnUlBBTics +ICdNUE9PTCcsJ01QQU4nLCAnUFInLCdKUFAnLCAnTUZST00nLCAnTU5FWFQnKQogICAgQU5EICJB +Y3Rpb24iLiJjb3VudHlObyIgPSA0MAogICAgQU5EIEVYSVNUUwogICAgICAgICgKICAgICAgICAg +IFNFTEVDVCAxIEZST00gIkp1cnlDb250cm9sIiBqYwogICAgICAgICAgICBXSEVSRSBqYy4iY291 +bnR5Tm8iID0gNDAKICAgICAgICAgICAgICBBTkQgamMuImNvdW50eU5vIiA9ICJBY3Rpb24iLiJj +b3VudHlObyIKICAgICAgICAgICAgICBBTkQgamMuImp1cnlZZWFyIiA9ICJBY3Rpb24iLiJqdXJ5 +WWVhciIKICAgICAgICApCiAgICBBTkQgKCAgKCAiQWN0aW9uIi4icG9vbElkIiBpcyBudWxsCiAg +ICAgICAgIEFORCBleGlzdHMKICAgICAgICAgICAgICgKICAgICAgICAgICAgICAgc2VsZWN0IDEg +ZnJvbSAiQWN0aW9uIiBhMQogICAgICAgICAgICAgICAgIHdoZXJlIGExLiJjb3VudHlObyIgICAg +PSA0MAogICAgICAgICAgICAgICAgICAgYW5kIGExLiJjb3VudHlObyIgICAgPSAiQWN0aW9uIi4i +Y291bnR5Tm8iCiAgICAgICAgICAgICAgICAgICBhbmQgYTEuImp1cnlZZWFyIiAgICA9ICJBY3Rp +b24iLiJqdXJ5WWVhciIKICAgICAgICAgICAgICAgICAgIGFuZCBhMS4ianVyb3JJZCIgICAgID0g +IkFjdGlvbiIuImp1cm9ySWQiCiAgICAgICAgICAgICAgICAgICBhbmQgYTEuImFjdGlvblNlcU5v +IiA8ICJBY3Rpb24iLiJhY3Rpb25TZXFObyIKICAgICAgICAgICAgICAgICAgIGFuZCBhMS4iYWN0 +aW9uQ29kZSIgaW4gKCdBUE9PTCcsJ01QT09MJykKICAgICAgICAgICAgICkKICAgICAgICAgICAp +CiAgICAgICBPUiAgKCAiQWN0aW9uIi4icGFuZWxJZCIgaXMgbnVsbAogICAgICAgICBBTkQgZXhp +c3RzCiAgICAgICAgICAgICAoCiAgICAgICAgICAgICAgIHNlbGVjdCAxIGZyb20gIkFjdGlvbiIg +YTEKICAgICAgICAgICAgICAgICB3aGVyZSBhMS4iY291bnR5Tm8iICAgID0gNDAKICAgICAgICAg +ICAgICAgICAgIGFuZCBhMS4iY291bnR5Tm8iICAgID0gIkFjdGlvbiIuImNvdW50eU5vIgogICAg +ICAgICAgICAgICAgICAgYW5kIGExLiJqdXJvcklkIiAgICAgPSAiQWN0aW9uIi4ianVyb3JJZCIK +ICAgICAgICAgICAgICAgICAgIGFuZCBhMS4ianVyeVllYXIiICAgID0gIkFjdGlvbiIuImp1cnlZ +ZWFyIgogICAgICAgICAgICAgICAgICAgYW5kIGExLiJhY3Rpb25TZXFObyIgPCAiQWN0aW9uIi4i +YWN0aW9uU2VxTm8iCiAgICAgICAgICAgICAgICAgICBhbmQgYTEuImFjdGlvbkNvZGUiIGluICgn +QVBBTicsJ01QQU4nKQogICAgICAgICAgICAgKQogICAgICAgICAgICkKICAgICAgICApCiAgICBB +TkQgYTIuImNvdW50eU5vIiA9IDQwCiAgICBBTkQgYTIuImNvdW50eU5vIiA9ICJBY3Rpb24iLiJj +b3VudHlObyIKICAgIEFORCBhMi4ianVyeVllYXIiID0gIkFjdGlvbiIuImp1cnlZZWFyIgogICAg +QU5EIGEyLiJqdXJvcklkIiAgPSAiQWN0aW9uIi4ianVyb3JJZCIKICAgIEFORCBhMi4iYWN0aW9u +Q29kZSIgSU4gKCdBUE9PTCcsJ1JQT09MJywnQVBBTicsJ1JQQU4nLCAnTVBPT0wnLCdNUEFOJykK +ICAgIEFORCBhMi4ic3RhcnREYXRlIiA8ICAiQWN0aW9uIi4ic3RhcnREYXRlIgogICAgQU5EIE5P +VCBFWElTVFMKICAgICAgICAoCiAgICAgICAgICBTRUxFQ1QgKiBGUk9NICJBY3Rpb24iIGEzCiAg +ICAgICAgICAgIFdIRVJFIGEzLiJjb3VudHlObyIgPSA0MAogICAgICAgICAgICAgIEFORCBhMy4i +Y291bnR5Tm8iID0gIkFjdGlvbiIuImNvdW50eU5vIgogICAgICAgICAgICAgIEFORCBhMy4ianVy +eVllYXIiID0gIkFjdGlvbiIuImp1cnlZZWFyIgogICAgICAgICAgICAgIEFORCBhMy4ianVyb3JJ +ZCIgID0gIkFjdGlvbiIuImp1cm9ySWQiCiAgICAgICAgICAgICAgQU5EIGEzLiJhY3Rpb25Db2Rl +IiBJTiAoJ0FQT09MJywnUlBPT0wnLCdBUEFOJywnUlBBTicsICdNUE9PTCcsJ01QQU4nKQogICAg +ICAgICAgICAgIEFORCBhMy4ic3RhcnREYXRlIiA8ICAiQWN0aW9uIi4ic3RhcnREYXRlIgogICAg +ICAgICAgICAgIEFORCBhMy4iY291bnR5Tm8iID0gYTIuImNvdW50eU5vIgogICAgICAgICAgICAg +IEFORCBhMy4ianVyeVllYXIiID0gYTIuImp1cnlZZWFyIgogICAgICAgICAgICAgIEFORCBhMy4i +anVyb3JJZCIgID0gYTIuImp1cm9ySWQiCiAgICAgICAgICAgICAgQU5EIGEzLiJzdGFydERhdGUi +ID49IGEyLiJzdGFydERhdGUiCiAgICAgICAgICAgICAgQU5EICggYTMuInN0YXJ0RGF0ZSIgPiBh +Mi4ic3RhcnREYXRlIgogICAgICAgICAgICAgICAgIE9SIGEzLiJhY3Rpb25TZXFObyIgPiBhMi4i +YWN0aW9uU2VxTm8iCiAgICAgICAgICAgICAgICAgICkKICAgICAgICApOwoK + +--=__Part9FBAD2D8.0__=-- + +From pgsql-hackers-owner@postgresql.org Tue Feb 28 12:45:22 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id EBFCB9DC9A1; + Tue, 28 Feb 2006 12:45:20 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 60557-09; Tue, 28 Feb 2006 12:45:19 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id E68399DCA1B; + Tue, 28 Feb 2006 12:45:16 -0400 (AST) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 38AAF56462; Tue, 28 Feb 2006 10:45:16 -0600 (CST) +Received: (hashcash-sendmail, from uid 1001); Tue, 28 Feb 2006 10:45:15 -0600 +Date: Tue, 28 Feb 2006 10:45:15 -0600 +From: "Jim C. Nasby" +To: Kevin Grittner +Cc: pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: temporary indexes +Message-ID: <20060228164515.GS82012@pervasive.com> +References: <44041B68.EE98.0025.0@wicourts.gov> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <44041B68.EE98.0025.0@wicourts.gov> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060228:kevin.grittner@wicourts.gov::65RGNlrIQ+dTb0L2:0000000000 + 0000000000000000000000000GJd +X-Hashcash: + 1:20:060228:pgsql-hackers@postgresql.org::90rWyTQTqjhTpzNH:000000000 + 0000000000000000000000002R6p +X-Hashcash: + 1:20:060228:pgsql-performance@postgresql.org::gWXt308QpANvQGJy:00000 + 00000000000000000000000061Ko +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.105 required=5 tests=[AWL=0.105] +X-Spam-Score: 0.105 +X-Spam-Level: +X-Archive-Number: 200602/1208 +X-Sequence-Number: 80346 + +On Tue, Feb 28, 2006 at 09:44:08AM -0600, Kevin Grittner wrote: +> It struck me that it would be outstanding if the planner could +> recognize this sort of situation, and build a temporary index based on +> the snapshot of the data visible to the transaction. It seems to me +> that the obvious downside of this would be the explosion in the number +> of permutations the planner would need to examine -- based not just on +> what indexes ARE there, but which ones it could build. At a minimum, +> there would need to be a cost threshold below which it would not even +> consider the option. (In this case, as long as the optimizer spent less +> than 13 hours and 50 minutes considering its options, we would have come +> out ahead.) + +FWIW, Sybase supported something similar a long time ago. It had the +ability to build a temporary 'clustered table' (think index organized +table) when there was enough benefit to do so. This is actually +much easier to make happen inside a transaction for us, because we don't +need to keep visibility information around. There's probably also some +index metadata that could be done away with. Perhaps the materialize +node could be made to allow this. +-- +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 Tue Feb 28 12:52:17 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 0E6929DC876; + Tue, 28 Feb 2006 12:52:16 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 63078-03; Tue, 28 Feb 2006 12:52:15 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 60FC69DC847; + Tue, 28 Feb 2006 12:52:11 -0400 (AST) +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 k1SGqBME015925; + Tue, 28 Feb 2006 11:52:11 -0500 (EST) +To: "Kevin Grittner" +cc: pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: [PERFORM] temporary indexes +In-reply-to: <44041B68.EE98.0025.0@wicourts.gov> +References: <44041B68.EE98.0025.0@wicourts.gov> +Comments: In-reply-to "Kevin Grittner" + message dated "Tue, 28 Feb 2006 09:44:08 -0600" +Date: Tue, 28 Feb 2006 11:52:11 -0500 +Message-ID: <15924.1141145531@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.111 required=5 tests=[AWL=0.111] +X-Spam-Score: 0.111 +X-Spam-Level: +X-Archive-Number: 200602/1210 +X-Sequence-Number: 80348 + +"Kevin Grittner" writes: +> It struck me that it would be outstanding if the planner could +> recognize this sort of situation, and build a temporary index based on +> the snapshot of the data visible to the transaction. + +I don't think that's an appropriate solution at all. What it looks like +to me (assuming that explain's estimated row counts are reasonably +on-target) is that the time is all going into the EXISTS subplans. The +real problem here is that we aren't doing anything to convert correlated +EXISTS subqueries into some form of join that's smarter than a raw +nestloop. + + regards, tom lane + +From pgsql-hackers-owner@postgresql.org Tue Feb 28 13:05:51 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id BF4089DCAEE + for ; + Tue, 28 Feb 2006 13:05:50 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 62575-10 + for ; + Tue, 28 Feb 2006 13:05:49 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 985A19DCA62 + for ; + Tue, 28 Feb 2006 13:05:48 -0400 (AST) +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 k1SH5mkd016077; + Tue, 28 Feb 2006 12:05:48 -0500 (EST) +To: "Jim C. Nasby" +cc: Kevin Grittner , + pgsql-hackers@postgresql.org, + pgsql-performance@postgresql.org +Subject: Re: [PERFORM] temporary indexes +In-reply-to: <20060228164515.GS82012@pervasive.com> +References: <44041B68.EE98.0025.0@wicourts.gov> + <20060228164515.GS82012@pervasive.com> +Comments: In-reply-to "Jim C. Nasby" + message dated "Tue, 28 Feb 2006 10:45:15 -0600" +Date: Tue, 28 Feb 2006 12:05:48 -0500 +Message-ID: <16076.1141146348@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.111 required=5 tests=[AWL=0.111] +X-Spam-Score: 0.111 +X-Spam-Level: +X-Archive-Number: 200602/1212 +X-Sequence-Number: 80350 + +"Jim C. Nasby" writes: +> FWIW, Sybase supported something similar a long time ago. It had the +> ability to build a temporary 'clustered table' (think index organized +> table) when there was enough benefit to do so. This is actually +> much easier to make happen inside a transaction for us, because we don't +> need to keep visibility information around. There's probably also some +> index metadata that could be done away with. Perhaps the materialize +> node could be made to allow this. + +How does what you describe differ from a merge join? Or a hash join, +if you imagine the temp index as being a hash rather than btree index? + +The issue at hand really has nothing to do with temp indexes, it's with +the constrained way that the planner deals with EXISTS subplans. The +subplans themselves are cheap enough, even in the poorly-indexed +variant, that the planner would certainly never have decided to create +an index to use for them. The problem only becomes apparent at the next +level up, where those subplans are going to be repeated a huge number of +times ---- but the subplan plan is already chosen and won't be changed. +So even if we invented a temp-index facility, it would fail to be +applied in Kevin's example. The limiting factor is that EXISTS subplans +aren't flattened ... and once that's fixed, I doubt the example would +need any new kind of join support. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Feb 28 13:23:53 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 019D59DC847 + for ; + Tue, 28 Feb 2006 13:23:52 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 67785-03 + for ; + Tue, 28 Feb 2006 13:23:51 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id C0ED39DC876 + for ; + Tue, 28 Feb 2006 13:23:50 -0400 (AST) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 8553656467; Tue, 28 Feb 2006 11:23:35 -0600 (CST) +Received: (hashcash-sendmail, from uid 1001); Tue, 28 Feb 2006 11:23:34 -0600 +Date: Tue, 28 Feb 2006 11:23:34 -0600 +From: "Jim C. Nasby" +To: Javier Somoza +Cc: Bruce Momjian , + Tino Wildenhain , pgsql-performance@postgresql.org +Subject: Re: fsync and battery-backed caches +Message-ID: <20060228172334.GV82012@pervasive.com> +References: <200602280106.k1S16DK16068@candle.pha.pa.us> + <1141114775.1555.7.camel@pndsoft> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1141114775.1555.7.camel@pndsoft> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060228:jsomoza@pandasoftware.es::rN9zQXol/y+JVsv0:0000000000000 + 0000000000000000000000003yOg +X-Hashcash: + 1:20:060228:pgman@candle.pha.pa.us::/1ARJvwQ7c9qtW8y:000000000000000 + 0000000000000000000000004hEP +X-Hashcash: + 1:20:060228:tino@wildenhain.de::dIStB0nu5qwMTS3u:0000000000000000000 + 00000000000000000000000032aR +X-Hashcash: + 1:20:060228:pgsql-performance@postgresql.org::6vE8B2EeR2ytWbtW:00000 + 00000000000000000000000033fd +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=1.355 required=5 tests=[AWL=-1.145, + RAZOR2_CF_RANGE_51_100=0.5, RAZOR2_CF_RANGE_E8_51_100=1.5, + RAZOR2_CHECK=0.5] +X-Spam-Score: 1.355 +X-Spam-Level: * +X-Archive-Number: 200602/436 +X-Sequence-Number: 17422 + +Actually, you can't assume that a BBU means you can safely disable +full-page-writes. Depending on the controller, it's still possible to +end up with partially written pages. + +BTW, if your mailer makes doing so convenient, it would be nice to trim +down your .signature; note that it's about 3x longer than the email you +actually sent. + +On Tue, Feb 28, 2006 at 09:19:36AM +0100, Javier Somoza wrote: +> +> Yeah, i saw it. It says full-page-writes can be disabled +> without problems. +> But i wanted to confirm fsync cannot be disabled although i +> have battery. +> +> Thanks!! :-) +> +> +> +> > We do mention battery-backed cache in our docs: +> > +> > http://www.postgresql.org/docs/8.1/static/wal.html +> > +> > If it is unclear, please let us know. +> +> Javier Somoza +> Oficina de Direcci?n Estrat?gica +> mailto:jsomoza@pandasoftware.es +> +> Panda Software +> Buenos Aires, 12 +> 48001 BILBAO - ESPA?A +> Tel?fono: 902 24 365 4 +> Fax: 94 424 46 97 +> http://www.pandasoftware.es +> Panda Software, una de las principales compa??as desarrolladoras de +> soluciones de protecci?n contra virus e intrusos, presenta su nueva +> familia de soluciones. Todos los usuarios de ordenadores, desde las +> redes m?s grandes a los dom?sticos, disponen ahora de nuevos productos +> con excelentes tecnolog?as de seguridad. M?s informaci?n en: +> http://www.pandasoftware.es/productos +> +> +> +> ?Prot?jase ahora contra virus e intrusos! Pruebe gratis nuestros +> productos en http://www.pandasoftware.es/descargas/ +> +> +> +> +> +> +> +> +> + +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue Feb 28 13:54:19 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id DCD539DCB9E + for ; + Tue, 28 Feb 2006 13:54:18 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 75669-07 + for ; + Tue, 28 Feb 2006 13:54:17 -0400 (AST) +X-Greylist: delayed 00:27:13.243499 by SQLgrey- +Received: from bilbao.pandasoftware.es (unknown [194.30.100.202]) + by postgresql.org (Postfix) with ESMTP id 3A0D39DCB5D + for ; + Tue, 28 Feb 2006 13:54:14 -0400 (AST) +Received: from escorpexh05.pandasoftware.local (escorpext02 [192.168.100.182]) + by bilbao.pandasoftware.es (Postfix) with ESMTP + id D8B741B3923; Tue, 28 Feb 2006 18:26:29 +0100 (CET) +Received: from ESCORPEXH03.pandasoftware.local ([172.16.0.70]) by + escorpexh05.pandasoftware.local with Microsoft + SMTPSVC(6.0.3790.211); Tue, 28 Feb 2006 18:26:50 +0100 +Received: escorpexh03.pandasoftware.local 172.16.0.73 from 172.16.3.16 + 172.16.3.16 via HTTP with MS-WebStorage 6.5.6944 +Received: from pndsoft by escorpexh03.pandasoftware.local; + 28 Feb 2006 18:27:34 +0100 +Subject: Re: fsync and battery-backed caches +From: Javier Somoza +To: "Jim C. Nasby" +Cc: Bruce Momjian , + Tino Wildenhain , pgsql-performance@postgresql.org +In-Reply-To: <20060228172334.GV82012@pervasive.com> +References: <200602280106.k1S16DK16068@candle.pha.pa.us> + <1141114775.1555.7.camel@pndsoft> + <20060228172334.GV82012@pervasive.com> +Content-Type: multipart/alternative; boundary="=-J3lZlvR3YpaghtVpGv1Q" +Message-Id: <1141147654.1555.46.camel@pndsoft> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Tue, 28 Feb 2006 18:27:34 +0100 +X-OriginalArrivalTime: 28 Feb 2006 17:26:50.0234 (UTC) + FILETIME=[28AFDDA0:01C63C8C] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.002 required=5 tests=[HTML_MESSAGE=0.001, + UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 0.002 +X-Spam-Level: +X-Archive-Number: 200602/438 +X-Sequence-Number: 17424 + + +--=-J3lZlvR3YpaghtVpGv1Q +Content-Type: text/plain +Content-Transfer-Encoding: 7bit + + + Ups sorry. + + +> Actually, you can't assume that a BBU means you can safely disable +> full-page-writes. Depending on the controller, it's still possible to +> end up with partially written pages. +> +> BTW, if your mailer makes doing so convenient, it would be nice to trim +> down your .signature; note that it's about 3x longer than the email you +> actually sent. + + + +--=-J3lZlvR3YpaghtVpGv1Q +Content-Type: text/html; charset=utf-8 + + + + + + + + +
+            Ups sorry.
+
+
+
Actually, you can't assume that a BBU means you can safely disable
+full-page-writes. Depending on the controller, it's still possible to
+end up with partially written pages.
+
+BTW, if your mailer makes doing so convenient, it would be nice to trim
+down your .signature; note that it's about 3x longer than the email you
+actually sent.
+
+
+ + + +--=-J3lZlvR3YpaghtVpGv1Q-- + +From pgsql-hackers-owner@postgresql.org Tue Feb 28 13:36:38 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 46F639DCC71; + Tue, 28 Feb 2006 13:36:37 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 69130-06; Tue, 28 Feb 2006 13:36:36 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from gwmta.wicourts.gov (gwmta.wicourts.gov [165.219.244.99]) + by postgresql.org (Postfix) with ESMTP id AE5EA9DCC75; + Tue, 28 Feb 2006 13:36:34 -0400 (AST) +Received: from Courts-MTA by gwmta.wicourts.gov + with Novell_GroupWise; Tue, 28 Feb 2006 11:36:34 -0600 +Message-Id: <440435BC.EE98.0025.0@wicourts.gov> +X-Mailer: Novell GroupWise Internet Agent 7.0 +Date: Tue, 28 Feb 2006 11:36:28 -0600 +From: "Kevin Grittner" +To: "Jim C. Nasby" , + "Tom Lane" +Cc: , +Subject: Re: [PERFORM] temporary indexes +References: <44041B68.EE98.0025.0@wicourts.gov> + <20060228164515.GS82012@pervasive.com><20060228164515.GS82012@pervasive.com> + <16076.1141146348@sss.pgh.pa.us> +In-Reply-To: <16076.1141146348@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.073 required=5 tests=[AWL=0.073] +X-Spam-Score: 0.073 +X-Spam-Level: +X-Archive-Number: 200602/1220 +X-Sequence-Number: 80358 + +>>> On Tue, Feb 28, 2006 at 11:05 am, in message +<16076.1141146348@sss.pgh.pa.us>, +Tom Lane wrote: +> +> The issue at hand really has nothing to do with temp indexes, it's +with +> the constrained way that the planner deals with EXISTS subplans. + +Yet when the index exists, the query is optimized well. + +> The +> subplans themselves are cheap enough, even in the poorly- indexed +> variant, that the planner would certainly never have decided to +create +> an index to use for them. + +That depends. If the planner was able to generate hypothetical index +descriptions which might be useful, and analyze everything based on +those (adding in creation cost, of course) -- why would it not be able +to come up with the plan which it DID use when the index existed. + +> The limiting factor is that EXISTS subplans +> aren't flattened ... and once that's fixed, I doubt the example +would +> need any new kind of join support. + + +I'm all for that. So far, we've been going after the low-hanging fruit +in our use of PostgreSQL. When we get to the main applications, we're +going to be dealing with a lot more in the way of EXISTS clauses. The +product we're moving from usually optimized an IN test the same as the +logically equivalent EXISTS test, and where a difference existed, it +almost always did better with the EXISTS -- so we encouraged application +programmers to use that form. Also, EXISTS works in situations where +you need to compare on multiple columns, so it is useful in many +situations where EXISTS or MIN/MAX techniques just don't work. + + +If fixing this would allow hash or merge techniques to cover this as +well as the index did, and that is true in a more general sense (not +just for this one example), then temporary indexes would clearly not +have any value. + +-Kevin + + + +From pgsql-hackers-owner@postgresql.org Tue Feb 28 13:55:45 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 3C4EC9DCA1B; + Tue, 28 Feb 2006 13:55:44 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 75797-07; Tue, 28 Feb 2006 13:55:43 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from gwmta.wicourts.gov (gwmta.wicourts.gov [165.219.244.99]) + by postgresql.org (Postfix) with ESMTP id 742E69DC876; + Tue, 28 Feb 2006 13:55:41 -0400 (AST) +Received: from Courts-MTA by gwmta.wicourts.gov + with Novell_GroupWise; Tue, 28 Feb 2006 11:55:41 -0600 +Message-Id: <44043A34.EE98.0025.0@wicourts.gov> +X-Mailer: Novell GroupWise Internet Agent 7.0 +Date: Tue, 28 Feb 2006 11:55:32 -0600 +From: "Kevin Grittner" +To: "Jim C. Nasby" , "Tom Lane" , + "Kevin Grittner" +Cc: , +Subject: Re: [PERFORM] temporary indexes +References: <44041B68.EE98.0025.0@wicourts.gov> + <20060228164515.GS82012@pervasive.com> + <20060228164515.GS82012@pervasive.com> + <16076.1141146348@sss.pgh.pa.us> + <440435BC.EE98.0025.0@wicourts.gov> +In-Reply-To: <440435BC.EE98.0025.0@wicourts.gov> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.077 required=5 tests=[AWL=0.077] +X-Spam-Score: 0.077 +X-Spam-Level: +X-Archive-Number: 200602/1224 +X-Sequence-Number: 80362 + +>>> On Tue, Feb 28, 2006 at 11:36 am, in message +<440435BC.EE98.0025.0@wicourts.gov>, "Kevin Grittner" +> Also, EXISTS works in situations where +> you need to compare on multiple columns, so it is useful in many +> situations where EXISTS or MIN/MAX techniques just don't work. + +Sorry. That should have read: + +EXISTS works in situations where +you need to compare on multiple columns, so it is useful in many +situations where IN or MIN/MAX techniques just don't work. + + +From pgsql-hackers-owner@postgresql.org Tue Feb 28 14:06:59 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 6CEA79DCA47 + for ; + Tue, 28 Feb 2006 14:06:58 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 79638-01 + for ; + Tue, 28 Feb 2006 14:06:57 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 364229DCA1B + for ; + Tue, 28 Feb 2006 14:06:56 -0400 (AST) +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 k1SI6u8J016798; + Tue, 28 Feb 2006 13:06:56 -0500 (EST) +To: "Kevin Grittner" +cc: "Jim C. Nasby" , pgsql-hackers@postgresql.org, + pgsql-performance@postgresql.org +Subject: Re: [PERFORM] temporary indexes +In-reply-to: <44043A34.EE98.0025.0@wicourts.gov> +References: <44041B68.EE98.0025.0@wicourts.gov> + <20060228164515.GS82012@pervasive.com> + <20060228164515.GS82012@pervasive.com> + <16076.1141146348@sss.pgh.pa.us> + <440435BC.EE98.0025.0@wicourts.gov> + <44043A34.EE98.0025.0@wicourts.gov> +Comments: In-reply-to "Kevin Grittner" + message dated "Tue, 28 Feb 2006 11:55:32 -0600" +Date: Tue, 28 Feb 2006 13:06:56 -0500 +Message-ID: <16797.1141150016@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.111 required=5 tests=[AWL=0.111] +X-Spam-Score: 0.111 +X-Spam-Level: +X-Archive-Number: 200602/1228 +X-Sequence-Number: 80366 + +"Kevin Grittner" writes: +> EXISTS works in situations where +> you need to compare on multiple columns, so it is useful in many +> situations where IN or MIN/MAX techniques just don't work. + +IN works fine on multiple columns: + + (foo, bar, baz) IN (SELECT x, y, z FROM ...) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Feb 28 14:08:27 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 988F49DCA1B + for ; + Tue, 28 Feb 2006 14:08:26 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 79779-03 + for ; + Tue, 28 Feb 2006 14:08:23 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from cassarossa.samfundet.no (cassarossa.samfundet.no + [129.241.93.19]) + by postgresql.org (Postfix) with ESMTP id 085279DCAB9 + for ; + Tue, 28 Feb 2006 14:08:20 -0400 (AST) +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 1FE9Gk-0001GJ-W3 + for pgsql-performance@postgresql.org; Tue, 28 Feb 2006 19:08:19 +0100 +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1FE9H3-0000QM-00 + for ; Tue, 28 Feb 2006 19:08:37 +0100 +Date: Tue, 28 Feb 2006 19:08:37 +0100 +From: "Steinar H. Gunderson" +To: pgsql-performance@postgresql.org +Subject: Re: [HACKERS] temporary indexes +Message-ID: <20060228180837.GA1593@uio.no> +Mail-Followup-To: pgsql-performance@postgresql.org +References: <44041B68.EE98.0025.0@wicourts.gov> + <20060228164515.GS82012@pervasive.com> + <20060228164515.GS82012@pervasive.com> + <16076.1141146348@sss.pgh.pa.us> + <440435BC.EE98.0025.0@wicourts.gov> + <44043A34.EE98.0025.0@wicourts.gov> +MIME-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Disposition: inline +In-Reply-To: <44043A34.EE98.0025.0@wicourts.gov> +X-Operating-System: Linux 2.6.14.3 on a x86_64 +X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ +User-Agent: Mutt/1.5.11+cvs20060126 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.083 required=5 tests=[AWL=0.083] +X-Spam-Score: 0.083 +X-Spam-Level: +X-Archive-Number: 200602/441 +X-Sequence-Number: 17427 + +On Tue, Feb 28, 2006 at 11:55:32AM -0600, Kevin Grittner wrote: +>> Also, EXISTS works in situations where +>> you need to compare on multiple columns, so it is useful in many +>> situations where EXISTS or MIN/MAX techniques just don't work. +> Sorry. That should have read: +> +> EXISTS works in situations where +> you need to compare on multiple columns, so it is useful in many +> situations where IN or MIN/MAX techniques just don't work. + +Can't you just do WHERE (foo,bar) IN ( SELECT baz,quux FROM table )? I'm +quite sure I've done that a number of times. + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-hackers-owner@postgresql.org Tue Feb 28 14:17:03 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 08A309DCC55; + Tue, 28 Feb 2006 14:17:02 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81310-04; Tue, 28 Feb 2006 14:17:01 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from gwmta.wicourts.gov (gwmta.wicourts.gov [165.219.244.99]) + by postgresql.org (Postfix) with ESMTP id E55C79DCC08; + Tue, 28 Feb 2006 14:16:56 -0400 (AST) +Received: from Courts-MTA by gwmta.wicourts.gov + with Novell_GroupWise; Tue, 28 Feb 2006 12:16:57 -0600 +Message-Id: <44043F32.EE98.0025.0@wicourts.gov> +X-Mailer: Novell GroupWise Internet Agent 7.0 +Date: Tue, 28 Feb 2006 12:16:50 -0600 +From: "Kevin Grittner" +To: "Tom Lane" +Cc: "Jim C. Nasby" , , + +Subject: Re: [PERFORM] temporary indexes +References: <44041B68.EE98.0025.0@wicourts.gov> + <20060228164515.GS82012@pervasive.com> + <20060228164515.GS82012@pervasive.com> + <16076.1141146348@sss.pgh.pa.us> + <440435BC.EE98.0025.0@wicourts.gov> + <44043A34.EE98.0025.0@wicourts.gov><44043A34.EE98.0025.0@wicourts.gov> + <16797.1141150016@sss.pgh.pa.us> +In-Reply-To: <16797.1141150016@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.081 required=5 tests=[AWL=0.081] +X-Spam-Score: 0.081 +X-Spam-Level: +X-Archive-Number: 200602/1231 +X-Sequence-Number: 80369 + +>>> On Tue, Feb 28, 2006 at 12:06 pm, in message +<16797.1141150016@sss.pgh.pa.us>, +Tom Lane wrote: +> IN works fine on multiple columns: +> +> (foo, bar, baz) IN (SELECT x, y, z FROM ...) + +Thanks for pointing that out. I recognize it as valid ANSI/ISO syntax, +using a row value constructor list. Unfortunately, row value +constructor lists failed to make the portability cut for allowed syntax +here, because it was not supported by all candidate products at the +time. It is still not supported by the product we're moving from, and +we'll have about a one year window when our code will need to run on +both. + +-Kevin + + +From pgsql-hackers-owner@postgresql.org Tue Feb 28 17:02:51 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 90AD79DC876; + Tue, 28 Feb 2006 17:02:50 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 19086-10; Tue, 28 Feb 2006 17:02:51 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 233A69DC869; + Tue, 28 Feb 2006 17:02:47 -0400 (AST) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 66D1B56467; Tue, 28 Feb 2006 15:02:34 -0600 (CST) +Received: (hashcash-sendmail, from uid 1001); Tue, 28 Feb 2006 15:02:33 -0600 +Date: Tue, 28 Feb 2006 15:02:32 -0600 +From: "Jim C. Nasby" +To: Kevin Grittner +Cc: Tom Lane , pgsql-hackers@postgresql.org, + pgsql-performance@postgresql.org +Subject: Re: [PERFORM] temporary indexes +Message-ID: <20060228210232.GW82012@pervasive.com> +References: <44041B68.EE98.0025.0@wicourts.gov> + <16076.1141146348@sss.pgh.pa.us> + <440435BC.EE98.0025.0@wicourts.gov> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <440435BC.EE98.0025.0@wicourts.gov> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060228:kevin.grittner@wicourts.gov::eudFjtrvuoIdeqC8:0000000000 + 0000000000000000000000002tId +X-Hashcash: + 1:20:060228:tgl@sss.pgh.pa.us::+Qa8IRGERe+gItmt:00000000000000000000 + 000000000000000000000000ALAs +X-Hashcash: + 1:20:060228:pgsql-hackers@postgresql.org::L7PIJDnCtWPxm0FV:000000000 + 0000000000000000000000001Dlu +X-Hashcash: + 1:20:060228:pgsql-performance@postgresql.org::bX9VFRkio2OM1BOe:00000 + 00000000000000000000000050tA +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.108 required=5 tests=[AWL=0.108] +X-Spam-Score: 0.108 +X-Spam-Level: +X-Archive-Number: 200602/1238 +X-Sequence-Number: 80376 + +On Tue, Feb 28, 2006 at 11:36:28AM -0600, Kevin Grittner wrote: +> +> I'm all for that. So far, we've been going after the low-hanging fruit +> in our use of PostgreSQL. When we get to the main applications, we're +> going to be dealing with a lot more in the way of EXISTS clauses. The +> product we're moving from usually optimized an IN test the same as the +> logically equivalent EXISTS test, and where a difference existed, it +> almost always did better with the EXISTS -- so we encouraged application +> programmers to use that form. Also, EXISTS works in situations where +> you need to compare on multiple columns, so it is useful in many +> situations where EXISTS or MIN/MAX techniques just don't work. +> + +Maybe it's just the way my twisted mind thinks, but I generally prefer +using a JOIN when possible... +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue Feb 28 17:09:27 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 4EDBA9DC876 + for ; + Tue, 28 Feb 2006 17:09:27 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 22079-02 + for ; + Tue, 28 Feb 2006 17:09:28 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 2D1859DC869 + for ; + Tue, 28 Feb 2006 17:09:24 -0400 (AST) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 97FB156468; Tue, 28 Feb 2006 15:09:26 -0600 (CST) +Received: (hashcash-sendmail, from uid 1001); Tue, 28 Feb 2006 15:09:25 -0600 +Date: Tue, 28 Feb 2006 15:09:25 -0600 +From: "Jim C. Nasby" +To: Javier Somoza +Cc: Bruce Momjian , + Tino Wildenhain , pgsql-performance@postgresql.org +Subject: Re: fsync and battery-backed caches +Message-ID: <20060228210925.GX82012@pervasive.com> +References: <200602280106.k1S16DK16068@candle.pha.pa.us> + <1141114775.1555.7.camel@pndsoft> + <20060228172334.GV82012@pervasive.com> + <1141147654.1555.46.camel@pndsoft> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1141147654.1555.46.camel@pndsoft> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060228:jsomoza@pandasoftware.es::+Rthp3+Yh3ew90zE:0000000000000 + 00000000000000000000000086wA +X-Hashcash: + 1:20:060228:pgman@candle.pha.pa.us::UVjVwg7k7GbFeToP:000000000000000 + 0000000000000000000000000FJw +X-Hashcash: + 1:20:060228:tino@wildenhain.de::AXGOC7fo9JyI+dYX:0000000000000000000 + 0000000000000000000000003gj/ +X-Hashcash: + 1:20:060228:pgsql-performance@postgresql.org::nbAiatcPdGzqkHk1:00000 + 0000000000000000000000000XT6 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.108 required=5 tests=[AWL=0.108] +X-Spam-Score: 0.108 +X-Spam-Level: +X-Archive-Number: 200602/444 +X-Sequence-Number: 17430 + +Ok, you absolutely can't guarantee you won't get partial page writes +then. A UPS buys you no more data safety than being plugged directly +into the wall. UPS's fail. People trip over cords. Breakers fail. Even +if you have multiple power supplies on multiple circuits fed by +different UPS's you can *still* have unexpected power failures. The +'master' for distributed.net had exactly that happen recently; the two +breakers feeding it (from 2 seperate UPS's) failed simultaneously. + +In a nutshell, having a server on a UPS is notthing at all like having a +BBU on the raid controller: commiting to the BBU is essentially the same +as committing to the drives, unless the BBU runs out of power before the +server has power restored, or fails in some similar fasion. But because +there's many fewer parts involved, such a failure of the BBU is far less +likely than a failure up-stream. + +So, if you want performance, get a controller with a BBU and allow it to +cache writes. While you're at it, try and get one that will +automatically disable write caching if the BBU fails for some reason. + +On Tue, Feb 28, 2006 at 06:27:34PM +0100, Javier Somoza wrote: +> +> Ups sorry. +> +> +> > Actually, you can't assume that a BBU means you can safely disable +> > full-page-writes. Depending on the controller, it's still possible to +> > end up with partially written pages. +> > +> > BTW, if your mailer makes doing so convenient, it would be nice to trim +> > down your .signature; note that it's about 3x longer than the email you +> > actually sent. +> +> + +-- +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 Tue Feb 28 17:15:48 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 90A299DC869; + Tue, 28 Feb 2006 17:15:46 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 19311-09; Tue, 28 Feb 2006 17:15:47 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from gwmta.wicourts.gov (gwmta.wicourts.gov [165.219.244.99]) + by postgresql.org (Postfix) with ESMTP id 9BFEB9DC806; + Tue, 28 Feb 2006 17:15:43 -0400 (AST) +Received: from Courts-MTA by gwmta.wicourts.gov + with Novell_GroupWise; Tue, 28 Feb 2006 15:15:44 -0600 +Message-Id: <44046913.EE98.0025.0@wicourts.gov> +X-Mailer: Novell GroupWise Internet Agent 7.0 +Date: Tue, 28 Feb 2006 15:15:31 -0600 +From: "Kevin Grittner" +To: "Jim C. Nasby" , + "Tom Lane" +Cc: , +Subject: Re: [PERFORM] temporary indexes +References: <44041B68.EE98.0025.0@wicourts.gov> + <20060228164515.GS82012@pervasive.com><20060228164515.GS82012@pervasive.com> + <16076.1141146348@sss.pgh.pa.us> +In-Reply-To: <16076.1141146348@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: multipart/mixed; boundary="=__PartF6D3BB63.1__=" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.085 required=5 tests=[AWL=0.085] +X-Spam-Score: 0.085 +X-Spam-Level: +X-Archive-Number: 200602/1239 +X-Sequence-Number: 80377 + +--=__PartF6D3BB63.1__= +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +Content-Disposition: inline + +>>> On Tue, Feb 28, 2006 at 11:05 am, in message +<16076.1141146348@sss.pgh.pa.us>, +Tom Lane wrote: +> The limiting factor is that EXISTS subplans +> aren't flattened ... and once that's fixed, I doubt the example +would +> need any new kind of join support. + +I rewrote the query to use IN predicates rather than EXISTS predicates, +and the cost estimates look like this: + +EXISTS, no index: 1.6 billion +EXISTS, with index: 0.023 billion +IN, no index: 13.7 billion +IN, with index: 10.6 billion + +At least for the two EXISTS cases, the estimates were roughly accurate. + These plans were run against the data after the fix, but analyze has +not been run since then, so the estimates should be comparable with the +earlier post. + +I'm not used to using the IN construct this way, so maybe someone can +spot something horribly stupid in how I tried to use it. + +-Kevin + + +--=__PartF6D3BB63.1__= +Content-Type: application/octet-stream; name="datafix-in-plan1.txt" +Content-Transfer-Encoding: base64 +Content-Disposition: attachment; filename="datafix-in-plan1.txt" + +IE1lcmdlIEpvaW4gIChjb3N0PTEzNzE4MjkwMDcwLjk4Li4yMzgyMzM5ODM5NC4wNSByb3dzPTEx +NDU2IHdpZHRoPTE4MikKICAgTWVyZ2UgQ29uZDogKCgib3V0ZXIiLiI/Y29sdW1uMTc/IiA9ICJp +bm5lciIuIj9jb2x1bW44PyIpIEFORCAoIm91dGVyIi4iP2NvbHVtbjE4PyIgPSAiaW5uZXIiLiI/ +Y29sdW1uOT8iKSkKICAgSm9pbiBGaWx0ZXI6ICgoKCJpbm5lciIuInN0YXJ0RGF0ZSIpOjpkYXRl +IDwgKCJvdXRlciIuInN0YXJ0RGF0ZSIpOjpkYXRlKSBBTkQgKE5PVCAoc3VicGxhbikpKQogICAt +PiAgU29ydCAgKGNvc3Q9MTM3MTc5ODQxMzkuODAuLjEzNzE3OTg0MjAwLjUyIHJvd3M9MjQyODkg +d2lkdGg9MTYyKQogICAgICAgICBTb3J0IEtleTogKCJBY3Rpb24iLiJqdXJvcklkIik6OmludGVn +ZXIsICgiQWN0aW9uIi4ianVyeVllYXIiKTo6YnBjaGFyCiAgICAgICAgIC0+ICBOZXN0ZWQgTG9v +cCAgKGNvc3Q9My43Ni4uMTM3MTc5ODIzNzAuNTggcm93cz0yNDI4OSB3aWR0aD0xNjIpCiAgICAg +ICAgICAgICAgIC0+ICBIYXNoQWdncmVnYXRlICAoY29zdD0zLjc2Li4zLjc3IHJvd3M9MSB3aWR0 +aD0xMCkKICAgICAgICAgICAgICAgICAgICAgLT4gIEluZGV4IFNjYW4gdXNpbmcgIkp1cnlDb250 +cm9sX3BrZXkiIG9uICJKdXJ5Q29udHJvbCIgamMgIChjb3N0PTAuMDAuLjMuNzUgcm93cz0xIHdp +ZHRoPTEwKQogICAgICAgICAgICAgICAgICAgICAgICAgICBJbmRleCBDb25kOiAoKCJjb3VudHlO +byIpOjpzbWFsbGludCA9IDQwKQogICAgICAgICAgICAgICAtPiAgSW5kZXggU2NhbiB1c2luZyAi +QWN0aW9uX3BrZXkiIG9uICJBY3Rpb24iICAoY29zdD0wLjAwLi4xMzcxNzk4MjA3NC42MSByb3dz +PTIzMzc3IHdpZHRoPTE1NCkKICAgICAgICAgICAgICAgICAgICAgSW5kZXggQ29uZDogKCgoIkFj +dGlvbiIuImNvdW50eU5vIik6OnNtYWxsaW50ID0gNDApIEFORCAoKCJBY3Rpb24iLiJqdXJ5WWVh +ciIpOjpicGNoYXIgPSAoIm91dGVyIi4ianVyeVllYXIiKTo6YnBjaGFyKSkKICAgICAgICAgICAg +ICAgICAgICAgRmlsdGVyOiAoKCgiYWN0aW9uQ29kZSIpOjpicGNoYXIgPD4gJ0FQT09MJzo6YnBj +aGFyKSBBTkQgKCgiYWN0aW9uQ29kZSIpOjpicGNoYXIgPD4gJ1JQT09MJzo6YnBjaGFyKSBBTkQg +KCgiYWN0aW9uQ29kZSIpOjpicGNoYXIgPD4gJ0FQQU4nOjpicGNoYXIpIEFORCAoKCJhY3Rpb25D +b2RlIik6OmJwY2hhciA8PiAnUlBBTic6OmJwY2hhcikgQU5EICgoImFjdGlvbkNvZGUiKTo6YnBj +aGFyIDw+ICdNUE9PTCc6OmJwY2hhcikgQU5EICgoImFjdGlvbkNvZGUiKTo6YnBjaGFyIDw+ICdN +UEFOJzo6YnBjaGFyKSBBTkQgKCgiYWN0aW9uQ29kZSIpOjpicGNoYXIgPD4gJ1BSJzo6YnBjaGFy +KSBBTkQgKCgiYWN0aW9uQ29kZSIpOjpicGNoYXIgPD4gJ0pQUCc6OmJwY2hhcikgQU5EICgoImFj +dGlvbkNvZGUiKTo6YnBjaGFyIDw+ICdNRlJPTSc6OmJwY2hhcikgQU5EICgoImFjdGlvbkNvZGUi +KTo6YnBjaGFyIDw+ICdNTkVYVCc6OmJwY2hhcikgQU5EICgoKCJwb29sSWQiIElTIE5VTEwpIEFO +RCAoc3VicGxhbikpIE9SICgoInBhbmVsSWQiIElTIE5VTEwpIEFORCAoc3VicGxhbikpKSkKICAg +ICAgICAgICAgICAgICAgICAgU3ViUGxhbgogICAgICAgICAgICAgICAgICAgICAgIC0+ICBCaXRt +YXAgSGVhcCBTY2FuIG9uICJBY3Rpb24iIGExICAoY29zdD02NTkxLjMyLi4yMTI2MTAuMDQgcm93 +cz01MTIxMyB3aWR0aD0xNCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBSZWNoZWNrIENv +bmQ6ICgoKCJjb3VudHlObyIpOjpzbWFsbGludCA9IDQwKSBBTkQgKCgiYWN0aW9uU2VxTm8iKTo6 +aW50ZWdlciA8ICgkMCk6OmludGVnZXIpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgIEZp +bHRlcjogKCgoImFjdGlvbkNvZGUiKTo6YnBjaGFyID0gJ0FQQU4nOjpicGNoYXIpIE9SICgoImFj +dGlvbkNvZGUiKTo6YnBjaGFyID0gJ01QQU4nOjpicGNoYXIpKQogICAgICAgICAgICAgICAgICAg +ICAgICAgICAgIC0+ICBCaXRtYXAgSW5kZXggU2NhbiBvbiAiQWN0aW9uX3BrZXkiICAoY29zdD0w +LjAwLi42NTkxLjMyIHJvd3M9NjI1Mzg2IHdpZHRoPTApCiAgICAgICAgICAgICAgICAgICAgICAg +ICAgICAgICAgICAgSW5kZXggQ29uZDogKCgoImNvdW50eU5vIik6OnNtYWxsaW50ID0gNDApIEFO +RCAoKCJhY3Rpb25TZXFObyIpOjppbnRlZ2VyIDwgKCQwKTo6aW50ZWdlcikpCiAgICAgICAgICAg +ICAgICAgICAgICAgLT4gIEJpdG1hcCBIZWFwIFNjYW4gb24gIkFjdGlvbiIgYTEgIChjb3N0PTY1 +OTEuMzIuLjIxMjYxMC4wNCByb3dzPTY3MzM1IHdpZHRoPTE0KQogICAgICAgICAgICAgICAgICAg +ICAgICAgICAgIFJlY2hlY2sgQ29uZDogKCgoImNvdW50eU5vIik6OnNtYWxsaW50ID0gNDApIEFO +RCAoKCJhY3Rpb25TZXFObyIpOjppbnRlZ2VyIDwgKCQwKTo6aW50ZWdlcikpCiAgICAgICAgICAg +ICAgICAgICAgICAgICAgICAgRmlsdGVyOiAoKCgiYWN0aW9uQ29kZSIpOjpicGNoYXIgPSAnQVBP +T0wnOjpicGNoYXIpIE9SICgoImFjdGlvbkNvZGUiKTo6YnBjaGFyID0gJ01QT09MJzo6YnBjaGFy +KSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAtPiAgQml0bWFwIEluZGV4IFNjYW4gb24g +IkFjdGlvbl9wa2V5IiAgKGNvc3Q9MC4wMC4uNjU5MS4zMiByb3dzPTYyNTM4NiB3aWR0aD0wKQog +ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEluZGV4IENvbmQ6ICgoKCJjb3VudHlO +byIpOjpzbWFsbGludCA9IDQwKSBBTkQgKCgiYWN0aW9uU2VxTm8iKTo6aW50ZWdlciA8ICgkMCk6 +OmludGVnZXIpKQogICAtPiAgU29ydCAgKGNvc3Q9MzA1OTMxLjE4Li4zMDY5MjkuNzggcm93cz0z +OTk0NDAgd2lkdGg9NTApCiAgICAgICAgIFNvcnQgS2V5OiAoYTIuImp1cm9ySWQiKTo6aW50ZWdl +ciwgKGEyLiJqdXJ5WWVhciIpOjpicGNoYXIKICAgICAgICAgLT4gIEJpdG1hcCBIZWFwIFNjYW4g +b24gIkFjdGlvbiIgYTIgIChjb3N0PTE1MDgwLjU1Li4yNjAxODUuOTAgcm93cz0zOTk0NDAgd2lk +dGg9NTApCiAgICAgICAgICAgICAgIFJlY2hlY2sgQ29uZDogKCgiY291bnR5Tm8iKTo6c21hbGxp +bnQgPSA0MCkKICAgICAgICAgICAgICAgRmlsdGVyOiAoKCgiYWN0aW9uQ29kZSIpOjpicGNoYXIg +PSAnQVBPT0wnOjpicGNoYXIpIE9SICgoImFjdGlvbkNvZGUiKTo6YnBjaGFyID0gJ1JQT09MJzo6 +YnBjaGFyKSBPUiAoKCJhY3Rpb25Db2RlIik6OmJwY2hhciA9ICdBUEFOJzo6YnBjaGFyKSBPUiAo +KCJhY3Rpb25Db2RlIik6OmJwY2hhciA9ICdSUEFOJzo6YnBjaGFyKSBPUiAoKCJhY3Rpb25Db2Rl +Iik6OmJwY2hhciA9ICdNUE9PTCc6OmJwY2hhcikgT1IgKCgiYWN0aW9uQ29kZSIpOjpicGNoYXIg +PSAnTVBBTic6OmJwY2hhcikpCiAgICAgICAgICAgICAgIC0+ICBCaXRtYXAgSW5kZXggU2NhbiBv +biAiQWN0aW9uX3BrZXkiICAoY29zdD0wLjAwLi4xNTA4MC41NSByb3dzPTE4NzYxNTggd2lkdGg9 +MCkKICAgICAgICAgICAgICAgICAgICAgSW5kZXggQ29uZDogKCgiY291bnR5Tm8iKTo6c21hbGxp +bnQgPSA0MCkKICAgU3ViUGxhbgogICAgIC0+ICBCaXRtYXAgSGVhcCBTY2FuIG9uICJBY3Rpb24i +IGEzICAoY29zdD0xNTA4MC41NS4uMjc4OTQ3LjQ4IHJvd3M9MTExMCB3aWR0aD0xNCkKICAgICAg +ICAgICBSZWNoZWNrIENvbmQ6ICgoImNvdW50eU5vIik6OnNtYWxsaW50ID0gNDApCiAgICAgICAg +ICAgRmlsdGVyOiAoKCgoImFjdGlvbkNvZGUiKTo6YnBjaGFyID0gJ0FQT09MJzo6YnBjaGFyKSBP +UiAoKCJhY3Rpb25Db2RlIik6OmJwY2hhciA9ICdSUE9PTCc6OmJwY2hhcikgT1IgKCgiYWN0aW9u +Q29kZSIpOjpicGNoYXIgPSAnQVBBTic6OmJwY2hhcikgT1IgKCgiYWN0aW9uQ29kZSIpOjpicGNo +YXIgPSAnUlBBTic6OmJwY2hhcikgT1IgKCgiYWN0aW9uQ29kZSIpOjpicGNoYXIgPSAnTVBPT0wn +OjpicGNoYXIpIE9SICgoImFjdGlvbkNvZGUiKTo6YnBjaGFyID0gJ01QQU4nOjpicGNoYXIpKSBB +TkQgKCgic3RhcnREYXRlIik6OmRhdGUgPCAoJDcpOjpkYXRlKSBBTkQgKCgic3RhcnREYXRlIik6 +OmRhdGUgPj0gKCQ4KTo6ZGF0ZSkgQU5EICgoKCJzdGFydERhdGUiKTo6ZGF0ZSA+ICgkOCk6OmRh +dGUpIE9SICgoImFjdGlvblNlcU5vIik6OmludGVnZXIgPiAoJDkpOjppbnRlZ2VyKSkpCiAgICAg +ICAgICAgLT4gIEJpdG1hcCBJbmRleCBTY2FuIG9uICJBY3Rpb25fcGtleSIgIChjb3N0PTAuMDAu +LjE1MDgwLjU1IHJvd3M9MTg3NjE1OCB3aWR0aD0wKQogICAgICAgICAgICAgICAgIEluZGV4IENv +bmQ6ICgoImNvdW50eU5vIik6OnNtYWxsaW50ID0gNDApCigzNiByb3dzKQoK + +--=__PartF6D3BB63.1__= +Content-Type: application/octet-stream; name="datafix-in-plan2.txt" +Content-Transfer-Encoding: base64 +Content-Disposition: attachment; filename="datafix-in-plan2.txt" + +IE5lc3RlZCBMb29wICAoY29zdD0zLjc0Li4xMDYyNTc1OTYxMi4yNiByb3dzPTg1NTIgd2lkdGg9 +MTU0KQogICBKb2luIEZpbHRlcjogKCgoImlubmVyIi4ic3RhcnREYXRlIik6OmRhdGUgPCAoIm91 +dGVyIi4ic3RhcnREYXRlIik6OmRhdGUpIEFORCAoTk9UIChzdWJwbGFuKSkpCiAgIC0+ICBOZXN0 +ZWQgTG9vcCAgKGNvc3Q9My43NC4uNzc0NTQ1NzQ2OS41OSByb3dzPTE5MjEyIHdpZHRoPTEzNCkK +ICAgICAgICAgLT4gIEhhc2hBZ2dyZWdhdGUgIChjb3N0PTMuNzQuLjMuNzUgcm93cz0xIHdpZHRo +PTEwKQogICAgICAgICAgICAgICAtPiAgSW5kZXggU2NhbiB1c2luZyAiSnVyeUNvbnRyb2xfcGtl +eSIgb24gIkp1cnlDb250cm9sIiBqYyAgKGNvc3Q9MC4wMC4uMy43MyByb3dzPTEgd2lkdGg9MTAp +CiAgICAgICAgICAgICAgICAgICAgIEluZGV4IENvbmQ6ICgoImNvdW50eU5vIik6OnNtYWxsaW50 +ID0gNDApCiAgICAgICAgIC0+ICBJbmRleCBTY2FuIHVzaW5nICJBY3Rpb25fanVyb3IiIG9uICJB +Y3Rpb24iICAoY29zdD0wLjAwLi43NzQ1NDU3MTc5LjAwIHJvd3M9MjI5NDggd2lkdGg9MTI2KQog +ICAgICAgICAgICAgICBJbmRleCBDb25kOiAoKCgiQWN0aW9uIi4iY291bnR5Tm8iKTo6c21hbGxp +bnQgPSA0MCkgQU5EICgoIkFjdGlvbiIuImp1cnlZZWFyIik6OmJwY2hhciA9ICgib3V0ZXIiLiJq +dXJ5WWVhciIpOjpicGNoYXIpKQogICAgICAgICAgICAgICBGaWx0ZXI6ICgoKCJhY3Rpb25Db2Rl +Iik6OmJwY2hhciA8PiAnQVBPT0wnOjpicGNoYXIpIEFORCAoKCJhY3Rpb25Db2RlIik6OmJwY2hh +ciA8PiAnUlBPT0wnOjpicGNoYXIpIEFORCAoKCJhY3Rpb25Db2RlIik6OmJwY2hhciA8PiAnQVBB +Tic6OmJwY2hhcikgQU5EICgoImFjdGlvbkNvZGUiKTo6YnBjaGFyIDw+ICdSUEFOJzo6YnBjaGFy +KSBBTkQgKCgiYWN0aW9uQ29kZSIpOjpicGNoYXIgPD4gJ01QT09MJzo6YnBjaGFyKSBBTkQgKCgi +YWN0aW9uQ29kZSIpOjpicGNoYXIgPD4gJ01QQU4nOjpicGNoYXIpIEFORCAoKCJhY3Rpb25Db2Rl +Iik6OmJwY2hhciA8PiAnUFInOjpicGNoYXIpIEFORCAoKCJhY3Rpb25Db2RlIik6OmJwY2hhciA8 +PiAnSlBQJzo6YnBjaGFyKSBBTkQgKCgiYWN0aW9uQ29kZSIpOjpicGNoYXIgPD4gJ01GUk9NJzo6 +YnBjaGFyKSBBTkQgKCgiYWN0aW9uQ29kZSIpOjpicGNoYXIgPD4gJ01ORVhUJzo6YnBjaGFyKSBB +TkQgKCgoInBvb2xJZCIgSVMgTlVMTCkgQU5EIChzdWJwbGFuKSkgT1IgKCgicGFuZWxJZCIgSVMg +TlVMTCkgQU5EIChzdWJwbGFuKSkpKQogICAgICAgICAgICAgICBTdWJQbGFuCiAgICAgICAgICAg +ICAgICAgLT4gIEJpdG1hcCBIZWFwIFNjYW4gb24gIkFjdGlvbiIgYTEgIChjb3N0PTYxNDY0LjI2 +Li42NjA0MC4wMCByb3dzPTU2MjAyIHdpZHRoPTE0KQogICAgICAgICAgICAgICAgICAgICAgIFJl +Y2hlY2sgQ29uZDogKCgoKCgiY291bnR5Tm8iKTo6c21hbGxpbnQgPSA0MCkgQU5EICgoImFjdGlv +blNlcU5vIik6OmludGVnZXIgPCAoJDApOjppbnRlZ2VyKSBBTkQgKCgiYWN0aW9uQ29kZSIpOjpi +cGNoYXIgPSAnQVBBTic6OmJwY2hhcikpIE9SICgoKCJjb3VudHlObyIpOjpzbWFsbGludCA9IDQw +KSBBTkQgKCgiYWN0aW9uU2VxTm8iKTo6aW50ZWdlciA8ICgkMCk6OmludGVnZXIpIEFORCAoKCJh +Y3Rpb25Db2RlIik6OmJwY2hhciA9ICdNUEFOJzo6YnBjaGFyKSkpIEFORCAoKCJjb3VudHlObyIp +OjpzbWFsbGludCA9IDQwKSBBTkQgKCgiYWN0aW9uU2VxTm8iKTo6aW50ZWdlciA8ICgkMCk6Omlu +dGVnZXIpKQogICAgICAgICAgICAgICAgICAgICAgIC0+ICBCaXRtYXBBbmQgIChjb3N0PTYxNDY0 +LjI2Li42MTQ2NC4yNiByb3dzPTI0MTIgd2lkdGg9MCkKICAgICAgICAgICAgICAgICAgICAgICAg +ICAgICAtPiAgQml0bWFwT3IgIChjb3N0PTU0ODY4LjY5Li41NDg2OC42OSByb3dzPTU2NjkwIHdp +ZHRoPTApCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLT4gIEJpdG1hcCBJbmRl +eCBTY2FuIG9uICJBY3Rpb25fanVyb3IiICAoY29zdD0wLjAwLi4yNzQzNC4zNCByb3dzPTUwNjU2 +IHdpZHRoPTApCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgSW5kZXgg +Q29uZDogKCgoImNvdW50eU5vIik6OnNtYWxsaW50ID0gNDApIEFORCAoKCJhY3Rpb25TZXFObyIp +OjppbnRlZ2VyIDwgKCQwKTo6aW50ZWdlcikgQU5EICgoImFjdGlvbkNvZGUiKTo6YnBjaGFyID0g +J0FQQU4nOjpicGNoYXIpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0+ICBC +aXRtYXAgSW5kZXggU2NhbiBvbiAiQWN0aW9uX2p1cm9yIiAgKGNvc3Q9MC4wMC4uMjc0MzQuMzQg +cm93cz02MDM0IHdpZHRoPTApCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg +ICAgSW5kZXggQ29uZDogKCgoImNvdW50eU5vIik6OnNtYWxsaW50ID0gNDApIEFORCAoKCJhY3Rp +b25TZXFObyIpOjppbnRlZ2VyIDwgKCQwKTo6aW50ZWdlcikgQU5EICgoImFjdGlvbkNvZGUiKTo6 +YnBjaGFyID0gJ01QQU4nOjpicGNoYXIpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0+ +ICBCaXRtYXAgSW5kZXggU2NhbiBvbiAiQWN0aW9uX3BrZXkiICAoY29zdD0wLjAwLi42NTk1LjMy +IHJvd3M9NjI1Mzg2IHdpZHRoPTApCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg +SW5kZXggQ29uZDogKCgoImNvdW50eU5vIik6OnNtYWxsaW50ID0gNDApIEFORCAoKCJhY3Rpb25T +ZXFObyIpOjppbnRlZ2VyIDwgKCQwKTo6aW50ZWdlcikpCiAgICAgICAgICAgICAgICAgLT4gIEJp +dG1hcCBIZWFwIFNjYW4gb24gIkFjdGlvbiIgYTEgIChjb3N0PTYxNDY0LjI2Li42NjY4Ny4xNyBy +b3dzPTY0NDYwIHdpZHRoPTE0KQogICAgICAgICAgICAgICAgICAgICAgIFJlY2hlY2sgQ29uZDog +KCgoKCgiY291bnR5Tm8iKTo6c21hbGxpbnQgPSA0MCkgQU5EICgoImFjdGlvblNlcU5vIik6Omlu +dGVnZXIgPCAoJDApOjppbnRlZ2VyKSBBTkQgKCgiYWN0aW9uQ29kZSIpOjpicGNoYXIgPSAnQVBP +T0wnOjpicGNoYXIpKSBPUiAoKCgiY291bnR5Tm8iKTo6c21hbGxpbnQgPSA0MCkgQU5EICgoImFj +dGlvblNlcU5vIik6OmludGVnZXIgPCAoJDApOjppbnRlZ2VyKSBBTkQgKCgiYWN0aW9uQ29kZSIp +OjpicGNoYXIgPSAnTVBPT0wnOjpicGNoYXIpKSkgQU5EICgoImNvdW50eU5vIik6OnNtYWxsaW50 +ID0gNDApIEFORCAoKCJhY3Rpb25TZXFObyIpOjppbnRlZ2VyIDwgKCQwKTo6aW50ZWdlcikpCiAg +ICAgICAgICAgICAgICAgICAgICAgLT4gIEJpdG1hcEFuZCAgKGNvc3Q9NjE0NjQuMjYuLjYxNDY0 +LjI2IHJvd3M9Mjc2NyB3aWR0aD0wKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0+ICBC +aXRtYXBPciAgKGNvc3Q9NTQ4NjguNjkuLjU0ODY4LjY5IHJvd3M9NjUwMjkgd2lkdGg9MCkKICAg +ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAtPiAgQml0bWFwIEluZGV4IFNjYW4gb24g +IkFjdGlvbl9qdXJvciIgIChjb3N0PTAuMDAuLjI3NDM0LjM0IHJvd3M9NTg5OTUgd2lkdGg9MCkK +ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBJbmRleCBDb25kOiAoKCgi +Y291bnR5Tm8iKTo6c21hbGxpbnQgPSA0MCkgQU5EICgoImFjdGlvblNlcU5vIik6OmludGVnZXIg +PCAoJDApOjppbnRlZ2VyKSBBTkQgKCgiYWN0aW9uQ29kZSIpOjpicGNoYXIgPSAnQVBPT0wnOjpi +cGNoYXIpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0+ICBCaXRtYXAgSW5k +ZXggU2NhbiBvbiAiQWN0aW9uX2p1cm9yIiAgKGNvc3Q9MC4wMC4uMjc0MzQuMzQgcm93cz02MDM0 +IHdpZHRoPTApCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgSW5kZXgg +Q29uZDogKCgoImNvdW50eU5vIik6OnNtYWxsaW50ID0gNDApIEFORCAoKCJhY3Rpb25TZXFObyIp +OjppbnRlZ2VyIDwgKCQwKTo6aW50ZWdlcikgQU5EICgoImFjdGlvbkNvZGUiKTo6YnBjaGFyID0g +J01QT09MJzo6YnBjaGFyKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAtPiAgQml0bWFw +IEluZGV4IFNjYW4gb24gIkFjdGlvbl9wa2V5IiAgKGNvc3Q9MC4wMC4uNjU5NS4zMiByb3dzPTYy +NTM4NiB3aWR0aD0wKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEluZGV4IENv +bmQ6ICgoKCJjb3VudHlObyIpOjpzbWFsbGludCA9IDQwKSBBTkQgKCgiYWN0aW9uU2VxTm8iKTo6 +aW50ZWdlciA8ICgkMCk6OmludGVnZXIpKQogICAtPiAgSW5kZXggU2NhbiB1c2luZyAiQWN0aW9u +X2p1cm9yIiBvbiAiQWN0aW9uIiBhMiAgKGNvc3Q9MC4wMC4uMTAuMjIgcm93cz0xIHdpZHRoPTUw +KQogICAgICAgICBJbmRleCBDb25kOiAoKChhMi4iY291bnR5Tm8iKTo6c21hbGxpbnQgPSA0MCkg +QU5EICgoYTIuImp1cnlZZWFyIik6OmJwY2hhciA9ICgib3V0ZXIiLiJqdXJ5WWVhciIpOjpicGNo +YXIpIEFORCAoKGEyLiJqdXJvcklkIik6OmludGVnZXIgPSAoIm91dGVyIi4ianVyb3JJZCIpOjpp +bnRlZ2VyKSkKICAgICAgICAgRmlsdGVyOiAoKCgiYWN0aW9uQ29kZSIpOjpicGNoYXIgPSAnQVBP +T0wnOjpicGNoYXIpIE9SICgoImFjdGlvbkNvZGUiKTo6YnBjaGFyID0gJ1JQT09MJzo6YnBjaGFy +KSBPUiAoKCJhY3Rpb25Db2RlIik6OmJwY2hhciA9ICdBUEFOJzo6YnBjaGFyKSBPUiAoKCJhY3Rp +b25Db2RlIik6OmJwY2hhciA9ICdSUEFOJzo6YnBjaGFyKSBPUiAoKCJhY3Rpb25Db2RlIik6OmJw +Y2hhciA9ICdNUE9PTCc6OmJwY2hhcikgT1IgKCgiYWN0aW9uQ29kZSIpOjpicGNoYXIgPSAnTVBB +Tic6OmJwY2hhcikpCiAgIFN1YlBsYW4KICAgICAtPiAgSW5kZXggU2NhbiB1c2luZyAiQWN0aW9u +X3BrZXkiIG9uICJBY3Rpb24iIGEzICAoY29zdD0wLjAwLi4yOTk4MjAuOTggcm93cz0xMDM5IHdp +ZHRoPTE0KQogICAgICAgICAgIEluZGV4IENvbmQ6ICgoImNvdW50eU5vIik6OnNtYWxsaW50ID0g +NDApCiAgICAgICAgICAgRmlsdGVyOiAoKCgoImFjdGlvbkNvZGUiKTo6YnBjaGFyID0gJ0FQT09M +Jzo6YnBjaGFyKSBPUiAoKCJhY3Rpb25Db2RlIik6OmJwY2hhciA9ICdSUE9PTCc6OmJwY2hhcikg +T1IgKCgiYWN0aW9uQ29kZSIpOjpicGNoYXIgPSAnQVBBTic6OmJwY2hhcikgT1IgKCgiYWN0aW9u +Q29kZSIpOjpicGNoYXIgPSAnUlBBTic6OmJwY2hhcikgT1IgKCgiYWN0aW9uQ29kZSIpOjpicGNo +YXIgPSAnTVBPT0wnOjpicGNoYXIpIE9SICgoImFjdGlvbkNvZGUiKTo6YnBjaGFyID0gJ01QQU4n +OjpicGNoYXIpKSBBTkQgKCgic3RhcnREYXRlIik6OmRhdGUgPCAoJDcpOjpkYXRlKSBBTkQgKCgi +c3RhcnREYXRlIik6OmRhdGUgPj0gKCQ4KTo6ZGF0ZSkgQU5EICgoKCJzdGFydERhdGUiKTo6ZGF0 +ZSA+ICgkOCk6OmRhdGUpIE9SICgoImFjdGlvblNlcU5vIik6OmludGVnZXIgPiAoJDkpOjppbnRl +Z2VyKSkpCigzNyByb3dzKQoK + +--=__PartF6D3BB63.1__= +Content-Type: application/octet-stream; name="datafix-in.qry" +Content-Transfer-Encoding: base64 +Content-Disposition: attachment; filename="datafix-in.qry" + +VVBEQVRFICJBY3Rpb24iCiAgU0VUICJwb29sSWQiICA9IGEyLiJwb29sSWQiLAogICAgICAicGFu +ZWxJZCIgPSBhMi4icGFuZWxJZCIKICBGUk9NICJBY3Rpb24iIGEyCiAgV0hFUkUgIkFjdGlvbiIu +ImFjdGlvbkNvZGUiIG5vdCBpbgogICAgICAoJ0FQT09MJywnUlBPT0wnLCdBUEFOJywnUlBBTics +ICdNUE9PTCcsJ01QQU4nLCAnUFInLCdKUFAnLCAnTUZST00nLCAnTU5FWFQnKQogICAgQU5EICJB +Y3Rpb24iLiJjb3VudHlObyIgPSA0MAogICAgQU5EICgiQWN0aW9uIi4iY291bnR5Tm8iLCAiQWN0 +aW9uIi4ianVyeVllYXIiKSBJTgogICAgICAgICgKICAgICAgICAgIFNFTEVDVCBqYy4iY291bnR5 +Tm8iLCBqYy4ianVyeVllYXIiCiAgICAgICAgICAgIEZST00gIkp1cnlDb250cm9sIiBqYwogICAg +ICAgICAgICBXSEVSRSBqYy4iY291bnR5Tm8iID0gNDAKICAgICAgICApCiAgICBBTkQgKCAgKCAi +QWN0aW9uIi4icG9vbElkIiBpcyBudWxsCiAgICAgICAgIEFORCAoIkFjdGlvbiIuImNvdW50eU5v +IiwgIkFjdGlvbiIuImp1cnlZZWFyIiwgIkFjdGlvbiIuImp1cm9ySWQiKSBJTgogICAgICAgICAg +ICAgKAogICAgICAgICAgICAgICBzZWxlY3QgYTEuImNvdW50eU5vIiwgYTEuImp1cnlZZWFyIiwg +YTEuImp1cm9ySWQiIGZyb20gIkFjdGlvbiIgYTEKICAgICAgICAgICAgICAgICB3aGVyZSBhMS4i +Y291bnR5Tm8iICAgID0gNDAKICAgICAgICAgICAgICAgICAgIGFuZCBhMS4iYWN0aW9uU2VxTm8i +IDwgIkFjdGlvbiIuImFjdGlvblNlcU5vIgogICAgICAgICAgICAgICAgICAgYW5kIGExLiJhY3Rp +b25Db2RlIiBpbiAoJ0FQT09MJywnTVBPT0wnKQogICAgICAgICAgICAgKQogICAgICAgICAgICkK +ICAgICAgIE9SICAoICJBY3Rpb24iLiJwYW5lbElkIiBpcyBudWxsCiAgICAgICAgIEFORCAoIkFj +dGlvbiIuImNvdW50eU5vIiwgIkFjdGlvbiIuImp1cnlZZWFyIiwgIkFjdGlvbiIuImp1cm9ySWQi +KSBJTgogICAgICAgICAgICAgKAogICAgICAgICAgICAgICBzZWxlY3QgYTEuImNvdW50eU5vIiwg +YTEuImp1cnlZZWFyIiwgYTEuImp1cm9ySWQiIGZyb20gIkFjdGlvbiIgYTEKICAgICAgICAgICAg +ICAgICB3aGVyZSBhMS4iY291bnR5Tm8iICAgID0gNDAKICAgICAgICAgICAgICAgICAgIGFuZCBh +MS4iYWN0aW9uU2VxTm8iIDwgIkFjdGlvbiIuImFjdGlvblNlcU5vIgogICAgICAgICAgICAgICAg +ICAgYW5kIGExLiJhY3Rpb25Db2RlIiBpbiAoJ0FQQU4nLCdNUEFOJykKICAgICAgICAgICAgICkK +ICAgICAgICAgICApCiAgICAgICAgKQogICAgQU5EIGEyLiJjb3VudHlObyIgPSA0MAogICAgQU5E +IGEyLiJjb3VudHlObyIgPSAiQWN0aW9uIi4iY291bnR5Tm8iCiAgICBBTkQgYTIuImp1cnlZZWFy +IiA9ICJBY3Rpb24iLiJqdXJ5WWVhciIKICAgIEFORCBhMi4ianVyb3JJZCIgID0gIkFjdGlvbiIu +Imp1cm9ySWQiCiAgICBBTkQgYTIuImFjdGlvbkNvZGUiIElOICgnQVBPT0wnLCdSUE9PTCcsJ0FQ +QU4nLCdSUEFOJywgJ01QT09MJywnTVBBTicpCiAgICBBTkQgYTIuInN0YXJ0RGF0ZSIgPCAgIkFj +dGlvbiIuInN0YXJ0RGF0ZSIKICAgIEFORCAoIkFjdGlvbiIuImNvdW50eU5vIiwgIkFjdGlvbiIu +Imp1cnlZZWFyIiwgIkFjdGlvbiIuImp1cm9ySWQiKSBOT1QgSU4KICAgICAgICAoCiAgICAgICAg +ICBTRUxFQ1QgYTMuImNvdW50eU5vIiwgYTMuImp1cnlZZWFyIiwgYTMuImp1cm9ySWQiIEZST00g +IkFjdGlvbiIgYTMKICAgICAgICAgICAgV0hFUkUgYTMuImNvdW50eU5vIiA9IDQwCiAgICAgICAg +ICAgICAgQU5EIGEzLiJhY3Rpb25Db2RlIiBJTiAoJ0FQT09MJywnUlBPT0wnLCdBUEFOJywnUlBB +TicsICdNUE9PTCcsJ01QQU4nKQogICAgICAgICAgICAgIEFORCBhMy4ic3RhcnREYXRlIiA8ICAi +QWN0aW9uIi4ic3RhcnREYXRlIgogICAgICAgICAgICAgIEFORCBhMy4ic3RhcnREYXRlIiA+PSBh +Mi4ic3RhcnREYXRlIgogICAgICAgICAgICAgIEFORCAoIGEzLiJzdGFydERhdGUiID4gYTIuInN0 +YXJ0RGF0ZSIKICAgICAgICAgICAgICAgICBPUiBhMy4iYWN0aW9uU2VxTm8iID4gYTIuImFjdGlv +blNlcU5vIgogICAgICAgICAgICAgICAgICApCiAgICAgICAgKTsKCg== + +--=__PartF6D3BB63.1__=-- + +From pgsql-hackers-owner@postgresql.org Tue Feb 28 19:02:54 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 6A2DF9DC823 + for ; + Tue, 28 Feb 2006 19:02:54 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 33110-09 + for ; + Tue, 28 Feb 2006 19:02:56 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id 0DD1D9DC806 + for ; + Tue, 28 Feb 2006 19:02:52 -0400 (AST) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 6E13D30C21; Wed, 1 Mar 2006 00:02:54 +0100 (MET) +From: Lukas Smith +X-Newsgroups: pgsql.hackers +Subject: Re: [PERFORM] temporary indexes +Date: Wed, 01 Mar 2006 00:02:55 +0100 +Organization: Hub.Org Networking Services +Lines: 30 +Message-ID: <4404D69F.7000407@pooteeweet.org> +References: <44041B68.EE98.0025.0@wicourts.gov> + <20060228164515.GS82012@pervasive.com><20060228164515.GS82012@pervasive.com> + <16076.1141146348@sss.pgh.pa.us> + <44046913.EE98.0025.0@wicourts.gov> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +To: Kevin Grittner +User-Agent: Thunderbird 1.5 (Windows/20051201) +In-Reply-To: <44046913.EE98.0025.0@wicourts.gov> +To: pgsql-hackers@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.114 required=5 tests=[AWL=0.114] +X-Spam-Score: 0.114 +X-Spam-Level: +X-Archive-Number: 200602/1247 +X-Sequence-Number: 80385 + +Kevin Grittner wrote: + +> I rewrote the query to use IN predicates rather than EXISTS predicates, +> and the cost estimates look like this: +> +> EXISTS, no index: 1.6 billion +> EXISTS, with index: 0.023 billion +> IN, no index: 13.7 billion +> IN, with index: 10.6 billion +> +> At least for the two EXISTS cases, the estimates were roughly accurate. +> These plans were run against the data after the fix, but analyze has +> not been run since then, so the estimates should be comparable with the +> earlier post. +> +> I'm not used to using the IN construct this way, so maybe someone can +> spot something horribly stupid in how I tried to use it. + +I will have a look at your queries tomorrow. Some general advice (rdbms +agnostic) on when to use IN and when to use EXISTS taken from "SQL +performance tuning": + +- if the inner table has few rows and the outer has many then IN is +preferred +- if however you have a restrictive expression on the outer query you +should preferr EXISTS +- use NOT EXISTS instead of NOT IN (break out early) + +regards, +Lukas + +From pgsql-performance-owner@postgresql.org Tue Feb 28 19:31:39 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 62E899DCC34 + for ; + Tue, 28 Feb 2006 19:31:38 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 39150-07 + for ; + Tue, 28 Feb 2006 19:31:40 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from peufeu.com (unknown [82.67.9.10]) + by postgresql.org (Postfix) with ESMTP id C73189DCC49 + for ; + Tue, 28 Feb 2006 19:31:35 -0400 (AST) +Received: (qmail 24288 invoked from network); 1 Mar 2006 00:31:34 +0100 +Received: from unknown (HELO apollo13) (82.67.9.10) + by boutiquenumerique.com with SMTP; 1 Mar 2006 00:31:34 +0100 +To: "Bruce Momjian" , + "Javier Somoza" +Cc: "Evgeny Gridasov" , pgsql-performance@postgresql.org +Subject: Re: wal sync method +References: <200602280114.k1S1EAQ17159@candle.pha.pa.us> +Message-ID: +Date: Wed, 01 Mar 2006 00:31:33 +0100 +From: PFC +Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +In-Reply-To: <200602280114.k1S1EAQ17159@candle.pha.pa.us> +User-Agent: Opera M2/8.51 (Linux, build 1462) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.104 required=5 tests=[AWL=0.104] +X-Spam-Score: 0.104 +X-Spam-Level: +X-Archive-Number: 200602/446 +X-Sequence-Number: 17432 + + + + Just a stupid question about the various fsync settings. + There is fsync=off, but is there fsync=fflush ? + fflush would mean only an OS crash could cause data loss, + I think.it could be useful for some applications where you need a speed +boost (like testing database import scripts...) without being as scary as +fsync=off... + + +From pgsql-performance-owner@postgresql.org Tue Feb 28 19:45:16 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id F422A9DCC49 + for ; + Tue, 28 Feb 2006 19:45:14 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 44754-02 + for ; + Tue, 28 Feb 2006 19:45:17 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 2A8889DCB82 + for ; + Tue, 28 Feb 2006 19:45:10 -0400 (AST) +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 k1SNj6i6003868; + Tue, 28 Feb 2006 18:45:06 -0500 (EST) +To: PFC +cc: "Bruce Momjian" , + "Javier Somoza" , + "Evgeny Gridasov" , pgsql-performance@postgresql.org +Subject: Re: wal sync method +In-reply-to: +References: <200602280114.k1S1EAQ17159@candle.pha.pa.us> + +Comments: In-reply-to PFC + message dated "Wed, 01 Mar 2006 00:31:33 +0100" +Date: Tue, 28 Feb 2006 18:45:06 -0500 +Message-ID: <3867.1141170306@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.111 required=5 tests=[AWL=0.111] +X-Spam-Score: 0.111 +X-Spam-Level: +X-Archive-Number: 200602/447 +X-Sequence-Number: 17433 + +PFC writes: +> Just a stupid question about the various fsync settings. +> There is fsync=off, but is there fsync=fflush ? +> fflush would mean only an OS crash could cause data loss, +> I think.it could be useful for some applications where you need a speed +> boost (like testing database import scripts...) without being as scary as +> fsync=off... + +I think you misunderstand. There aren't any scenarios where a PG crash +(without hardware/OS crash) risks data, because we always at least +write() data before commit. The only issue is how hard do we try to get +the OS+hardware to push that data down to disk. + + regards, tom lane +