diff --git "a/pgsql-performance.200404" "b/pgsql-performance.200404" new file mode 100644--- /dev/null +++ "b/pgsql-performance.200404" @@ -0,0 +1,46233 @@ +From pgsql-performance-owner@postgresql.org Wed Mar 31 21:14:59 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 25BEAD1E8CE + for ; + Thu, 1 Apr 2004 01:14:46 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 80332-01 + for ; + Wed, 31 Mar 2004 21:14:45 -0400 (AST) +Received: from houston.familyhealth.com.au (fhnet.arach.net.au + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 15D8BD1E8AD + for ; + Wed, 31 Mar 2004 21:14:42 -0400 (AST) +Received: from familyhealth.com.au (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id + i311EYWL071036; Thu, 1 Apr 2004 09:14:34 +0800 (WST) + (envelope-from chriskl@familyhealth.com.au) +Message-ID: <406B6E0B.9050200@familyhealth.com.au> +Date: Thu, 01 Apr 2004 09:19:07 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "Priem, Alexander" +Cc: pgsql-performance@postgresql.org +Subject: Re: What index for 'like (%keyword%)' ??? +References: <2A07EC2D0BC2774AAD6F74769F60D52A08329A@ahmose.cict_ad.nl> +In-Reply-To: <2A07EC2D0BC2774AAD6F74769F60D52A08329A@ahmose.cict_ad.nl> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/444 +X-Sequence-Number: 6300 + +> I am building a query which uses a clause like "Where doc_description like +> '%keyword%'". I know a normal index won't be of any use here, but since the +> table in question will get fairly big, I do want to use an index. +> +> Can anyone give me some advise on what kind of index I can use here? Or +> shouldn't I use one in this case? + +You have to use a proper full text indexing scheme. Investigate +contrib/tsearch2 module in the postgres distribution. + +Chirs + + +From pgsql-performance-owner@postgresql.org Thu Apr 1 15:21:36 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E2261D1EB0F + for ; + Thu, 1 Apr 2004 19:16:48 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 52634-08 + for ; + Thu, 1 Apr 2004 15:16:31 -0400 (AST) +Received: from gpdnet.co.uk (gpdnet.plus.com [212.56.100.243]) + by svr1.postgresql.org (Postfix) with ESMTP id 1D212D1EA3B + for ; + Thu, 1 Apr 2004 15:16:17 -0400 (AST) +Received: from Spooler by gpdnet.co.uk (Mercury/32 v4.01a) ID MO001CFC; + 1 Apr 2004 20:20:15 +0100 +Received: from spooler by gpdnet.co.uk (Mercury/32 v4.01a); + 1 Apr 2004 20:19:44 +0100 +Received: from gary (192.168.1.2) by gpdnet.co.uk (Mercury/32 v4.01a) with + ESMTP ID MG001CFB; 1 Apr 2004 20:19:35 +0100 +From: "Gary Doades" +To: pgsql-performance@postgresql.org +Date: Thu, 01 Apr 2004 20:19:34 +0100 +MIME-Version: 1.0 +Subject: PostgreSQL and Linux 2.6 kernel. +Message-ID: <406C7956.17885.4B2DCD2@localhost> +In-reply-to: <5090.1080747621@sss.pgh.pa.us> +References: +X-mailer: Pegasus Mail for Windows (v4.12a) +Content-type: text/plain; charset=US-ASCII +Content-transfer-encoding: 7BIT +Content-description: Mail message body +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/1 +X-Sequence-Number: 6301 + +As part of my ongoing evaluation of PostgreSQL I have been doing a little stress testing. +I though I would share an interesting result here.. + +Machine spec: +500 MHz PIII +256MB RAM +"old-ish" IDE HD (5400RPM) +Linux 2.4.22 kernel (Madrake 9.2) + +I have PostgreSQL 7.4.1 installed and have managed to load up a 1.4 GB database +from MS SQLServer. Vaccum analyzed it. + +As a test in PosgreSQL I issued a statement to update a single column of a table +containing 2.8 million rows with the values of a column in a table with similar rowcount. +Using the above spec I had to stop the server after 17 hours. The poor thing was +thrashing the hard disk and doing more swapping than useful work. + +Having obtained a copy of Mandrake 10.0 with the 2.6 kernal I though I would give it a +go. Same hardware. Same setup. Same database loaded up. Same postgresql.conf file +to make sure all the settings were the same. Vaccum analyzed it. + +same update statement COMPLETED in 2 hours 50 minutes. I'm impressed. + +I could see from vmstat that the system was achieving much greater IO thoughput than +the 2.4 kernel. Although the system was still swapping there seems to be a completely +different memory management pattern that suits PostgreSQL very well. + +Just to see that this wasn't a coincidence I am repeating the test. It is now into the 14th +hour using the old 2.4 kernel. I'm going to give up..... + +Has anyone else done any comparative testing with the 2.6 kernel? + +Cheers, +Gary. + + +From pgsql-performance-owner@postgresql.org Mon Apr 5 15:59:37 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 40187D1E928 + for ; + Thu, 1 Apr 2004 20:19:31 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 80056-10 + for ; + Thu, 1 Apr 2004 16:19:25 -0400 (AST) +Received: from mail2.fbab.net (spectre.fbab.net [212.214.165.139]) + by svr1.postgresql.org (Postfix) with SMTP id 69A9FD1E8FB + for ; + Thu, 1 Apr 2004 16:19:22 -0400 (AST) +Received: (qmail 17709 invoked by uid 136); 1 Apr 2004 20:19:21 -0000 +Received: from mag@fbab.net by mail2.fbab.net by uid 133 with + qmail-scanner-1.20rc1 (avp: 4.0.3.0. Clear:RC:0:. + Processed in 0.053725 secs); 01 Apr 2004 20:19:21 -0000 +Received: from unknown (HELO fbab.net) (magpool1@212.214.165.129) + by mail2.fbab.net with SMTP; 1 Apr 2004 20:19:20 -0000 +Message-ID: <406C7942.40900@fbab.net> +Date: Thu, 01 Apr 2004 22:19:14 +0200 +From: "Magnus Naeslund(t)" +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Gary Doades +Cc: pgsql-performance@postgresql.org +Subject: Re: PostgreSQL and Linux 2.6 kernel. +References: + <406C7956.17885.4B2DCD2@localhost> +In-Reply-To: <406C7956.17885.4B2DCD2@localhost> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/46 +X-Sequence-Number: 6346 + +Gary Doades wrote: + +> +> Has anyone else done any comparative testing with the 2.6 kernel? +> + +I know for a fact that certain stuff is recognized differently between +2.2, 2.4 and 2.6 kernels. +For example i have one box that i installed debian stable on that used a +2.2 kernel which automatically tuned on DMA on the harddrive, didn't do +it on a 2.4 kernel, but on 2.6 one it saw it as DMA able. +Such things can dramatically affect performance, so make sure to compare +what capabilities the kernel thinks your hardware has between the +kernels first... + +But i'll grant that the 2.6 kernel is a great deal faster on some of our +test servers. + +Regards +Magnus + + +From pgsql-performance-owner@postgresql.org Thu Apr 1 19:00:51 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6C79BD1E159 + for ; + Thu, 1 Apr 2004 23:00:48 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 45099-06 + for ; + Thu, 1 Apr 2004 19:00:48 -0400 (AST) +Received: from palle.girgensohn.se (1-2-8-5a.asp.sth.bostream.se + [82.182.157.66]) + by svr1.postgresql.org (Postfix) with ESMTP id 1C1A2D1E0F6 + for ; + Thu, 1 Apr 2004 19:00:45 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by palle.girgensohn.se (8.12.11/8.12.11) with ESMTP id i31N0jsA036201; + Fri, 2 Apr 2004 01:00:45 +0200 (CEST) + (envelope-from girgen@pingpong.net) +Date: Fri, 02 Apr 2004 01:00:45 +0200 +From: Palle Girgensohn +To: pgsql-performance@postgresql.org +Subject: single index on more than two coulumns a bad thing? +Message-ID: <24070000.1080860445@palle.girgensohn.se> +X-Mailer: Mulberry/3.1.0 (Linux/x86) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/2 +X-Sequence-Number: 6302 + +Hi, + +I remember reading a post ages ago, maybe from Vadim, about the fact that +people creating indices on more than two columns will be the first to be +put againts the wall when the revolution comes... sort of... + +Is it always bad to create index xx on yy (field1, field2, field3); + +I guess the problem is that the index might often grow bigger than the +table, or at least big enough not to speed up the queries? + +/Palle + + +From pgsql-performance-owner@postgresql.org Thu Apr 1 20:36:23 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1A26FD1D44F + for ; + Fri, 2 Apr 2004 00:36:17 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 71483-09 + for ; + Thu, 1 Apr 2004 20:36:17 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 2369FD1E9D5 + for ; + Thu, 1 Apr 2004 20:36:14 -0400 (AST) +Received: from [63.195.55.98] (HELO 192.168.1.29) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4750237; Thu, 01 Apr 2004 16:37:35 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Palle Girgensohn , + pgsql-performance@postgresql.org +Subject: Re: single index on more than two coulumns a bad thing? +Date: Thu, 1 Apr 2004 16:35:45 -0800 +User-Agent: KMail/1.5.4 +References: <24070000.1080860445@palle.girgensohn.se> +In-Reply-To: <24070000.1080860445@palle.girgensohn.se> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200404011635.45440.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/3 +X-Sequence-Number: 6303 + +Palle, + +> Is it always bad to create index xx on yy (field1, field2, field3); + +No, it seldom bad, in fact. I have some indexes that run up to seven +columns, becuase they are required for unique keys. + +Indexes of 3-4 columns are often *required* for many-to-many join tables. + +I'm afraid that you've been given some misleading advice. + +> I guess the problem is that the index might often grow bigger than the +> table, or at least big enough not to speed up the queries? + +Well, yes ... a 4-column index on a 5-column table could be bigger than the +table if allowed to bloat and not re-indexed. But that's just a reason for +better maintainence. + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Fri Apr 2 00:38:15 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E6459D1EA71 + for ; + Fri, 2 Apr 2004 04:36:59 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 42904-01 + for ; + Fri, 2 Apr 2004 00:36:48 -0400 (AST) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 6835BD1D5A3 + for ; + Fri, 2 Apr 2004 00:36:47 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i324ac56018755; + Thu, 1 Apr 2004 23:36:38 -0500 (EST) +To: josh@agliodbs.com +Cc: Palle Girgensohn , + pgsql-performance@postgresql.org +Subject: Re: single index on more than two coulumns a bad thing? +In-reply-to: <200404011635.45440.josh@agliodbs.com> +References: <24070000.1080860445@palle.girgensohn.se> + <200404011635.45440.josh@agliodbs.com> +Comments: In-reply-to Josh Berkus + message dated "Thu, 01 Apr 2004 16:35:45 -0800" +Date: Thu, 01 Apr 2004 23:36:38 -0500 +Message-ID: <18754.1080880598@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/4 +X-Sequence-Number: 6304 + +Josh Berkus writes: +>> Is it always bad to create index xx on yy (field1, field2, field3); + +> I'm afraid that you've been given some misleading advice. + +I'd say it's a matter of getting your optimizations straight. + +If you have a query that can make use of that index, and the query is +executed often enough to make it worth maintaining the index during +table updates, then by all means make the index. + +The standard advice is meant to warn you against creating a zillion +indexes without any thought to what you'll be paying in update costs. +Indexes with more than a couple of columns are usually of only narrow +applicability, and so you have to be sure that they'll really pay for +themselves... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Apr 2 00:44:35 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6A6DDD1D5A3 + for ; + Fri, 2 Apr 2004 04:44:32 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 41032-07 + for ; + Fri, 2 Apr 2004 00:44:31 -0400 (AST) +Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) + by svr1.postgresql.org (Postfix) with ESMTP id 9D003D1D2B5 + for ; + Fri, 2 Apr 2004 00:44:30 -0400 (AST) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by smtp.istop.com (Postfix) with ESMTP + id 094E617C4A8; Thu, 1 Apr 2004 23:44:30 -0500 (EST) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1B9GXd-0005Qq-00; Thu, 01 Apr 2004 23:44:29 -0500 +To: "Damien Dougan" +Cc: +Subject: Re: Index Performance Help +References: <004b01c3ebe1$7e0c9a70$7701a8c0@pestilence> +In-Reply-To: <004b01c3ebe1$7e0c9a70$7701a8c0@pestilence> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 01 Apr 2004 23:44:29 -0500 +Message-ID: <87d66rouoi.fsf@stark.xeocode.com> +Lines: 25 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/5 +X-Sequence-Number: 6305 + + +"Damien Dougan" writes: + +> Sample analyze output for an initial query: +> +> hydradb=# explain analyze select * from pvsubscriber where actorid = +> 'b3432-asdas-232-Subscriber793500'; + +I take it pvsubscriber is a view? What's the definition of your view? + +> -> Index Scan using mc_actor_key on mc_actor +> (cost=0.00..4.08 rows=1 width=69) +> (actual time=39.497..39.499 rows=1 loops=1) + +Is this table regularly vacuumed? Is it possible it has lots of dead records +with this value for actorid? Try running vacuum full, or better "vacuum full +verbose" and keep the output, it might explain. + +What version of postgres is this? You might try reindexing all your indexes +(but particularly this one). Older versions of postgres were prone to index +bloat problems. + + +-- +greg + + +From pgsql-performance-owner@postgresql.org Fri Apr 2 00:59:56 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7FBC1D1D606 + for ; + Fri, 2 Apr 2004 04:59:49 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 49526-01 + for ; + Fri, 2 Apr 2004 00:59:48 -0400 (AST) +Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) + by svr1.postgresql.org (Postfix) with ESMTP id 77B85D1D2B5 + for ; + Fri, 2 Apr 2004 00:59:47 -0400 (AST) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by smtp.istop.com (Postfix) with ESMTP + id EB42217C464; Thu, 1 Apr 2004 23:59:46 -0500 (EST) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1B9GmQ-0005Ss-00; Thu, 01 Apr 2004 23:59:46 -0500 +To: Palle Girgensohn +Cc: pgsql-performance@postgresql.org +Subject: Re: single index on more than two coulumns a bad thing? +References: <24070000.1080860445@palle.girgensohn.se> +In-Reply-To: <24070000.1080860445@palle.girgensohn.se> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 01 Apr 2004 23:59:46 -0500 +Message-ID: <871xn7otz1.fsf@stark.xeocode.com> +Lines: 17 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/6 +X-Sequence-Number: 6306 + + +Palle Girgensohn writes: + +> Is it always bad to create index xx on yy (field1, field2, field3); + +All generalisations are false... + +Seriously, it's true that as the length of your index key gets longer the +harder and harder it is to justify it. That doesn't mean they're always wrong, +but you should consider whether a shorter key would perform just as well. + +The other problem with long index keys is that they often show up in the same +place as having dozens of indexes on the same table. Usually in shops where +the indexes were created after the fact looking at specific queries. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Fri Apr 2 02:32:23 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E4B59D1EC4E + for ; + Fri, 2 Apr 2004 06:32:18 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 71138-05 + for ; + Fri, 2 Apr 2004 02:32:17 -0400 (AST) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id AE36AD1EC43 + for ; + Fri, 2 Apr 2004 02:32:13 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i326WBJi023110; + Fri, 2 Apr 2004 01:32:11 -0500 (EST) +To: "Gary Doades" +Cc: pgsql-performance@postgresql.org +Subject: Re: PostgreSQL and Linux 2.6 kernel. +In-reply-to: <406C7956.17885.4B2DCD2@localhost> +References: + <406C7956.17885.4B2DCD2@localhost> +Comments: In-reply-to "Gary Doades" + message dated "Thu, 01 Apr 2004 20:19:34 +0100" +Date: Fri, 02 Apr 2004 01:32:10 -0500 +Message-ID: <23109.1080887530@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/7 +X-Sequence-Number: 6307 + +"Gary Doades" writes: +> As a test in PosgreSQL I issued a statement to update a single column +> of a table containing 2.8 million rows with the values of a column in +> a table with similar rowcount. Using the above spec I had to stop the +> server after 17 hours. The poor thing was thrashing the hard disk and +> doing more swapping than useful work. + +This statement is pretty much content-free, since you did not show us +the table schemas, the query, or the EXPLAIN output for the query. +(I'll forgive you the lack of EXPLAIN ANALYZE, but you could easily +have provided all the other hard facts.) There's really no way to tell +where the bottleneck is. Maybe it's a kernel-level issue, but I would +not bet on that without more evidence. I'd definitely not bet on it +without direct confirmation that the same query plan was used in both +setups. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Apr 2 03:04:20 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3C8B8D1EA9D + for ; + Fri, 2 Apr 2004 07:04:14 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 77782-07 + for ; + Fri, 2 Apr 2004 03:04:13 -0400 (AST) +Received: from gpdnet.co.uk (gpdnet.plus.com [212.56.100.243]) + by svr1.postgresql.org (Postfix) with ESMTP id 623A6D1EA89 + for ; + Fri, 2 Apr 2004 03:04:11 -0400 (AST) +Received: from Spooler by gpdnet.co.uk (Mercury/32 v4.01a) ID MO001D53; + 2 Apr 2004 08:07:59 +0100 +Received: from spooler by gpdnet.co.uk (Mercury/32 v4.01a); + 2 Apr 2004 08:07:44 +0100 +Received: from gary (192.168.1.2) by gpdnet.co.uk (Mercury/32 v4.01a) with + ESMTP ID MG001D52; 2 Apr 2004 08:07:39 +0100 +From: "Gary Doades" +To: pgsql-performance@postgresql.org +Date: Fri, 02 Apr 2004 08:07:38 +0100 +MIME-Version: 1.0 +Subject: Re: PostgreSQL and Linux 2.6 kernel. +Message-ID: <406D1F4A.27973.73B2299@localhost> +In-reply-to: <23109.1080887530@sss.pgh.pa.us> +References: <406C7956.17885.4B2DCD2@localhost> +X-mailer: Pegasus Mail for Windows (v4.12a) +Content-type: text/plain; charset=US-ASCII +Content-transfer-encoding: 7BIT +Content-description: Mail message body +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/8 +X-Sequence-Number: 6308 + +The post was not intended to be content-rich, just my initial feedback +after only just switching to 2.6. Since I had largely given up on this +particular line of attack using 2.4 I didn't think to do a detailed analysis +at this time. I was also hoping that others would add to the discussion. + +As this could become important I will be doing more analysis, but due to +the nature of the issue and trying to keep as many factors constant as +possible, this may take some time. + +Cheers, +Gary. + +On 2 Apr 2004 at 1:32, Tom Lane wrote: + +> "Gary Doades" writes: +> > As a test in PosgreSQL I issued a statement to update a single column +> > of a table containing 2.8 million rows with the values of a column in +> > a table with similar rowcount. Using the above spec I had to stop the +> > server after 17 hours. The poor thing was thrashing the hard disk and +> > doing more swapping than useful work. +> +> This statement is pretty much content-free, since you did not show us +> the table schemas, the query, or the EXPLAIN output for the query. +> (I'll forgive you the lack of EXPLAIN ANALYZE, but you could easily +> have provided all the other hard facts.) There's really no way to tell +> where the bottleneck is. Maybe it's a kernel-level issue, but I would +> not bet on that without more evidence. I'd definitely not bet on it +> without direct confirmation that the same query plan was used in both +> setups. +> +> regards, tom lane +> +> +> -- +> Incoming mail is certified Virus Free. +> Checked by AVG Anti-Virus (http://www.grisoft.com). +> Version: 7.0.230 / Virus Database: 262.6.5 - Release Date: 31/03/2004 +> + + + +From pgsql-performance-owner@postgresql.org Fri Apr 2 07:56:31 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9FC6DD1E930 + for ; + Fri, 2 Apr 2004 11:56:29 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 88171-02 + for ; + Fri, 2 Apr 2004 07:56:30 -0400 (AST) +Received: from hotmail.com (law10-oe58.law10.hotmail.com [64.4.14.193]) + by svr1.postgresql.org (Postfix) with ESMTP id 7406ED1E8C6 + for ; + Fri, 2 Apr 2004 07:56:27 -0400 (AST) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Fri, 2 Apr 2004 03:56:30 -0800 +Received: from 67.81.102.201 by law10-oe58.law10.hotmail.com with DAV; + Fri, 02 Apr 2004 11:56:30 +0000 +X-Originating-IP: [67.81.102.201] +X-Originating-Email: [awerman2@hotmail.com] +X-Sender: awerman2@hotmail.com +From: "Aaron Werman" +To: , "Palle Girgensohn" , + +References: <24070000.1080860445@palle.girgensohn.se> + <200404011635.45440.josh@agliodbs.com> +Subject: Re: single index on more than two coulumns a bad thing? +Date: Fri, 2 Apr 2004 06:56:42 -0500 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1158 +X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +Message-ID: +X-OriginalArrivalTime: 02 Apr 2004 11:56:30.0273 (UTC) + FILETIME=[89261310:01C418A9] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/9 +X-Sequence-Number: 6309 + +another thing that I have all over the place is a hierarchy: +index on grandfather_table(grandfather) +index on father_table(grandfather, father) +index on son_table(grandfather, father, son) + +almost all of my indices are composite. Are you thinking about composite +indices with low cardinality leading columns? + +/Aaron + +----- Original Message ----- +From: "Josh Berkus" +To: "Palle Girgensohn" ; + +Sent: Thursday, April 01, 2004 7:35 PM +Subject: Re: [PERFORM] single index on more than two coulumns a bad thing? + + +> Palle, +> +> > Is it always bad to create index xx on yy (field1, field2, field3); +> +> No, it seldom bad, in fact. I have some indexes that run up to seven +> columns, becuase they are required for unique keys. +> +> Indexes of 3-4 columns are often *required* for many-to-many join tables. +> +> I'm afraid that you've been given some misleading advice. +> +> > I guess the problem is that the index might often grow bigger than the +> > table, or at least big enough not to speed up the queries? +> +> Well, yes ... a 4-column index on a 5-column table could be bigger than +the +> table if allowed to bloat and not re-indexed. But that's just a reason +for +> better maintainence. +> +> -- +> -Josh Berkus +> Aglio Database Solutions +> San Francisco +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 7: don't forget to increase your free space map settings +> + +From pgsql-performance-owner@postgresql.org Fri Apr 2 10:56:36 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 330AAD1ECD5 + for ; + Fri, 2 Apr 2004 14:55:28 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 43598-09 + for ; + Fri, 2 Apr 2004 10:55:30 -0400 (AST) +Received: from artemis.le.ac.uk (artemis.le.ac.uk [143.210.16.126]) + by svr1.postgresql.org (Postfix) with ESMTP id 436A7D1EC47 + for ; + Fri, 2 Apr 2004 10:55:26 -0400 (AST) +Received: from [143.210.36.58] (helo=mail.star.le.ac.uk) + by artemis.le.ac.uk with smtp (Exim 4.30) id 1B9Q4w-0004g1-51 + for pgsql-performance@postgresql.org; Fri, 02 Apr 2004 15:55:30 +0100 +Received: (qmail 15397 invoked from network); 2 Apr 2004 14:55:48 -0000 +Received: from peneca.star.le.ac.uk (143.210.36.224) + by mail.star.le.ac.uk with SMTP; 2 Apr 2004 14:55:48 -0000 +Date: Fri, 2 Apr 2004 15:55:26 +0100 (BST) +From: Clive Page +To: pgsql-performance@postgresql.org +Subject: Spatial join insists on sequential scan of larger table +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/10 +X-Sequence-Number: 6310 + +I am trying to do a spatial join between two tables each of which has a +column of type BOX called ERRBOX, with R-TREE indices created on both. + +The smaller table, xmm1, has 56,711 rows, +the larger one, twomass, has 177,757,299 rows. + +The most efficient way to join these is to do a sequential scan of the +smaller table, and an R-tree lookup on the larger. However for a simple +inner join the optimiser seems to want to do the reverse, for example: + +EXPLAIN +SELECT x.ra AS xra, x.decl AS xdecl, t.ra AS tra, t.decl AS tdecl +FROM xmm1 AS x INNER JOIN twomass AS t +ON x.errbox && t.errbox; + + QUERY PLAN +---------------------------------------------------------------------------------- + Nested Loop (cost=0.00..196642756520.34 rows=49506496044 width=32) + -> Seq Scan on twomass t (cost=0.00..9560002.72 rows=177023872 width=48) + -> Index Scan using xmm1box on xmm1 x (cost=0.00..1107.28 rows=280 width=48) + Index Cond: (x.errbox && "outer".errbox) + + +Reversing the join condition (i.e. t.errbox && x.errbox) and similar make +no difference, nor does using the old implicit join syntax. + +If, however, I specify an outer join such as: + +EXPLAIN +SELECT x.ra AS xra, x.decl AS xdecl, t.ra AS tra, t.decl AS tdecl +FROM xmm1 AS x LEFT OUTER JOIN twomass AS t +ON x.errbox && t.errbox; + + QUERY PLAN +---------------------------------------------------------------------------------------- + Nested Loop Left Join (cost=0.00..198945259325.90 rows=49506496044 +width=32) + -> Seq Scan on xmm1 x (cost=0.00..8592.32 rows=55932 width=48) + -> Index Scan using tbox on twomass t (cost=0.00..3545848.88 rows=885119 width=48) + Index Cond: ("outer".errbox && t.errbox) + + +This executes, it need hardly be said, a whole lot faster. + +I found that I can also force a sequential scan of the smaller table by +dropping its R-tree index, but I may need this in other operations, so +this isn't a very satisfactory solution. It's odd that an outer join +should be faster than an inner one, or to put it another way, after +dropping an index there is more than an order of magnitude speed increase. + +I'm using Postgres 7.4.1 on Red Hat Linux. Has anyone had similar +problems with spatial joins? + + +-- +Clive Page +Dept of Physics & Astronomy, +University of Leicester, +Leicester, LE1 7RH, U.K. + + + +From pgsql-performance-owner@postgresql.org Fri Apr 2 11:47:18 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 66E0FD1EB5F + for ; + Fri, 2 Apr 2004 15:46:25 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 69256-01 + for ; + Fri, 2 Apr 2004 11:46:27 -0400 (AST) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 99D67D1EB47 + for ; + Fri, 2 Apr 2004 11:46:22 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i32FkRkc027944; + Fri, 2 Apr 2004 10:46:27 -0500 (EST) +To: Clive Page +Cc: pgsql-performance@postgresql.org +Subject: Re: Spatial join insists on sequential scan of larger table +In-reply-to: +References: +Comments: In-reply-to Clive Page + message dated "Fri, 02 Apr 2004 15:55:26 +0100" +Date: Fri, 02 Apr 2004 10:46:26 -0500 +Message-ID: <27943.1080920786@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/11 +X-Sequence-Number: 6311 + +Clive Page writes: +> This executes, it need hardly be said, a whole lot faster. + +Could we see EXPLAIN ANALYZE output? + +The estimated costs for the two cases are nearly the same, which says to +me that there's something wrong with the cost model for r-tree lookups, +but I don't know what it is. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Apr 2 11:53:10 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A3159D1EB59 + for ; + Fri, 2 Apr 2004 15:52:39 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 67475-06 + for ; + Fri, 2 Apr 2004 11:52:42 -0400 (AST) +Received: from wolff.to (wolff.to [66.93.249.74]) + by svr1.postgresql.org (Postfix) with SMTP id 33C36D1EB5F + for ; + Fri, 2 Apr 2004 11:52:37 -0400 (AST) +Received: (qmail 5373 invoked by uid 500); 2 Apr 2004 15:56:04 -0000 +Date: Fri, 2 Apr 2004 09:56:04 -0600 +From: Bruno Wolff III +To: Palle Girgensohn +Cc: pgsql-performance@postgresql.org +Subject: Re: single index on more than two coulumns a bad thing? +Message-ID: <20040402155604.GC5151@wolff.to> +Mail-Followup-To: Palle Girgensohn , + pgsql-performance@postgresql.org +References: <24070000.1080860445@palle.girgensohn.se> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <24070000.1080860445@palle.girgensohn.se> +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/12 +X-Sequence-Number: 6312 + +On Fri, Apr 02, 2004 at 01:00:45 +0200, + Palle Girgensohn wrote: +> +> Is it always bad to create index xx on yy (field1, field2, field3); +> +> I guess the problem is that the index might often grow bigger than the +> table, or at least big enough not to speed up the queries? + +One place where you need them in postgres is enforcing unique multicolumn +keys. These will get created implicitly from the unique (or primary key) +constraint. It isn't all that unusual to have a table that describes +a many to many (to many ...) relationship where the primary key is all +of the columns. + +From pgsql-performance-owner@postgresql.org Fri Apr 2 12:06:34 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 05A85D1EB55 + for ; + Fri, 2 Apr 2004 16:05:00 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 75182-05 + for ; + Fri, 2 Apr 2004 12:05:03 -0400 (AST) +Received: from artemis.le.ac.uk (ntp2c.le.ac.uk [143.210.16.126]) + by svr1.postgresql.org (Postfix) with ESMTP id CE6EED1ECBC + for ; + Fri, 2 Apr 2004 12:04:57 -0400 (AST) +Received: from [143.210.36.58] (helo=mail.star.le.ac.uk) + by artemis.le.ac.uk with smtp (Exim 4.30) id 1B9RAE-00052C-1D + for pgsql-performance@postgresql.org; Fri, 02 Apr 2004 17:05:02 +0100 +Received: (qmail 3565 invoked from network); 2 Apr 2004 16:05:23 -0000 +Received: from peneca.star.le.ac.uk (143.210.36.224) + by mail.star.le.ac.uk with SMTP; 2 Apr 2004 16:05:23 -0000 +Date: Fri, 2 Apr 2004 17:05:01 +0100 (BST) +From: Clive Page +To: pgsql-performance@postgresql.org +Subject: Re: Spatial join insists on sequential scan of larger +In-Reply-To: <27943.1080920786@sss.pgh.pa.us> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/13 +X-Sequence-Number: 6313 + +On Fri, 2 Apr 2004, Tom Lane wrote: + +> Could we see EXPLAIN ANALYZE output? + +Certainly, but that's going to take a little time (as the ANALYZE causes +it to run the actual query, which I only just discovered), so may have to +wait until Monday if I don't get time to finish it this afternoon. + + +-- +Clive Page +Dept of Physics & Astronomy, +University of Leicester, +Leicester, LE1 7RH, U.K. + + +From pgsql-performance-owner@postgresql.org Sat Apr 3 06:47:07 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 78170D1ECA7 + for ; + Sat, 3 Apr 2004 10:47:05 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 98402-03 + for ; + Sat, 3 Apr 2004 06:47:15 -0400 (AST) +Received: from gpdnet.co.uk (gpdnet.plus.com [212.56.100.243]) + by svr1.postgresql.org (Postfix) with ESMTP id 73DCDD1ECFC + for ; + Sat, 3 Apr 2004 06:47:02 -0400 (AST) +Received: from Spooler by gpdnet.co.uk (Mercury/32 v4.01a) ID MO001DF5; + 3 Apr 2004 11:51:09 +0100 +Received: from spooler by gpdnet.co.uk (Mercury/32 v4.01a); + 3 Apr 2004 11:51:02 +0100 +Received: from gary (192.168.1.2) by gpdnet.co.uk (Mercury/32 v4.01a) with + ESMTP ID MG001DF4; 3 Apr 2004 11:50:52 +0100 +From: "Gary Doades" +To: pgsql-performance@postgresql.org +Date: Sat, 03 Apr 2004 11:50:51 +0100 +MIME-Version: 1.0 +Subject: Re: PostgreSQL and Linux 2.6 kernel. +Message-ID: <406EA51B.21218.D2DE061@localhost> +X-mailer: Pegasus Mail for Windows (v4.12a) +Content-type: text/plain; charset=US-ASCII +Content-transfer-encoding: 7BIT +Content-description: Mail message body +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/14 +X-Sequence-Number: 6314 + +On 2 Apr 2004 at 22:36, pgsql-performance@postgresql. wrote: + +OK, some more detail: + +Before wiping 2.4 off my test box for the second time: + +SQL Statement for update: +update staff_booking set time_from = r.time_from from order_reqt r where r.reqt_id = +staff_booking.reqt_id; + +Explain: (on 2.4) +QUERY PLAN +Merge Join (cost=0.00..185731.30 rows=2845920 width=92) + Merge Cond: ("outer".reqt_id = "inner".reqt_id) + -> Index Scan using order_reqt_pkey on order_reqt r (cost=0.00..53068.20 +rows=2206291 width=6) + -> Index Scan using staff_book_idx2 on staff_booking (cost=0.00..99579.21 +rows=2845920 width=90) + +Total execution time: 18 hours 12 minutes + +vacuum full analyze: total time 3 hours 22 minutes + +Wait 2 hours for re-install 2.6, set params etc. +restore database. + +Same SQL Statement +Explain: (on 2.6) +QUERY PLAN +Merge Join (cost=0.00..209740.24 rows=2845920 width=92) + Merge Cond: ("outer".reqt_id = "inner".reqt_id) + -> Index Scan using order_reqt_pkey on order_reqt r (cost=0.00..50734.20 +rows=2206291 width=6) + -> Index Scan using staff_book_idx2 on staff_booking (cost=0.00..117921.92 +rows=2845920 width=90) + +Total execution time: 2 hours 53 minutes + +vacuum full analyze: total time 1 hours 6 minutes + +Table definitions for the two tables involved: +CREATE TABLE ORDER_REQT +( + REQT_ID SERIAL, + ORDER_ID integer NOT NULL, + DAYOFWEEK smallint NOT NULL CHECK (DAYOFWEEK +BETWEEN 0 AND 6), + TIME_FROM smallint NOT NULL CHECK (TIME_FROM +BETWEEN 0 AND 1439), + DURATION smallint NOT NULL CHECK (DURATION +BETWEEN 0 AND 1439), + PRODUCT_ID integer NOT NULL, + NUMBER_REQT smallint NOT NULL DEFAULT (1), + WROPTIONS integer NOT NULL DEFAULT 0, + UID_REF integer NOT NULL, + DT_STAMP timestamp NOT NULL DEFAULT +current_timestamp, + Sentinel_Priority integer NOT NULL DEFAULT 0, + PERIOD smallint NOT NULL DEFAULT 1 CHECK +(PERIOD BETWEEN -2 AND 4), + FREQUENCY smallint NOT NULL DEFAULT 1, + PRIMARY KEY (REQT_ID) +); + +CREATE TABLE STAFF_BOOKING +( + BOOKING_ID SERIAL, + REQT_ID integer NOT NULL, + ENTITY_TYPE smallint NOT NULL DEFAULT 3 +check(ENTITY_TYPE in(3,4)), + STAFF_ID integer NOT NULL, + CONTRACT_ID integer NOT NULL, + TIME_FROM smallint NOT NULL CHECK (TIME_FROM +BETWEEN 0 AND 1439), + DURATION smallint NOT NULL CHECK (DURATION +BETWEEN 0 AND 1439), + PERIOD smallint NOT NULL DEFAULT 1 CHECK +(PERIOD BETWEEN -2 AND 4), + FREQUENCY smallint NOT NULL DEFAULT 1, + TRAVEL_TO smallint NOT NULL DEFAULT 0, + UID_REF integer NOT NULL, + DT_STAMP timestamp NOT NULL DEFAULT +current_timestamp, + SELL_PRICE numeric(10,4) NOT NULL DEFAULT 0, + COST_PRICE numeric(10,4) NOT NULL DEFAULT 0, + MIN_SELL_PRICE numeric(10,4) NOT NULL DEFAULT 0, + MIN_COST_PRICE numeric(10,4) NOT NULL DEFAULT 0, + Sentinel_Priority integer NOT NULL DEFAULT 0, + CHECK_INTERVAL smallint NOT NULL DEFAULT 0, + STATUS smallint NOT NULL DEFAULT 0, + WROPTIONS integer NOT NULL DEFAULT 0, + PRIMARY KEY (BOOKING_ID) +); + +Foreign keys: + +ALTER TABLE ORDER_REQT ADD + FOREIGN KEY + ( + ORDER_ID + ) REFERENCES MAIN_ORDER ( + ORDER_ID + ) ON DELETE CASCADE; + +ALTER TABLE ORDER_REQT ADD + FOREIGN KEY + ( + PRODUCT_ID + ) REFERENCES PRODUCT ( + PRODUCT_ID + ); + +ALTER TABLE STAFF_BOOKING ADD + FOREIGN KEY + ( + CONTRACT_ID + ) REFERENCES STAFF_CONTRACT ( + CONTRACT_ID + ); + +ALTER TABLE STAFF_BOOKING ADD + FOREIGN KEY + ( + STAFF_ID + ) REFERENCES STAFF ( + STAFF_ID + ); + + +Indexes: + +CREATE INDEX FK_IDX_ORDER_REQT + ON ORDER_REQT + ( + ORDER_ID + ); + +CREATE INDEX FK_IDX_ORDER_REQT_2 + ON ORDER_REQT + ( + PRODUCT_ID + ); + +CREATE INDEX ORDER_REQT_IDX ON ORDER_REQT +( + ORDER_ID, + PRODUCT_ID +); + +CREATE INDEX ORDER_REQT_IDX4 ON ORDER_REQT +( + REQT_ID, + TIME_FROM, + DURATION +); + +CREATE INDEX FK_IDX_STAFF_BOOKING + ON STAFF_BOOKING + ( + CONTRACT_ID + ); + +CREATE INDEX FK_IDX_STAFF_BOOKING_2 + ON STAFF_BOOKING + ( + STAFF_ID + ); + +CREATE INDEX STAFF_BOOK_IDX1 ON STAFF_BOOKING +( + STAFF_ID, + REQT_ID +); + +CREATE INDEX STAFF_BOOK_IDX2 ON STAFF_BOOKING +( + REQT_ID +); + +CREATE INDEX STAFF_BOOK_IDX3 ON STAFF_BOOKING +( + BOOKING_ID, + REQT_ID +); + + +CREATE INDEX STAFF_BOOK_IDX4 ON STAFF_BOOKING +( + BOOKING_ID, + CONTRACT_ID +); + +There are no indexes on the columns involved in the update, they are +not required for my usual select statements. This is an attempt to +slightly denormalise the design to get the performance up comparable +to SQL Server 2000. We hope to move some of our databases over to +PostgreSQL later in the year and this is part of the ongoing testing. +SQLServer's query optimiser is a bit smarter that PostgreSQL's (yet) +so I am hand optimising some of the more frequently used +SQL and/or tweaking the database design slightly. + +Later, after deciphering SQLServers graphical plans I will attempt to +post comparitive performance/access plans, using the same data of +course, if anyone would be interested.... + +Cheers, +Gary. + + + +On 2 Apr 2004 at 1:32, Tom Lane wrote: + +> "Gary Doades" writes: +> > As a test in PosgreSQL I issued a statement to update a single column +> > of a table containing 2.8 million rows with the values of a column in +> > a table with similar rowcount. Using the above spec I had to stop the +> > server after 17 hours. The poor thing was thrashing the hard disk and +> > doing more swapping than useful work. +> +> This statement is pretty much content-free, since you did not show us +> the table schemas, the query, or the EXPLAIN output for the query. +> (I'll forgive you the lack of EXPLAIN ANALYZE, but you could easily +> have provided all the other hard facts.) There's really no way to tell +> where the bottleneck is. Maybe it's a kernel-level issue, but I would +> not bet on that without more evidence. I'd definitely not bet on it +> without direct confirmation that the same query plan was used in both +> setups. +> +> regards, tom lane +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 3: if posting/reading through Usenet, please send an appropriate +> subscribe-nomail command to majordomo@postgresql.org so that your +> message can get through to the mailing list cleanly +> +> +> -- +> Incoming mail is certified Virus Free. +> Checked by AVG Anti-Virus (http://www.grisoft.com). +> Version: 7.0.230 / Virus Database: 262.6.5 - Release Date: 31/03/2004 +> + + + +From pgsql-performance-owner@postgresql.org Sat Apr 3 09:23:59 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 05C7DD1DB5B + for ; + Sat, 3 Apr 2004 13:23:58 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 31923-10 + for ; + Sat, 3 Apr 2004 09:24:09 -0400 (AST) +Received: from palle.girgensohn.se (1-2-8-5a.asp.sth.bostream.se + [82.182.157.66]) + by svr1.postgresql.org (Postfix) with ESMTP id 1FC6CD1D55F + for ; + Sat, 3 Apr 2004 09:23:55 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by palle.girgensohn.se (8.12.11/8.12.11) with ESMTP id i33DO7LF019918; + Sat, 3 Apr 2004 15:24:07 +0200 (CEST) + (envelope-from girgen@pingpong.net) +Date: Sat, 03 Apr 2004 15:24:07 +0200 +From: Palle Girgensohn +To: Bruno Wolff III +Cc: pgsql-performance@postgresql.org +Subject: Re: single index on more than two coulumns a bad thing? +Message-ID: <1730000.1080998647@palle.girgensohn.se> +In-Reply-To: <20040402155604.GC5151@wolff.to> +References: <24070000.1080860445@palle.girgensohn.se> + <20040402155604.GC5151@wolff.to> +X-Mailer: Mulberry/3.1.0 (Linux/x86) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/15 +X-Sequence-Number: 6315 + +--On fredag, april 02, 2004 09.56.04 -0600 Bruno Wolff III +wrote: + +> On Fri, Apr 02, 2004 at 01:00:45 +0200, +> Palle Girgensohn wrote: +>> +>> Is it always bad to create index xx on yy (field1, field2, field3); +>> +>> I guess the problem is that the index might often grow bigger than the +>> table, or at least big enough not to speed up the queries? +> +> One place where you need them in postgres is enforcing unique multicolumn +> keys. These will get created implicitly from the unique (or primary key) +> constraint. It isn't all that unusual to have a table that describes +> a many to many (to many ...) relationship where the primary key is all +> of the columns. + +True, of course! + +/Palle + + +From pgsql-performance-owner@postgresql.org Sat Apr 3 15:00:10 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A1EFED1ECBD + for ; + Sat, 3 Apr 2004 19:00:01 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 22193-06 + for ; + Sat, 3 Apr 2004 15:00:14 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 55A5CD1ECA7 + for ; + Sat, 3 Apr 2004 14:59:54 -0400 (AST) +Received: from [63.195.55.98] (HELO 192.168.1.29) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4763818; Sat, 03 Apr 2004 11:01:30 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: "Gary Doades" , + pgsql-performance@postgresql.org +Subject: Re: PostgreSQL and Linux 2.6 kernel. +Date: Sat, 3 Apr 2004 10:59:39 -0800 +User-Agent: KMail/1.5.4 +References: <406EA51B.21218.D2DE061@localhost> +In-Reply-To: <406EA51B.21218.D2DE061@localhost> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200404031059.39268.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/16 +X-Sequence-Number: 6316 + +Gary, + +> There are no indexes on the columns involved in the update, they are +> not required for my usual select statements. This is an attempt to +> slightly denormalise the design to get the performance up comparable +> to SQL Server 2000. We hope to move some of our databases over to +> PostgreSQL later in the year and this is part of the ongoing testing. +> SQLServer's query optimiser is a bit smarter that PostgreSQL's (yet) +> so I am hand optimising some of the more frequently used +> SQL and/or tweaking the database design slightly. + +Hmmm ... that hasn't been my general experience on complex queries. However, +it may be due to a difference in ANALYZE statistics. I'd love to see you +increase your default_stats_target, re-analyze, and see if PostgreSQL gets +"smarter". + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Sat Apr 3 17:30:14 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 041E4D1ED8D + for ; + Sat, 3 Apr 2004 21:30:13 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 59107-07 + for ; + Sat, 3 Apr 2004 17:30:27 -0400 (AST) +Received: from gpdnet.co.uk (gpdnet.plus.com [212.56.100.243]) + by svr1.postgresql.org (Postfix) with ESMTP id 77832D1ED91 + for ; + Sat, 3 Apr 2004 17:30:10 -0400 (AST) +Received: from Spooler by gpdnet.co.uk (Mercury/32 v4.01a) ID MO001E59; + 3 Apr 2004 22:34:24 +0100 +Received: from spooler by gpdnet.co.uk (Mercury/32 v4.01a); + 3 Apr 2004 22:34:06 +0100 +Received: from gary (192.168.1.2) by gpdnet.co.uk (Mercury/32 v4.01a) with + ESMTP ID MG001E58; 3 Apr 2004 22:33:56 +0100 +Resent-From: "Gary Doades" +Resent-To: pgsql-performance@postgresql.org +Resent-date: Sat, 03 Apr 2004 22:33:56 +0100 +X-cs: R +From: Gary Doades +X-RS-ID: +X-RS-Flags: 0,0,1,1,0,0,0 +X-RS-Header: In-reply-to: <200404031059.39268.josh@agliodbs.com> +X-RS-Header: References: <406EA51B.21218.D2DE061@localhost> +X-RS-Sigset: 0 +To: pgsql-performance-owner@postgresql.org +Subject: Re: PostgreSQL and Linux 2.6 kernel. +MIME-Version: 1.0 +Content-type: text/plain; charset=ISO-8859-1 +Content-transfer-encoding: 8BIT +Date: Sat, 03 Apr 2004 20:32:35 +0100 +Message-ID: +Resent-Message-Id: <20040403213010.77832D1ED91@svr1.postgresql.org> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/17 +X-Sequence-Number: 6317 + +Actually it hasn't been my experience either. Most of my queries against +the database, large and small are either a little quicker or no real +difference. I have only really noticed big differences under stress when +memory (RAM) is being squeezed. The main winner on 2.6 seems to be +write performance and memory management. + +Unfortunately I only have one test machine and I can't really keep +switching between 2.4 and 2.6 to do the comparisons. I had written +down 27 timings from a set of SQL of varying complexity using the 2.4 +kernel. Each SQL statement was executed 10 times and the average of +the last 5 was used. I can only really compare those timings against the +new installation on 2.6. I know that this is not ideal "real world" testing, +but it is good enough for me at the moment. Unless anyone has +contradictory indications then I will proceed with 2.6. + +I did increase the default stats target from 10 to 50 and re-analysed. +The explain numbers are slightly different, but the time to run was +almost the same. Not surprising since the plan was the same. + +QUERY PLAN +Merge Join (cost=0.00..192636.20 rows=2845920 width=92) + Merge Cond: ("outer".reqt_id = "inner".reqt_id) + -> Index Scan using order_reqt_pkey on order_reqt r (cost=0.00..52662.40 +rows=2206291 width=6) + -> Index Scan using staff_book_idx2 on staff_booking (cost=0.00..102529.28 +rows=2845920 width=90) + + +On 3 Apr 2004 at 10:59, Josh Berkus wrote: + +Gary, + +> There are no indexes on the columns involved in the update, they are +> not required for my usual select statements. This is an attempt to +> slightly denormalise the design to get the performance up comparable +> to SQL Server 2000. We hope to move some of our databases over to +> PostgreSQL later in the year and this is part of the ongoing testing. +> SQLServer's query optimiser is a bit smarter that PostgreSQL's (yet) +> so I am hand optimising some of the more frequently used +> SQL and/or tweaking the database design slightly. + +Hmmm ... that hasn't been my general experience on complex queries. However, +it may be due to a difference in ANALYZE statistics. I'd love to see you +increase your default_stats_target, re-analyze, and see if PostgreSQL gets +"smarter". + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +---------------------------(end of broadcast)--------------------------- +TIP 3: if posting/reading through Usenet, please send an appropriate + subscribe-nomail command to majordomo@postgresql.org so that your + message can get through to the mailing list cleanly + + +-- +Incoming mail is certified Virus Free. +Checked by AVG Anti-Virus (http://www.grisoft.com). +Version: 7.0.230 / Virus Database: 262.6.5 - Release Date: 31/03/2004 + + +From pgsql-performance-owner@postgresql.org Sat Apr 3 17:31:02 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 45624D1E2D7 + for ; + Sat, 3 Apr 2004 21:31:01 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 62435-02 + for ; + Sat, 3 Apr 2004 17:31:15 -0400 (AST) +Received: from gpdnet.co.uk (gpdnet.plus.com [212.56.100.243]) + by svr1.postgresql.org (Postfix) with ESMTP id B7E31D1CAD0 + for ; + Sat, 3 Apr 2004 17:30:58 -0400 (AST) +Received: from Spooler by gpdnet.co.uk (Mercury/32 v4.01a) ID MO001E5B; + 3 Apr 2004 22:35:12 +0100 +Received: from spooler by gpdnet.co.uk (Mercury/32 v4.01a); + 3 Apr 2004 22:35:01 +0100 +Received: from gary (192.168.1.2) by gpdnet.co.uk (Mercury/32 v4.01a) with + ESMTP ID MG001E5A; 3 Apr 2004 22:34:54 +0100 +Resent-From: "Gary Doades" +Resent-To: pgsql-performance@postgresql.org +Resent-date: Sat, 03 Apr 2004 22:34:54 +0100 +X-cs: R +From: Gary Doades +X-RS-ID: +X-RS-Flags: 0,0,1,1,0,0,0 +X-RS-Header: In-reply-to: <200404031059.39268.josh@agliodbs.com> +X-RS-Header: References: <406EA51B.21218.D2DE061@localhost> +X-RS-Sigset: 0 +To: pgsql-performance-owner@postgresql.org +Subject: Re: PostgreSQL and Linux 2.6 kernel. +MIME-Version: 1.0 +Content-type: text/plain; charset=ISO-8859-1 +Content-transfer-encoding: 8BIT +Date: Sat, 03 Apr 2004 21:16:10 +0100 +Message-ID: +Resent-Message-Id: <20040403213058.B7E31D1CAD0@svr1.postgresql.org> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/18 +X-Sequence-Number: 6318 + +Sorry, I think I misread your post in my last reply. I thought you were still talking about +the big update.... + +The main thing I have noticed about SQLServer is it seems more willing to do hash or +merge joins than PostgreSQL. I have experimented with various postgresql.conf +parameters and even turned off nested loops to see the difference. When actually +getting a merge join out of PostgreSQL when it wanted to do a nested loop it, not +surprisingly, took longer to execute. + +Looking at the SQLServer plan it seemed to be spending MUCH less time in the sort +operations than PostgreSQL. This is probably what leads SQLServer to go for +hash/merge joins more often. The other problem is that the SQLServer timings are +skewed by its query plan caching. + +For one query SQLserver plan said it spent 2% of its time in a big sort, the same query +in PostgreSQL when hash join was forced spent 23% of its time on the sort (from explain +analyse actual stats). I have played about with the sort_mem, but it doesn't make much +diffrence. + +I have also noticed that SQLServer tends to fold more complex IN subselects into the +main query using merge joins, maybe for the same reason as above. + +SQLServer seems to have some more "exotic" joins ("nested loop/left semi join","nested +loop/left anti semi join"). These are probably just variants of nested loops, but I don't +know enough about it to say if they make a difference. Clustered indexes and clustered +index seeks also seem to be a big player in the more complex queries. + +I still have quite a lot comparitive testing and tuning to do before I can nail it down +further, but I will let you know when I have some hard stats to go on. + + +On 3 Apr 2004 at 10:59, Josh Berkus wrote: + +Gary, + +> There are no indexes on the columns involved in the update, they are +> not required for my usual select statements. This is an attempt to +> slightly denormalise the design to get the performance up comparable +> to SQL Server 2000. We hope to move some of our databases over to +> PostgreSQL later in the year and this is part of the ongoing testing. +> SQLServer's query optimiser is a bit smarter that PostgreSQL's (yet) +> so I am hand optimising some of the more frequently used +> SQL and/or tweaking the database design slightly. + +Hmmm ... that hasn't been my general experience on complex queries. However, +it may be due to a difference in ANALYZE statistics. I'd love to see you +increase your default_stats_target, re-analyze, and see if PostgreSQL gets +"smarter". + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +---------------------------(end of broadcast)--------------------------- +TIP 3: if posting/reading through Usenet, please send an appropriate + subscribe-nomail command to majordomo@postgresql.org so that your + message can get through to the mailing list cleanly + + +-- +Incoming mail is certified Virus Free. +Checked by AVG Anti-Virus (http://www.grisoft.com). +Version: 7.0.230 / Virus Database: 262.6.5 - Release Date: 31/03/2004 + + +From pgsql-performance-owner@postgresql.org Sat Apr 3 17:31:21 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A4F4ED1E9C8 + for ; + Sat, 3 Apr 2004 21:31:17 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 63360-01 + for ; + Sat, 3 Apr 2004 17:31:31 -0400 (AST) +Received: from gpdnet.co.uk (gpdnet.plus.com [212.56.100.243]) + by svr1.postgresql.org (Postfix) with ESMTP id 7ACA1D1E9BB + for ; + Sat, 3 Apr 2004 17:31:14 -0400 (AST) +Received: from Spooler by gpdnet.co.uk (Mercury/32 v4.01a) ID MO001E5D; + 3 Apr 2004 22:35:28 +0100 +Received: from spooler by gpdnet.co.uk (Mercury/32 v4.01a); + 3 Apr 2004 22:35:13 +0100 +Received: from gary (192.168.1.2) by gpdnet.co.uk (Mercury/32 v4.01a) with + ESMTP ID MG001E5C; 3 Apr 2004 22:35:08 +0100 +Resent-From: "Gary Doades" +Resent-To: pgsql-performance@postgresql.org +Resent-date: Sat, 03 Apr 2004 22:35:07 +0100 +X-cs: R +From: Gary Doades +X-RS-ID: +X-RS-Flags: 0,0,1,1,0,0,0 +X-RS-Header: In-reply-to: <200404031338.i33DccbP015107@smtp.gvtc.com> +X-RS-Header: References: <406EA51B.21218.D2DE061@localhost> +X-RS-Sigset: 0 +To: pgsql-performance-owner@postgresql.org +Subject: Re: PostgreSQL and Linux 2.6 kernel. +MIME-Version: 1.0 +Content-type: text/plain; charset=ISO-8859-1 +Content-transfer-encoding: 8BIT +Date: Sat, 03 Apr 2004 21:20:49 +0100 +Message-ID: +Resent-Message-Id: <20040403213114.7ACA1D1E9BB@svr1.postgresql.org> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/20 +X-Sequence-Number: 6320 + +Thanks, + +I know about set showplan_text, but it is only the equivalent of explain, +not explain analyze. The graphical plan gives full statistics, runtime, +percentage cost, loop execution counts etc. which is much more useful. +I don't know of a way of getting the graphical plan content in text form. + +Cheers, +Gary. + +On 3 Apr 2004 at 6:50, @g v t c wrote: + +Use "Set Show_Plan" or something of the sort in Query Analyzer. Then +run your SQL. This will change the graphical plan to a text plan +similar to Postgresql or at least something close to readable. + +Gary Doades wrote: + +>On 2 Apr 2004 at 22:36, pgsql-performance@postgresql. wrote: +> +>OK, some more detail: +> +>Before wiping 2.4 off my test box for the second time: +> +>SQL Statement for update: +>update staff_booking set time_from = r.time_from from order_reqt r where r.reqt_id = +>staff_booking.reqt_id; +> +>Explain: (on 2.4) +>QUERY PLAN +>Merge Join (cost=0.00..185731.30 rows=2845920 width=92) +> Merge Cond: ("outer".reqt_id = "inner".reqt_id) +> -> Index Scan using order_reqt_pkey on order_reqt r (cost=0.00..53068.20 +>rows=2206291 width=6) +> -> Index Scan using staff_book_idx2 on staff_booking (cost=0.00..99579.21 +>rows=2845920 width=90) +> +>Total execution time: 18 hours 12 minutes +> +>vacuum full analyze: total time 3 hours 22 minutes +> +>Wait 2 hours for re-install 2.6, set params etc. +>restore database. +> +>Same SQL Statement +>Explain: (on 2.6) +>QUERY PLAN +>Merge Join (cost=0.00..209740.24 rows=2845920 width=92) +> Merge Cond: ("outer".reqt_id = "inner".reqt_id) +> -> Index Scan using order_reqt_pkey on order_reqt r (cost=0.00..50734.20 +>rows=2206291 width=6) +> -> Index Scan using staff_book_idx2 on staff_booking (cost=0.00..117921.92 +>rows=2845920 width=90) +> +>Total execution time: 2 hours 53 minutes +> +>vacuum full analyze: total time 1 hours 6 minutes +> +>Table definitions for the two tables involved: +>CREATE TABLE ORDER_REQT +>( +> REQT_ID SERIAL, +> ORDER_ID integer NOT NULL, +> DAYOFWEEK smallint NOT NULL CHECK (DAYOFWEEK +>BETWEEN 0 AND 6), +> TIME_FROM smallint NOT NULL CHECK (TIME_FROM +>BETWEEN 0 AND 1439), +> DURATION smallint NOT NULL CHECK (DURATION +>BETWEEN 0 AND 1439), +> PRODUCT_ID integer NOT NULL, +> NUMBER_REQT smallint NOT NULL DEFAULT (1), +> WROPTIONS integer NOT NULL DEFAULT 0, +> UID_REF integer NOT NULL, +> DT_STAMP timestamp NOT NULL DEFAULT +>current_timestamp, +> Sentinel_Priority integer NOT NULL DEFAULT 0, +> PERIOD smallint NOT NULL DEFAULT 1 CHECK +>(PERIOD BETWEEN -2 AND 4), +> FREQUENCY smallint NOT NULL DEFAULT 1, +> PRIMARY KEY (REQT_ID) +>); +> +>CREATE TABLE STAFF_BOOKING +>( +> BOOKING_ID SERIAL, +> REQT_ID integer NOT NULL, +> ENTITY_TYPE smallint NOT NULL DEFAULT 3 +>check(ENTITY_TYPE in(3,4)), +> STAFF_ID integer NOT NULL, +> CONTRACT_ID integer NOT NULL, +> TIME_FROM smallint NOT NULL CHECK (TIME_FROM +>BETWEEN 0 AND 1439), +> DURATION smallint NOT NULL CHECK (DURATION +>BETWEEN 0 AND 1439), +> PERIOD smallint NOT NULL DEFAULT 1 CHECK +>(PERIOD BETWEEN -2 AND 4), +> FREQUENCY smallint NOT NULL DEFAULT 1, +> TRAVEL_TO smallint NOT NULL DEFAULT 0, +> UID_REF integer NOT NULL, +> DT_STAMP timestamp NOT NULL DEFAULT +>current_timestamp, +> SELL_PRICE numeric(10,4) NOT NULL DEFAULT 0, +> COST_PRICE numeric(10,4) NOT NULL DEFAULT 0, +> MIN_SELL_PRICE numeric(10,4) NOT NULL DEFAULT 0, +> MIN_COST_PRICE numeric(10,4) NOT NULL DEFAULT 0, +> Sentinel_Priority integer NOT NULL DEFAULT 0, +> CHECK_INTERVAL smallint NOT NULL DEFAULT 0, +> STATUS smallint NOT NULL DEFAULT 0, +> WROPTIONS integer NOT NULL DEFAULT 0, +> PRIMARY KEY (BOOKING_ID) +>); +> +>Foreign keys: +> +>ALTER TABLE ORDER_REQT ADD +> FOREIGN KEY +> ( +> ORDER_ID +> ) REFERENCES MAIN_ORDER ( +> ORDER_ID +> ) ON DELETE CASCADE; +> +>ALTER TABLE ORDER_REQT ADD +> FOREIGN KEY +> ( +> PRODUCT_ID +> ) REFERENCES PRODUCT ( +> PRODUCT_ID +> ); +> +>ALTER TABLE STAFF_BOOKING ADD +> FOREIGN KEY +> ( +> CONTRACT_ID +> ) REFERENCES STAFF_CONTRACT ( +> CONTRACT_ID +> ); +> +>ALTER TABLE STAFF_BOOKING ADD +> FOREIGN KEY +> ( +> STAFF_ID +> ) REFERENCES STAFF ( +> STAFF_ID +> ); +> +> +>Indexes: +> +>CREATE INDEX FK_IDX_ORDER_REQT +> ON ORDER_REQT +> ( +> ORDER_ID +> ); +> +>CREATE INDEX FK_IDX_ORDER_REQT_2 +> ON ORDER_REQT +> ( +> PRODUCT_ID +> ); +> +>CREATE INDEX ORDER_REQT_IDX ON ORDER_REQT +>( +> ORDER_ID, +> PRODUCT_ID +>); +> +>CREATE INDEX ORDER_REQT_IDX4 ON ORDER_REQT +>( +> REQT_ID, +> TIME_FROM, +> DURATION +>); +> +>CREATE INDEX FK_IDX_STAFF_BOOKING +> ON STAFF_BOOKING +> ( +> CONTRACT_ID +> ); +> +>CREATE INDEX FK_IDX_STAFF_BOOKING_2 +> ON STAFF_BOOKING +> ( +> STAFF_ID +> ); +> +>CREATE INDEX STAFF_BOOK_IDX1 ON STAFF_BOOKING +>( +> STAFF_ID, +> REQT_ID +>); +> +>CREATE INDEX STAFF_BOOK_IDX2 ON STAFF_BOOKING +>( +> REQT_ID +>); +> +>CREATE INDEX STAFF_BOOK_IDX3 ON STAFF_BOOKING +>( +> BOOKING_ID, +> REQT_ID +>); +> +> +>CREATE INDEX STAFF_BOOK_IDX4 ON STAFF_BOOKING +>( +> BOOKING_ID, +> CONTRACT_ID +>); +> +>There are no indexes on the columns involved in the update, they are +>not required for my usual select statements. This is an attempt to +>slightly denormalise the design to get the performance up comparable +>to SQL Server 2000. We hope to move some of our databases over to +>PostgreSQL later in the year and this is part of the ongoing testing. +>SQLServer's query optimiser is a bit smarter that PostgreSQL's (yet) +>so I am hand optimising some of the more frequently used +>SQL and/or tweaking the database design slightly. +> +>Later, after deciphering SQLServers graphical plans I will attempt to +>post comparitive performance/access plans, using the same data of +>course, if anyone would be interested.... +> +>Cheers, +>Gary. +> +> +> +>On 2 Apr 2004 at 1:32, Tom Lane wrote: +> +> +> +>>"Gary Doades" writes: +>> +>> +>>>As a test in PosgreSQL I issued a statement to update a single column +>>>of a table containing 2.8 million rows with the values of a column in +>>>a table with similar rowcount. Using the above spec I had to stop the +>>>server after 17 hours. The poor thing was thrashing the hard disk and +>>>doing more swapping than useful work. +>>> +>>> +>> +>>This statement is pretty much content-free, since you did not show us +>>the table schemas, the query, or the EXPLAIN output for the query. +>>(I'll forgive you the lack of EXPLAIN ANALYZE, but you could easily +>>have provided all the other hard facts.) There's really no way to tell +>>where the bottleneck is. Maybe it's a kernel-level issue, but I would +>>not bet on that without more evidence. I'd definitely not bet on it +>>without direct confirmation that the same query plan was used in both +>>setups. +>> +>> regards, tom lane +>> +>>---------------------------(end of broadcast)--------------------------- +>>TIP 3: if posting/reading through Usenet, please send an appropriate +>> subscribe-nomail command to majordomo@postgresql.org so that your +>> message can get through to the mailing list cleanly +>> +>> +>>-- +>>Incoming mail is certified Virus Free. +>>Checked by AVG Anti-Virus (http://www.grisoft.com). +>>Version: 7.0.230 / Virus Database: 262.6.5 - Release Date: 31/03/2004 +>> +>> +>> +> +> +> +>---------------------------(end of broadcast)--------------------------- +>TIP 2: you can get off all lists at once with the unregister command +> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) +> +> +> +> + + +-- +Incoming mail is certified Virus Free. +Checked by AVG Anti-Virus (http://www.grisoft.com). +Version: 7.0.230 / Virus Database: 262.6.5 - Release Date: 31/03/2004 + + +From pgsql-performance-owner@postgresql.org Sat Apr 3 17:31:19 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 67F53D1E9D3 + for ; + Sat, 3 Apr 2004 21:31:18 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 59322-06 + for ; + Sat, 3 Apr 2004 17:31:31 -0400 (AST) +Received: from gpdnet.co.uk (gpdnet.plus.com [212.56.100.243]) + by svr1.postgresql.org (Postfix) with ESMTP id 7D9C5D1E9BC + for ; + Sat, 3 Apr 2004 17:31:14 -0400 (AST) +Received: from Spooler by gpdnet.co.uk (Mercury/32 v4.01a) ID MO001E5F; + 3 Apr 2004 22:35:28 +0100 +Received: from spooler by gpdnet.co.uk (Mercury/32 v4.01a); + 3 Apr 2004 22:35:24 +0100 +Received: from gary (192.168.1.2) by gpdnet.co.uk (Mercury/32 v4.01a) with + ESMTP ID MG001E5E; 3 Apr 2004 22:35:18 +0100 +Resent-From: "Gary Doades" +Resent-To: pgsql-performance@postgresql.org +Resent-date: Sat, 03 Apr 2004 22:35:18 +0100 +X-cs: R +From: Gary Doades +X-RS-ID: +X-RS-Flags: 0,0,1,1,0,0,0 +X-RS-Header: In-reply-to: <200404031059.39268.josh@agliodbs.com> +X-RS-Header: References: <406EA51B.21218.D2DE061@localhost> +X-RS-Sigset: 0 +To: pgsql-performance-owner@postgresql.org +Subject: Re: PostgreSQL and Linux 2.6 kernel. +MIME-Version: 1.0 +Content-type: text/plain; charset=ISO-8859-1 +Content-transfer-encoding: 8BIT +Date: Sat, 03 Apr 2004 22:29:01 +0100 +Message-ID: +Resent-Message-Id: <20040403213114.7D9C5D1E9BC@svr1.postgresql.org> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/19 +X-Sequence-Number: 6319 + +Following on from Josh's response and my previous reply on SQLServer planning. + +The main problem query is this one: + +SELECT VS.*,VL.TEL1,SC.CONTRACT_ID,SC.CONTRACT_REF, SC.MAX_HOURS, +SC.MIN_HOURS, + (SELECT COUNT(*) FROM TIMESHEET_DETAIL JOIN MAIN_ORDER ON +(MAIN_ORDER.ORDER_ID = TIMESHEET_DETAIL.ORDER_ID AND +MAIN_ORDER.CLIENT_ID = 6) WHERE TIMESHEET_DETAIL.CONTRACT_ID = +SC.CONTRACT_ID) AS VISITS, +(SELECT (SUM(R.DURATION+1))/60.0 FROM ORDER_REQT R + JOIN STAFF_BOOKING B ON (B.REQT_ID = R.REQT_ID) + JOIN BOOKING_PLAN BP ON (BP.BOOKING_ID = B.BOOKING_ID) WHERE +B.CONTRACT_ID = SC.CONTRACT_ID + AND BP.BOOKING_DATE BETWEEN '2004-06-12' AND '2004-06-18') AS RHOURS +FROM VSTAFF VS +JOIN STAFF_CONTRACT SC ON (SC.STAFF_ID = VS.STAFF_ID) +JOIN VLOCATION VL ON (VL.LOCATION_ID = VS.LOCATION_ID) +JOIN SEARCH_REQT_RESULT SR ON (SR.STAFF_ID = VS.STAFF_ID) +WHERE SR.SEARCH_ID = 1 AND SC.CONTRACT_ID IN +(SELECT C.CONTRACT_ID FROM STAFF_PRODUCT P,STAFF_CONTRACT C +WHERE P.CONTRACT_ID=C.CONTRACT_ID AND C.STAFF_ID = VS.STAFF_ID AND +P.PRODUCT_ID IN (SELECT PRODUCT_ID FROM SEARCH_ORDER_REQT WHERE +SEARCH_ID = 1) AND C.AVAIL_DATE_FROM <= '2004-06-12' AND +C.AVAIL_DATE_TO >= '2004-06-18' GROUP BY C.CONTRACT_ID + HAVING (COUNT(C.CONTRACT_ID) = (SELECT COUNT(DISTINCT PRODUCT_ID) +FROM SEARCH_ORDER_REQT WHERE SEARCH_ID = 1))) + +The explain analyze is: +QUERY PLAN +Nested Loop (cost=101.54..1572059.57 rows=135 width=152) (actual +time=13749.100..1304586.501 rows=429 loops=1) + InitPlan + -> Index Scan using fk_idx_wruserarea on wruserarea (cost=3.26..6.52 rows=1 +width=4) (actual time=0.944..0.944 rows=1 loops=1) + Index Cond: (area_id = 1) + Filter: (uid = $4) + InitPlan + -> Seq Scan on wruser (cost=0.00..3.26 rows=1 width=4) (actual +time=0.686..0.691 rows=1 loops=1) + Filter: ((username)::name = "current_user"()) + -> Hash Join (cost=95.02..3701.21 rows=215 width=138) (actual +time=100.476..1337.392 rows=429 loops=1) + Hash Cond: ("outer".staff_id = "inner".staff_id) + Join Filter: (subplan) + -> Seq Scan on staff_contract sc (cost=0.00..33.24 rows=1024 width=37) (actual +time=0.114..245.366 rows=1024 loops=1) + -> Hash (cost=93.95..93.95 rows=430 width=109) (actual time=38.563..38.563 +rows=0 loops=1) + -> Hash Join (cost=47.47..93.95 rows=430 width=109) (actual +time=15.502..36.627 rows=429 loops=1) + Hash Cond: ("outer".staff_id = "inner".staff_id) + -> Seq Scan on staff (cost=34.61..66.48 rows=1030 width=105) (actual +time=9.655..15.264 rows=1030 loops=1) + Filter: ((hashed subplan) OR $5) + SubPlan + -> Seq Scan on staff_area (cost=10.73..33.38 rows=493 width=4) +(actual time=8.452..8.452 rows=0 loops=1) + Filter: ((hashed subplan) OR (area_id = 1)) + SubPlan + -> Seq Scan on wruserarea (cost=3.26..10.72 rows=5 width=4) +(actual time=0.977..1.952 rows=1 loops=1) + Filter: (uid = $1) + InitPlan + -> Seq Scan on wruser (cost=0.00..3.26 rows=1 width=4) +(actual time=0.921..0.926 rows=1 loops=1) + Filter: ((username)::name = "current_user"()) + -> Hash (cost=11.79..11.79 rows=430 width=4) (actual time=5.705..5.705 +rows=0 loops=1) + -> Index Scan using fk_idx_search_reqt_result on search_reqt_result +sr (cost=0.00..11.79 rows=430 width=4) (actual time=0.470..4.482 rows=429 loops=1) + Index Cond: (search_id = 1) + SubPlan + -> HashAggregate (cost=8.32..8.32 rows=1 width=4) (actual time=2.157..2.157 +rows=1 loops=429) + Filter: (count(contract_id) = $9) + InitPlan + -> Aggregate (cost=1.04..1.04 rows=1 width=4) (actual time=0.172..0.173 +rows=1 loops=1) + -> Seq Scan on search_order_reqt (cost=0.00..1.04 rows=1 width=4) +(actual time=0.022..0.038 rows=1 loops=1) + Filter: (search_id = 1) + -> Hash IN Join (cost=1.04..7.27 rows=1 width=4) (actual time=2.064..2.117 +rows=1 loops=429) + Hash Cond: ("outer".product_id = "inner".product_id) + -> Nested Loop (cost=0.00..6.19 rows=7 width=8) (actual +time=1.112..2.081 rows=8 loops=429) + -> Index Scan using fk_idx_staff_contract_2 on staff_contract c +(cost=0.00..3.03 rows=1 width=4) (actual time=0.206..0.245 rows=1 loops=429) + Index Cond: (staff_id = $8) + Filter: ((avail_date_from <= '2004-06-12'::date) AND (avail_date_to +>= '2004-06-18'::date)) + -> Index Scan using fk_idx_staff_product on staff_product p +(cost=0.00..3.08 rows=6 width=8) (actual time=0.873..1.764 rows=8 loops=429) + Index Cond: (p.contract_id = "outer".contract_id) + -> Hash (cost=1.04..1.04 rows=1 width=4) (actual time=0.086..0.086 +rows=0 loops=1) + -> Seq Scan on search_order_reqt (cost=0.00..1.04 rows=1 width=4) +(actual time=0.037..0.050 rows=1 loops=1) + Filter: (search_id = 1) + -> Index Scan using location_pkey on "location" (cost=0.00..12.66 rows=1 width=18) +(actual time=0.876..0.887 rows=1 loops=429) + Index Cond: ("location".location_id = "outer".location_id) + Filter: ((area_id = 1) OR (subplan)) + SubPlan + -> Index Scan using fk_idx_wruserarea, fk_idx_wruserarea on wruserarea +(cost=3.26..9.64 rows=1 width=4) (never executed) + Index Cond: ((area_id = 1) OR (area_id = $7)) + Filter: (uid = $6) + InitPlan + -> Seq Scan on wruser (cost=0.00..3.26 rows=1 width=4) (never executed) + Filter: ((username)::name = "current_user"()) + SubPlan + -> Aggregate (cost=11233.28..11233.29 rows=1 width=2) (actual +time=3036.814..3036.815 rows=1 loops=429) + -> Nested Loop (cost=10391.71..11233.21 rows=30 width=2) (actual +time=2817.923..3036.516 rows=34 loops=429) + -> Hash Join (cost=10391.71..11142.43 rows=30 width=4) (actual +time=2813.349..3007.936 rows=34 loops=429) + Hash Cond: ("outer".booking_id = "inner".booking_id) + -> Index Scan using booking_plan_idx2 on booking_plan bp +(cost=0.00..572.52 rows=23720 width=4) (actual time=0.070..157.028 rows=24613 +loops=429) + Index Cond: ((booking_date >= '2004-06-12'::date) AND +(booking_date <= '2004-06-18'::date)) + -> Hash (cost=10382.78..10382.78 rows=3571 width=8) (actual +time=2746.122..2746.122 rows=0 loops=429) + -> Index Scan using fk_idx_staff_booking on staff_booking b +(cost=0.00..10382.78 rows=3571 width=8) (actual time=14.168..2733.315 rows=3815 +loops=429) + Index Cond: (contract_id = $0) + -> Index Scan using order_reqt_pkey on order_reqt r (cost=0.00..3.01 +rows=1 width=6) (actual time=0.826..0.832 rows=1 loops=14401) + Index Cond: ("outer".reqt_id = r.reqt_id) + -> Aggregate (cost=363.94..363.94 rows=1 width=0) (actual time=0.057..0.058 +rows=1 loops=429) + -> Nested Loop (cost=0.00..363.94 rows=1 width=0) (actual time=0.034..0.034 +rows=0 loops=429) + -> Index Scan using fk_idx_main_order on main_order (cost=0.00..4.99 +rows=1 width=4) (actual time=0.031..0.031 rows=0 loops=429) + Index Cond: (client_id = 6) + -> Index Scan using fk_idx_timesheet_detail_3 on timesheet_detail +(cost=0.00..358.93 rows=1 width=4) (never executed) + Index Cond: ("outer".order_id = timesheet_detail.order_id) + Filter: (contract_id = $0) +Total runtime: 1304591.861 ms + +Long Time! The main issue here is that the RHOURS subselect is executed as a nested +join 429 times. unfortunately this is an expensive subquery. + +SQLServer executed this in just over 1 second on comparable hardware. Looking at its +execution plan it flattens out the two subselects with a merge join. So I manually rewrote +the query using derived tables and joins as: + +SELECT VS.*,VL.TEL1,SC.CONTRACT_ID,SC.CONTRACT_REF, SC.MAX_HOURS, +SC.MIN_HOURS, TBOOK.RHOURS, TVIS.VISITS FROM SEARCH_REQT_RESULT +SR +JOIN STAFF_CONTRACT SC ON (SR.STAFF_ID = SC.STAFF_ID) AND +SC.AVAIL_DATE_FROM <= '2004-06-12' AND SC.AVAIL_DATE_TO >= '2004-06-18' +JOIN VSTAFF VS ON (VS.STAFF_ID = SC.STAFF_ID) +JOIN VLOCATION VL ON (VL.LOCATION_ID = VS.LOCATION_ID) +LEFT OUTER JOIN (SELECT B.CONTRACT_ID, SUM(R.DURATION+1)/60.0 AS +RHOURS FROM STAFF_BOOKING B +JOIN BOOKING_PLAN BP ON (BP.BOOKING_ID = B.BOOKING_ID) AND +BP.BOOKING_DATE BETWEEN '2004-06-12' AND '2004-06-18' +JOIN ORDER_REQT R ON (R.REQT_ID = B.REQT_ID) + GROUP BY B.CONTRACT_ID) AS TBOOK +ON (SC.CONTRACT_ID = TBOOK.CONTRACT_ID) +LEFT OUTER JOIN (SELECT CONTRACT_ID,COUNT(*) AS VISITS FROM +TIMESHEET_DETAIL +JOIN MAIN_ORDER ON (MAIN_ORDER.ORDER_ID = +TIMESHEET_DETAIL.ORDER_ID) WHERE MAIN_ORDER.CLIENT_ID = 6 +GROUP BY CONTRACT_ID) AS TVIS ON (TVIS.CONTRACT_ID = SC.CONTRACT_ID) +JOIN (SELECT P.CONTRACT_ID FROM STAFF_PRODUCT P, +SEARCH_ORDER_REQT SR +WHERE P.PRODUCT_ID = SR.PRODUCT_ID AND SR.SEARCH_ID = 1 +GROUP BY P.CONTRACT_ID +HAVING (COUNT(P.CONTRACT_ID) = (SELECT COUNT(DISTINCT PRODUCT_ID) +FROM SEARCH_ORDER_REQT WHERE SEARCH_ID = 1))) AS TCONT ON +(TCONT.CONTRACT_ID = SC.CONTRACT_ID) +WHERE SR.SEARCH_ID = 1 + +With the explain analyze as: +QUERY PLAN +Hash Join (cost=137054.42..137079.74 rows=159 width=192) (actual +time=6228.354..6255.058 rows=429 loops=1) + Hash Cond: ("outer".contract_id = "inner".contract_id) + InitPlan + -> Index Scan using fk_idx_wruserarea on wruserarea (cost=3.26..6.52 rows=1 +width=4) (actual time=0.850..0.850 rows=1 loops=1) + Index Cond: (area_id = 1) + Filter: (uid = $3) + InitPlan + -> Seq Scan on wruser (cost=0.00..3.26 rows=1 width=4) (actual +time=0.670..0.675 rows=1 loops=1) + Filter: ((username)::name = "current_user"()) + -> Subquery Scan tcont (cost=152.63..161.81 rows=612 width=4) (actual +time=36.312..42.268 rows=612 loops=1) + -> HashAggregate (cost=152.63..155.69 rows=612 width=4) (actual +time=36.301..40.040 rows=612 loops=1) + Filter: (count(contract_id) = $7) + InitPlan + -> Aggregate (cost=1.04..1.04 rows=1 width=4) (actual time=0.107..0.108 +rows=1 loops=1) + -> Seq Scan on search_order_reqt (cost=0.00..1.04 rows=1 width=4) +(actual time=0.025..0.037 rows=1 loops=1) + Filter: (search_id = 1) + -> Hash Join (cost=1.04..148.53 rows=612 width=4) (actual +time=0.419..32.284 rows=612 loops=1) + Hash Cond: ("outer".product_id = "inner".product_id) + -> Seq Scan on staff_product p (cost=0.00..109.91 rows=6291 width=8) +(actual time=0.117..17.943 rows=6291 loops=1) + -> Hash (cost=1.04..1.04 rows=1 width=4) (actual time=0.190..0.190 +rows=0 loops=1) + -> Seq Scan on search_order_reqt sr (cost=0.00..1.04 rows=1 +width=4) (actual time=0.165..0.177 rows=1 loops=1) + Filter: (search_id = 1) + -> Hash (cost=136894.61..136894.61 rows=266 width=192) (actual +time=6191.923..6191.923 rows=0 loops=1) + -> Merge Left Join (cost=136886.03..136894.61 rows=266 width=192) (actual +time=6143.315..6189.685 rows=429 loops=1) + Merge Cond: ("outer".contract_id = "inner".contract_id) + -> Merge Left Join (cost=136517.64..136525.04 rows=266 width=184) (actual +time=6142.896..6171.676 rows=429 loops=1) + Merge Cond: ("outer".contract_id = "inner".contract_id) + -> Sort (cost=5529.68..5530.34 rows=266 width=152) (actual +time=129.548..130.027 rows=429 loops=1) + Sort Key: sc.contract_id + -> Nested Loop (cost=88.35..5518.96 rows=266 width=152) (actual +time=33.213..121.666 rows=429 loops=1) + -> Hash Join (cost=88.35..143.88 rows=424 width=138) (actual +time=32.739..76.357 rows=429 loops=1) + Hash Cond: ("outer".staff_id = "inner".staff_id) + -> Hash Join (cost=47.47..93.95 rows=430 width=109) (actual +time=15.232..40.040 rows=429 loops=1) + Hash Cond: ("outer".staff_id = "inner".staff_id) + -> Seq Scan on staff (cost=34.61..66.48 rows=1030 +width=105) (actual time=9.412..16.105 rows=1030 loops=1) + Filter: ((hashed subplan) OR $4) + SubPlan + -> Seq Scan on staff_area (cost=10.73..33.38 +rows=493 width=4) (actual time=8.380..8.380 rows=0 loops=1) + Filter: ((hashed subplan) OR (area_id = 1)) + SubPlan + -> Seq Scan on wruserarea (cost=3.26..10.72 +rows=5 width=4) (actual time=0.953..1.941 rows=1 loops=1) + Filter: (uid = $0) + InitPlan + -> Seq Scan on wruser (cost=0.00..3.26 +rows=1 width=4) (actual time=0.902..0.908 rows=1 loops=1) + Filter: ((username)::name = +"current_user"()) + -> Hash (cost=11.79..11.79 rows=430 width=4) (actual +time=5.670..5.670 rows=0 loops=1) + -> Index Scan using fk_idx_search_reqt_result on +search_reqt_result sr (cost=0.00..11.79 rows=430 width=4) (actual time=0.448..4.516 +rows=429 loops=1) + Index Cond: (search_id = 1) + -> Hash (cost=38.36..38.36 rows=1008 width=37) (actual +time=17.386..17.386 rows=0 loops=1) + -> Seq Scan on staff_contract sc (cost=0.00..38.36 +rows=1008 width=37) (actual time=0.222..14.063 rows=1008 loops=1) + Filter: ((avail_date_from <= '2004-06-12'::date) AND +(avail_date_to >= '2004-06-18'::date)) + -> Index Scan using location_pkey on "location" (cost=0.00..12.66 +rows=1 width=18) (actual time=0.043..0.050 rows=1 loops=429) + Index Cond: ("location".location_id = "outer".location_id) + Filter: ((area_id = 1) OR (subplan)) + SubPlan + -> Index Scan using fk_idx_wruserarea, fk_idx_wruserarea on +wruserarea (cost=3.26..9.64 rows=1 width=4) (never executed) + Index Cond: ((area_id = 1) OR (area_id = $6)) + Filter: (uid = $5) + InitPlan + -> Seq Scan on wruser (cost=0.00..3.26 rows=1 width=4) +(never executed) + Filter: ((username)::name = "current_user"()) + -> Sort (cost=130987.97..130989.96 rows=797 width=36) (actual +time=6013.254..6014.112 rows=746 loops=1) + Sort Key: tbook.contract_id + -> Subquery Scan tbook (cost=130933.62..130949.56 rows=797 +width=36) (actual time=5993.070..6007.677 rows=746 loops=1) + -> HashAggregate (cost=130933.62..130941.59 rows=797 +width=6) (actual time=5993.055..6004.099 rows=746 loops=1) + -> Merge Join (cost=74214.90..130815.02 rows=23720 +width=6) (actual time=4950.951..5807.985 rows=24613 loops=1) + Merge Cond: ("outer".reqt_id = "inner".reqt_id) + -> Index Scan using order_reqt_pkey on order_reqt r +(cost=0.00..50734.20 rows=2206291 width=6) (actual time=0.444..2753.374 +rows=447439 loops=1) + -> Sort (cost=74214.90..74274.20 rows=23720 width=8) +(actual time=1822.405..1856.081 rows=24613 loops=1) + Sort Key: b.reqt_id + -> Nested Loop (cost=0.00..72491.19 rows=23720 +width=8) (actual time=1.955..1633.124 rows=24613 loops=1) + -> Index Scan using booking_plan_idx2 on +booking_plan bp (cost=0.00..572.52 rows=23720 width=4) (actual time=1.468..243.827 +rows=24613 loops=1) + Index Cond: ((booking_date >= '2004-06- +12'::date) AND (booking_date <= '2004-06-18'::date)) + -> Index Scan using staff_booking_pkey on +staff_booking b (cost=0.00..3.02 rows=1 width=12) (actual time=0.037..0.042 rows=1 +loops=24613) + Index Cond: ("outer".booking_id = b.booking_id) + -> Sort (cost=368.38..368.55 rows=68 width=12) (actual time=0.338..0.338 +rows=0 loops=1) + Sort Key: tvis.contract_id + -> Subquery Scan tvis (cost=365.46..366.31 rows=68 width=12) (actual +time=0.307..0.307 rows=0 loops=1) + -> HashAggregate (cost=365.46..365.63 rows=68 width=4) (actual +time=0.302..0.302 rows=0 loops=1) + -> Nested Loop (cost=0.00..365.12 rows=68 width=4) (actual +time=0.290..0.290 rows=0 loops=1) + -> Index Scan using fk_idx_main_order on main_order +(cost=0.00..4.99 rows=1 width=4) (actual time=0.286..0.286 rows=0 loops=1) + Index Cond: (client_id = 6) + -> Index Scan using fk_idx_timesheet_detail_3 on +timesheet_detail (cost=0.00..358.63 rows=120 width=8) (never executed) + Index Cond: ("outer".order_id = timesheet_detail.order_id) +Total runtime: 6266.205 ms + +This now gives me the same results, but with orders of magnitude better execution +times! + +Oddly enough, SQLServer really struggles with the second query, taking longer then +PostgreSQL!!!! + +Regards, +Gary. + + +On 3 Apr 2004 at 10:59, Josh Berkus wrote: + +Gary, + +> There are no indexes on the columns involved in the update, they are +> not required for my usual select statements. This is an attempt to +> slightly denormalise the design to get the performance up comparable +> to SQL Server 2000. We hope to move some of our databases over to +> PostgreSQL later in the year and this is part of the ongoing testing. +> SQLServer's query optimiser is a bit smarter that PostgreSQL's (yet) +> so I am hand optimising some of the more frequently used +> SQL and/or tweaking the database design slightly. + +Hmmm ... that hasn't been my general experience on complex queries. However, +it may be due to a difference in ANALYZE statistics. I'd love to see you +increase your default_stats_target, re-analyze, and see if PostgreSQL gets +"smarter". + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +---------------------------(end of broadcast)--------------------------- +TIP 3: if posting/reading through Usenet, please send an appropriate + subscribe-nomail command to majordomo@postgresql.org so that your + message can get through to the mailing list cleanly + + +-- +Incoming mail is certified Virus Free. +Checked by AVG Anti-Virus (http://www.grisoft.com). +Version: 7.0.230 / Virus Database: 262.6.5 - Release Date: 31/03/2004 + + +From pgsql-performance-owner@postgresql.org Sat Apr 3 18:34:36 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 56A8AD1ED6D + for ; + Sat, 3 Apr 2004 22:34:34 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 76300-02 + for ; + Sat, 3 Apr 2004 18:34:48 -0400 (AST) +Received: from artemis.le.ac.uk (mailsend.le.ac.uk [143.210.16.126]) + by svr1.postgresql.org (Postfix) with ESMTP id E04DED1ED69 + for ; + Sat, 3 Apr 2004 18:34:31 -0400 (AST) +Received: from [143.210.36.58] (helo=mail.star.le.ac.uk) + by artemis.le.ac.uk with smtp (Exim 4.30) id 1B9tiz-0004iN-Sn + for pgsql-performance@postgresql.org; Sat, 03 Apr 2004 23:34:49 +0100 +Received: (qmail 11789 invoked from network); 3 Apr 2004 22:35:11 -0000 +Received: from sparky.star.le.ac.uk (143.210.36.10) + by mail.star.le.ac.uk with SMTP; 3 Apr 2004 22:35:11 -0000 +Date: Sat, 3 Apr 2004 23:35:11 +0100 (BST) +From: Clive Page +To: pgsql-performance@postgresql.org +Subject: Re: Spatial join insists on sequential scan of larger +In-Reply-To: <27943.1080920786@sss.pgh.pa.us> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/21 +X-Sequence-Number: 6321 + +On Fri, 2 Apr 2004, Tom Lane wrote: + +> Could we see EXPLAIN ANALYZE output? + +The original EXPLAIN output was: + + QUERY PLAN +---------------------------------------------------------------------------------- + Nested Loop (cost=0.00..196642756520.34 rows=49506496044 width=32) + -> Seq Scan on twomass t (cost=0.00..9560002.72 rows=177023872 width=48) + -> Index Scan using xmm1box on xmm1 x (cost=0.00..1107.28 rows=280 width=48) + Index Cond: (x.errbox && "outer".errbox) + +The EXPLAIN ANALYZE query was: + +explain analyze +SELECT x.ra AS xra, x.decl AS xdecl, t.ra AS tra, t.decl AS tdecl +INTO tempjoin +FROM xmm1 AS x INNER JOIN twomass AS t +ON x.errbox && t.errbox; + +And this produced: + +\timing +Timing is on. +dw=# \i join1.sql + QUERY PLAN +-------------------------------------------------------------------------------------------------------------------------------------- + Nested Loop (cost=0.00..196642756520.34 rows=49506496044 width=32) (actual time=701.919..7796111.624 rows=1513 loops=1) + -> Seq Scan on twomass t (cost=0.00..9560002.72 rows=177023872 width=48) (actual time=22.064..617462.486 rows=177757299 loops=1) + -> Index Scan using xmmbox on xmm1 x (cost=0.00..1107.28 rows=280 width=48) (actual time=0.036..0.036 rows=0 loops=177757299) + Index Cond: (x.errbox && "outer".errbox) + Total runtime: 7796410.533 ms +(5 rows) + +Time: 7796996.093 ms + + +-- +Clive Page +Dept of Physics & Astronomy, +University of Leicester, +Leicester, LE1 7RH, U.K. + + +From pgsql-performance-owner@postgresql.org Sat Apr 3 18:43:24 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B022ED1CA77 + for ; + Sat, 3 Apr 2004 22:43:22 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 76300-06 + for ; + Sat, 3 Apr 2004 18:43:37 -0400 (AST) +Received: from hotmail.com (law10-oe20.law10.hotmail.com [64.4.14.124]) + by svr1.postgresql.org (Postfix) with ESMTP id BB8B4D1B4BB + for ; + Sat, 3 Apr 2004 18:43:20 -0400 (AST) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Sat, 3 Apr 2004 14:43:39 -0800 +Received: from 67.81.102.201 by law10-oe20.law10.hotmail.com with DAV; + Sat, 03 Apr 2004 22:43:39 +0000 +X-Originating-IP: [67.81.102.201] +X-Originating-Email: [awerman2@hotmail.com] +X-Sender: awerman2@hotmail.com +From: "Aaron Werman" +To: , "Gary Doades" , + +References: <406EA51B.21218.D2DE061@localhost> + <200404031059.39268.josh@agliodbs.com> +Subject: Re: PostgreSQL and Linux 2.6 kernel. +Date: Sat, 3 Apr 2004 17:43:52 -0500 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1158 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +Message-ID: +X-OriginalArrivalTime: 03 Apr 2004 22:43:39.0389 (UTC) + FILETIME=[1B84BAD0:01C419CD] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/22 +X-Sequence-Number: 6322 + +Almost any cross dbms migration shows a drop in performance. The engine +effectively trains developers and administrators in what works and what +doesn't. The initial migration thus compares a tuned to an untuned version. + +/Aaron + +----- Original Message ----- +From: "Josh Berkus" +To: "Gary Doades" ; +Sent: Saturday, April 03, 2004 1:59 PM +Subject: Re: [PERFORM] PostgreSQL and Linux 2.6 kernel. + + +> Gary, +> +> > There are no indexes on the columns involved in the update, they are +> > not required for my usual select statements. This is an attempt to +> > slightly denormalise the design to get the performance up comparable +> > to SQL Server 2000. We hope to move some of our databases over to +> > PostgreSQL later in the year and this is part of the ongoing testing. +> > SQLServer's query optimiser is a bit smarter that PostgreSQL's (yet) +> > so I am hand optimising some of the more frequently used +> > SQL and/or tweaking the database design slightly. +> +> Hmmm ... that hasn't been my general experience on complex queries. +However, +> it may be due to a difference in ANALYZE statistics. I'd love to see you +> increase your default_stats_target, re-analyze, and see if PostgreSQL gets +> "smarter". +> +> -- +> -Josh Berkus +> Aglio Database Solutions +> San Francisco +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 3: if posting/reading through Usenet, please send an appropriate +> subscribe-nomail command to majordomo@postgresql.org so that your +> message can get through to the mailing list cleanly +> + +From pgsql-performance-owner@postgresql.org Sat Apr 3 19:52:37 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DC9CFD1EA01 + for ; + Sat, 3 Apr 2004 23:52:34 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 90994-10 + for ; + Sat, 3 Apr 2004 19:52:49 -0400 (AST) +Received: from jinx.internetstaff.com (unknown [63.214.174.240]) + by svr1.postgresql.org (Postfix) with ESMTP id 276E7D1E9B0 + for ; + Sat, 3 Apr 2004 19:52:32 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by jinx.internetstaff.com (Postfix) with ESMTP id 621034BC0BC + for ; + Sat, 3 Apr 2004 16:52:50 -0700 (MST) +Received: from jinx.internetstaff.com ([127.0.0.1]) + by localhost (jinx [127.0.0.1]) (amavisd-new, port 10024) with LMTP + id 28839-03 for ; + Sat, 3 Apr 2004 16:52:50 -0700 (MST) +Subject: Re: PostgreSQL and Linux 2.6 kernel. +From: Cott Lang +To: pgsql-performance@postgresql.org +In-Reply-To: <406EA51B.21218.D2DE061@localhost> +References: <406EA51B.21218.D2DE061@localhost> +Content-Type: text/plain +Message-Id: <1081036369.11561.1.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-1) +Date: Sat, 03 Apr 2004 16:52:49 -0700 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at internetstaff.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/23 +X-Sequence-Number: 6323 + +On Sat, 2004-04-03 at 03:50, Gary Doades wrote: +> On 2 Apr 2004 at 22:36, pgsql-performance@postgresql. wrote: +> +> OK, some more detail: +> +> Before wiping 2.4 off my test box for the second time: + +Perhaps I missed it, but which io scheduler are you using under 2.6? + + + +From pgsql-performance-owner@postgresql.org Sat Apr 3 23:27:02 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D6FCBD1CA77 + for ; + Sun, 4 Apr 2004 03:27:00 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 43753-03 + for ; + Sat, 3 Apr 2004 23:27:16 -0400 (AST) +Received: from gw.tssi.com (gw.tssi.com [198.147.197.1]) + by svr1.postgresql.org (Postfix) with ESMTP id 64292D1ED2F + for ; + Sat, 3 Apr 2004 23:26:57 -0400 (AST) +Received: from gw.tssi.com (nolan@gw.tssi.com [127.0.0.1] (may be forged)) + by gw.tssi.com (8.12.6/8.12.6) with ESMTP id i343Nx8S002749; + Sat, 3 Apr 2004 21:23:59 -0600 +Received: (from nolan@localhost) + by gw.tssi.com (8.12.6/8.12.6/Submit) id i343Nw3Z002747; + Sat, 3 Apr 2004 21:23:58 -0600 +From: Mike Nolan +Message-Id: <200404040323.i343Nw3Z002747@gw.tssi.com> +Subject: Re: PostgreSQL and Linux 2.6 kernel. +To: awerman2@hotmail.com (Aaron Werman) +Date: Sat, 3 Apr 2004 21:23:57 -0600 (CST) +Cc: josh@agliodbs.com, gpd@gpdnet.co.uk (Gary Doades), + pgsql-performance@postgresql.org +In-Reply-To: from "Aaron Werman" at + Apr 03, 2004 05:43:52 PM +X-Mailer: ELM [version 2.5 PL3] +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/24 +X-Sequence-Number: 6324 + +> Almost any cross dbms migration shows a drop in performance. The engine +> effectively trains developers and administrators in what works and what +> doesn't. The initial migration thus compares a tuned to an untuned version. + +I think it is also possible that Microsoft has more programmers working +on tuning issues for SQL Server than PostgreSQL has working on the +whole project. +-- +Mike Nolan + +From pgsql-performance-owner@postgresql.org Sun Apr 4 05:13:48 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 85F43D1B8B6 + for ; + Sun, 4 Apr 2004 08:13:46 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 08505-02 + for ; + Sun, 4 Apr 2004 05:14:03 -0300 (ADT) +Received: from mail.networkprograms.com (unknown [203.190.139.254]) + by svr1.postgresql.org (Postfix) with ESMTP id 7F11AD1E9B8 + for ; + Sun, 4 Apr 2004 05:13:40 -0300 (ADT) +Received: from KAMALR ([192.9.203.78]) + by mail.networkprograms.com (8.12.9/8.12.9) with SMTP id i348H1bB028241 + for ; Sun, 4 Apr 2004 13:47:01 +0530 +Message-ID: <02ad01c41a1d$4255a7a0$4ecb09c0@KAMALR> +Reply-To: "Kamalraj Singh Madhan" +From: "Kamalraj Singh Madhan" +To: +References: <200404040323.i343Nw3Z002747@gw.tssi.com> +Subject: Substitute for this oracle query in postGre +Date: Sun, 4 Apr 2004 13:47:24 +0530 +MIME-Version: 1.0 +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 5.50.4807.1700 +X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300 +X-Scanned-By: MIMEDefang 2.40 +X-Virus-Scanned: by amavisd-new at postgresql.org +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset="iso-8859-1" +Content-Disposition: inline +X-Archive-Number: 200404/25 +X-Sequence-Number: 6325 + +Hi Friends, + Does anybody know the substitute of the oracle function 'connect by +prior' in postgre sql. + The query is basically being used to get a tree structure of records. The +query in oracle is :- + +select pkmsgid +from mstmessage +connect by prior pkmsgid = msgparentid +start with msgparentid = 1 + +Kindly suggest. + +regards +Kamal + + + +********************************************************************* +Network Programs is a SEI CMM Level 5 Certified Company +******************************************************************** +The information contained in this communication (including any attachments) is +intended solely for the use of the individual or entity to whom it is addressed +and others authorized to receive it. It may contain confidential or legally +privileged information. If you are not the intended recipient you are hereby +notified that any disclosure, copying, distribution or taking any action in +reliance on the contents of this information is strictly prohibited and may be +unlawful. If you have received this communication in error, please notify us +immediately by responding to this email and then delete it from your system. +Network Programs (India) Limited is neither liable for the proper and complete +transmission of the information contained in this communication nor for any +delay in its receipt. +********************************************************************* + + +From pgsql-performance-owner@postgresql.org Sun Apr 4 05:45:21 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 012D9D1EA65 + for ; + Sun, 4 Apr 2004 08:45:21 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 12296-07 + for ; + Sun, 4 Apr 2004 05:45:37 -0300 (ADT) +Received: from gpdnet.co.uk (gpdnet.plus.com [212.56.100.243]) + by svr1.postgresql.org (Postfix) with ESMTP id 83F04D1EA01 + for ; + Sun, 4 Apr 2004 05:45:17 -0300 (ADT) +Received: from Spooler by gpdnet.co.uk (Mercury/32 v4.01a) ID MO001EC1; + 4 Apr 2004 09:49:38 +0100 +Received: from spooler by gpdnet.co.uk (Mercury/32 v4.01a); + 4 Apr 2004 09:49:30 +0100 +Received: from gary (192.168.1.2) by gpdnet.co.uk (Mercury/32 v4.01a) with + ESMTP ID MG001EC0; 4 Apr 2004 09:49:24 +0100 +From: "Gary Doades" +To: pgsql-performance@postgresql.org +Date: Sun, 04 Apr 2004 09:49:23 +0100 +MIME-Version: 1.0 +Subject: Re: PostgreSQL and Linux 2.6 kernel. +Message-ID: <406FDA23.19934.24163F4@localhost> +In-reply-to: +X-mailer: Pegasus Mail for Windows (v4.12a) +Content-type: text/plain; charset=US-ASCII +Content-transfer-encoding: 7BIT +Content-description: Mail message body +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/26 +X-Sequence-Number: 6326 + +Possibly. + +A lot of my queries show comparable performance, some a little slower +and a few a little faster. There are a few, however, that really grind on +PostgreSQL. I am leaning patterns from these to try and and target the +most likely performance problems to come and hand tune these types +of SQL. + +I'm not complaining about PostgreSQL or saying that SQLServer is +better, in most cases it is not. SQLServer seems to be more predictable +and forgiving in performance which tends to make for lazy SQL +programming. It also has implications when the SQL is dynamically +created based on user input, there are more chances of PostgreSQL +hitting a performance problem than SQLServer. + +Overall I'm still very impressed with PostgreSQL. Given the $7000 per +processor licence for SQLServer makes the case for PostgreSQL even +stronger! + +Cheers, +Gary. + +On 3 Apr 2004 at 17:43, Aaron Werman wrote: + +Almost any cross dbms migration shows a drop in performance. The engine +effectively trains developers and administrators in what works and what +doesn't. The initial migration thus compares a tuned to an untuned version. + +/Aaron + +----- Original Message ----- +From: "Josh Berkus" +To: "Gary Doades" ; +Sent: Saturday, April 03, 2004 1:59 PM +Subject: Re: [PERFORM] PostgreSQL and Linux 2.6 kernel. + + +> Gary, +> +> > There are no indexes on the columns involved in the update, they are +> > not required for my usual select statements. This is an attempt to +> > slightly denormalise the design to get the performance up comparable +> > to SQL Server 2000. We hope to move some of our databases over to +> > PostgreSQL later in the year and this is part of the ongoing testing. +> > SQLServer's query optimiser is a bit smarter that PostgreSQL's (yet) +> > so I am hand optimising some of the more frequently used +> > SQL and/or tweaking the database design slightly. +> +> Hmmm ... that hasn't been my general experience on complex queries. +However, +> it may be due to a difference in ANALYZE statistics. I'd love to see you +> increase your default_stats_target, re-analyze, and see if PostgreSQL gets +> "smarter". +> +> -- +> -Josh Berkus +> Aglio Database Solutions +> San Francisco +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 3: if posting/reading through Usenet, please send an appropriate +> subscribe-nomail command to majordomo@postgresql.org so that your +> message can get through to the mailing list cleanly +> + +---------------------------(end of broadcast)--------------------------- +TIP 6: Have you searched our list archives? + + http://archives.postgresql.org + + +-- +Incoming mail is certified Virus Free. +Checked by AVG Anti-Virus (http://www.grisoft.com). +Version: 7.0.230 / Virus Database: 262.6.5 - Release Date: 31/03/2004 + + +From pgsql-performance-owner@postgresql.org Sun Apr 4 06:06:59 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id F212ED1D2CE + for ; + Sun, 4 Apr 2004 09:06:57 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 18031-06 + for ; + Sun, 4 Apr 2004 06:07:13 -0300 (ADT) +Received: from gpdnet.co.uk (gpdnet.plus.com [212.56.100.243]) + by svr1.postgresql.org (Postfix) with ESMTP id 59A5DD1BB89 + for ; + Sun, 4 Apr 2004 06:06:53 -0300 (ADT) +Received: from Spooler by gpdnet.co.uk (Mercury/32 v4.01a) ID MO001ECC; + 4 Apr 2004 10:11:14 +0100 +Received: from spooler by gpdnet.co.uk (Mercury/32 v4.01a); + 4 Apr 2004 10:11:00 +0100 +Received: from gary (192.168.1.2) by gpdnet.co.uk (Mercury/32 v4.01a) with + ESMTP ID MG001ECB; 4 Apr 2004 10:11:00 +0100 +Resent-From: "Gary Doades" +Resent-To: pgsql-performance@postgresql.org +Resent-date: Sun, 04 Apr 2004 10:10:59 +0100 +X-cs: R +From: Gary Doades +X-RS-ID: +X-RS-Flags: 0,0,1,1,0,0,0 +X-RS-Header: In-reply-to: <200404040323.i343Nw3Z002747@gw.tssi.com> +X-RS-Header: References: from "Aaron + Werman" at Apr 03, 2004 05:43:52 PM +X-RS-Sigset: 0 +To: Mike Nolan +Subject: Re: PostgreSQL and Linux 2.6 kernel. +MIME-Version: 1.0 +Content-type: text/plain; charset=ISO-8859-1 +Content-transfer-encoding: 8BIT +Date: Sun, 04 Apr 2004 09:52:40 +0100 +Message-ID: +Resent-Message-Id: <20040404090653.59A5DD1BB89@svr1.postgresql.org> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/29 +X-Sequence-Number: 6329 + +On 3 Apr 2004 at 21:23, Mike Nolan wrote: + +> > Almost any cross dbms migration shows a drop in performance. The engine +> > effectively trains developers and administrators in what works and what +> > doesn't. The initial migration thus compares a tuned to an untuned version. +> +> I think it is also possible that Microsoft has more programmers working +> on tuning issues for SQL Server than PostgreSQL has working on the +> whole project. +> -- +> Mike Nolan +> + +Agreed. Also considering the high price of SQLServer it is in their +interests to spend a lot of resources on tuning/performance to give it a +commercial edge over it rivals and in silly benchmark scores. + +Cheers, +Gary. + + +> -- +> Incoming mail is certified Virus Free. +> Checked by AVG Anti-Virus (http://www.grisoft.com). +> Version: 7.0.230 / Virus Database: 262.6.5 - Release Date: 31/03/2004 +> + + + +From pgsql-performance-owner@postgresql.org Sun Apr 4 05:52:33 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2646FD1BB89 + for ; + Sun, 4 Apr 2004 08:52:32 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 17233-01 + for ; + Sun, 4 Apr 2004 05:52:49 -0300 (ADT) +Received: from gpdnet.co.uk (gpdnet.plus.com [212.56.100.243]) + by svr1.postgresql.org (Postfix) with ESMTP id 4DC0BD1EAC4 + for ; + Sun, 4 Apr 2004 05:52:29 -0300 (ADT) +Received: from Spooler by gpdnet.co.uk (Mercury/32 v4.01a) ID MO001EC6; + 4 Apr 2004 09:56:50 +0100 +Received: from spooler by gpdnet.co.uk (Mercury/32 v4.01a); + 4 Apr 2004 09:56:40 +0100 +Received: from gary (192.168.1.2) by gpdnet.co.uk (Mercury/32 v4.01a) with + ESMTP ID MG001EC5; 4 Apr 2004 09:56:34 +0100 +From: "Gary Doades" +To: pgsql-performance@postgresql.org +Date: Sun, 04 Apr 2004 09:56:34 +0100 +MIME-Version: 1.0 +Subject: Re: PostgreSQL and Linux 2.6 kernel. +Message-ID: <406FDBD2.9910.247F995@localhost> +In-reply-to: <1081036369.11561.1.camel@localhost.localdomain> +References: <406EA51B.21218.D2DE061@localhost> +X-mailer: Pegasus Mail for Windows (v4.12a) +Content-type: text/plain; charset=US-ASCII +Content-transfer-encoding: 7BIT +Content-description: Mail message body +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/27 +X-Sequence-Number: 6327 + +Unfortunately I don't understand the question! + +My background is the primarily Win32. The last time I used a *nix OS +was about 20 years ago apart from occasional dips into the linux OS +over the past few years. If you can tell be how to find out what you want +I will gladly give you the information. + +Regards, +Gary. + +On 3 Apr 2004 at 16:52, Cott Lang wrote: + +> On Sat, 2004-04-03 at 03:50, Gary Doades wrote: +> > On 2 Apr 2004 at 22:36, pgsql-performance@postgresql. wrote: +> > +> > OK, some more detail: +> > +> > Before wiping 2.4 off my test box for the second time: +> +> Perhaps I missed it, but which io scheduler are you using under 2.6? +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 3: if posting/reading through Usenet, please send an appropriate +> subscribe-nomail command to majordomo@postgresql.org so that your +> message can get through to the mailing list cleanly +> +> +> -- +> Incoming mail is certified Virus Free. +> Checked by AVG Anti-Virus (http://www.grisoft.com). +> Version: 7.0.230 / Virus Database: 262.6.5 - Release Date: 31/03/2004 +> + + + +From pgsql-performance-owner@postgresql.org Sun Apr 4 05:56:17 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2114AD1EB92 + for ; + Sun, 4 Apr 2004 08:56:16 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 12736-10 + for ; + Sun, 4 Apr 2004 05:56:33 -0300 (ADT) +Received: from gpdnet.co.uk (gpdnet.plus.com [212.56.100.243]) + by svr1.postgresql.org (Postfix) with ESMTP id 588F5D1EA91 + for ; + Sun, 4 Apr 2004 05:56:13 -0300 (ADT) +Received: from Spooler by gpdnet.co.uk (Mercury/32 v4.01a) ID MO001EC9; + 4 Apr 2004 10:00:34 +0100 +Received: from spooler by gpdnet.co.uk (Mercury/32 v4.01a); + 4 Apr 2004 10:00:21 +0100 +Received: from gary (192.168.1.2) by gpdnet.co.uk (Mercury/32 v4.01a) with + ESMTP ID MG001EC8; 4 Apr 2004 10:00:10 +0100 +From: "Gary Doades" +To: pgsql-performance@postgresql.org +Date: Sun, 04 Apr 2004 10:00:10 +0100 +MIME-Version: 1.0 +Subject: Re: PostgreSQL and Linux 2.6 kernel. +Message-ID: <406FDCAA.30459.24B450F@localhost> +In-reply-to: +X-mailer: Pegasus Mail for Windows (v4.12a) +Content-type: text/plain; charset=US-ASCII +Content-transfer-encoding: 7BIT +Content-description: Mail message body +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/28 +X-Sequence-Number: 6328 + +Unfortunately I have to try and keep both SQLServer and PostgreSQL +compatibilty. Our main web application is currently SQLServer, but we +want to migrate customers who don't care what the DB server is over to +PostgreSQL. Some of our larger customers demand SQLServer, you +know how it is! + +I don't want to maintain two sets of code or SQL, so I am trying to find +common ground. The code is not a problem, but the SQL sometimes is. + +Cheers, +Gary. + + +On 3 Apr 2004 at 17:43, Aaron Werman wrote: + +> Almost any cross dbms migration shows a drop in performance. The engine +> effectively trains developers and administrators in what works and what +> doesn't. The initial migration thus compares a tuned to an untuned version. +> +> /Aaron +> +> ----- Original Message ----- +> From: "Josh Berkus" +> To: "Gary Doades" ; +> Sent: Saturday, April 03, 2004 1:59 PM +> Subject: Re: [PERFORM] PostgreSQL and Linux 2.6 kernel. +> +> +> > Gary, +> > +> > > There are no indexes on the columns involved in the update, they are +> > > not required for my usual select statements. This is an attempt to +> > > slightly denormalise the design to get the performance up comparable +> > > to SQL Server 2000. We hope to move some of our databases over to +> > > PostgreSQL later in the year and this is part of the ongoing testing. +> > > SQLServer's query optimiser is a bit smarter that PostgreSQL's (yet) +> > > so I am hand optimising some of the more frequently used +> > > SQL and/or tweaking the database design slightly. +> > +> > Hmmm ... that hasn't been my general experience on complex queries. +> However, +> > it may be due to a difference in ANALYZE statistics. I'd love to see you +> > increase your default_stats_target, re-analyze, and see if PostgreSQL gets +> > "smarter". +> > +> > -- +> > -Josh Berkus +> > Aglio Database Solutions +> > San Francisco +> > +> > +> > ---------------------------(end of broadcast)--------------------------- +> > TIP 3: if posting/reading through Usenet, please send an appropriate +> > subscribe-nomail command to majordomo@postgresql.org so that your +> > message can get through to the mailing list cleanly +> > +> +> +> -- +> Incoming mail is certified Virus Free. +> Checked by AVG Anti-Virus (http://www.grisoft.com). +> Version: 7.0.230 / Virus Database: 262.6.5 - Release Date: 31/03/2004 +> + + + +From pgsql-performance-owner@postgresql.org Sun Apr 4 06:44:23 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D5368D1ED14 + for ; + Sun, 4 Apr 2004 09:44:22 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 25430-09 + for ; + Sun, 4 Apr 2004 06:44:41 -0300 (ADT) +Received: from anchor-post-34.mail.demon.net (anchor-post-34.mail.demon.net + [194.217.242.92]) + by svr1.postgresql.org (Postfix) with ESMTP id EA32ED1ED0B + for ; + Sun, 4 Apr 2004 06:44:20 -0300 (ADT) +Received: from tmsl-adsl.demon.co.uk ([80.177.114.181] + helo=bacon.tmsl.demon.co.uk) + by anchor-post-34.mail.demon.net with esmtp (Exim 3.35 #1) + id 1BA4BI-0007bQ-0Y; Sun, 04 Apr 2004 10:44:44 +0100 +Date: Sun, 4 Apr 2004 10:41:33 +0100 +From: Paul Thomas +To: Gary Doades +Cc: "pgsql-performance @ postgresql . org" +Subject: Re: PostgreSQL and Linux 2.6 kernel. +Message-ID: <20040404104133.A1704@bacon> +References: <406EA51B.21218.D2DE061@localhost> + <1081036369.11561.1.camel@localhost.localdomain> + <406FDBD2.9910.247F995@localhost> +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed; charset=ISO-8859-1 +In-Reply-To: <406FDBD2.9910.247F995@localhost>; + from gpd@gpdnet.co.uk on Sun, Apr 04, 2004 at 09:56:34 +0100 +X-Mailer: Balsa 1.2.3 +Lines: 30 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/30 +X-Sequence-Number: 6330 + + +On 04/04/2004 09:56 Gary Doades wrote: +> Unfortunately I don't understand the question! +> +> My background is the primarily Win32. The last time I used a *nix OS +> was about 20 years ago apart from occasional dips into the linux OS +> over the past few years. If you can tell be how to find out what you want +> +> I will gladly give you the information. + + +Googling threw up + +http://spider.tm/apr2004/cstory2.html + +Interesting and possibly relevant quote: + +"Benchmarks have shown that in certain conditions the anticipatory +algorithm is almost 10 times faster than what 2.4 kernel supports". + +HTH + +-- +Paul Thomas ++------------------------------+---------------------------------------------+ +| Thomas Micro Systems Limited | Software Solutions for +Business | +| Computer Consultants | +http://www.thomas-micro-systems-ltd.co.uk | ++------------------------------+---------------------------------------------+ + +From pgsql-performance-owner@postgresql.org Sun Apr 4 07:14:37 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7065FD1ED27 + for ; + Sun, 4 Apr 2004 10:14:36 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 31706-06 + for ; + Sun, 4 Apr 2004 07:14:54 -0300 (ADT) +Received: from relay01.kbs.net.au (relay01.kbs.net.au [203.220.32.149]) + by svr1.postgresql.org (Postfix) with ESMTP id 337A2D1ED20 + for ; + Sun, 4 Apr 2004 07:14:33 -0300 (ADT) +Received: from [203.221.247.226] (helo=familyhealth.com.au) + by relay01.kbs.net.au with esmtp (Exim 3.36 #2) + id 1BA4eR-0002IX-00; Sun, 04 Apr 2004 20:14:52 +1000 +Message-ID: <406FE017.1010602@familyhealth.com.au> +Date: Sun, 04 Apr 2004 18:14:47 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.6b) Gecko/20031205 Thunderbird/0.4 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Kamalraj Singh Madhan +Cc: pgsql-performance@postgresql.org +Subject: Re: Substitute for this oracle query in postGre +References: <200404040323.i343Nw3Z002747@gw.tssi.com> + <02ad01c41a1d$4255a7a0$4ecb09c0@KAMALR> +In-Reply-To: <02ad01c41a1d$4255a7a0$4ecb09c0@KAMALR> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/31 +X-Sequence-Number: 6331 + +Hi, + +Try looking at the contrib/tablefunc add-in module. + +Chris + +Kamalraj Singh Madhan wrote: +> Hi Friends, +> Does anybody know the substitute of the oracle function 'connect by +> prior' in postgre sql. +> The query is basically being used to get a tree structure of records. The +> query in oracle is :- +> +> select pkmsgid +> from mstmessage +> connect by prior pkmsgid = msgparentid +> start with msgparentid = 1 +> +> Kindly suggest. +> +> regards +> Kamal +> +> +> +> ********************************************************************* +> Network Programs is a SEI CMM Level 5 Certified Company +> ******************************************************************** +> The information contained in this communication (including any attachments) is +> intended solely for the use of the individual or entity to whom it is addressed +> and others authorized to receive it. It may contain confidential or legally +> privileged information. If you are not the intended recipient you are hereby +> notified that any disclosure, copying, distribution or taking any action in +> reliance on the contents of this information is strictly prohibited and may be +> unlawful. If you have received this communication in error, please notify us +> immediately by responding to this email and then delete it from your system. +> Network Programs (India) Limited is neither liable for the proper and complete +> transmission of the information contained in this communication nor for any +> delay in its receipt. +> ********************************************************************* +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org + +From pgsql-performance-owner@postgresql.org Sun Apr 4 10:04:14 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8BE58D1EBBD + for ; + Sun, 4 Apr 2004 13:04:13 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 67843-02 + for ; + Sun, 4 Apr 2004 10:04:32 -0300 (ADT) +Received: from jinx.internetstaff.com (unknown [63.214.174.240]) + by svr1.postgresql.org (Postfix) with ESMTP id 7E108D1EA61 + for ; + Sun, 4 Apr 2004 10:04:11 -0300 (ADT) +Received: from localhost (localhost [127.0.0.1]) + by jinx.internetstaff.com (Postfix) with ESMTP id 0A04D4BC0C6 + for ; + Sun, 4 Apr 2004 06:04:36 -0700 (MST) +Received: from jinx.internetstaff.com ([127.0.0.1]) + by localhost (jinx [127.0.0.1]) (amavisd-new, port 10024) with LMTP + id 04831-03-10 for ; + Sun, 4 Apr 2004 06:04:35 -0700 (MST) +Subject: Re: PostgreSQL and Linux 2.6 kernel. +From: Cott Lang +To: pgsql-performance@postgresql.org +In-Reply-To: <406FDBD2.9910.247F995@localhost> +References: <406EA51B.21218.D2DE061@localhost> + <406FDBD2.9910.247F995@localhost> +Content-Type: text/plain +Message-Id: <1081083874.2172.3.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-1) +Date: Sun, 04 Apr 2004 06:04:35 -0700 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at internetstaff.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/32 +X-Sequence-Number: 6332 + +On Sun, 2004-04-04 at 01:56, Gary Doades wrote: +> Unfortunately I don't understand the question! +> +> My background is the primarily Win32. The last time I used a *nix OS +> was about 20 years ago apart from occasional dips into the linux OS +> over the past few years. If you can tell be how to find out what you want +> I will gladly give you the information. + +There are two available io schedulers in 2.6 (new feature), deadline and +anticipatory. It should show be listed in the boot messages: + +dmesg | grep scheduler + +I've seen people arguing for each of the two schedulers, saying one is +better than the other for databases. I'm curious which one you're +using. :) + + + + +From pgsql-performance-owner@postgresql.org Sun Apr 4 11:46:21 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A053FD1ECF6 + for ; + Sun, 4 Apr 2004 14:46:20 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 90328-04 + for ; + Sun, 4 Apr 2004 11:46:40 -0300 (ADT) +Received: from gpdnet.co.uk (gpdnet.plus.com [212.56.100.243]) + by svr1.postgresql.org (Postfix) with ESMTP id 51DA3D1ECF2 + for ; + Sun, 4 Apr 2004 11:46:18 -0300 (ADT) +Received: from Spooler by gpdnet.co.uk (Mercury/32 v4.01a) ID MO001EED; + 4 Apr 2004 15:50:43 +0100 +Received: from spooler by gpdnet.co.uk (Mercury/32 v4.01a); + 4 Apr 2004 15:50:33 +0100 +Received: from gary (192.168.1.2) by gpdnet.co.uk (Mercury/32 v4.01a) with + ESMTP ID MG001EEC; 4 Apr 2004 15:50:23 +0100 +From: "Gary Doades" +To: pgsql-performance@postgresql.org +Date: Sun, 04 Apr 2004 15:50:22 +0100 +MIME-Version: 1.0 +Subject: Re: PostgreSQL and Linux 2.6 kernel. +Message-ID: <40702EBE.5594.38BE2E3@localhost> +In-reply-to: <1081083874.2172.3.camel@localhost.localdomain> +References: <406FDBD2.9910.247F995@localhost> +X-mailer: Pegasus Mail for Windows (v4.12a) +Content-type: text/plain; charset=US-ASCII +Content-transfer-encoding: 7BIT +Content-description: Mail message body +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/33 +X-Sequence-Number: 6333 + +It says: + +Using anticipatory io scheduler. + +This then fits with the earlier post on other observations of up to 10 +times better performance, which I what I was seeing in in certain +circumstances. + +Cheers, +Gary. + + +On 4 Apr 2004 at 6:04, Cott Lang wrote: + +> On Sun, 2004-04-04 at 01:56, Gary Doades wrote: +> > Unfortunately I don't understand the question! +> > +> > My background is the primarily Win32. The last time I used a *nix OS +> > was about 20 years ago apart from occasional dips into the linux OS +> > over the past few years. If you can tell be how to find out what you want +> > I will gladly give you the information. +> +> There are two available io schedulers in 2.6 (new feature), deadline and +> anticipatory. It should show be listed in the boot messages: +> +> dmesg | grep scheduler +> +> I've seen people arguing for each of the two schedulers, saying one is +> better than the other for databases. I'm curious which one you're +> using. :) +> +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org +> +> +> -- +> Incoming mail is certified Virus Free. +> Checked by AVG Anti-Virus (http://www.grisoft.com). +> Version: 7.0.230 / Virus Database: 262.6.5 - Release Date: 31/03/2004 +> + + + +From pgsql-performance-owner@postgresql.org Sun Apr 4 18:05:29 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8E104D1CCAD + for ; + Sun, 4 Apr 2004 21:05:27 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 75512-08 + for ; + Sun, 4 Apr 2004 18:05:49 -0300 (ADT) +Received: from usea-naimss1.unisys.com (usea-naimss1.unisys.com + [192.61.61.103]) + by svr1.postgresql.org (Postfix) with ESMTP id 19FD5D1CA77 + for ; + Sun, 4 Apr 2004 18:05:25 -0300 (ADT) +Received: from usea-nagw2.na.uis.unisys.com ([129.224.72.18]unverified) by + usea-naimss1 with InterScan Messaging Security Suite; + Sun, 04 Apr 2004 16:09:52 -0500 +Received: from usea-nagw2.na.uis.unisys.com ([129.224.72.53]) by + usea-nagw2.na.uis.unisys.com with Microsoft SMTPSVC(5.0.2195.6713); + Sun, 4 Apr 2004 16:05:53 -0500 +Received: from gbmk-eugw1.eu.uis.unisys.com ([129.221.133.28]) by + usea-nagw2.na.uis.unisys.com with Microsoft SMTPSVC(5.0.2195.6713); + Sun, 4 Apr 2004 16:05:52 -0500 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.0.6487.1 +Subject: Re: single index on more than two coulumns a bad thing? +Date: Sun, 4 Apr 2004 22:06:11 +0100 +Message-ID: +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] single index on more than two coulumns a bad thing? +Thread-Index: AcQYq7LTjW8JZm4tREecA3JXJST1fAB3B71g +From: "Leeuw van der, Tim" +To: +X-OriginalArrivalTime: 04 Apr 2004 21:05:52.0958 (UTC) + FILETIME=[9D4425E0:01C41A88] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/34 +X-Sequence-Number: 6334 + +Hi Aaron, + +> -----Original Message----- +> From: pgsql-performance-owner@postgresql.org +> [mailto:pgsql-performance-owner@postgresql.org]On Behalf Of=20 +> Aaron Werman +> Sent: vrijdag 2 april 2004 13:57 +>=20 +>=20 +> another thing that I have all over the place is a hierarchy: +> index on grandfather_table(grandfather) +> index on father_table(grandfather, father) +> index on son_table(grandfather, father, son) +>=20 + +It depends on your data-distribution, but I find that in almost all cases i= +t's beneficial to have your indexes the other way round in such cases: + +index on grandfather_table(grandfather) +index on father_table(father, grandfather) +index on son_table(son, father, grandfather) + +That usually gives a less common, more selective value at the start of the = +index, making the initial selection in the index smaller. + +And AFAIK I don't have to rewrite my queries for that; the planner doesn't = +care about the order of expressions in the query that are on the same level. + +That said, I tend to use 'surrogate keys'; keys generated from sequences or= + auto-number columns for my tables. It makes the tables less readable, but = +the indexes remain smaller. + + +Greetings, + +--Tim + + + +From pgsql-performance-owner@postgresql.org Mon Apr 5 16:19:59 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E1F3FD1EB5E + for ; + Mon, 5 Apr 2004 02:08:33 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 47416-06 + for ; + Sun, 4 Apr 2004 23:08:56 -0300 (ADT) +Received: from hotmail.com (bay9-dav30.bay9.hotmail.com [64.4.46.87]) + by svr1.postgresql.org (Postfix) with ESMTP id A7883D1E9AE + for ; + Sun, 4 Apr 2004 23:08:30 -0300 (ADT) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Sun, 4 Apr 2004 19:09:02 -0700 +Received: from 67.81.102.201 by bay9-dav30.bay9.hotmail.com with DAV; + Mon, 05 Apr 2004 02:09:01 +0000 +X-Originating-IP: [67.81.102.201] +X-Originating-Email: [awerman@hotmail.com] +X-Sender: awerman@hotmail.com +From: "Aaron Werman" +To: "Leeuw van der, Tim" , + +References: +Subject: Re: single index on more than two coulumns a bad thing? +Date: Sun, 4 Apr 2004 22:09:21 -0400 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1158 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +Message-ID: +X-OriginalArrivalTime: 05 Apr 2004 02:09:02.0223 (UTC) + FILETIME=[F6E9B9F0:01C41AB2] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/48 +X-Sequence-Number: 6348 + +You're absolutely correct that the general rule is to lead a composite index +with the highest cardinality index columns for fastest selectivity. Indices +and all physical design are based on usage. In this case of unique indices +supporting primary keys in a hierarchy, it depends. For selection of small +sets of arbitrary rows, your arrangement is best. For hierarchy based +queries, such as "for grandparent of foo, and parent of bar, give average +age of sons" - the hierarchy based index is often more efficient. + +Surrogate keys have a role, and can improve performance, but also carry an +enormous penalty of intentionally obfuscating logical keys and data +semantics, and almost always lead to data errors not being caught because +they obscure irrational relationships. I hate them, but use them frequently +in high transaction rate operational systems where there is much functional +validation outside the dbms (and the apps behave therefore like object +databases and surrogate keys are network database pointers) and in data +warehousing (where downstream data cannot be corrected anyway). + +/Aaron + +----- Original Message ----- +From: "Leeuw van der, Tim" +To: +Sent: Sunday, April 04, 2004 5:06 PM +Subject: Re: [PERFORM] single index on more than two coulumns a bad thing? + + +Hi Aaron, + +> -----Original Message----- +> From: pgsql-performance-owner@postgresql.org +> [mailto:pgsql-performance-owner@postgresql.org]On Behalf Of +> Aaron Werman +> Sent: vrijdag 2 april 2004 13:57 +> +> +> another thing that I have all over the place is a hierarchy: +> index on grandfather_table(grandfather) +> index on father_table(grandfather, father) +> index on son_table(grandfather, father, son) +> + +It depends on your data-distribution, but I find that in almost all cases +it's beneficial to have your indexes the other way round in such cases: + +index on grandfather_table(grandfather) +index on father_table(father, grandfather) +index on son_table(son, father, grandfather) + +That usually gives a less common, more selective value at the start of the +index, making the initial selection in the index smaller. + +And AFAIK I don't have to rewrite my queries for that; the planner doesn't +care about the order of expressions in the query that are on the same level. + +That said, I tend to use 'surrogate keys'; keys generated from sequences or +auto-number columns for my tables. It makes the tables less readable, but +the indexes remain smaller. + + +Greetings, + +--Tim + + + +---------------------------(end of broadcast)--------------------------- +TIP 4: Don't 'kill -9' the postmaster + +From pgsql-performance-owner@postgresql.org Mon Apr 5 12:42:02 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B5AAFD1B97B + for ; + Mon, 5 Apr 2004 15:39:36 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 24326-01 + for ; + Mon, 5 Apr 2004 12:39:57 -0300 (ADT) +Received: from ol-mailrelay-01.fh-oldenburg.de + (ol-mailrelay-01.fh-oldenburg.de [139.13.186.99]) + by svr1.postgresql.org (Postfix) with ESMTP id 6C479D1B535 + for ; + Mon, 5 Apr 2004 12:39:26 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by ol-mailrelay-01.fh-oldenburg.de (Postfix) with ESMTP id 7EDC438C3F6 + for ; + Mon, 5 Apr 2004 17:31:39 +0200 (CEST) +Received: from ol-mailrelay-01.fh-oldenburg.de ([127.0.0.1]) + by localhost (ol-mailrelay-01 [127.0.0.1]) (amavisd-new, port 10023) + with ESMTP id 26538-03 for ; + Mon, 5 Apr 2004 17:31:39 +0200 (CEST) +Received: from webmail.fh-oldenburg.de (ol-mailrelay-01.fh-oldenburg.de + [139.13.186.99]) + by ol-mailrelay-01.fh-oldenburg.de (Postfix) with SMTP id 4DB9C38C3BB + for ; + Mon, 5 Apr 2004 17:31:39 +0200 (CEST) +Received: from 195.243.253.146 (SquirrelMail authenticated user kehlenbh) + by webmail.fh-oldenburg.de with HTTP; + Mon, 5 Apr 2004 17:31:39 +0200 (CEST) +Message-ID: + <48932.195.243.253.146.1081179099.squirrel@webmail.fh-oldenburg.de> +Date: Mon, 5 Apr 2004 17:31:39 +0200 (CEST) +Subject: performance comparission postgresql/ms-sql server +From: "Heiko Kehlenbrink" +To: pgsql-performance@postgresql.org +User-Agent: SquirrelMail/1.4.2 +MIME-Version: 1.0 +Content-Type: text/plain;charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Priority: 3 +Importance: Normal +X-Virus-Scanned: by amavisd-new +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/35 +X-Sequence-Number: 6335 + +hi list, + +i want to convince people to use postgresql instead of ms-sql server, so i +set up a kind of comparission insert data / select data from postgresql / +ms-sql server + +the table i use was pretty basic, + +id bigserial +dist float8 +x float8 +y float8 +z float8 + +i filled the table with a function which filled x,y,z with incremental +increasing values (1,2,3,4,5,6...) and computing from that the dist value +for every tupel (sqrt((x*x)+(y*y)+(z*z))). + +this works fine for both dbms + +postgresql needs 13:37 min for 10.000.000 tupel, +ms-sql needs 1:01:27 h for 10.000.000 tupel. + +so far so good. + +i attached an index on the dist row and started to query the dbs with +scripts which select a serial row of 100.000,200.000,500.000 tupels based +on the dist row. +i randomizly compute the start and the end distance and made a "select +avg(dist) from table where dist > startdist and dist < enddist" + +Did the same with a table with 50.000.000 tupel in ms-sql and postgres. + +the outcome so far: + +100.000 from 50.000.000: + +postgres: 0.88 sec +ms-sql: 0.38 sec + +200.000 from 50.000.000: + +postgres: 1.57 sec +ms-sql: 0.54 sec + +500.000 from 50.000.000: + +postgres: 3.66 sec +ms-sql: 1.18 sec + +i try a lot of changes to the postgresql.conf regarding "Tuning +PostgreSQL for performance" +by +Shridhar Daithankar, Josh Berkus + +which did not make a big diffrence to the answering times from postgresql. + +i'm pretty fine with the insert time... + +do you have any hints like compiler-flags and so on to get the answering +time from postgresql equal to ms-sql? + +(btw both dbms were running on exactly the same hardware) + +i use suse 8.1 + postgresql 7.2 compiled from the rpms for using postgis, but that is +anothe story... + 1.5 gig ram + 1.8 mhz intel cpu + + +every help welcome + +best regards heiko + + + + +From pgsql-performance-owner@postgresql.org Mon Apr 5 12:46:41 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 73A21D1BA93 + for ; + Mon, 5 Apr 2004 15:37:46 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 17791-07 + for ; + Mon, 5 Apr 2004 12:38:14 -0300 (ADT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 1AC96D1BA90 + for ; + Mon, 5 Apr 2004 12:37:44 -0300 (ADT) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4774963; Mon, 05 Apr 2004 08:39:40 -0700 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: Mike Nolan , + awerman2@hotmail.com (Aaron Werman) +Subject: Re: PostgreSQL and Linux 2.6 kernel. +Date: Mon, 5 Apr 2004 08:36:52 -0700 +User-Agent: KMail/1.4.3 +Cc: gpd@gpdnet.co.uk (Gary Doades), pgsql-performance@postgresql.org +References: <200404040323.i343Nw3Z002747@gw.tssi.com> +In-Reply-To: <200404040323.i343Nw3Z002747@gw.tssi.com> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200404050836.52115.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/36 +X-Sequence-Number: 6336 + +Mike, + +> I think it is also possible that Microsoft has more programmers working +> on tuning issues for SQL Server than PostgreSQL has working on the +> whole project. + +Ah, but quantity != quality. Or they wouldn't be trolling our mailing lists +trying to hire PostgreSQL programmers for the SQL Server project (really!). +And we had nearly 200 contributors between 7.3 and 7.4 ... a respectable +development staff for even a large corporation. + +Point taken, though, SQL Server has done a better job in opitimizing for +"dumb" queries. This is something that PostgreSQL needs to work on, as is +self-referential updates for large tables, which also tend to be really slow. +Mind you, in SQL Server 7 I used to be able to crash the server with a big +self-referential update, so this is a common database problem. + +Unfortunately, these days only Tom and Neil seem to be seriously working on +the query planner (beg pardon in advance if I've missed someone) so I think +the real answer is that we need another person interested in this kind of +optimization before it's going to get much better. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Mon Apr 5 12:53:56 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id CA4F9D1D12E + for ; + Mon, 5 Apr 2004 15:53:44 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 29651-02 + for ; + Mon, 5 Apr 2004 12:54:13 -0300 (ADT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 952FCD1CCCA + for ; + Mon, 5 Apr 2004 12:53:42 -0300 (ADT) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4775049; Mon, 05 Apr 2004 08:55:40 -0700 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: "Heiko Kehlenbrink" , + pgsql-performance@postgresql.org +Subject: Re: performance comparission postgresql/ms-sql server +Date: Mon, 5 Apr 2004 08:52:51 -0700 +User-Agent: KMail/1.4.3 +References: + <48932.195.243.253.146.1081179099.squirrel@webmail.fh-oldenburg.de> +In-Reply-To: + <48932.195.243.253.146.1081179099.squirrel@webmail.fh-oldenburg.de> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200404050852.51709.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/37 +X-Sequence-Number: 6337 + +Heiko, + +> 100.000 from 50.000.000: +> +> postgres: 0.88 sec +> ms-sql: 0.38 sec +> +> 200.000 from 50.000.000: +> +> postgres: 1.57 sec +> ms-sql: 0.54 sec +> +> 500.000 from 50.000.000: +> +> postgres: 3.66 sec +> ms-sql: 1.18 sec + +Questions: + +1. Is this the time to return *all rows* or just the first row? Given the +different way that PostgreSQL fetches rows to the client from MSSQL, it makes +a difference. + +2. What are your sort-mem and shared-mem settings? + +3. Have you tried clustering the table? + +4. Have you done a comparison of selecting random or scattered, instead of +serial rows? MSSQL has a tendency to physically store rows in "order" which +gives it a certain advantage in this kind of query. + + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Mon Apr 5 13:08:09 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D5302D1CCCA + for ; + Mon, 5 Apr 2004 15:54:30 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 26581-06 + for ; + Mon, 5 Apr 2004 12:54:45 -0300 (ADT) +Received: from frodo.hserus.net (frodo.hserus.net [204.74.68.40]) + by svr1.postgresql.org (Postfix) with ESMTP id C09C1D1C516 + for ; + Mon, 5 Apr 2004 12:54:14 -0300 (ADT) +Received: from concord.pspl.co.in ([202.54.11.72]:64379 helo=frodo.hserus.net) + by frodo.hserus.net with asmtp + (Cipher TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.31 #0) + id 1BAWR0-000Nty-GP by authid with plain; + Mon, 05 Apr 2004 21:24:51 +0530 +Message-ID: <40718146.1010506@frodo.hserus.net> +Date: Mon, 05 Apr 2004 21:24:46 +0530 +From: Shridhar Daithankar +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.6b) Gecko/20031205 Thunderbird/0.4 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Heiko Kehlenbrink +Cc: pgsql-performance@postgresql.org +Subject: Re: performance comparission postgresql/ms-sql server +References: + <48932.195.243.253.146.1081179099.squirrel@webmail.fh-oldenburg.de> +In-Reply-To: + <48932.195.243.253.146.1081179099.squirrel@webmail.fh-oldenburg.de> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/38 +X-Sequence-Number: 6338 + +Heiko Kehlenbrink wrote: + +> hi list, +> +> i want to convince people to use postgresql instead of ms-sql server, so i +> set up a kind of comparission insert data / select data from postgresql / +> ms-sql server +> +> the table i use was pretty basic, +> +> id bigserial +> dist float8 +> x float8 +> y float8 +> z float8 +> +> i filled the table with a function which filled x,y,z with incremental +> increasing values (1,2,3,4,5,6...) and computing from that the dist value +> for every tupel (sqrt((x*x)+(y*y)+(z*z))). +> +> this works fine for both dbms +> +> postgresql needs 13:37 min for 10.000.000 tupel, +> ms-sql needs 1:01:27 h for 10.000.000 tupel. +> +> so far so good. +> +> i attached an index on the dist row and started to query the dbs with +> scripts which select a serial row of 100.000,200.000,500.000 tupels based +> on the dist row. +> i randomizly compute the start and the end distance and made a "select +> avg(dist) from table where dist > startdist and dist < enddist" + +Some basics to check quickly. + +1. vacuum analyze the table before you start selecting. +2. for slow running queries, check explain analyze output and find out who takes +maximum time. +3. Check for typecasting. You need to typecast the query correctly e.g. + +select avg(dist) from table where dist >startdist::float8 and dist; + Mon, 5 Apr 2004 16:11:01 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 31183-07 + for ; + Mon, 5 Apr 2004 13:11:28 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id EB892D1BCB9 + for ; + Mon, 5 Apr 2004 13:10:57 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i35GBafl012486; + Mon, 5 Apr 2004 12:11:36 -0400 (EDT) +To: "Heiko Kehlenbrink" +Cc: pgsql-performance@postgresql.org +Subject: Re: performance comparission postgresql/ms-sql server +In-reply-to: + <48932.195.243.253.146.1081179099.squirrel@webmail.fh-oldenburg.de> +References: + <48932.195.243.253.146.1081179099.squirrel@webmail.fh-oldenburg.de> +Comments: In-reply-to "Heiko Kehlenbrink" + + message dated "Mon, 05 Apr 2004 17:31:39 +0200" +Date: Mon, 05 Apr 2004 12:11:35 -0400 +Message-ID: <12485.1081181495@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/39 +X-Sequence-Number: 6339 + +"Heiko Kehlenbrink" writes: +> i use suse 8.1 +> postgresql 7.2 compiled from the rpms for using postgis, but that is +> anothe story... + +7.4 might be a little quicker; but in any case you should be doing this +sort of comparison using the current release, no? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Apr 5 13:27:00 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0865AD1BBA2 + for ; + Mon, 5 Apr 2004 16:27:00 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 38980-10 + for ; + Mon, 5 Apr 2004 13:27:27 -0300 (ADT) +Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com + [24.128.241.68]) + by svr1.postgresql.org (Postfix) with SMTP id 46098D1B560 + for ; + Mon, 5 Apr 2004 13:26:56 -0300 (ADT) +Received: (qmail 37033 invoked from network); 5 Apr 2004 16:27:38 -0000 +Received: from unknown (HELO ?192.168.0.4?) (10.10.10.177) + by 10.10.10.10 with SMTP; 5 Apr 2004 16:27:38 -0000 +Mime-Version: 1.0 (Apple Message framework v609) +Content-Transfer-Encoding: 7bit +Message-Id: <49B1B198-871E-11D8-B8C1-000393D1F76E@torgo.978.org> +Content-Type: text/plain; charset=US-ASCII; format=flowed +To: pgsql-performance@postgresql.org +From: Jeff +Subject: SETOF performance +Date: Mon, 5 Apr 2004 12:28:36 -0400 +X-Mailer: Apple Mail (2.609) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/40 +X-Sequence-Number: 6340 + +I think it was on this list - someone posted a message about SETOF +being slower. Tom replied saying it was because it needed to create an +on-disk tuplestore. + +I was just looking for some clarification - a SETOF function will +always write the reslting tuples to disk (Not buffering in say a +sort_mem sized buffer)? + +I think if that is the case I may need to go back and change some stuff +around. +I have a procedure that I broke out a bit to make life easier. + +Basically it goes + +for v_row in + select blah from function_that_gets_data_from_some_cache(....) + rowcount := rowcount + 1; + return next v_row; +end for; + +if rowcount = 0 then + [same thing, but we call some_function_that_creates_data_for_cache] +end if; + +Doing it this way means I avoid having to deal with it in the client +and I also avoid having a giant stored procedure. (I like short & sweet +things) + +What I've found for timings is this: + +select * from function_that_gets_data_from_some_cache() runs around 1.8 +ms +but select * from the_top_level_function() runs around 4.2ms +(Yes, I know 4.2 ms is fast, but that is not the point). + +could this overhead be related to the SETOF tuplestores? + +Might it be better to use refcursor or something or bite the bullet and +live with a giant procedure? + +-- +Jeff Trout +http://www.jefftrout.com/ +http://www.stuarthamm.net/ + + +From pgsql-performance-owner@postgresql.org Mon Apr 5 13:56:56 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1FEB3D1E9CF + for ; + Mon, 5 Apr 2004 16:43:13 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 50730-04 + for ; + Mon, 5 Apr 2004 13:43:41 -0300 (ADT) +Received: from mail.osdl.org (fw.osdl.org [65.172.181.6]) + by svr1.postgresql.org (Postfix) with ESMTP id B49FBD1E9C5 + for ; + Mon, 5 Apr 2004 13:43:09 -0300 (ADT) +Received: from osdl.org (markw@ibm-b.pdx.osdl.net [172.20.1.51]) + by mail.osdl.org (8.11.6/8.11.6) with ESMTP id i35Ghd200769; + Mon, 5 Apr 2004 09:43:40 -0700 +Message-Id: <200404051643.i35Ghd200769@mail.osdl.org> +Date: Mon, 5 Apr 2004 09:43:36 -0700 (PDT) +From: markw@osdl.org +Subject: Re: PostgreSQL and Linux 2.6 kernel. +To: cott@internetstaff.com +Cc: pgsql-performance@postgresql.org +In-Reply-To: <1081083874.2172.3.camel@localhost.localdomain> +MIME-Version: 1.0 +Content-Type: TEXT/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/41 +X-Sequence-Number: 6341 + +On 4 Apr, Cott Lang wrote: +> On Sun, 2004-04-04 at 01:56, Gary Doades wrote: +>> Unfortunately I don't understand the question! +>> +>> My background is the primarily Win32. The last time I used a *nix OS +>> was about 20 years ago apart from occasional dips into the linux OS +>> over the past few years. If you can tell be how to find out what you want +>> I will gladly give you the information. +> +> There are two available io schedulers in 2.6 (new feature), deadline and +> anticipatory. It should show be listed in the boot messages: +> +> dmesg | grep scheduler +> +> I've seen people arguing for each of the two schedulers, saying one is +> better than the other for databases. I'm curious which one you're +> using. :) + +Our database tests (TPC fair use implementations) show that the deadline +scheduler has an edge on the anticipatory scheduler. Depending on the +current state of the AS scheduler, it can be within a few percent to 10% +or so. + +I have some data with one of our tests here: + http://developer.osdl.org/markw/fs/dbt2_project_results.html + +Mark + +From pgsql-performance-owner@postgresql.org Mon Apr 5 14:05:53 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C2A44D1BABB + for ; + Mon, 5 Apr 2004 17:05:04 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 62338-01 + for ; + Mon, 5 Apr 2004 14:05:31 -0300 (ADT) +Received: from www.totalcardinc.com (unknown [64.33.232.186]) + by svr1.postgresql.org (Postfix) with ESMTP id BAC39D1B441 + for ; + Mon, 5 Apr 2004 14:04:59 -0300 (ADT) +Received: from RSCHWARZW2K ([10.250.0.37]) (authenticated bits=0) + by www.totalcardinc.com (8.12.8/8.12.8) with ESMTP id i35H5bTN019089 + for ; Mon, 5 Apr 2004 12:05:37 -0500 +From: "Rosser Schwarz" +To: +Subject: Re: atrocious update performance +Date: Mon, 5 Apr 2004 12:05:37 -0500 +Message-ID: <009801c41b30$37872380$2500fa0a@CardServices.TCI.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.4510 +In-Reply-To: <004301c411be$74004650$2500fa0a@CardServices.TCI.com> +Importance: Normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/42 +X-Sequence-Number: 6342 + +After deinstalling and scrubbing PostgreSQL from my server and doing +a clean build using a vanilla 7.4.2 tree, I'm rather more confident +that foreign key validation is at cause in my performance problems. + +I recreated my schemas and ran the original update, with foreign +keys referring to the identity column of the target table. The +update took roughly two days, as I'd predicted based on my analysis +of the previous installation. (I can't say how long with certainty, +beyond that it finished some time between when I left work one night +and came in the next morning, the second day after starting the +query.) I'm not sure what was wrong with the previous install, such +that the update took several days; two-ish days is long enough. + +Just this morning, however, I created a copy of the target table (all +4.7M rows), with absolutely no foreign keys referring to it, and ran +the update against the copy. That update took 2300 seconds. The +join columns were indexed in both cases. + +I'm in the process of migrating the machine to run kernel 2.6.4, +following the thread started by Gary, though I suspect that the +kernel revision is moot with respect to whether or not foreign keys +are being incorrectly validated. I can keep the 2.4 kernel and +modules around to run using the current versions for testing +purposes, though any such work would necessarily be off-hours. + +Please advise of anything I can do to help narrow down the specific +cause of the issue; I know just enough C to be mildly dangerous. + +/rls + +-- +Rosser Schwarz +Total Card, Inc. + + +From pgsql-performance-owner@postgresql.org Mon Apr 5 14:51:22 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 470C9D1BAA5 + for ; + Mon, 5 Apr 2004 17:49:59 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 80197-07 + for ; + Mon, 5 Apr 2004 14:50:26 -0300 (ADT) +Received: from joeconway.com (66-146-172-82.skyriver.net [66.146.172.82]) + by svr1.postgresql.org (Postfix) with ESMTP id 1B5BFD1BABD + for ; + Mon, 5 Apr 2004 14:49:55 -0300 (ADT) +Received: from [206.19.64.3] (account jconway HELO joeconway.com) + by joeconway.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP-TLS id 1259946; Mon, 05 Apr 2004 10:45:08 -0700 +Message-ID: <40719C31.5030505@joeconway.com> +Date: Mon, 05 Apr 2004 10:49:37 -0700 +From: Joe Conway +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.6) Gecko/20040113 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Jeff +Cc: pgsql-performance@postgresql.org +Subject: Re: SETOF performance +References: <49B1B198-871E-11D8-B8C1-000393D1F76E@torgo.978.org> +In-Reply-To: <49B1B198-871E-11D8-B8C1-000393D1F76E@torgo.978.org> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/43 +X-Sequence-Number: 6343 + +Jeff wrote: +> I think it was on this list - someone posted a message about SETOF +> being slower. Tom replied saying it was because it needed to create an +> on-disk tuplestore. +> +> I was just looking for some clarification - a SETOF function will always +> write the reslting tuples to disk (Not buffering in say a sort_mem sized +> buffer)? + +I think at least part of what you're seeing is normal function call +overhead. As far as tuplestores writing to disk, here's what the source +says: + +In src/backend/utils/sort/tuplestore.c +8<--------------------------------------- + * maxKBytes: how much data to store in memory (any data beyond this + * amount is paged to disk). When in doubt, use work_mem. + */ +Tuplestorestate * +tuplestore_begin_heap(bool randomAccess, bool interXact, int maxKBytes) +8<--------------------------------------- + +In src/backend/executor/execQual.c:ExecMakeTableFunctionResult(): +8<--------------------------------------- +tupstore = tuplestore_begin_heap(true, false, work_mem); +8<--------------------------------------- + +So up to work_mem (sort_mem in 7.4 and earlier) should be stored in memory. + +Joe + + +From pgsql-performance-owner@postgresql.org Mon Apr 5 16:35:10 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 66118D1B441 + for ; + Mon, 5 Apr 2004 18:10:25 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 83270-10 + for ; + Mon, 5 Apr 2004 15:10:54 -0300 (ADT) +Received: from mail.ez3pl.com (66-136-75-131.ded.swbell.net [66.136.75.131]) + by svr1.postgresql.org (Postfix) with ESMTP id DB169D1B54E + for ; + Mon, 5 Apr 2004 15:10:21 -0300 (ADT) +Received: from kbarnard ([172.25.96.149]) + by mail.ez3pl.com (8.11.2/8.11.2) with ESMTP id i35I9sL20799 + for ; Mon, 5 Apr 2004 13:09:54 -0500 +From: "Kevin Barnard" +To: +Date: Mon, 05 Apr 2004 13:04:52 -0500 +MIME-Version: 1.0 +Subject: Re: atrocious update performance +Message-ID: <40715974.10626.ED9A003@localhost> +In-reply-to: <009801c41b30$37872380$2500fa0a@CardServices.TCI.com> +References: <004301c411be$74004650$2500fa0a@CardServices.TCI.com> +X-mailer: Pegasus Mail for Windows (v4.12a) +Content-type: text/plain; charset=US-ASCII +Content-transfer-encoding: 7BIT +Content-description: Mail message body +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/49 +X-Sequence-Number: 6349 + +On 5 Apr 2004 at 12:05, Rosser Schwarz wrote: + +> Just this morning, however, I created a copy of the target table (all +> 4.7M rows), with absolutely no foreign keys referring to it, and ran +> the update against the copy. That update took 2300 seconds. The +> join columns were indexed in both cases. + +Have you added indexes for the custid column for tables account.acct accunt.orgacct +and note? + +I haven't followed the entire thread but it you have cascading FK on those tables +without an index on the column that could cause your delay. + +Kevin Barnard +SpeedFC + + + +From pgsql-performance-owner@postgresql.org Mon Apr 5 16:14:52 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id AB300D1BAA5 + for ; + Mon, 5 Apr 2004 18:11:27 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 90570-02 + for ; + Mon, 5 Apr 2004 15:11:56 -0300 (ADT) +Received: from gpdnet.co.uk (gpdnet.plus.com [212.56.100.243]) + by svr1.postgresql.org (Postfix) with ESMTP id EC736D1BAF8 + for ; + Mon, 5 Apr 2004 15:11:24 -0300 (ADT) +Received: from Spooler by gpdnet.co.uk (Mercury/32 v4.01a) ID MO001FDC; + 5 Apr 2004 19:16:08 +0100 +Received: from spooler by gpdnet.co.uk (Mercury/32 v4.01a); + 5 Apr 2004 19:16:02 +0100 +Received: from gary (192.168.1.2) by gpdnet.co.uk (Mercury/32 v4.01a) with + ESMTP ID MG001FDB; 5 Apr 2004 19:15:53 +0100 +From: "Gary Doades" +To: pgsql-performance@postgresql.org +Date: Mon, 05 Apr 2004 19:11:56 +0100 +MIME-Version: 1.0 +Subject: Re: PostgreSQL and Linux 2.6 kernel. +Message-ID: <4071AF7C.15265.52B583C@localhost> +In-reply-to: <200404050836.52115.josh@agliodbs.com> +References: <200404040323.i343Nw3Z002747@gw.tssi.com> +X-mailer: Pegasus Mail for Windows (v4.12a) +Content-type: text/plain; charset=US-ASCII +Content-transfer-encoding: 7BIT +Content-description: Mail message body +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/47 +X-Sequence-Number: 6347 + +On 5 Apr 2004 at 8:36, Josh Berkus wrote: + +> +> Point taken, though, SQL Server has done a better job in opitimizing for +> "dumb" queries. This is something that PostgreSQL needs to work on, as is +> self-referential updates for large tables, which also tend to be really slow. +> Mind you, in SQL Server 7 I used to be able to crash the server with a big +> self-referential update, so this is a common database problem. +> + +I agree about the "dumb" queries (I'm not mine are *that* dumb :) ) + +When you can write SQL that looks right, feels right, gives the right +answers during testing and SQLServer runs them really fast, you stop +there and tend not to tinker with the SQL further. + +You *can* (I certainly do) achieve comparable performance with +PostgreSQL, but you just have to work harder for it. Now that I have +learned the characteristics of both servers I can write SQL that is pretty +good on both. I suspect that there are people who evaluate PostgreSQL +by executing their favorite SQLSever queries against it, see that it is +slower and never bother to go further. + +Cheers, +Gary. + + +From pgsql-admin-owner@postgresql.org Mon Apr 5 20:32:58 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id EC4C0D1B88F + for ; + Mon, 5 Apr 2004 19:42:50 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 31757-09 + for ; + Mon, 5 Apr 2004 16:43:19 -0300 (ADT) +Received: from loki.globexplorer.com (unknown [208.35.14.101]) + by svr1.postgresql.org (Postfix) with ESMTP id AD36BD1B837 + for ; Mon, 5 Apr 2004 16:42:43 -0300 (ADT) +X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="Windows-1252" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Raw devices vs. Filesystems +Date: Mon, 5 Apr 2004 12:43:21 -0700 +Message-ID: + <71E37EF6B7DCC1499CEA0316A25683280105786A@loki.wc.globexplorer.net> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [ADMIN] Raw devices vs. Filesystems +Thread-Index: AcQbPaTHRcbj4ePWROSnezctjwhSmwAB89Ar +From: "Gregory S. Williamson" +To: "Christopher Browne" , + +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/75 +X-Sequence-Number: 13048 + + +No point to beating a dead horse (other than the sheer joy of the thing) si= +nce postgres does not have raw device support, but ... + +raw devices, at least on solaris, are about 10 times as fast as cooked file= + systems for Informix. This might still be a gain for postgres' performance= +, but the portability issues remain. + +raw device use in Informix is safer in terms of data because Informix does = +not ever have to use the regular file system and so issues of buffering and= + so on go away. My understanding -- fortunately not ever tried in the real = +world -- is that postgres' WAL log system is as reliable as Informix writin= +g to raw devices. + +raw devices can't be copied or tampered with with regular file tools (mv, c= +p etc.); this changes how backups get done but also adds a layer of insulat= +ion between valuable data and users. + +Greg Williamson +DBA +GlobeXplorer LLC +-----Original Message----- +From: Christopher Browne [mailto:cbbrowne@acm.org] +Sent: Mon 3/29/2004 10:28 AM +To: pgsql-admin@postgresql.org +Cc:=09 +Subject: Re: [ADMIN] Raw devices vs. Filesystems +After takin a swig o' Arrakan spice grog, el_vigia_ec@hotmail.com ("Jaime C= +asanova") belched out: +> Can you tell me (or at least guide me to a palce where i can find the +> answer) what are the benefits of filesystems over raw devices? + +For PostgreSQL, filesystems have the merit that you can actually use +them. PostgreSQL doesn't support use of "raw devices." + +Two major benefits of using filesystems as opposed to raw devices are +that: + +a) The use of raw devices is dramatically non-portable; you have to + reimplement data access on every platform you are trying to + support;=20 + +b) The use of raw devices essentially mandates that you implement + some form of generic filesystem on top of them, which adds + considerable complexity to your code. + +Two benefits to raw devices are claimed... + +c) It's faster. But that assumes that the "cooked" filesystems are + implemented fairly badly. That was typically true, a dozen + years ago, but it isn't so typical now, particularly with a + fancy cacheing controller. + +d) It guarantees application control of update ordering. Of course, + with a cacheing controller, or disk drives that lie to one degree + or another, those guarantees might be gone anyways. + +There are other filesystem advantages, such as + +e) Shifting "cooked" data around may be as simple as a "mv," whereas + reorganizing on raw disk requires DB-specific tools... + +> And what filesystem is the best for postgresql performance? + +That would depend, assortedly, on what OS you are using, what kind of +hardware you are running on, what kind of usage patterns you have, as +well as on how you define the notion of "best." + +Absent of any indication of any of those things, the best that can be +said is "that depends..." +--=20 +(format nil "~S@~S" "cbbrowne" "acm.org") +http://cbbrowne.com/info/languages.html +TTY Message from The-XGP at MIT-AI: +The-XGP@AI 02/59/69 02:59:69 +Your XGP output is startling. + +---------------------------(end of broadcast)--------------------------- +TIP 8: explain analyze is your friend + + + + +From pgsql-performance-owner@postgresql.org Mon Apr 5 20:22:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 129C4D1BB4C + for ; + Mon, 5 Apr 2004 19:58:59 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 44582-03 + for ; + Mon, 5 Apr 2004 16:59:27 -0300 (ADT) +Received: from www.totalcardinc.com (unknown [64.33.232.186]) + by svr1.postgresql.org (Postfix) with ESMTP id 5E2FDD1BAFD + for ; + Mon, 5 Apr 2004 16:58:55 -0300 (ADT) +Received: from RSCHWARZW2K ([10.250.0.37]) (authenticated bits=0) + by www.totalcardinc.com (8.12.8/8.12.8) with ESMTP id i35JxWTN025873 + for ; Mon, 5 Apr 2004 14:59:32 -0500 +From: "Rosser Schwarz" +To: +Subject: Re: atrocious update performance +Date: Mon, 5 Apr 2004 14:59:32 -0500 +Message-ID: <009901c41b48$8357c860$2500fa0a@CardServices.TCI.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.4510 +In-Reply-To: <40715974.10626.ED9A003@localhost> +Importance: Normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/51 +X-Sequence-Number: 6351 + +while you weren't looking, Kevin Barnard wrote: + +> Have you added indexes for the custid column for tables +> account.acct accunt.orgacct and note? + +They were indexed in the original case, yes. There was no +need to index them in today's test case, as that was done +purely in attempt to rule in or out foreign key validation +as the cause of the performance hit. No foreign keys that +might be validated, no need to index the foreign key columns. + +> I haven't followed the entire thread but it you have +> cascading FK on those tables without an index on the +> column that could cause your delay. + +The issue is that the foreign keys are being validated at +all, when the column being referenced by those foreign keys +(account.cust.custid) is never touched. + +Regardless of whether or not the referencing columns are +indexed, validating them at all--in this specific case--is +broken. The column they refer to is never touched; they +should remain utterly ignorant of whatever happens to other +columns in the same row. + +/rls + +-- +Rosser Schwarz +Total Card, Inc. + + +From pgsql-performance-owner@postgresql.org Mon Apr 5 18:32:06 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A3311D1D25F + for ; + Mon, 5 Apr 2004 21:27:57 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 85771-10 + for ; + Mon, 5 Apr 2004 18:28:24 -0300 (ADT) +Received: from outbound.mailhop.org (outbound.mailhop.org [63.208.196.171]) + by svr1.postgresql.org (Postfix) with ESMTP id 7A4AFD1CCC2 + for ; + Mon, 5 Apr 2004 18:27:52 -0300 (ADT) +Received: from ool-4353b51a.dyn.optonline.net ([67.83.181.26] helo=zeut.net) + by outbound.mailhop.org with asmtp (TLSv1:AES256-SHA:256) (Exim 4.20) + id 1BAbdu-00083K-77; Mon, 05 Apr 2004 17:28:30 -0400 +Message-ID: <4071CF81.2000204@zeut.net> +Date: Mon, 05 Apr 2004 17:28:33 -0400 +From: "Matthew T. O'Connor" +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Heiko Kehlenbrink +Cc: pgsql-performance@postgresql.org +Subject: Re: performance comparission postgresql/ms-sql server +References: + <48932.195.243.253.146.1081179099.squirrel@webmail.fh-oldenburg.de> +In-Reply-To: + <48932.195.243.253.146.1081179099.squirrel@webmail.fh-oldenburg.de> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Mail-Handler: MailHop Outbound by DynDNS.org +X-Report-Abuse-To: abuse@dyndns.org +X-MHO-User: zeut +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/50 +X-Sequence-Number: 6350 + +Heiko Kehlenbrink wrote: + +>i use suse 8.1 +> postgresql 7.2 compiled from the rpms for using postgis, but that is +> +> +> +Try v7.4, there are many performance improvements. It may not make up +all the differences but it should help. + +From pgsql-performance-owner@postgresql.org Mon Apr 5 21:48:53 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 109D8D1D206 + for ; + Mon, 5 Apr 2004 22:49:40 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 16002-08 + for ; + Mon, 5 Apr 2004 19:50:09 -0300 (ADT) +Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) + by svr1.postgresql.org (Postfix) with ESMTP id 67EF3D1CCC1 + for ; + Mon, 5 Apr 2004 19:49:34 -0300 (ADT) +Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) + by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i35MmcBK015420; + Mon, 5 Apr 2004 16:48:39 -0600 (MDT) +Date: Mon, 5 Apr 2004 16:48:49 -0600 (MDT) +From: "scott.marlowe" +To: Kevin Barnard +Cc: +Subject: Re: atrocious update performance +In-Reply-To: <40715974.10626.ED9A003@localhost> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-IHS-MailScanner: Found to be clean +X-IHS-MailScanner-SpamCheck: +X-IHS-MailScanner-Envelope-Sender: scott.marlowe@ihs.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/52 +X-Sequence-Number: 6352 + +On Mon, 5 Apr 2004, Kevin Barnard wrote: + +> On 5 Apr 2004 at 12:05, Rosser Schwarz wrote: +> +> > Just this morning, however, I created a copy of the target table (all +> > 4.7M rows), with absolutely no foreign keys referring to it, and ran +> > the update against the copy. That update took 2300 seconds. The +> > join columns were indexed in both cases. +> +> Have you added indexes for the custid column for tables account.acct accunt.orgacct +> and note? +> +> I haven't followed the entire thread but it you have cascading FK on those tables +> without an index on the column that could cause your delay. + +also make sure the fk/pk types match, or the index likely won't get used +anyway. + + +From pgsql-performance-owner@postgresql.org Mon Apr 5 22:37:12 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id EB30FD1C9ED + for ; + Tue, 6 Apr 2004 00:19:39 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 57188-01 + for ; + Mon, 5 Apr 2004 21:20:11 -0300 (ADT) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id C8E7DD1C995 + for ; + Mon, 5 Apr 2004 21:19:37 -0300 (ADT) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id 13F8A35517; Mon, 5 Apr 2004 17:20:20 -0700 (PDT) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id 127A4350A3; Mon, 5 Apr 2004 17:20:20 -0700 (PDT) +Date: Mon, 5 Apr 2004 17:20:20 -0700 (PDT) +From: Stephan Szabo +To: Rosser Schwarz +Cc: pgsql-performance@postgresql.org +Subject: Re: atrocious update performance +In-Reply-To: <009901c41b48$8357c860$2500fa0a@CardServices.TCI.com> +Message-ID: <20040405170631.M19491@megazone.bigpanda.com> +References: <009901c41b48$8357c860$2500fa0a@CardServices.TCI.com> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/54 +X-Sequence-Number: 6354 + +On Mon, 5 Apr 2004, Rosser Schwarz wrote: + +> while you weren't looking, Kevin Barnard wrote: +> +> > Have you added indexes for the custid column for tables +> > account.acct accunt.orgacct and note? +> +> They were indexed in the original case, yes. There was no +> need to index them in today's test case, as that was done +> purely in attempt to rule in or out foreign key validation +> as the cause of the performance hit. No foreign keys that +> might be validated, no need to index the foreign key columns. +> +> > I haven't followed the entire thread but it you have +> > cascading FK on those tables without an index on the +> > column that could cause your delay. +> +> The issue is that the foreign keys are being validated at +> all, when the column being referenced by those foreign keys +> (account.cust.custid) is never touched. +> +> Regardless of whether or not the referencing columns are +> indexed, validating them at all--in this specific case--is +> broken. The column they refer to is never touched; they +> should remain utterly ignorant of whatever happens to other +> columns in the same row. + +It shouldn't be checking the other table if the values of the key column +hadn't changed. The ri_KeysEqual check should be causing it to return just +before actually doing the check on the other table (it still does a few +things before then but nothing that should be particularly expensive). In +some simple tests on my 7.4.2 machine, this appears to work for me on pk +cascade updates. It would be interesting to know if it's actually doing +any checks for you, you might be able to poke around the triggers +(backend/utils/adt/ri_triggers.c). + +From pgsql-performance-owner@postgresql.org Mon Apr 5 22:35:14 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 271DAD1B441 + for ; + Tue, 6 Apr 2004 00:53:30 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 68383-02 + for ; + Mon, 5 Apr 2004 21:54:00 -0300 (ADT) +Received: from leo.supplyfx.com (h-67-100-199-42.lsanca54.covad.net + [67.100.199.42]) + by svr1.postgresql.org (Postfix) with ESMTP id ACC14D1ED4E + for ; + Mon, 5 Apr 2004 21:53:26 -0300 (ADT) +Received: from [10.0.100.21] (unknown [10.0.100.21]) + by leo.supplyfx.com (Postfix) with ESMTP id 16108EC26D + for ; + Mon, 5 Apr 2004 17:54:08 -0700 (PDT) +Mime-Version: 1.0 (Apple Message framework v612) +In-Reply-To: <009901c41b48$8357c860$2500fa0a@CardServices.TCI.com> +References: <009901c41b48$8357c860$2500fa0a@CardServices.TCI.com> +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: +Content-Transfer-Encoding: 7bit +From: Qing Zhao +Subject: possible improvement between G4 and G5 +Date: Mon, 5 Apr 2004 17:53:49 -0700 +To: pgsql-performance@postgresql.org +X-Mailer: Apple Mail (2.612) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/53 +X-Sequence-Number: 6353 + +Hi, + +We have got a G5 64-bit processor to replace an old G4 32-bit +processor. Given everything +else equal, should we see a big improvement on PG's performance? + +The other question I have is that, when I tried different size for +shared_buffer ( i used 10,000, +1,000, 528, 256) and Max connections=32, it gives me error when I tried +to start PG using +pg_ctl start as postgres. It kept saying this is bigger than the system +Shared Memory. So finally +I started PG using SystemStarter start PostgreSQL and it seems starting +OK. Any idea? + + +Thanks a lot! + +Qing Zhao + + +From pgsql-performance-owner@postgresql.org Tue Apr 6 12:01:06 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 910BFD1B91B + for ; + Tue, 6 Apr 2004 01:41:23 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 84992-04 + for ; + Mon, 5 Apr 2004 22:41:54 -0300 (ADT) +Received: from exchange.rampageusa.net (exchange.dslextreme.com + [66.51.198.16]) + by svr1.postgresql.org (Postfix) with ESMTP id 57B0DD1ED8E + for ; + Mon, 5 Apr 2004 22:41:19 -0300 (ADT) +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C41B78.3BF37693" +Subject: Wierd issues +Date: Mon, 5 Apr 2004 18:41:08 -0700 +Message-ID: + <79AEF92046759442A4AA04C2AB08C0B80834E2@exchange.corp.dslextreme.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: Wierd issues +Thread-Index: AcQbeDuW3/erCMLlTduaiu8lxIPCEQ== +From: "Andrew Matthews" +To: +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/63 +X-Sequence-Number: 6363 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C41B78.3BF37693 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + +This is what I got... + +=20 + +Two servers, one debian, one fedora + +=20 + +Debain dual 3ghz, 1 gig ram, ide, PostgreSQL 7.2.1 on i686-pc-linux-gnu, +compiled by GCC 2.95.4 + +=20 + +=20 + +Fedora: Dual 3ghz, 1 gig ram, scsi, PostgreSQL 7.3.4-RH on +i386-redhat-linux-gnu, compiled by GCC i386-redhat-linux-gcc (GCC) 3.3.2 +20031022 (Red Hat Linux 3.3.2-1) + +=20 + +=20 + +Both have same databases, Both have had vacume full ran on them. Both +doing the same query + +=20 + +Select * from vpopmail; The vpopmail is a view, this is the view + +=20 + +=20 + + View "vpopmail" + + Column | Type | Modifiers=20 + +-----------+------------------------+----------- + + pw_name | character varying(32) |=20 + + pw_domain | character varying(64) |=20 + + pw_passwd | character varying |=20 + + pw_uid | integer |=20 + + pw_gid | integer |=20 + + pw_gecos | character varying |=20 + + pw_dir | character varying(160) |=20 + + pw_shell | character varying(20) |=20 + +View definition: SELECT ea.email_name AS pw_name, ea.domain AS +pw_domain, get_pwd(u.username, '127.0.0.1'::"varchar", '101'::"varchar", +'MD5'::"varchar") AS pw_passwd, 0 AS pw_uid, 0 AS pw_gid, ''::"varchar" +AS pw_gecos, ei.directory AS pw_dir, ei.quota AS pw_shell FROM +email_addresses ea, email_info ei, users u, user_resources ur WHERE +(((((ea.user_resource_id =3D ei.user_resource_id) AND (get_pwd(u.username, +'127.0.0.1'::"varchar", '101'::"varchar", 'MD5'::"varchar") IS NOT +NULL)) AND (ur.id =3D ei.user_resource_id)) AND (u.id =3D ur.user_id)) AND +(NOT (EXISTS (SELECT forwarding.email_id FROM forwarding WHERE +(forwarding.email_id =3D ea.id))))); + +=20 + +=20 + +=20 + +Both are set to the same buffers and everything... this is the execution +time: + +=20 + +Debian: Total runtime: 35594.81 msec + +=20 + +Fedora: Total runtime: 2279869.08 msec + +=20 + +Huge difference as you can see... here are the pastes of the stuff + +=20 + +Debain: + +=20 + +user_acl=3D# explain analyze SELECT count(*) from vpopmail; + +NOTICE: QUERY PLAN: + +=20 + +Aggregate (cost=3D438231.94..438231.94 rows=3D1 width=3D20) (actual +time=3D35594.67..35594.67 rows=3D1 loops=3D1) + + -> Hash Join (cost=3D434592.51..438142.51 rows=3D35774 width=3D20) (act= +ual +time=3D34319.24..35537.11 rows=3D70613 loops=3D1) + + -> Seq Scan on email_info ei (cost=3D0.00..1721.40 rows=3D71640 +width=3D4) (actual time=3D0.04..95.13 rows=3D71689 loops=3D1) + + -> Hash (cost=3D434328.07..434328.07 rows=3D35776 width=3D16) +(actual time=3D34319.00..34319.00 rows=3D0 loops=3D1) + + -> Hash Join (cost=3D430582.53..434328.07 rows=3D35776 +width=3D16) (actual time=3D2372.45..34207.21 rows=3D70613 loops=3D1) + + -> Seq Scan on users u (cost=3D0.00..1938.51 +rows=3D71283 width=3D4) (actual time=3D0.81..30119.58 rows=3D70809 loops=3D= +1) + + -> Hash (cost=3D430333.64..430333.64 rows=3D35956 +width=3D12) (actual time=3D2371.51..2371.51 rows=3D0 loops=3D1) + + -> Hash Join (cost=3D2425.62..430333.64 +rows=3D35956 width=3D12) (actual time=3D176.73..2271.14 rows=3D71470 loops= +=3D1) + + -> Seq Scan on email_addresses ea +(cost=3D0.00..426393.25 rows=3D35956 width=3D4) (actual time=3D0.06..627.49 +rows=3D71473 loops=3D1) + + SubPlan + + -> Index Scan using +forwarding_idx on forwarding (cost=3D0.00..5.88 rows=3D1 width=3D4) (actual +time=3D0.00..0.00 rows=3D0 loops=3D71960) + + -> Hash (cost=3D1148.37..1148.37 +rows=3D71637 width=3D8) (actual time=3D176.38..176.38 rows=3D0 loops=3D1) + + -> Seq Scan on user_resources ur +(cost=3D0.00..1148.37 rows=3D71637 width=3D8) (actual time=3D0.03..82.21 +rows=3D71686 loops=3D1) + +Total runtime: 35594.81 msec + +=20 + +EXPLAIN + +=20 + +=20 + +=20 + +And for fedora it's + +=20 + +=20 + +Aggregate (cost=3D416775.52..416775.52 rows=3D1 width=3D20) (actual +time=3D2279868.57..2279868.58 rows=3D1 loops=3D1) + -> Hash Join (cost=3D413853.79..416686.09 rows=3D35772 width=3D20) +(actual time=3D2279271.26..2279803.91 rows=3D70841 loops=3D1) + Hash Cond: ("outer".user_resource_id =3D "inner".id) + -> Seq Scan on email_info ei (cost=3D0.00..1666.07 rows=3D71907 +width=3D4) (actual time=3D8.12..171.10 rows=3D71907 loops=3D1) + -> Hash (cost=3D413764.36..413764.36 rows=3D35772 width=3D16) +(actual time=3D2279263.03..2279263.03 rows=3D0 loops=3D1) + -> Hash Join (cost=3D410712.87..413764.36 rows=3D35772 +width=3D16) (actual time=3D993.90..2279008.72 rows=3D70841 loops=3D1) + Hash Cond: ("outer".id =3D "inner".user_id) + -> Seq Scan on users u (cost=3D0.00..1888.85 +rows=3D71548 width=3D4) (actual time=3D18.38..2277152.51 rows=3D71028 loops= +=3D1) + Filter: (get_pwd(username, +'127.0.0.1'::character varying, '101'::character varying, +'MD5'::character varying) IS NOT NULL) + -> Hash (cost=3D410622.99..410622.99 rows=3D35952 +width=3D12) (actual time=3D975.40..975.40 rows=3D0 loops=3D1) + -> Hash Join (cost=3D408346.51..410622.99 +rows=3D35952 width=3D12) (actual time=3D507.52..905.91 rows=3D71697 loops= +=3D1) + Hash Cond: ("outer".id =3D +"inner".user_resource_id) + -> Seq Scan on user_resources ur +(cost=3D0.00..1108.04 rows=3D71904 width=3D8) (actual time=3D0.05..95.65 +rows=3D71904 loops=3D1) + -> Hash (cost=3D408256.29..408256.29 +rows=3D36091 width=3D4) (actual time=3D507.33..507.33 rows=3D0 loops=3D1) + -> Seq Scan on email_addresses +ea (cost=3D0.00..408256.29 rows=3D36091 width=3D4) (actual time=3D0.15..43= +2.83 +rows=3D71700 loops=3D1) + Filter: (NOT (subplan)) + SubPlan + -> Index Scan using +forwarding_idx on forwarding (cost=3D0.00..5.63 rows=3D1 width=3D4) (actual +time=3D0.00..0.00 rows=3D0 loops=3D72182) + Index Cond: +(email_id =3D $0) + Total runtime: 2279869.08 msec + +(20 rows) + +=20 + +=20 + +=20 + +Any suggestions? + +=20 + +I can't figure this out. There is no reason it should be that much of a +difference, It's all the same value's, Thanks in advanced. + +=20 + +Andrew + + +------_=_NextPart_001_01C41B78.3BF37693 +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + + + + +
+ +

This is what I got…

+ +

 

+ +

Two servers, one debian, one fedora

+ +

 

+ +

Debain dual 3ghz, 1 gig ram, ide, PostgreSQL 7.2.1 on +i686-pc-linux-gnu, compiled by GCC 2.95.4

+ +

 

+ +

 

+ +

Fedora: Dual 3ghz, 1 gig ram, scsi, PostgreSQL 7.3.4-RH = +on +i386-redhat-linux-gnu, compiled by GCC i386-redhat-linux-gcc (GCC) 3.3.2 +20031022 (Red Hat Linux 3.3.2-1)

+ +

 

+ +

 

+ +

Both have same databases, Both have had vacume full ran = +on +them. Both doing the same query

+ +

 

+ +

Select * from vpopmail; The vpopmail is a view, this is = +the +view

+ +

 

+ +

 

+ +

         &n= +bsp;      View "vpopmail"

+ +

  Column   |     = +;     Type       &nb= +sp;  | Modifiers

+ +

-----------+------------------------+-----------

+ +

 pw_name   | character varying(32)  = +|

+ +

 pw_domain | character varying(64)  |

+ +

 pw_passwd | character varying   &nb= +sp;  |

+ +

 pw_uid    | integer  &nbs= +p;             = +|

+ +

 pw_gid    | integer  &nbs= +p;             = +|

+ +

 pw_gecos  | character varying  &nbs= +p;   |

+ +

 pw_dir    | character varying(160) = +|

+ +

 pw_shell  | character varying(20)  |

+ +

View definition: SELECT ea.email_name AS pw_name, ea.dom= +ain +AS pw_domain, get_pwd(u.username, '127.0.0.1'::"varchar", +'101'::"varchar", 'MD5'::"varchar") AS pw_passwd, 0 AS +pw_uid, 0 AS pw_gid, ''::"varchar" AS pw_gecos, ei.directory AS +pw_dir, ei.quota AS pw_shell FROM email_addresses ea, email_info ei, users = +u, +user_resources ur WHERE (((((ea.user_resource_id =3D ei.user_resource_id) A= +ND +(get_pwd(u.username, '127.0.0.1'::"varchar", +'101'::"varchar", 'MD5'::"varchar") IS NOT NULL)) AND +(ur.id =3D ei.user_resource_id)) AND (u.id =3D ur.user_id)) AND (NOT (EXISTS +(SELECT forwarding.email_id FROM forwarding WHERE (forwarding.email_id =3D +ea.id)))));

+ +

 

+ +

 

+ +

 

+ +

Both are set to the same buffers and everything… t= +his +is the execution time:

+ +

 

+ +

Debian: Total runtime: 35594.81 msec

+ +

 

+ +

Fedora: Total runtime: 2279869.08 msec= +

+ +

 

+ +

Huge difference as you can see… here are the paste= +s of +the stuff

+ +

 

+ +

Debain:

+ +

 

+ +

user_acl=3D# explain analyze SELECT count(*) from vpopma= +il;

+ +

NOTICE:  QUERY PLAN:

+ +

 

+ +

Aggregate  (cost=3D438231.94..438231.94 rows=3D1 wi= +dth=3D20) +(actual time=3D35594.67..35594.67 rows=3D1 loops=3D1)

+ +

  ->  Hash Join  (cost=3D434592.51..43= +8142.51 rows=3D35774 +width=3D20) (actual time=3D34319.24..35537.11 rows=3D70613 loops=3D1)<= +/o:p>

+ +

        ->  S= +eq Scan on email_info ei  +(cost=3D0.00..1721.40 rows=3D71640 width=3D4) (actual time=3D0.04..95.13 ro= +ws=3D71689 +loops=3D1)

+ +

        ->  H= +ash  (cost=3D434328.07..434328.07 rows=3D35776 +width=3D16) (actual time=3D34319.00..34319.00 rows=3D0 loops=3D1)

+ +

         &n= +bsp;    ->  Hash Join  (cost=3D430582.53..43432= +8.07 +rows=3D35776 width=3D16) (actual time=3D2372.45..34207.21 rows=3D70613 loop= +s=3D1)

+ +

         &n= +bsp;          ->  Seq = +Scan on users u  +(cost=3D0.00..1938.51 rows=3D71283 width=3D4) (actual time=3D0.81..30119.58= + rows=3D70809 +loops=3D1)

+ +

         &n= +bsp;          ->  Hash= +  (cost=3D430333.64..430333.64 +rows=3D35956 width=3D12) (actual time=3D2371.51..2371.51 rows=3D0 loops=3D1= +)

+ +

         &n= +bsp;            = +;    ->  Hash Join  +(cost=3D2425.62..430333.64 rows=3D35956 width=3D12) (actual time=3D176.73..= +2271.14 +rows=3D71470 loops=3D1)

+ +

         &n= +bsp;            = +;          ->  Seq Sca= +n on +email_addresses ea  (cost=3D0.00..426393.25 rows=3D35956 width=3D4) (a= +ctual time=3D0.06..627.49 +rows=3D71473 loops=3D1)

+ +

         &n= +bsp;            = +;            &n= +bsp;   SubPlan

+ +

         &n= +bsp;            = +;            &n= +bsp;     ->  Index Scan +using forwarding_idx on forwarding  (cost=3D0.00..5.88 rows=3D1 width= +=3D4) (actual +time=3D0.00..0.00 rows=3D0 loops=3D71960)

+ +

          &= +nbsp;           &nbs= +p;         ->  Hash&nb= +sp; +(cost=3D1148.37..1148.37 rows=3D71637 width=3D8) (actual time=3D176.38..176= +.38 rows=3D0 +loops=3D1)

+ +

         &n= +bsp;            = +;            &n= +bsp;   ->  Seq Scan on +user_resources ur<= +/st1:City>  +(cost=3D0.00..1148.37 rows=3D71637 width=3D8) (actual time=3D0.03..82.21 ro= +ws=3D71686 +loops=3D1)

+ +

Total runtime: 35594.81 msec

+ +

 

+ +

EXPLAIN

+ +

 

+ +

 

+ +

 

+ +

And for fedora it’s

+ +

 

+ +

 

+ +
Aggregate  (cost=3D416775.52..416775.52 row=
+s=3D1 width=3D20) (actual time=3D2279868.57..2279868.58 rows=3D1 loops=3D1)=
+
   ->&nb=
+sp; Hash Join  (cost=3D413853.79..416686.09 rows=3D35772 width=3D20) (=
+actual time=3D2279271.26..2279803.91 rows=3D70841 loops=3D1)
   &nb=
+sp;     Hash Cond: ("outer".user_resource_id =
+=3D "inner".id)
   &nb=
+sp;     ->  Seq Scan on email_info ei  (co=
+st=3D0.00..1666.07 rows=3D71907 width=3D4) (actual time=3D8.12..171.10 rows=
+=3D71907 loops=3D1)
   &nb=
+sp;     ->  Hash  (cost=3D413764.36..41376=
+4.36 rows=3D35772 width=3D16) (actual time=3D2279263.03..2279263.03 rows=3D=
+0 loops=3D1)
   &nb=
+sp;           -> =
+ Hash Join  (cost=3D410712.87..413764.36 rows=3D35772 width=3D16) (act=
+ual time=3D993.90..2279008.72 rows=3D70841 loops=3D1)
   &nb=
+sp;            =
+     Hash Cond: ("outer".id =3D "inner&q=
+uot;.user_id)
   &nb=
+sp;            =
+     ->  Seq Scan on users u  (cost=3D0.00=
+..1888.85 rows=3D71548 width=3D4) (actual time=3D18.38..2277152.51 rows=3D7=
+1028 loops=3D1)
   &nb=
+sp;            =
+           Filter: (get_p=
+wd(username, '127.0.0.1'::character varying, '101'::character varying, 'MD5=
+'::character varying) IS NOT NULL)
   &nb=
+sp;            =
+     ->  Hash  (cost=3D410622.99..410622.9=
+9 rows=3D35952 width=3D12) (actual time=3D975.40..975.40 rows=3D0 loops=3D1=
+)
   &nb=
+sp;             =
+;          ->  Ha=
+sh Join  (cost=3D408346.51..410622.99 rows=3D35952 width=3D12) (actual=
+ time=3D507.52..905.91 rows=3D71697 loops=3D1)
   &nb=
+sp;            =
+            &nb=
+sp;    Hash Cond: ("outer".id =3D "inner"=
+;.user_resource_id)
   &nb=
+sp;            =
+            &nb=
+sp;    ->  Seq Scan on user_resources ur  (cost=3D=
+0.00..1108.04 rows=3D71904 width=3D8) (actual time=3D0.05..95.65 rows=3D719=
+04 loops=3D1)
   &nb=
+sp;            =
+            &nb=
+sp;    ->  Hash  (cost=3D408256.29..408256.29 r=
+ows=3D36091 width=3D4) (actual time=3D507.33..507.33 rows=3D0 loops=3D1)
   &nb=
+sp;             =
+;            &n=
+bsp;         ->  Seq S=
+can on email_addresses ea  (cost=3D0.00..408256.29 rows=3D36091 width=
+=3D4) (actual time=3D0.15..432.83 rows=3D71700 loops=3D1)=
+
   &nb=
+sp;            =
+            &nb=
+sp;            =
+    Filter: (NOT (subplan))
   &nb= +sp;            = +            &nb= +sp;             = +;   SubPlan
   &nb=
+sp;            =
+            &nb=
+sp;            =
+      ->  Index Scan using forwarding_idx =
+on forwarding  (cost=3D0.00..5.63 rows=3D1 width=3D4) (actual time=3D0=
+.00..0.00 rows=3D0 loops=3D72182)
   &nb=
+sp;            =
+            &nb=
+sp;            =
+            Index Co=
+nd: (email_id =3D $0)
 Total runtime: 22798=
+69.08 msec
+ +

(20 rows)

+ +

 

+ +

 

+ +

 

+ +

Any suggestions?

+ +

 

+ +

I can’t figure this out. There is no reason it should be that +much of a difference, It’s all the same value’s, Thanks in +advanced.

+ +

 

+ +

Andrew

+ +
+ + + + + +------_=_NextPart_001_01C41B78.3BF37693-- + +From pgsql-performance-owner@postgresql.org Tue Apr 6 02:46:47 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9F64FD1B4BE + for ; + Tue, 6 Apr 2004 02:46:45 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 53968-08 + for ; + Tue, 6 Apr 2004 02:47:24 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id E9B03D1B4B6 + for ; + Tue, 6 Apr 2004 02:46:38 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i365lNvI019782; + Tue, 6 Apr 2004 01:47:23 -0400 (EDT) +To: Qing Zhao +Cc: pgsql-performance@postgresql.org +Subject: Re: possible improvement between G4 and G5 +In-reply-to: +References: <009901c41b48$8357c860$2500fa0a@CardServices.TCI.com> + +Comments: In-reply-to Qing Zhao + message dated "Mon, 05 Apr 2004 17:53:49 -0700" +Date: Tue, 06 Apr 2004 01:47:22 -0400 +Message-ID: <19781.1081230442@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/55 +X-Sequence-Number: 6355 + +Qing Zhao writes: +> We have got a G5 64-bit processor to replace an old G4 32-bit +> processor. Given everything else equal, should we see a big +> improvement on PG's performance? + +Nope. Database performance typically depends on disk performance first, +and RAM size second. A 64-bit processor might help by allowing you to +install more RAM, but you didn't say that you had. + +> The other question I have is that, when I tried different size for +> shared_buffer ( i used 10,000, 1,000, 528, 256) and Max +> connections=32, it gives me error when I tried to start PG using +> pg_ctl start as postgres. It kept saying this is bigger than the +> system Shared Memory. + +Out-of-the-box, Mac OS X has a very low SHMMAX limit. See the PG admin +docs or the mail list archives about how to increase it. You should do +this --- most people find that you want to set shared_buffers to 1000 or +10000 or so for best performance. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Apr 6 04:26:42 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7A0E2D1B8DF + for ; + Tue, 6 Apr 2004 04:26:40 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 95895-03 + for ; + Tue, 6 Apr 2004 04:27:21 -0300 (ADT) +Received: from frodo.hserus.net (frodo.hserus.net [204.74.68.40]) + by svr1.postgresql.org (Postfix) with ESMTP id ECBFBD1B54E + for ; + Tue, 6 Apr 2004 04:26:35 -0300 (ADT) +Received: from concord.pspl.co.in ([202.54.11.72]:61708 helo=frodo.hserus.net) + by frodo.hserus.net with asmtp + (Cipher TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.31 #0) + id 1BAkzQ-0006du-E8 by authid with plain; + Tue, 06 Apr 2004 12:57:21 +0530 +Message-ID: <40725BD1.3050008@frodo.hserus.net> +Date: Tue, 06 Apr 2004 12:57:13 +0530 +From: Shridhar Daithankar +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.6b) Gecko/20031205 Thunderbird/0.4 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Heiko Kehlenbrink , + Performance +Subject: Re: performance comparission postgresql/ms-sql server +References: + <48932.195.243.253.146.1081179099.squirrel@webmail.fh-oldenburg.de> + <40718146.1010506@frodo.hserus.net> + <56755.195.243.253.146.1081233367.squirrel@webmail.fh-oldenburg.de> +In-Reply-To: + <56755.195.243.253.146.1081233367.squirrel@webmail.fh-oldenburg.de> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/56 +X-Sequence-Number: 6356 + +Heiko Kehlenbrink wrote: + +> hkehlenbrink@lin0493l:~> psql -d test -c 'explain analyse select avg(dist) +> from massive2 where dist > (1000000*sqrt(3.0))::float8 and dist < +> (1500000*sqrt(3.0))::float8;' +> NOTICE: QUERY PLAN: +> +> Aggregate (cost=14884.61..14884.61 rows=1 width=8) (actual +> time=3133.24..3133.24 rows=1 loops=1) +> -> Index Scan using massive2_dist on massive2 (cost=0.00..13648.17 +> rows=494573 width=8) (actual time=0.11..2061.38 rows=499999 loops=1) +> Total runtime: 3133.79 msec +> +> EXPLAIN +> +> seems to me that most time was needed for the index scanning... + +Hmm... I would suggest if you are testing, you should try 7.4.2. 7.4 has some +good optimisation for hash agregates though I am not sure if it apply to averaging. + +Also try forcing a seq. scan by turning off index scan. I guess index scan for +so many rows is not exactly good thing even if tuple size if pretty small. + + Shridhar + +From pgsql-performance-owner@postgresql.org Tue Apr 6 05:04:34 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6F58AD1E172 + for ; + Tue, 6 Apr 2004 05:04:33 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 01070-06 + for ; + Tue, 6 Apr 2004 05:05:09 -0300 (ADT) +Received: from mail (unknown [202.108.142.212]) + by svr1.postgresql.org (Postfix) with ESMTP id 80DB0D1B98D + for ; + Tue, 6 Apr 2004 05:04:22 -0300 (ADT) +Received: from HUANGYQ ([61.149.153.189]) + by mail.gthome.com (iPlanet Messaging Server 5.1 (built May 7 2001)) + with ESMTPA id <0HVQ00E32PI95I@mail.gthome.com> for + pgsql-performance@postgresql.org; Tue, 06 Apr 2004 16:13:22 +0800 (CST) +Date: Tue, 06 Apr 2004 16:01:34 +0800 +From: huang yaqin +Subject: good pc but bad performance,why? +To: "pgsql-performance@postgresql.org" +Message-id: <0HVQ00E33PI95I@mail.gthome.com> +MIME-version: 1.0 +X-Mailer: Foxmail 4.2 [cn] +Content-type: text/plain; charset=GB2312 +Content-transfer-encoding: quoted-printable +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.9 tagged_above=0.0 required=5.0 tests=RCVD_IN_RFCI, + TO_ADDRESS_EQ_REAL +X-Spam-Level: +X-Archive-Number: 200404/57 +X-Sequence-Number: 6357 + +hello, + + I have some question when I use postgresql 7.4.1 on redhat adv server 2.1 . +I use IBM335 as server, it has 4 cpus, 1G RAM. but I got very bad performan= +ce. +I can only do about 50 inserts per sencond. Event worse than my pc(PIII 800= +,256M RAM), can anyone give me some advice?=09 + +=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1huang yaqin +=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1hyq@gthome.com +=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A12004-04-06 + + + +From pgsql-performance-owner@postgresql.org Tue Apr 6 08:15:48 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1329ED1E9E1 + for ; + Tue, 6 Apr 2004 08:15:46 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 78119-09 + for ; + Tue, 6 Apr 2004 08:16:28 -0300 (ADT) +Received: from anchor-post-33.mail.demon.net (anchor-post-33.mail.demon.net + [194.217.242.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 9EA7FD1E9C5 + for ; + Tue, 6 Apr 2004 08:15:40 -0300 (ADT) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-33.mail.demon.net with esmtp (Exim 3.35 #1) + id 1BAoZ8-0000MC-0X; Tue, 06 Apr 2004 12:16:27 +0100 +Received: by mainbox.archonet.com (Postfix, from userid 529) + id 900FF1666F; Tue, 6 Apr 2004 12:16:24 +0100 (BST) +Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 9934316486; Tue, 6 Apr 2004 12:16:22 +0100 (BST) +From: Richard Huxton +To: huang yaqin , + "pgsql-performance@postgresql.org" +Subject: Re: good pc but bad performance,why? +Date: Tue, 6 Apr 2004 12:16:22 +0100 +User-Agent: KMail/1.5 +References: <0HVQ00E33PI95I@mail.gthome.com> +In-Reply-To: <0HVQ00E33PI95I@mail.gthome.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="gb2312" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200404061216.22856.dev@archonet.com> +X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/58 +X-Sequence-Number: 6358 + +On Tuesday 06 April 2004 09:01, huang yaqin wrote: +> hello, +> +> I have some question when I use postgresql 7.4.1 on redhat adv server 2.1 +> . I use IBM335 as server, it has 4 cpus, 1G RAM. but I got very bad +> performance. I can only do about 50 inserts per sencond. Event worse than +> my pc(PIII 800,256M RAM), can anyone give me some advice? + +How have you tuned your postgresql.conf file? +What disk systems do you have? +What does vmstat/iostat show as the bottleneck in the system? + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Tue Apr 6 09:46:08 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 07E8CD1D4DA + for ; + Tue, 6 Apr 2004 09:46:06 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 15832-08 + for ; + Tue, 6 Apr 2004 09:46:51 -0300 (ADT) +Received: from internet.potentialtech.com (h-66-167-251-6.phlapafg.covad.net + [66.167.251.6]) + by svr1.postgresql.org (Postfix) with ESMTP id CEBC2D1D391 + for ; + Tue, 6 Apr 2004 09:46:03 -0300 (ADT) +Received: from potentialtech.com (pa-plum1c-102.pit.adelphia.net + [24.53.179.102]) by internet.potentialtech.com (Postfix) with ESMTP + id 48BBA69A71; Tue, 6 Apr 2004 08:46:51 -0400 (EDT) +Message-ID: <4072A6B9.5050502@potentialtech.com> +Date: Tue, 06 Apr 2004 08:46:49 -0400 +From: Bill Moran +User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.4) Gecko/20031005 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: huang yaqin +Cc: "pgsql-performance@postgresql.org" +Subject: Re: good pc but bad performance,why? +References: <0HVQ00E33PI95I@mail.gthome.com> +In-Reply-To: <0HVQ00E33PI95I@mail.gthome.com> +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/59 +X-Sequence-Number: 6359 + +huang yaqin wrote: +> hello, +> +> I have some question when I use postgresql 7.4.1 on redhat adv server 2.1 . +> I use IBM335 as server, it has 4 cpus, 1G RAM. but I got very bad performance. +> I can only do about 50 inserts per sencond. Event worse than my pc(PIII 800,256M RAM), can anyone give me some advice? + +Have you referenced this document?: + +http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html + +-- +Bill Moran +Potential Technologies +http://www.potentialtech.com + + +From pgsql-performance-owner@postgresql.org Tue Apr 6 10:00:45 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 892A4D1D370 + for ; + Tue, 6 Apr 2004 10:00:42 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 21737-06 + for ; + Tue, 6 Apr 2004 10:01:27 -0300 (ADT) +Received: from anchor-post-32.mail.demon.net (anchor-post-32.mail.demon.net + [194.217.242.90]) + by svr1.postgresql.org (Postfix) with ESMTP id 0935AD1D282 + for ; + Tue, 6 Apr 2004 10:00:39 -0300 (ADT) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-32.mail.demon.net with esmtp (Exim 3.35 #1) + id 1BAqCk-000IEF-0W + for pgsql-performance@postgresql.org; Tue, 06 Apr 2004 14:01:26 +0100 +Received: by mainbox.archonet.com (Postfix, from userid 529) + id 77BDE1799E; Tue, 6 Apr 2004 14:01:25 +0100 (BST) +Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP id 23E1216486 + for ; + Tue, 6 Apr 2004 14:01:23 +0100 (BST) +From: Richard Huxton +To: pgsql-performance@postgresql.org +Subject: Back to Linux 2.6 kernel thoughts... +Date: Tue, 6 Apr 2004 14:01:23 +0100 +User-Agent: KMail/1.5 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200404061401.23189.dev@archonet.com> +X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/60 +X-Sequence-Number: 6360 + +I seem to remember discussion of anticipatory vs deadline scheduler in 2.6. +Here is what Andrew Morton (I think) says: + +"The deadline scheduler has two additional scheduling queues that were not +available to the 2.4 IO scheduler. The two new queues are a FIFO read queue +and a FIFO write queue. This new multi-queue method allows for greater +interactivity by giving the read requests a better deadline than write +requests, thus ensuring that applications rarely will be delayed by read +requests. + +Deadline scheduling is best suited for database servers and high disk +performance systems. Morton has experienced up to 15 percent increases on +database loads while using deadline scheduling." + +http://story.news.yahoo.com/news?tmpl=story&cid=75&e=2&u=/nf/20040405/tc_nf/23603 + +Nothing very in-depth in the story. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Tue Apr 6 11:40:41 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 15946D1B8DF + for ; + Tue, 6 Apr 2004 11:40:40 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 71071-05 + for ; + Tue, 6 Apr 2004 11:41:21 -0300 (ADT) +Received: from frodo.hserus.net (frodo.hserus.net [204.74.68.40]) + by svr1.postgresql.org (Postfix) with ESMTP id C1EABD1B88D + for ; + Tue, 6 Apr 2004 11:40:32 -0300 (ADT) +Received: from concord.pspl.co.in ([202.54.11.72]:65087 helo=frodo.hserus.net) + by frodo.hserus.net with asmtp + (Cipher TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.31 #0) + id 1BArlQ-00099m-4v by authid with plain; + Tue, 06 Apr 2004 20:11:20 +0530 +Message-ID: <4072C18B.1030600@frodo.hserus.net> +Date: Tue, 06 Apr 2004 20:11:15 +0530 +From: Shridhar Daithankar +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.6b) Gecko/20031205 Thunderbird/0.4 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Heiko Kehlenbrink , + Performance +Subject: Re: performance comparission postgresql/ms-sql server +References: + <48932.195.243.253.146.1081179099.squirrel@webmail.fh-oldenburg.de> + <40718146.1010506@frodo.hserus.net> + <56755.195.243.253.146.1081233367.squirrel@webmail.fh-oldenburg.de> + <40725BD1.3050008@frodo.hserus.net> + <58199.195.243.253.146.1081238266.squirrel@webmail.fh-oldenburg.de> +In-Reply-To: + <58199.195.243.253.146.1081238266.squirrel@webmail.fh-oldenburg.de> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/61 +X-Sequence-Number: 6361 + +Heiko Kehlenbrink wrote: +>>Hmm... I would suggest if you are testing, you should try 7.4.2. 7.4 has +>>some +>>good optimisation for hash agregates though I am not sure if it apply to +>>averaging. +> would be the last option till we are runing other applications on that 7.2 +> system + +I can understand.. + +>>Also try forcing a seq. scan by turning off index scan. I guess index scan +>>for +>>so many rows is not exactly good thing even if tuple size if pretty small. +> a sequential scann gives me the following result: +> +> HKehlenbrink@lin0493l:~> time psql -d test -c 'explain analyse select +> avg(dist) from massive2 where dist > 1000000*sqrt(3.0)::float8 and dist < +> 1500000*sqrt(3.0)::float8 ;' +> NOTICE: QUERY PLAN: +> +> Aggregate (cost=1193714.43..1193714.43 rows=1 width=8) (actual +> time=166718.54..166718.54 rows=1 loops=1) +> -> Seq Scan on massive2 (cost=0.00..1192478.00 rows=494573 width=8) +> (actual time=3233.22..165576.40 rows=499999 loops=1) +> Total runtime: 166733.73 msec + +Certainly bad and not an option.. I can't think of anything offhand to speed +this up.. + + Shridhar + +From pgsql-performance-owner@postgresql.org Tue Apr 6 11:42:20 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DFD42D1DC17 + for ; + Tue, 6 Apr 2004 11:42:19 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 66886-08 + for ; + Tue, 6 Apr 2004 11:43:04 -0300 (ADT) +Received: from MXR-8.estpak.ee (ld1.estpak.ee [194.126.101.98]) + by svr1.postgresql.org (Postfix) with ESMTP id A9604D1D9E6 + for ; + Tue, 6 Apr 2004 11:42:15 -0300 (ADT) +Received: from localhost (localhost [127.0.0.1]) + by MXR-8.estpak.ee (Postfix) with ESMTP + id 651302993B; Tue, 6 Apr 2004 17:43:03 +0300 (EEST) +Received: from MXR-8.estpak.ee ([127.0.0.1]) + by localhost (Relay8 [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 32755-03; Tue, 6 Apr 2004 17:43:03 +0300 (EEST) +Received: from future.ee (80-235-33-83-dsl.mus.estpak.ee [80.235.33.83]) + by MXR-8.estpak.ee (Postfix) with ESMTP + id 3F6242992C; Tue, 6 Apr 2004 17:43:02 +0300 (EEST) +Message-ID: <4072C209.1060902@future.ee> +Date: Tue, 06 Apr 2004 17:43:21 +0300 +From: Kaarel +User-Agent: Mozilla Thunderbird 0.5+ (X11/20040220) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Heiko Kehlenbrink +Cc: pgsql-performance@postgresql.org +Subject: Re: performance comparission postgresql/ms-sql server +References: + <48932.195.243.253.146.1081179099.squirrel@webmail.fh-oldenburg.de> +In-Reply-To: + <48932.195.243.253.146.1081179099.squirrel@webmail.fh-oldenburg.de> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new-20030616-p7 (Debian) at neti.ee +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/62 +X-Sequence-Number: 6362 + +Heiko Kehlenbrink wrote: + +>i want to convince people to use postgresql instead of ms-sql server, so i +>set up a kind of comparission insert data / select data from postgresql / +>ms-sql server +> +> +[...] + +>do you have any hints like compiler-flags and so on to get the answering +>time from postgresql equal to ms-sql? +> +>(btw both dbms were running on exactly the same hardware) +> +>i use suse 8.1 +> postgresql 7.2 compiled from the rpms for using postgis, but that is +>anothe story... +> 1.5 gig ram +> 1.8 mhz intel cpu +> +> +>every help welcome +> +> +Suse 8.1 comes with 2.4 series kernel I suppose. Many have witnessed a +speed increase when using 2.6 series kernel. Might consider this too +besides the newer PostgreSQL version already suggested. 2.6 has some +scheduling options that are not enabled by default but may enhance +database performance +(http://story.news.yahoo.com/news?tmpl=story&cid=75&e=2&u=/nf/20040405/tc_nf/23603). + +Kaarel + +From pgsql-performance-owner@postgresql.org Tue Apr 6 12:42:52 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B1A65D1EB28 + for ; + Tue, 6 Apr 2004 12:42:15 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 01203-06 + for ; + Tue, 6 Apr 2004 12:42:14 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 57AE4D1E146 + for ; + Tue, 6 Apr 2004 12:42:13 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i36Fg95R025242; + Tue, 6 Apr 2004 11:42:09 -0400 (EDT) +To: huang yaqin +Cc: "pgsql-performance@postgresql.org" +Subject: Re: good pc but bad performance,why? +In-reply-to: <0HVQ00E33PI95I@mail.gthome.com> +References: <0HVQ00E33PI95I@mail.gthome.com> +Comments: In-reply-to huang yaqin + message dated "Tue, 06 Apr 2004 16:01:34 +0800" +Date: Tue, 06 Apr 2004 11:42:09 -0400 +Message-ID: <25241.1081266129@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/64 +X-Sequence-Number: 6364 + +huang yaqin writes: +> I have some question when I use postgresql 7.4.1 on redhat adv server 2.1 . +> I use IBM335 as server, it has 4 cpus, 1G RAM. but I got very bad performance. +> I can only do about 50 inserts per sencond. Event worse than my pc(PIII 800,256M RAM), can anyone give me some advice? + +If the cheap machine appears to be able to commit more transactions +per second than the better one, it's very likely because the cheap +machine has a disk that lies about write completion. Is the server +using SCSI disks by any chance? To a first approximation, IDE drives +lie by default, SCSI drives don't. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Apr 6 13:22:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 893CFD1ED0B + for ; + Tue, 6 Apr 2004 12:45:34 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 01753-08 + for ; + Tue, 6 Apr 2004 12:45:32 -0300 (ADT) +Received: from hotmail.com (law10-oe30.law10.hotmail.com [64.4.14.87]) + by svr1.postgresql.org (Postfix) with ESMTP id A8F7AD1EB25 + for ; + Tue, 6 Apr 2004 12:45:31 -0300 (ADT) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Tue, 6 Apr 2004 08:45:30 -0700 +Received: from 67.81.102.201 by law10-oe30.law10.hotmail.com with DAV; + Tue, 06 Apr 2004 15:45:30 +0000 +X-Originating-IP: [67.81.102.201] +X-Originating-Email: [awerman2@hotmail.com] +X-Sender: awerman2@hotmail.com +From: "Aaron Werman" +To: "Qing Zhao" , "Tom Lane" +Cc: +References: <009901c41b48$8357c860$2500fa0a@CardServices.TCI.com> + + <19781.1081230442@sss.pgh.pa.us> +Subject: Re: possible improvement between G4 and G5 +Date: Tue, 6 Apr 2004 11:45:29 -0400 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1158 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +Message-ID: +X-OriginalArrivalTime: 06 Apr 2004 15:45:30.0742 (UTC) + FILETIME=[30C24160:01C41BEE] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/66 +X-Sequence-Number: 6366 + + +----- Original Message ----- +From: "Tom Lane" +To: "Qing Zhao" +Cc: +Sent: Tuesday, April 06, 2004 1:47 AM +Subject: Re: [PERFORM] possible improvement between G4 and G5 + + +> Qing Zhao writes: +> > We have got a G5 64-bit processor to replace an old G4 32-bit +> > processor. Given everything else equal, should we see a big +> > improvement on PG's performance? +> +> Nope. Database performance typically depends on disk performance first, +> and RAM size second. + +I'm surprised by this thought. I tend to hit CPU bottlenecks more often than +I/O ones. In most applications, db I/O is a combination of buffer misses and +logging, which are both reasonably constrained. RAM size seems to me to be +the best way to improve performance, and then CPU which is needed to perform +the in-memory searching, locking, versioning, and processing, and finally +I/O (this is not the case in small I/O subsystems - if you have less than a +dozen drives, you're easily I/O bound). I/O is often the thing I tune first, +because I can do it in place without buying hardware. + +Conceptually, an RDBMS converts slow random I/O into in memory processing +and sequential logging writes. If successful, it should reduce the I/O +overhead. + +/Aaron + +From pgsql-performance-owner@postgresql.org Tue Apr 6 12:53:11 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3489FD1E149 + for ; + Tue, 6 Apr 2004 12:52:45 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 07714-07 + for ; + Tue, 6 Apr 2004 12:52:43 -0300 (ADT) +Received: from flake.decibel.org (flake.decibel.org [66.143.173.58]) + by svr1.postgresql.org (Postfix) with SMTP id 5BA0CD1DC17 + for ; + Tue, 6 Apr 2004 12:52:42 -0300 (ADT) +Received: (qmail 737 invoked by uid 1001); 6 Apr 2004 15:52:35 -0000 +Date: Tue, 6 Apr 2004 10:52:35 -0500 +From: "Jim C. Nasby" +To: Tom Lane +Cc: Qing Zhao , pgsql-performance@postgresql.org +Subject: Re: possible improvement between G4 and G5 +Message-ID: <20040406155235.GZ74840@nasby.net> +References: <009901c41b48$8357c860$2500fa0a@CardServices.TCI.com> + + <19781.1081230442@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <19781.1081230442@sss.pgh.pa.us> +User-Agent: Mutt/1.4.2.1i +X-Operating-System: FreeBSD 4.9-RELEASE-p3 i386 +X-Distributed: Join the Effort! http://www.distributed.net +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/65 +X-Sequence-Number: 6365 + +On Tue, Apr 06, 2004 at 01:47:22AM -0400, Tom Lane wrote: +> Qing Zhao writes: +> > We have got a G5 64-bit processor to replace an old G4 32-bit +> > processor. Given everything else equal, should we see a big +> > improvement on PG's performance? +> +> Nope. Database performance typically depends on disk performance first, +> and RAM size second. A 64-bit processor might help by allowing you to +> install more RAM, but you didn't say that you had. + +Memory bandwidth is a consideration too, so you might see some +performance improvements on a G5. We recently debated between Xeons and +Opterons in a new PGSQL server and a little poking around on the lists +indicated that the Opterons did perform better, presumably due to the +increased memory bandwidth. Incidentally, this is why you need about 2x +the CPUs on Sun hardware vs RS6000 hardware for database stuff (and that +gets expensive if you're paying per CPU!). +-- +Jim C. Nasby, Database Consultant jim@nasby.net +Member: Triangle Fraternity, Sports Car Club of America +Give your computer some brain candy! www.distributed.net Team #1828 + +Windows: "Where do you want to go today?" +Linux: "Where do you want to go tomorrow?" +FreeBSD: "Are you guys coming, or what?" + +From pgsql-performance-owner@postgresql.org Tue Apr 6 16:16:40 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 258A6D1C951 + for ; + Tue, 6 Apr 2004 13:23:08 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 20467-09 + for ; + Tue, 6 Apr 2004 13:23:05 -0300 (ADT) +Received: from cronos.madness.at (madness.at [213.153.61.104]) + by svr1.postgresql.org (Postfix) with ESMTP id 9A98CD1BAFC + for ; + Tue, 6 Apr 2004 13:23:04 -0300 (ADT) +Received: from masterbrain.kaltenbrunner.cc ([195.70.118.74] helo=madness.at) + by cronos.madness.at with asmtp (TLSv1:AES256-SHA:256) (Exim 4.30) + id 1BAtLn-0006hY-0I; Tue, 06 Apr 2004 18:22:59 +0200 +Message-ID: <4072D959.5090905@madness.at> +Date: Tue, 06 Apr 2004 18:22:49 +0200 +From: Stefan Kaltenbrunner +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.7b) Gecko/20040326 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: huang yaqin +Cc: pgsql-performance@postgresql.org +Subject: Re: good pc but bad performance,why? +References: <0HVQ00E33PI95I@mail.gthome.com> +In-Reply-To: <0HVQ00E33PI95I@mail.gthome.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/68 +X-Sequence-Number: 6368 + +huang yaqin wrote: +> hello, +> +> I have some question when I use postgresql 7.4.1 on redhat adv server 2.1 . +> I use IBM335 as server, it has 4 cpus, 1G RAM. but I got very bad performance. + +This is most likely a dual processor Xeon machine with HT, because the +x335 is limited to two physical cpus. + +> I can only do about 50 inserts per sencond. Event worse than my pc(PIII 800,256M RAM), can anyone give me some advice? + +any chance you are using the onboard MPT-Fusion "Raid"controller with a +RAID1 - we have seen absolutely horrible performance from these +controllers here. +Using them as a normal SCSI-Controller with Softwareraid on top fixed +this for us ... + + +stefan + +From pgsql-performance-owner@postgresql.org Tue Apr 6 15:51:54 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3E0C0D1E171 + for ; + Tue, 6 Apr 2004 15:51:52 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 94439-01 + for ; + Tue, 6 Apr 2004 15:51:52 -0300 (ADT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 21692D1E158 + for ; + Tue, 6 Apr 2004 15:51:50 -0300 (ADT) +Received: from [63.195.55.98] (HELO 192.168.1.29) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4784265; Tue, 06 Apr 2004 11:53:11 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: "Aaron Werman" , + "Qing Zhao" , "Tom Lane" +Subject: Re: possible improvement between G4 and G5 +Date: Tue, 6 Apr 2004 11:52:17 -0700 +User-Agent: KMail/1.5.4 +Cc: +References: <009901c41b48$8357c860$2500fa0a@CardServices.TCI.com> + <19781.1081230442@sss.pgh.pa.us> + +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200404061152.17997.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/67 +X-Sequence-Number: 6367 + +Aaron, + +> I'm surprised by this thought. I tend to hit CPU bottlenecks more often than +> I/O ones. In most applications, db I/O is a combination of buffer misses and +> logging, which are both reasonably constrained. + +Not my experience at all. In fact, the only times I've seen modern platforms +max out the CPU was when: +a) I had bad queries with bad plans, or +b) I had reporting queires that did a lot of calculation for display (think +OLAP). + +Otherwise, on the numerous servers I administrate, RAM spikes, and I/O +bottlenecks, but the CPU stays almost flat. + +Of course, most of my apps are large databases (i.e. too big for RAM) with a +heavy transaction-processing component. + +What kind of applications are you running? + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Tue Apr 6 17:22:49 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id ECB71D1E086 + for ; + Tue, 6 Apr 2004 17:22:48 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 34495-06 + for ; + Tue, 6 Apr 2004 17:22:48 -0300 (ADT) +Received: from hotmail.com (law10-oe46.law10.hotmail.com [64.4.14.18]) + by svr1.postgresql.org (Postfix) with ESMTP id 4E3D9D1D12F + for ; + Tue, 6 Apr 2004 17:22:46 -0300 (ADT) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Tue, 6 Apr 2004 13:22:47 -0700 +Received: from 67.81.102.201 by law10-oe46.law10.hotmail.com with DAV; + Tue, 06 Apr 2004 20:22:47 +0000 +X-Originating-IP: [67.81.102.201] +X-Originating-Email: [awerman2@hotmail.com] +X-Sender: awerman2@hotmail.com +From: "Aaron Werman" +To: +Cc: +References: <009901c41b48$8357c860$2500fa0a@CardServices.TCI.com> + <19781.1081230442@sss.pgh.pa.us> + + <200404061152.17997.josh@agliodbs.com> +Subject: Re: possible improvement between G4 and G5 +Date: Tue, 6 Apr 2004 16:22:46 -0400 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1158 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +Message-ID: +X-OriginalArrivalTime: 06 Apr 2004 20:22:47.0833 (UTC) + FILETIME=[ED3CE090:01C41C14] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/69 +X-Sequence-Number: 6369 + + + +----- Original Message ----- +From: "Josh Berkus" +To: "Aaron Werman" ; "Qing Zhao" ; +"Tom Lane" +Cc: +Sent: Tuesday, April 06, 2004 2:52 PM +Subject: Re: [PERFORM] possible improvement between G4 and G5 + + +> Aaron, +> +> > I'm surprised by this thought. I tend to hit CPU bottlenecks more often +than +> > I/O ones. In most applications, db I/O is a combination of buffer misses +and +> > logging, which are both reasonably constrained. +> +> Not my experience at all. In fact, the only times I've seen modern +platforms +> max out the CPU was when: +> a) I had bad queries with bad plans, or +> b) I had reporting queires that did a lot of calculation for display +(think +> OLAP). +> +> Otherwise, on the numerous servers I administrate, RAM spikes, and I/O +> bottlenecks, but the CPU stays almost flat. +> +> Of course, most of my apps are large databases (i.e. too big for RAM) with +a +> heavy transaction-processing component. +> +> What kind of applications are you running? +> +> -- +> -Josh Berkus +> Aglio Database Solutions +> San Francisco +> +> + + + +I do consulting, so they're all over the place and tend to be complex. Very +few fit in RAM, but still are very buffered. These are almost all backed +with very high end I/O subsystems, with dozens of spindles with battery +backed up writethrough cache and gigs of buffers, which may be why I worry +so much about CPU. I have had this issue with multiple servers. + +Consider an analysis db with 10G data. Of that, 98% of the access is read +and only 2% write (that is normal for almost anything that is not order +entry, even transaction processing with thorough cross validation). Almost +all the queries access 10%, or 1G of the data. Of the reads, they average ~3 +level b-trees, with the first 2 levels certainly cached, and the last ones +often cached. Virtually all the I/O activity is logical reads against +buffer. A system with a 100 transactions which on average access 200 rows +does 98% of 200 rows x 100 transactions x 3 logical I/Os per read = 58,800 +logical reads, of which actually maybe a hundred are physical reads. It +also does 2% of 200 rows x 100 transactions x (1 table logical I/O and say 2 +index logical writes) per write = 1,200 logical writes to log, of which +there are 100 transaction commit synch writes, and in reality less than that +because of queuing against logs (there are also 1,200 logical writes +deferred to checkpoint, of which it is likely to only be 40 physical writes +because of page overlaps). + +Transaction processing is a spectrum between activity logging, and database +centric design. The former, where actions are stored in the database is +totally I/O bound with the engine acting as a thin layer of logical to +physical mapping. Database centric processing makes the engine a functional +server of discrete actions - and is a big CPU hog. + +What my CPU tends to be doing is a combination of general processing, +complex SQL processing: nested loops and sorting and hashing and triggers +and SPs. + +I'm curious about you having flat CPU, which is not my experience. Are your +apps mature and stable? + + + +/Aaron + +From pgsql-performance-owner@postgresql.org Tue Apr 6 17:26:01 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3CB01D1E0FD + for ; + Tue, 6 Apr 2004 17:25:59 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 33440-10 + for ; + Tue, 6 Apr 2004 17:25:58 -0300 (ADT) +Received: from mail4.speakeasy.net (mail4.speakeasy.net [216.254.0.204]) + by svr1.postgresql.org (Postfix) with ESMTP id 6450CD1DB0E + for ; + Tue, 6 Apr 2004 17:25:55 -0300 (ADT) +Received: (qmail 27061 invoked from network); 6 Apr 2004 20:25:56 -0000 +Received: from dsl093-130-165.sfo4.dsl.speakeasy.net (HELO speakeasy.org) + (kgeis@[66.93.130.165]) (envelope-sender ) + by mail4.speakeasy.net (qmail-ldap-1.03) with AES256-SHA encrypted SMTP + for ; 6 Apr 2004 20:25:56 -0000 +Message-ID: <40731252.2030002@speakeasy.org> +Date: Tue, 06 Apr 2004 13:25:54 -0700 +From: Ken Geis +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.5) Gecko/20031007 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: plan problem +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/70 +X-Sequence-Number: 6370 + +I am trying to find an efficient way to draw a random sample from a +complex query. I also want it to be easy to use within my application. + +So I've defined a view that encapsulates the query. The id in the +"driving" table is exposed, and I run a query like: + +select * from stats_record_view + where id in (select id from driver_stats + order by random() + limit 30000); + +driver_stats.id is unique, the primary key. The problem I'm having is +that neither the ORDER BY nor the LIMIT change the uniqueness of that +column, but the planner doesn't know that. It does a HashAggregate to +make sure the results are unique. It thinks that 200 rows will come out +of that operation, and then 200 rows is small enough that it thinks a +Nested Loop is the best way to proceed from there. + +I can post more query plan, but I don't think it would be that very +helpful. I'm considering just making a sample table and creating an +analogous view around that. I'd like to be able to keep this as simple +as possible though. + + +Ken + + + +From pgsql-admin-owner@postgresql.org Tue Apr 6 18:10:10 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8BEDBD1E92A + for ; + Tue, 6 Apr 2004 18:10:07 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 51438-10 + for ; + Tue, 6 Apr 2004 18:10:06 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 003A8D1E8FC + for ; Tue, 6 Apr 2004 18:10:04 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i36LA3Sx094816 + for ; Tue, 6 Apr 2004 21:10:03 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i36LA0Qh094624 + for pgsql-admin@postgresql.org; Tue, 6 Apr 2004 21:10:00 GMT +From: Chris Browne +X-Newsgroups: comp.databases.postgresql.admin +Subject: Re: Raw devices vs. Filesystems +Date: Tue, 06 Apr 2004 16:57:02 -0400 +Organization: cbbrowne Computing Inc +Lines: 23 +Message-ID: <603c7gj04h.fsf@dev6.int.libertyrms.info> +References: + <71E37EF6B7DCC1499CEA0316A25683280105786A@loki.wc.globexplorer.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@news.hub.org +User-Agent: Gnus/5.110002 (No Gnus v0.2) XEmacs/21.4 (Security Through + Obscurity, linux) +Cancel-Lock: sha1:15plkEF3LHVUmqYr2DqVhI1f/Z0= +To: pgsql-admin@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/96 +X-Sequence-Number: 13069 + +gsw@globexplorer.com ("Gregory S. Williamson") writes: +> No point to beating a dead horse (other than the sheer joy of the +> thing) since postgres does not have raw device support, but ... raw +> devices, at least on solaris, are about 10 times as fast as cooked +> file systems for Informix. This might still be a gain for postgres' +> performance, but the portability issues remain. + +That claim seems really rather remarkable. + +It implies an entirely stunning degree of inefficiency in the +implementation of filesystems on Solaris. + +The amount of indirection involved in walking through i-nodes and such +is something I would expect to introduce some percentage of +performance loss, but for it to introduce overhead of over 900% +presumably implies that Sun (and/or Veritas) got something really +horribly wrong. +-- +select 'cbbrowne' || '@' || 'cbbrowne.com'; +http://www.ntlug.org/~cbbrowne/nonrdbms.html +Rules of the Evil Overlord #1. "My Legions of Terror will have helmets +with clear plexiglass visors, not face-concealing ones." + + +From pgsql-performance-owner@postgresql.org Tue Apr 6 18:42:01 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E85CFD1B4F8 + for ; + Tue, 6 Apr 2004 18:41:57 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 67522-10 + for ; + Tue, 6 Apr 2004 18:41:58 -0300 (ADT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id C40CBD1B905 + for ; + Tue, 6 Apr 2004 18:41:55 -0300 (ADT) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4785389; Tue, 06 Apr 2004 14:43:17 -0700 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: "Aaron Werman" +Subject: Re: possible improvement between G4 and G5 +Date: Tue, 6 Apr 2004 14:41:53 -0700 +User-Agent: KMail/1.4.3 +Cc: +References: <009901c41b48$8357c860$2500fa0a@CardServices.TCI.com> + <200404061152.17997.josh@agliodbs.com> + +In-Reply-To: +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200404061441.53598.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/71 +X-Sequence-Number: 6371 + +Aaron, + +> I do consulting, so they're all over the place and tend to be complex. Very +> few fit in RAM, but still are very buffered. These are almost all backed +> with very high end I/O subsystems, with dozens of spindles with battery +> backed up writethrough cache and gigs of buffers, which may be why I worry +> so much about CPU. I have had this issue with multiple servers. + +Aha, I think this is the difference. I never seem to be able to get my +clients to fork out for adequate disk support. They are always running off +single or double SCSI RAID in the host server; not the sort of setup you +have. + +> What my CPU tends to be doing is a combination of general processing, +> complex SQL processing: nested loops and sorting and hashing and triggers +> and SPs. + +I haven't noticed SPs to be particularly CPU-hoggish, more RAM. + +> I'm curious about you having flat CPU, which is not my experience. Are your +> apps mature and stable? + +Well, "flat" was a bit of an exaggeration ... there are spikes ... but average +CPU load is < 30%. I think the difference is that your clients listen to +you about disk access. Mine are all too liable to purchase a quad-Xeon +machine but with an Adaptec RAID-5 card with 4 drives, and *then* call me and +ask for advice. + +As a result, most intensive operations don't tend to swamp the CPU because +they are waiting for disk. + +I have noticed the limitiations on RAM for 64 vs. 32, as I find it easier to +convince a client to get 8GB RAM than four-channel RAID with 12 drives, +mostly because the former is cheaper. Linux 2.4 + Bigmem just doesn't cut +it for making effective use of > 3GB of RAM. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Wed Apr 7 01:03:59 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 66841D1C9BB + for ; + Wed, 7 Apr 2004 01:03:58 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 83539-10 + for ; + Wed, 7 Apr 2004 01:03:54 -0300 (ADT) +Received: from mail (unknown [202.108.142.212]) + by svr1.postgresql.org (Postfix) with ESMTP id 45522D1C9C4 + for ; + Wed, 7 Apr 2004 01:03:53 -0300 (ADT) +Received: from HUANGYQ ([61.149.154.25]) + by mail.gthome.com (iPlanet Messaging Server 5.1 (built May 7 2001)) + with ESMTPA id <0HVS00F9M905F7@mail.gthome.com> for + pgsql-performance@postgresql.org; Wed, 07 Apr 2004 12:12:07 +0800 (CST) +Date: Wed, 07 Apr 2004 12:00:37 +0800 +From: huang yaqin +Subject: Re: good pc but bad performance,why? +To: Tom Lane +Cc: "pgsql-performance@postgresql.org" +Message-id: <0HVS00F9Q906F7@mail.gthome.com> +MIME-version: 1.0 +X-Mailer: Foxmail 4.2 [cn] +Content-type: text/plain; charset=GB2312 +Content-transfer-encoding: quoted-printable +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/72 +X-Sequence-Number: 6372 + +hello=A3=A1 + + Thanks, you are right. + I use "postmaster -o "-F" " to start my PG=A3=ACand performance improved = +greatly. + + Best regards, + huang yaqin + +>huang yaqin writes: +>> I have some question when I use postgresql 7.4.1 on redhat adv server 2= +.1 . +>> I use IBM335 as server, it has 4 cpus, 1G RAM. but I got very bad perfor= +mance. +>> I can only do about 50 inserts per sencond. Event worse than my pc(PIII = +800,256M RAM), can anyone give me some advice?=09 +> +>If the cheap machine appears to be able to commit more transactions +>per second than the better one, it's very likely because the cheap +>machine has a disk that lies about write completion. Is the server +>using SCSI disks by any chance? To a first approximation, IDE drives +>lie by default, SCSI drives don't. +> +> regards, tom lane +> +> +> +> +>Powered by MessageSoft SMG +>SPAM, virus-free and secure email +>http://www.messagesoft.com + +=3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D= + =3D +=09=09=09 + +=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=D6=C2 +=C0=F1=A3=A1 + +=09=09=09=09 +=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1huang yaqin +=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1hyq@gthome.com +=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A12004-04-07 + + + + +From pgsql-admin-owner@postgresql.org Wed Apr 7 02:26:06 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A6E61D1BB8C + for ; + Wed, 7 Apr 2004 02:26:05 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 11650-07 + for ; + Wed, 7 Apr 2004 02:26:05 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 40FD4D1D08F + for ; Wed, 7 Apr 2004 02:26:03 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i375Q2PU005720; + Wed, 7 Apr 2004 01:26:03 -0400 (EDT) +To: Chris Browne +Cc: pgsql-admin@postgresql.org +Subject: Re: Raw devices vs. Filesystems +In-reply-to: <603c7gj04h.fsf@dev6.int.libertyrms.info> +References: + <71E37EF6B7DCC1499CEA0316A25683280105786A@loki.wc.globexplorer.net> + <603c7gj04h.fsf@dev6.int.libertyrms.info> +Comments: In-reply-to Chris Browne + message dated "Tue, 06 Apr 2004 16:57:02 -0400" +Date: Wed, 07 Apr 2004 01:26:02 -0400 +Message-ID: <5719.1081315562@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/100 +X-Sequence-Number: 13073 + +Chris Browne writes: +> That claim seems really rather remarkable. +> It implies an entirely stunning degree of inefficiency in the +> implementation of filesystems on Solaris. + +Solaris has a reputation for having stunning degrees of inefficiency +in a number of places :-(. On the other hand I've also heard it praised +for its ability to survive partial hardware failures (eg, N out of M +CPUs down), so maybe that's the price you gotta pay. + +But to get back to the point of this discussion: to allow PG to use raw +devices instead of filesystems, we'd first have to do a ton of +portability work (since raw disk access is nowhere standard), and +abandon our principle that Postgres does not run as root (since raw disk +access is not permitted to non-root processes by any sane sysadmin). +But that last is a mighty comforting principle to have, anytime someone +complains that their el cheapo whitebox PC locks up as soon as they +start to stress the database. I know I'd have wasted a lot more time +chasing random hardware breakages if I couldn't say "system freezes and +filesystem corruption are Clearly Not Our Fault". + +After that, we get to implement our own filesystem-equivalent management +of disk space allocation, disk I/O scheduling, etc. Are we really +smarter than all those kernel hackers doing this for a living? I doubt it. + +After that, we get to re-optimize all the existing Postgres behaviors +that are designed to sit on top of a standard Unix buffering filesystem +layer. + +After that, we might reap some performance benefits. Or maybe not. +There's not a heck of a lot of hard evidence that we would --- and +what there is traces to twenty-year-old assumptions about disk drive +and OS behavior, which are quite unlikely to still apply today. + +Personally, I have a lot of more-promising projects to pursue... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Apr 7 04:15:33 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C1646D1BB16 + for ; + Wed, 7 Apr 2004 04:15:30 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 50922-01 + for ; + Wed, 7 Apr 2004 04:15:28 -0300 (ADT) +Received: from ol-mailrelay-01.fh-oldenburg.de + (ol-mailrelay-01.fh-oldenburg.de [139.13.186.99]) + by svr1.postgresql.org (Postfix) with ESMTP id 74853D1BAD6 + for ; + Wed, 7 Apr 2004 04:15:25 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by ol-mailrelay-01.fh-oldenburg.de (Postfix) with ESMTP id 148FA38C3F7 + for ; + Wed, 7 Apr 2004 09:06:42 +0200 (CEST) +Received: from ol-mailrelay-01.fh-oldenburg.de ([127.0.0.1]) + by localhost (ol-mailrelay-01 [127.0.0.1]) (amavisd-new, port 10023) + with ESMTP id 24456-03 for ; + Wed, 7 Apr 2004 09:06:41 +0200 (CEST) +Received: from webmail.fh-oldenburg.de (ol-mailrelay-01.fh-oldenburg.de + [139.13.186.99]) + by ol-mailrelay-01.fh-oldenburg.de (Postfix) with SMTP id B95F538C3F4 + for ; + Wed, 7 Apr 2004 09:06:41 +0200 (CEST) +Received: from 195.243.253.146 (SquirrelMail authenticated user kehlenbh) + by webmail.fh-oldenburg.de with HTTP; + Wed, 7 Apr 2004 09:06:41 +0200 (CEST) +Message-ID: + <39651.195.243.253.146.1081321601.squirrel@webmail.fh-oldenburg.de> +Date: Wed, 7 Apr 2004 09:06:41 +0200 (CEST) +Subject: Re: performance comparission postgresql/ms-sql server +From: "Heiko Kehlenbrink" +To: pgsql-performance@postgresql.org +User-Agent: SquirrelMail/1.4.2 +MIME-Version: 1.0 +Content-Type: text/plain;charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Priority: 3 +Importance: Normal +X-Virus-Scanned: by amavisd-new +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/73 +X-Sequence-Number: 6373 + +hi shridhar, + + +> Heiko Kehlenbrink wrote: +> +>> hi list, +>> +>> i want to convince people to use postgresql instead of ms-sql server, so i +>> set up a kind of comparission insert data / select data from postgresql / +>> ms-sql server +>> +>> the table i use was pretty basic, +>> +>> id bigserial +>> dist float8 +>> x float8 +>> y float8 +>> z float8 +>> +>> i filled the table with a function which filled x,y,z with incremental +increasing values (1,2,3,4,5,6...) and computing from that the dist +value +>> for every tupel (sqrt((x*x)+(y*y)+(z*z))). +>> +>> this works fine for both dbms +>> +>> postgresql needs 13:37 min for 10.000.000 tupel, +>> ms-sql needs 1:01:27 h for 10.000.000 tupel. +>> +>> so far so good. +>> +>> i attached an index on the dist row and started to query the dbs with +scripts which select a serial row of 100.000,200.000,500.000 tupels +based +>> on the dist row. +>> i randomizly compute the start and the end distance and made a "select +avg(dist) from table where dist > startdist and dist < enddist" +> +> Some basics to check quickly. +> +> 1. vacuum analyze the table before you start selecting. + +was done, + +> 2. for slow running queries, check explain analyze output and find out +who takes +> maximum time. + +hkehlenbrink@lin0493l:~> psql -d test -c 'explain analyse select avg(dist) +from massive2 where dist > (1000000*sqrt(3.0))::float8 and dist < +(1500000*sqrt(3.0))::float8;' +NOTICE: QUERY PLAN: + +Aggregate (cost=14884.61..14884.61 rows=1 width=8) (actual +time=3133.24..3133.24 rows=1 loops=1) + -> Index Scan using massive2_dist on massive2 (cost=0.00..13648.17 +rows=494573 width=8) (actual time=0.11..2061.38 rows=499999 loops=1) Total +runtime: 3133.79 msec + +EXPLAIN + +seems to me that most time was needed for the index scanning... + +> 3. Check for typecasting. You need to typecast the query correctly e.g. +> +> select avg(dist) from table where dist >startdist::float8 and +> dist +> This might still end up with sequential scan depending upon the plan. +but if +> index scan is picked up, it might be plenty fast.. +> +nope, the dist row is float8 and the query-borders are float8 too, also +the explain says that an index scann was done. + +> Post explain analyze for the queries if things don't improve. +> +see above.. + +> HTH +> +> Shridhar +> +best regards +heiko + + +> +> + + + + +From pgsql-admin-owner@postgresql.org Wed Apr 7 04:19:05 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 7F4ECD1B911; Wed, 7 Apr 2004 04:19:03 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 49595-06; Wed, 7 Apr 2004 04:19:02 -0300 (ADT) +Received: from elbereth.noviforum.si (unknown [193.189.169.66]) + by svr1.postgresql.org (Postfix) with ESMTP + id 5A853D1B515; Wed, 7 Apr 2004 04:19:00 -0300 (ADT) +Received: from elbereth.noviforum.si (localhost [127.0.0.1]) + by elbereth.noviforum.si (8.12.10/8.12.10) with ESMTP id i377IxHh014859; + Wed, 7 Apr 2004 09:18:59 +0200 +Received: (from gregab@localhost) + by elbereth.noviforum.si (8.12.10/8.12.10/Submit) id i377IwPq014845; + Wed, 7 Apr 2004 09:18:58 +0200 +Date: Wed, 7 Apr 2004 09:18:58 +0200 +From: Grega Bremec +To: Tom Lane +Cc: Chris Browne , pgsql-admin@postgresql.org, + pgsql-performance@postgresql.org +Subject: Re: Raw devices vs. Filesystems +Message-ID: <20040407071858.GA7973@elbereth.noviforum.si> +References: + <71E37EF6B7DCC1499CEA0316A25683280105786A@loki.wc.globexplorer.net> + <603c7gj04h.fsf@dev6.int.libertyrms.info> + <5719.1081315562@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; boundary="k1lZvvs/B4yU6o8G" +Content-Disposition: inline +In-Reply-To: <5719.1081315562@sss.pgh.pa.us> +User-Agent: Mutt/1.4.2i +Organization: Noviforum, Ltd., Software & Media +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/102 +X-Sequence-Number: 13075 + +--k1lZvvs/B4yU6o8G +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +Content-Transfer-Encoding: quoted-printable + +...and on Wed, Apr 07, 2004 at 01:26:02AM -0400, Tom Lane used the keyboard: +>=20 +> After that, we get to implement our own filesystem-equivalent management +> of disk space allocation, disk I/O scheduling, etc. Are we really +> smarter than all those kernel hackers doing this for a living? I doubt i= +t. +>=20 +> After that, we get to re-optimize all the existing Postgres behaviors +> that are designed to sit on top of a standard Unix buffering filesystem +> layer. +>=20 +> After that, we might reap some performance benefits. Or maybe not. +> There's not a heck of a lot of hard evidence that we would --- and +> what there is traces to twenty-year-old assumptions about disk drive +> and OS behavior, which are quite unlikely to still apply today. +>=20 +> Personally, I have a lot of more-promising projects to pursue... +>=20 + +Has anyone tried PostgreSQL on top of OCFS? Personally, I'm not sure it +would even work, as Oracle clearly state that OCFS was _never_ meant to +be a fully fledged UNIX filesystem with POSIX features such as correct +timestamp updates, inode changes, etc., but OCFSv2 brings some features +that might lead one into thinking they're about to make it suitable for +uses beyond that of just having Oracle databases sitting on top of it. + +Furthermore, this filesystem would be a blazing one stop solution for +all replication issues PostgreSQL currently suffers from, as its main +design goal was to present "a consistent file system image across the +servers in a cluster". + +Now, if both goals can be achieved in one go, hell, I'm willing to try +it out myself in an attempt to extract off of it, some performance +indicators that could be compared to other database performance tests +sent to both this and the PERFORM mailing list. + +So, anyone? :) + +Cheers, +--=20 + Grega Bremec + Senior Administrator + Noviforum Ltd., Software & Media + http://www.noviforum.si/ + +--k1lZvvs/B4yU6o8G +Content-Type: application/pgp-signature +Content-Disposition: inline + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.3 (GNU/Linux) + +iD8DBQFAc6tiDo/EMYD4+osRAu+xAJ4t6r9JMoTTgMH2q5I3ab6A0pqRUwCfU8Ky +o6Pu6BIKTMZw/dfgbdcY47M= +=029G +-----END PGP SIGNATURE----- + +--k1lZvvs/B4yU6o8G-- + +From pgsql-performance-owner@postgresql.org Wed Apr 7 05:33:20 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 48163D1B97B + for ; + Wed, 7 Apr 2004 05:33:17 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 76754-06 + for ; + Wed, 7 Apr 2004 05:33:17 -0300 (ADT) +Received: from anchor-post-33.mail.demon.net (anchor-post-33.mail.demon.net + [194.217.242.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 4F96CD1B515 + for ; + Wed, 7 Apr 2004 05:33:15 -0300 (ADT) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-33.mail.demon.net with esmtp (Exim 3.35 #1) + id 1BB8Um-000Lzg-0X; Wed, 07 Apr 2004 09:33:16 +0100 +Received: by mainbox.archonet.com (Postfix, from userid 529) + id 0B831165B0; Wed, 7 Apr 2004 09:33:14 +0100 (BST) +Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 1C7B21643F; Wed, 7 Apr 2004 09:33:13 +0100 (BST) +From: Richard Huxton +To: huang yaqin , Tom Lane +Subject: Re: good pc but bad performance,why? +Date: Wed, 7 Apr 2004 09:33:12 +0100 +User-Agent: KMail/1.5 +Cc: "pgsql-performance@postgresql.org" +References: <0HVS00F9Q906F7@mail.gthome.com> +In-Reply-To: <0HVS00F9Q906F7@mail.gthome.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="gb2312" +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +Message-Id: <200404070933.12544.dev@archonet.com> +X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/75 +X-Sequence-Number: 6375 + +On Wednesday 07 April 2004 05:00, huang yaqin wrote: +> hello=A3=A1 +> +> Thanks, you are right. +> I use "postmaster -o "-F" " to start my PG=A3=ACand performance improved +> greatly. + +I don't think Tom was recommending turning fsync off. If you have a system= +=20 +crash/power glitch then the database can become corrupted. + +If you are happy the possibility if losing your data, write performance wil= +l=20 +improve noticably. + +--=20 + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Wed Apr 7 05:38:17 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4EE24D1B459 + for ; + Wed, 7 Apr 2004 05:38:16 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 82267-01 + for ; + Wed, 7 Apr 2004 05:38:16 -0300 (ADT) +Received: from anchor-post-34.mail.demon.net (anchor-post-34.mail.demon.net + [194.217.242.92]) + by svr1.postgresql.org (Postfix) with ESMTP id EF093D1C4C4 + for ; + Wed, 7 Apr 2004 05:38:13 -0300 (ADT) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-34.mail.demon.net with esmtp (Exim 3.35 #1) + id 1BB8Zb-000CTT-0Y; Wed, 07 Apr 2004 09:38:15 +0100 +Received: by mainbox.archonet.com (Postfix, from userid 529) + id 1A17A1643F; Wed, 7 Apr 2004 09:38:14 +0100 (BST) +Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 19E3A1643F; Wed, 7 Apr 2004 09:38:12 +0100 (BST) +From: Richard Huxton +To: Ken Geis , pgsql-performance@postgresql.org +Subject: Re: plan problem +Date: Wed, 7 Apr 2004 09:38:11 +0100 +User-Agent: KMail/1.5 +References: <40731252.2030002@speakeasy.org> +In-Reply-To: <40731252.2030002@speakeasy.org> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200404070938.11482.dev@archonet.com> +X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/76 +X-Sequence-Number: 6376 + +On Tuesday 06 April 2004 21:25, Ken Geis wrote: +> I am trying to find an efficient way to draw a random sample from a +> complex query. I also want it to be easy to use within my application. +> +> So I've defined a view that encapsulates the query. The id in the +> "driving" table is exposed, and I run a query like: +> +> select * from stats_record_view +> where id in (select id from driver_stats +> order by random() +> limit 30000); + +How about a join? + +SELECT s.* +FROM +stats_record_view s +JOIN +(SELECT id FROM driver_stats ORDER BY random() LIMIT 30000) AS r +ON s.id = r.id; + +Or, what about a cursor and fetch forward (or back?) a random number of rows +before each fetch. That's probably not going to be so random though. + +Also worth checking the various list archives - this has come up in the past, +but some time ago. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Wed Apr 7 06:00:44 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 024B5D1C9C4 + for ; + Wed, 7 Apr 2004 06:00:39 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 91514-02 + for ; + Wed, 7 Apr 2004 06:00:37 -0300 (ADT) +Received: from mail (unknown [202.108.142.212]) + by svr1.postgresql.org (Postfix) with ESMTP id 5DB39D1C995 + for ; + Wed, 7 Apr 2004 06:00:34 -0300 (ADT) +Received: from HUANGYQ ([61.149.145.64]) + by mail.gthome.com (iPlanet Messaging Server 5.1 (built May 7 2001)) + with ESMTPA id <0HVS00G7EMQG35@mail.gthome.com> for + pgsql-performance@postgresql.org; Wed, 07 Apr 2004 17:08:49 +0800 (CST) +Date: Wed, 07 Apr 2004 16:56:56 +0800 +From: huang yaqin +Subject: Re: good pc but bad performance,why? +To: Richard Huxton +Cc: "pgsql-performance@postgresql.org" +Message-id: <0HVS00G7FMQO35@mail.gthome.com> +MIME-version: 1.0 +X-Mailer: Foxmail 4.2 [cn] +Content-type: text/plain; charset=GB2312 +Content-transfer-encoding: quoted-printable +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/77 +X-Sequence-Number: 6377 + +Hello, Richard Huxton, +=09 + You said turning fsync off may cause losing data, that's terrible. + I use SCSI disk, and file system is ext3. I tune postgresql.conf and can't= + get any improvement. So what can I do? + Does SCSI disk and IDE disk have difference? + + Regards, + Huang yaqin + +=3D=3D=3D=3D=3D=3D=3D 2004-04-07 09:33:00 =3D=3D=3D=3D=3D=3D=3D + +>On Wednesday 07 April 2004 05:00, huang yaqin wrote: +>> hello=A3=A1 +>> +>> Thanks, you are right. +>> I use "postmaster -o "-F" " to start my PG=A3=ACand performance improv= +ed +>> greatly. +> +>I don't think Tom was recommending turning fsync off. If you have a system +>crash/power glitch then the database can become corrupted. +> +>If you are happy the possibility if losing your data, write performance wi= +ll +>improve noticably. +> +>-- +> Richard Huxton +> Archonet Ltd +> +> +> +> +>Powered by MessageSoft SMG +>SPAM, virus-free and secure email +>http://www.messagesoft.com +> +>. + +=3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D= + =3D +=09=09=09 + +=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=D6=C2 +=C0=F1=A3=A1 + +=09=09=09=09 +=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1huang yaqin +=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1hyq@gthome.com +=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A12004-04-07 + + + + +From pgsql-performance-owner@postgresql.org Wed Apr 7 06:03:33 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B27B3D1CC93 + for ; + Wed, 7 Apr 2004 06:03:30 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 89770-08 + for ; + Wed, 7 Apr 2004 06:03:30 -0300 (ADT) +Received: from mail2.speakeasy.net (mail2.speakeasy.net [216.254.0.202]) + by svr1.postgresql.org (Postfix) with ESMTP id 56F76D1CACC + for ; + Wed, 7 Apr 2004 06:03:27 -0300 (ADT) +Received: (qmail 15087 invoked from network); 7 Apr 2004 09:03:28 -0000 +Received: from dsl093-130-165.sfo4.dsl.speakeasy.net (HELO speakeasy.org) + (kgeis@[66.93.130.165]) (envelope-sender ) + by mail2.speakeasy.net (qmail-ldap-1.03) with AES256-SHA encrypted SMTP + for ; 7 Apr 2004 09:03:28 -0000 +Message-ID: <4073C3DF.2070307@speakeasy.org> +Date: Wed, 07 Apr 2004 02:03:27 -0700 +From: Ken Geis +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.5) Gecko/20031007 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Richard Huxton , + pgsql-performance@postgresql.org +Subject: Re: plan problem +References: <40731252.2030002@speakeasy.org> + <200404070938.11482.dev@archonet.com> +In-Reply-To: <200404070938.11482.dev@archonet.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/78 +X-Sequence-Number: 6378 + +Richard Huxton wrote: +> On Tuesday 06 April 2004 21:25, Ken Geis wrote: +> +>>I am trying to find an efficient way to draw a random sample from a +>>complex query. I also want it to be easy to use within my application. +>> +>>So I've defined a view that encapsulates the query. The id in the +>>"driving" table is exposed, and I run a query like: +>> +>>select * from stats_record_view +>> where id in (select id from driver_stats +>> order by random() +>> limit 30000); +> +> +> How about a join? +> +> SELECT s.* +> FROM +> stats_record_view s +> JOIN +> (SELECT id FROM driver_stats ORDER BY random() LIMIT 30000) AS r +> ON s.id = r.id; + +Yes, I tried this too after I sent the first mail, and this was somewhat +better. I ended up adding a random column to the driving table, putting +an index on it, and exposing that column in the view. Now I can say + +SELECT * FROM stats_record_view WHERE random < 0.093; + +For my application, it's OK if the same sample is picked time after time +and it may change if data is added. + +... +> Also worth checking the various list archives - this has come up in the past, +> but some time ago. + +There are some messages in the archives about how to get a random +sample. I know how to do that, and that's not why I posted my message. + Are you saying that the planner behavior I spoke of is in the +archives? I wouldn't know what to search on to find that thread. Does +anyone think that the planner issue has merit to address? Can someone +help me figure out what code I would look at? + + +Ken Geis + + + +From pgsql-performance-owner@postgresql.org Wed Apr 7 06:54:01 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2B889D1B893 + for ; + Wed, 7 Apr 2004 06:53:59 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 08926-07 + for ; + Wed, 7 Apr 2004 06:54:00 -0300 (ADT) +Received: from zigo.dhs.org (as2-4-3.an.g.bonet.se [194.236.34.191]) + by svr1.postgresql.org (Postfix) with ESMTP id 5F50FD1BA2E + for ; + Wed, 7 Apr 2004 06:53:57 -0300 (ADT) +Received: from zigo.zigo.dhs.org (zigo.zigo.dhs.org [192.168.0.1]) + by zigo.dhs.org (Postfix) with ESMTP + id 79E8586FA; Wed, 7 Apr 2004 11:53:59 +0200 (CEST) +Date: Wed, 7 Apr 2004 11:53:59 +0200 (CEST) +From: Dennis Bjorklund +To: huang yaqin +Cc: Richard Huxton , + "pgsql-performance@postgresql.org" +Subject: Re: good pc but bad performance,why? +In-Reply-To: <0HVS00G7FMQO35@mail.gthome.com> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=ISO-8859-1 +Content-Transfer-Encoding: 8BIT +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/79 +X-Sequence-Number: 6379 + +On Wed, 7 Apr 2004, huang yaqin wrote: + +> You said turning fsync off may cause losing data, that's terrible. I use +> SCSI disk, and file system is ext3. I tune postgresql.conf and can't get +> any improvement. So what can I do? + +Make sure you do as much as possible inside one transaction. If you want +to do 1000 inserts, then do BEGIN; insert ....; insert; ... ; COMMIT; + +-- +/Dennis Bj�rklund + + +From pgsql-performance-owner@postgresql.org Wed Apr 7 07:41:19 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 36660D1C9F3 + for ; + Wed, 7 Apr 2004 07:41:17 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 28071-04 + for ; + Wed, 7 Apr 2004 07:41:13 -0300 (ADT) +Received: from gizmo08bw.bigpond.com (gizmo08bw.bigpond.com [144.140.70.18]) + by svr1.postgresql.org (Postfix) with SMTP id 8F672D1BCB8 + for ; + Wed, 7 Apr 2004 07:41:09 -0300 (ADT) +Received: (qmail 17836 invoked from network); 7 Apr 2004 10:31:59 -0000 +Received: from unknown (HELO bwmam08.bigpond.com) (144.135.24.91) + by gizmo08bw.bigpond.com with SMTP; 7 Apr 2004 10:31:59 -0000 +Received: from cpe-203-45-197-156.qld.bigpond.net.au ([203.45.197.156]) by + bwmam08.bigpond.com(MAM REL_3_4_2 135/13709782) with SMTP id + 13709782; Wed, 07 Apr 2004 20:41:09 +1000 +Message-ID: <001c01c41c8c$993eded0$fd08a8c0@steve> +From: "Steven Butler" +To: "huang yaqin" +Cc: +References: <0HVS00G7FMQO35@mail.gthome.com> +Subject: Re: good pc but bad performance,why? +Date: Wed, 7 Apr 2004 20:39:25 +1000 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="gb2312" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1158 +X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/80 +X-Sequence-Number: 6380 + +It sounds almost like you're doing one insert per transaction. Try wrapping +multiple inserts into a single transaction and see if that helps. This may +not be appropriate for your application, but it does guarantee that +committed transactions will not be lost. + +My apologies if you are already doing this. :) + +BEGIN; +insert ... +insert ... +insert ... +COMMIT; + +Regards, +Steve Butler + +----- Original Message ----- +From: "huang yaqin" +To: "Richard Huxton" +Cc: +Sent: Wednesday, April 07, 2004 6:56 PM +Subject: Re: [PERFORM] good pc but bad performance,why? + + +Hello, Richard Huxton, + + You said turning fsync off may cause losing data, that's terrible. +I use SCSI disk, and file system is ext3. I tune postgresql.conf and can't +get any improvement. So what can I do? +Does SCSI disk and IDE disk have difference? + + Regards, +Huang yaqin + + + +From pgsql-performance-owner@postgresql.org Wed Apr 7 08:30:15 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 73BC0D1D05D + for ; + Wed, 7 Apr 2004 08:30:12 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 41465-09 + for ; + Wed, 7 Apr 2004 08:30:12 -0300 (ADT) +Received: from lamb.mcmillan.net.nz (218-101-13-8.paradise.net.nz + [218.101.13.8]) + by svr1.postgresql.org (Postfix) with ESMTP id 04890D1BAD5 + for ; + Wed, 7 Apr 2004 08:30:09 -0300 (ADT) +Received: from lamb.mcmillan.net.nz (lamb.mcmillan.net.nz [127.0.0.1]) + by lamb.mcmillan.net.nz (Postfix) with ESMTP + id 4F737AD98581; Wed, 7 Apr 2004 23:29:43 +1200 (NZST) +Subject: Re: good pc but bad performance,why? +From: Andrew McMillan +To: huang yaqin +Cc: pgsql-performance@postgresql.org +In-Reply-To: <0HVS00G7FMQO35@mail.gthome.com> +References: <0HVS00G7FMQO35@mail.gthome.com> +Content-Type: text/plain +Message-Id: <1081337381.522.57.camel@lamb.mcmillan.net.nz> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Wed, 07 Apr 2004 23:29:42 +1200 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/81 +X-Sequence-Number: 6381 + +On Wed, 2004-04-07 at 20:56, huang yaqin wrote: +> Hello, Richard Huxton, +> +> You said turning fsync off may cause losing data, that's terrible. +> I use SCSI disk, and file system is ext3. I tune postgresql.conf and can't get any improvement. So what can I do? +> Does SCSI disk and IDE disk have difference? + +Yes, turning off fsync means that the database is not guaranteeing +consistency of writes to disk any longer. On the other hand your IDE +system probably never was, because IDE drives just typically turn on +write caching in hardware without telling anyone. + +SCSI typically doesn't turn on write caching in the physical drive by +default, as Tom Lane pointed out earlier. Good SCSI has a battery +backed up cache, and then it is OK to turn on write caching, because the +controller has enough battery to complete all writes in the event of a +power failure. + +One thing I recommend is to use ext2 (or almost anything but ext3). +There is no real need (or benefit) from having the database on a +journalled filesystem - the journalling is only trying to give similar +sorts of guarantees to what the fsync in PostgreSQL is doing. + +The suggestion someone else made regarding use of software raid is +probably also a good one if you are trying to use the on-board RAID at +the moment. + +Finally, I would say that because you are seeing poor performance on one +box and great performance on another, you should look at the hardware, +or at the hardware drivers, for the problem - not so much at PostgreSQL. + +Of course if it is application performance you want to achieve, we _can_ +help here, but you will need to provide more details of what you are +trying to do in your application, including; + - confirmation that you have done a VACUUM and ANALYZE of all tables +before you start + - output from EXPLAIN ANALYZE for slow queries + - anything else you think is useful. + +without that sort of detail we can only give vague suggestions, like +"wrap everything in a transaction" - excellent advice, certainly, but +you can read that in the manual. + +There are no magic bullets, but I am sure most of the people on this +list have systems that regularly do way more than 50 inserts / second on +server hardware. + +Regards, + Andrew McMillan + +------------------------------------------------------------------------- +Andrew @ Catalyst .Net .NZ Ltd, PO Box 11-053, Manners St, Wellington +WEB: http://catalyst.net.nz/ PHYS: Level 2, 150-154 Willis St +DDI: +64(4)916-7201 MOB: +64(21)635-694 OFFICE: +64(4)499-2267 + http://survey.net.nz/ - any questions? +------------------------------------------------------------------------- + + +From pgsql-performance-owner@postgresql.org Fri Apr 9 21:25:44 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E0641D1D066 + for ; + Wed, 7 Apr 2004 08:51:50 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 51172-08 + for ; + Wed, 7 Apr 2004 08:51:50 -0300 (ADT) +Received: from smtp.pspl.co.in (unknown [202.54.11.65]) + by svr1.postgresql.org (Postfix) with ESMTP id 116B2D1C50B + for ; + Wed, 7 Apr 2004 08:51:45 -0300 (ADT) +Received: (from root@localhost) + by smtp.pspl.co.in (8.12.9/8.12.9) id i37BpuoO026414 + for ; Wed, 7 Apr 2004 17:21:56 +0530 +X-Scanned: XAM28854 Scanned by XAMIME +Received: from ps0499.intranet.pspl.co.in (PS0499.intranet.pspl.co.in + [192.168.10.204]) (authenticated bits=0) + by persistent.co.in (8.12.9/8.12.9) with ESMTP id i37Bpr26026372; + Wed, 7 Apr 2004 17:21:54 +0530 +From: Shridhar Daithankar +To: Andrew McMillan +Subject: Re: good pc but bad performance,why? +Date: Wed, 7 Apr 2004 17:21:43 +0530 +User-Agent: KMail/1.6.1 +Cc: huang yaqin , pgsql-performance@postgresql.org +References: <0HVS00G7FMQO35@mail.gthome.com> + <1081337381.522.57.camel@lamb.mcmillan.net.nz> +In-Reply-To: <1081337381.522.57.camel@lamb.mcmillan.net.nz> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200404071721.43059.shridhar_daithankar@persistent.co.in> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/124 +X-Sequence-Number: 6424 + +On Wednesday 07 April 2004 16:59, Andrew McMillan wrote: +> One thing I recommend is to use ext2 (or almost anything but ext3). +> There is no real need (or benefit) from having the database on a +> journalled filesystem - the journalling is only trying to give similar +> sorts of guarantees to what the fsync in PostgreSQL is doing. + +That is not correct assumption. A journalling file system ensures file system +consistency even at a cost of loss of some data. And postgresql can not +guarantee recovery if WAL logs are corrupt. Some months back, there was a +case reported where ext2 corrupted WAL and database. BAckup is only solution +then.. + +Journalling file systems are usually very close to ext2 in performance, many a +times lot better. With ext2, you are buying a huge risk. + +Unless there are good reason, I would not put a database on ext2. Performance +isn't one ofthem.. + + Shridhar + +From pgsql-performance-owner@postgresql.org Wed Apr 7 08:54:45 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B46BDD1C4C4 + for ; + Wed, 7 Apr 2004 08:54:43 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 55872-05 + for ; + Wed, 7 Apr 2004 08:54:45 -0300 (ADT) +Received: from frodo.hserus.net (frodo.hserus.net [204.74.68.40]) + by svr1.postgresql.org (Postfix) with ESMTP id CA8A3D1BC5C + for ; + Wed, 7 Apr 2004 08:54:41 -0300 (ADT) +Received: from concord.pspl.co.in ([202.54.11.72]:61805 + helo=ps0499.intranet.pspl.co.in) by frodo.hserus.net with asmtp + (Cipher TLSv1:RC4-MD5:128) (Exim 4.31 #0) + id 1BBBdk-000IKR-2P by authid with plain + for ; Wed, 07 Apr 2004 17:24:44 +0530 +From: Shridhar Daithankar +Reply-To: shridhar@frodo.hserus.net +To: pgsql-performance@postgresql.org +Subject: Re: good pc but bad performance,why? +Date: Wed, 7 Apr 2004 17:24:41 +0530 +User-Agent: KMail/1.6.1 +References: <0HVS00G7FMQO35@mail.gthome.com> + <1081337381.522.57.camel@lamb.mcmillan.net.nz> + <200404071721.43059.shridhar_daithankar@persistent.co.in> +In-Reply-To: <200404071721.43059.shridhar_daithankar@persistent.co.in> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200404071724.41860.shridhar@frodo.hserus.net> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/82 +X-Sequence-Number: 6382 + +Sending again bacuse of MUA error.. Chose a wrong address in From..:-( + + Shridhar + +On Wednesday 07 April 2004 17:21, Shridhar Daithankar wrote: +> On Wednesday 07 April 2004 16:59, Andrew McMillan wrote: +> > One thing I recommend is to use ext2 (or almost anything but ext3). +> > There is no real need (or benefit) from having the database on a +> > journalled filesystem - the journalling is only trying to give similar +> > sorts of guarantees to what the fsync in PostgreSQL is doing. +> +> That is not correct assumption. A journalling file system ensures file +> system consistency even at a cost of loss of some data. And postgresql can +> not guarantee recovery if WAL logs are corrupt. Some months back, there was +> a case reported where ext2 corrupted WAL and database. BAckup is only +> solution then.. +> +> Journalling file systems are usually very close to ext2 in performance, +> many a times lot better. With ext2, you are buying a huge risk. +> +> Unless there are good reason, I would not put a database on ext2. +> Performance isn't one ofthem.. +> +> Shridhar + +From pgsql-performance-owner@postgresql.org Wed Apr 7 09:31:36 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 16C76D1D064 + for ; + Wed, 7 Apr 2004 09:31:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 73273-03 + for ; + Wed, 7 Apr 2004 09:31:35 -0300 (ADT) +Received: from anchor-post-33.mail.demon.net (anchor-post-33.mail.demon.net + [194.217.242.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 5F09FD1BC5C + for ; + Wed, 7 Apr 2004 09:31:31 -0300 (ADT) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-33.mail.demon.net with esmtp (Exim 3.35 #1) + id 1BBCDO-000BEf-0X; Wed, 07 Apr 2004 13:31:34 +0100 +Received: by mainbox.archonet.com (Postfix, from userid 529) + id 2EB95165A8; Wed, 7 Apr 2004 13:31:33 +0100 (BST) +Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 922E11639A; Wed, 7 Apr 2004 13:31:30 +0100 (BST) +From: Richard Huxton +To: Ken Geis , pgsql-performance@postgresql.org +Subject: Re: plan problem +Date: Wed, 7 Apr 2004 13:31:30 +0100 +User-Agent: KMail/1.5 +References: <40731252.2030002@speakeasy.org> + <200404070938.11482.dev@archonet.com> + <4073C3DF.2070307@speakeasy.org> +In-Reply-To: <4073C3DF.2070307@speakeasy.org> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200404071331.30925.dev@archonet.com> +X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/83 +X-Sequence-Number: 6383 + +On Wednesday 07 April 2004 10:03, Ken Geis wrote: +> Richard Huxton wrote: +> > On Tuesday 06 April 2004 21:25, Ken Geis wrote: +> >>I am trying to find an efficient way to draw a random sample from a +> >>complex query. I also want it to be easy to use within my application. +> >> +> >>So I've defined a view that encapsulates the query. The id in the +> >>"driving" table is exposed, and I run a query like: +> >> +> >>select * from stats_record_view +> >> where id in (select id from driver_stats +> >> order by random() +> >> limit 30000); +> > +> > How about a join? +> > +> > SELECT s.* +> > FROM +> > stats_record_view s +> > JOIN +> > (SELECT id FROM driver_stats ORDER BY random() LIMIT 30000) AS r +> > ON s.id = r.id; +> +> Yes, I tried this too after I sent the first mail, and this was somewhat +> better. I ended up adding a random column to the driving table, putting +> an index on it, and exposing that column in the view. Now I can say +> +> SELECT * FROM stats_record_view WHERE random < 0.093; +> +> For my application, it's OK if the same sample is picked time after time +> and it may change if data is added. + +Fair enough - that'll certainly do it. + +> > Also worth checking the various list archives - this has come up in the +> > past, but some time ago. +> +> There are some messages in the archives about how to get a random +> sample. I know how to do that, and that's not why I posted my message. +> Are you saying that the planner behavior I spoke of is in the +> archives? I wouldn't know what to search on to find that thread. Does +> anyone think that the planner issue has merit to address? Can someone +> help me figure out what code I would look at? + +I was assuming after getting a random subset they'd see the same problem you +are. If not, probably worth looking at. In which case, an EXPLAIN ANALYZE of +your original query would be good. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-admin-owner@postgresql.org Wed Apr 7 10:10:41 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 125CAD1B459 + for ; + Wed, 7 Apr 2004 10:10:40 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 94333-01 + for ; + Wed, 7 Apr 2004 10:10:41 -0300 (ADT) +Received: from main.gmane.org (main.gmane.org [80.91.224.249]) + by svr1.postgresql.org (Postfix) with ESMTP id 5E5EED1CB3F + for ; Wed, 7 Apr 2004 10:10:37 -0300 (ADT) +Received: from root by main.gmane.org with local (Exim 3.35 #1 (Debian)) + id 1BBCpE-0001tD-00 + for ; Wed, 07 Apr 2004 15:10:40 +0200 +Received: from srv.protecting.net ([212.126.218.242]) + by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) + id 1AlnuQ-0007hv-00 + for ; Wed, 07 Apr 2004 15:10:40 +0200 +Received: from hf320 by srv.protecting.net with local (Gmexim 0.1 (Debian)) + id 1AlnuQ-0007hv-00 + for ; Wed, 07 Apr 2004 15:10:40 +0200 +X-Injected-Via-Gmane: http://gmane.org/ +To: pgsql-admin@postgresql.org +From: Harald Fuchs +Subject: Re: Raw devices vs. Filesystems +Date: 07 Apr 2004 15:05:55 +0200 +Organization: Linux Private Site +Lines: 19 +Message-ID: +References: + <71E37EF6B7DCC1499CEA0316A25683280105786A@loki.wc.globexplorer.net> + <603c7gj04h.fsf@dev6.int.libertyrms.info> + <5719.1081315562@sss.pgh.pa.us> +Reply-To: hf320@protecting.net +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +X-Complaints-To: usenet@sea.gmane.org +X-Gmane-NNTP-Posting-Host: srv.protecting.net +X-No-Archive: yes +User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/105 +X-Sequence-Number: 13078 + +In article <5719.1081315562@sss.pgh.pa.us>, +Tom Lane writes: + +> But to get back to the point of this discussion: to allow PG to use raw +> devices instead of filesystems, we'd first have to do a ton of +> portability work (since raw disk access is nowhere standard), and +> abandon our principle that Postgres does not run as root (since raw disk +> access is not permitted to non-root processes by any sane sysadmin). + +Why not? In MySQL/InnoDB, you do a "chown mysql.daemon /dev/raw/raw1" +(or whatever raw disk you want to access), and that's all. + +> After that, we get to implement our own filesystem-equivalent management +> of disk space allocation, disk I/O scheduling, etc. Are we really +> smarter than all those kernel hackers doing this for a living? I doubt it. + +Ditto. I don't have hard numbers for MySQL, but I didn't see any +noticeable improvement when messing with raw disks (at least under +Linux). + + +From pgsql-performance-owner@postgresql.org Wed Apr 7 11:36:49 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 947C6D1CA50 + for ; + Wed, 7 Apr 2004 11:36:45 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 27142-09 + for ; + Wed, 7 Apr 2004 11:36:46 -0300 (ADT) +Received: from hotmail.com (law10-oe60.law10.hotmail.com [64.4.14.195]) + by svr1.postgresql.org (Postfix) with ESMTP id BF362D1BAD5 + for ; + Wed, 7 Apr 2004 11:36:41 -0300 (ADT) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Wed, 7 Apr 2004 07:36:45 -0700 +Received: from 67.81.102.201 by law10-oe60.law10.hotmail.com with DAV; + Wed, 07 Apr 2004 14:36:45 +0000 +X-Originating-IP: [67.81.102.201] +X-Originating-Email: [awerman2@hotmail.com] +X-Sender: awerman2@hotmail.com +From: "Aaron Werman" +Cc: +References: <0HVS00F9Q906F7@mail.gthome.com> + <200404070933.12544.dev@archonet.com> +Subject: Re: good pc but bad performance,why? +Date: Wed, 7 Apr 2004 10:36:48 -0400 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="GB2312" +Content-Transfer-Encoding: 8bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1158 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +Message-ID: +X-OriginalArrivalTime: 07 Apr 2004 14:36:45.0889 (UTC) + FILETIME=[C0916310:01C41CAD] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/84 +X-Sequence-Number: 6384 + +fsync I'm thinking 50 inserts, if autocommiting is 50TPS = ~100 IO per +second (50 WAL + checkpoint IO) = roughly the I/O rate of a single drive. + +Huang - Are you using a single drive for pg? If so, there is a safety +problem of both the data and logs used for recovery on the same drive. If +the drive crashes, there is nothing left for recovery. + +Also, there is a big contention issue, since the log is a fast sequential +write, and checkpointing is random. If the log is on a separate drive, +you'll probably see insert speed at disk sequential write speed, since the +other drive(s) should hopefully be able to keep up when checkpointing. If +they share the same drive, you'll see an initial burst of inserts, then a +order of magnitude performance drop-off as soon as you checkpoint - because +the disk is interleaving the log and data writes. + +fsync off is only appropriate for externally recoverable processes, such as +loading an empty server from a file. + +/Aaron + +----- Original Message ----- +From: "Richard Huxton" +To: "huang yaqin" ; "Tom Lane" +Cc: +Sent: Wednesday, April 07, 2004 4:33 AM +Subject: Re: [PERFORM] good pc but bad performance,why? + + +On Wednesday 07 April 2004 05:00, huang yaqin wrote: +> hello�� +> +> Thanks, you are right. +> I use "postmaster -o "-F" " to start my PG��and performance improved +> greatly. + +I don't think Tom was recommending turning fsync off. If you have a system +crash/power glitch then the database can become corrupted. + +If you are happy the possibility if losing your data, write performance will +improve noticably. + +-- + Richard Huxton + Archonet Ltd + +---------------------------(end of broadcast)--------------------------- +TIP 4: Don't 'kill -9' the postmaster + +From pgsql-admin-owner@postgresql.org Wed Apr 7 13:09:35 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 06B67D1B9EB; Wed, 7 Apr 2004 13:09:31 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 79265-01; Wed, 7 Apr 2004 13:09:28 -0300 (ADT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP + id A5209D1B989; Wed, 7 Apr 2004 13:09:26 -0300 (ADT) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4790870; Wed, 07 Apr 2004 09:10:47 -0700 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: Grega Bremec , Tom Lane +Subject: Re: [PERFORM] Raw devices vs. Filesystems +Date: Wed, 7 Apr 2004 09:09:16 -0700 +User-Agent: KMail/1.4.3 +Cc: Chris Browne , pgsql-admin@postgresql.org, + pgsql-performance@postgresql.org +References: + <71E37EF6B7DCC1499CEA0316A25683280105786A@loki.wc.globexplorer.net> + <5719.1081315562@sss.pgh.pa.us> + <20040407071858.GA7973@elbereth.noviforum.si> +In-Reply-To: <20040407071858.GA7973@elbereth.noviforum.si> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200404070909.16123.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/109 +X-Sequence-Number: 13082 + +Grega, + +> Furthermore, this filesystem would be a blazing one stop solution for +> all replication issues PostgreSQL currently suffers from, as its main +> design goal was to present "a consistent file system image across the +> servers in a cluster". + +Does it work, though? Without Oracle admin tools? + +> Now, if both goals can be achieved in one go, hell, I'm willing to try +> it out myself in an attempt to extract off of it, some performance +> indicators that could be compared to other database performance tests +> sent to both this and the PERFORM mailing list. + +Hey, any test you wanna run is fine with us. I'm pretty sure that OCFS +belongs to Oracle, though, patent & copyright, so we couldn't actually use it +in practice. + +If your intention in this test is to show the superiority of raw devices, let +me give you a reality check: barring some major corporate backing getting +involved, we can't possibly implement our own PG-FS for database support. We +already have a TODO list which is far too long for our developer pool, and +implementing a custom FS either takes a large team (OCFS) or several years of +development (Reiser). + +Now, if you know somebody who might pay for one, then great .... + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-admin-owner@postgresql.org Wed Apr 7 13:37:47 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 03D00D1C951; Wed, 7 Apr 2004 13:37:44 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 85699-09; Wed, 7 Apr 2004 13:37:42 -0300 (ADT) +Received: from gp.word-to-the-wise.com (gp.word-to-the-wise.com + [64.71.176.18]) + by svr1.postgresql.org (Postfix) with ESMTP + id 73E78D1BA90; Wed, 7 Apr 2004 13:37:41 -0300 (ADT) +Received: by gp.word-to-the-wise.com (Postfix, from userid 500) + id 14FC1900060; Wed, 7 Apr 2004 09:29:47 -0700 (PDT) +Date: Wed, 7 Apr 2004 09:29:47 -0700 +From: Steve Atkins +To: pgsql-admin@postgresql.org +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Raw devices vs. Filesystems +Message-ID: <20040407162946.GA7271@gp.word-to-the-wise.com> +References: + <71E37EF6B7DCC1499CEA0316A25683280105786A@loki.wc.globexplorer.net> + <5719.1081315562@sss.pgh.pa.us> + <20040407071858.GA7973@elbereth.noviforum.si> + <200404070909.16123.josh@agliodbs.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <200404070909.16123.josh@agliodbs.com> +User-Agent: Mutt/1.4.1i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/111 +X-Sequence-Number: 13084 + +On Wed, Apr 07, 2004 at 09:09:16AM -0700, Josh Berkus wrote: + +> If your intention in this test is to show the superiority of raw devices, let +> me give you a reality check: barring some major corporate backing getting +> involved, we can't possibly implement our own PG-FS for database support. We +> already have a TODO list which is far too long for our developer pool, and +> implementing a custom FS either takes a large team (OCFS) or several years of +> development (Reiser). + +Is there any documentation as to what guarantees PostgreSQL requires +from the filesystem, or what posix semantics can be relaxed? + +Cheers, + Steve + +From pgsql-performance-owner@postgresql.org Wed Apr 7 14:07:58 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E4146D1C50B + for ; + Wed, 7 Apr 2004 14:07:56 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 97441-08 + for ; + Wed, 7 Apr 2004 14:07:53 -0300 (ADT) +Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) + by svr1.postgresql.org (Postfix) with ESMTP id 7826CD1BB93 + for ; + Wed, 7 Apr 2004 14:07:52 -0300 (ADT) +Received: from localhost (localhost [127.0.0.1]) + by bob.samurai.com (Postfix) with ESMTP + id E982B20EC; Wed, 7 Apr 2004 13:07:50 -0400 (EDT) +Received: from bob.samurai.com ([127.0.0.1]) + by localhost (bob.samurai.com [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 63453-01-9; Wed, 7 Apr 2004 13:07:46 -0400 (EDT) +Received: from [192.168.1.104] (d226-89-59.home.cgocable.net [24.226.89.59]) + (using TLSv1 with cipher RC4-MD5 (128/128 bits)) + (No client certificate requested) + by bob.samurai.com (Postfix) with ESMTP + id CA51B1FC3; Wed, 7 Apr 2004 13:07:45 -0400 (EDT) +Subject: Re: PostgreSQL and Linux 2.6 kernel. +From: Neil Conway +To: Josh Berkus +Cc: Mike Nolan , + Aaron Werman , Gary Doades , + pgsql-performance@postgresql.org +In-Reply-To: <200404050836.52115.josh@agliodbs.com> +References: <200404040323.i343Nw3Z002747@gw.tssi.com> + <200404050836.52115.josh@agliodbs.com> +Content-Type: text/plain +Message-Id: <1081357665.506.44.camel@tokyo> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Wed, 07 Apr 2004 13:07:45 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at mailbox.samurai.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/87 +X-Sequence-Number: 6387 + +On Mon, 2004-04-05 at 11:36, Josh Berkus wrote: +> Unfortunately, these days only Tom and Neil seem to be seriously working on +> the query planner (beg pardon in advance if I've missed someone) + +Actually, Tom is the only person actively working on the planner -- +while I hope to contribute to it in the future, I haven't done so yet. + +-Neil + + + +From pgsql-performance-owner@postgresql.org Wed Apr 7 16:10:09 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D268DD1BB16 + for ; + Wed, 7 Apr 2004 16:10:03 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 54324-09 + for ; + Wed, 7 Apr 2004 16:10:02 -0300 (ADT) +Received: from sccrmhc11.comcast.net (sccrmhc11.comcast.net [204.127.202.55]) + by svr1.postgresql.org (Postfix) with ESMTP id B37C3D1D05F + for ; + Wed, 7 Apr 2004 16:09:55 -0300 (ADT) +Received: from game (c-24-13-191-126.client.comcast.net[24.13.191.126]) + by comcast.net (sccrmhc11) with SMTP + id <2004040719095701100rrcgue>; Wed, 7 Apr 2004 19:09:57 +0000 +Message-ID: <00dd01c41cd3$ed6e1bf0$0201a8c0@game> +Reply-To: "Nid" +From: "Nid" +To: +Subject: Postgresql educational sources +Date: Wed, 7 Apr 2004 14:10:01 -0500 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_00DA_01C41CAA.045EDB80" +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1158 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=BAYES_50, + HTML_MESSAGE, RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200404/88 +X-Sequence-Number: 6388 + +This is a multi-part message in MIME format. + +------=_NextPart_000_00DA_01C41CAA.045EDB80 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +Rather than ask some general, unanswerable question on how to tune my datab= +ase...I thought I ask where I might find an introduction to...or manual/tut= +orial for the depths of managing a postgres db. Books? Websites? Assume = +a basic to intermediate knowledge of DBs in general with a desire to learn = +about postgres from the ground up. If it makes a difference I'm using a po= +stgres db in a Red Hat Linux OS environment. Thanks! + +nid +------=_NextPart_000_00DA_01C41CAA.045EDB80 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
Rather than ask some general, unanswerable= + question=20 +on how to tune my database...I thought I ask where I might find an introduc= +tion=20 +to...or manual/tutorial for the depths of managing a postgres db. =20 +Books?  Websites?  Assume a basic to intermediate knowledge of DB= +s in=20 +general with a desire to learn about postgres from the ground up.  If = +it=20 +makes a difference I'm using a postgres db in a Red Hat Linux OS=20 +environment.  Thanks!
+
 
+
nid
+ +------=_NextPart_000_00DA_01C41CAA.045EDB80-- + + + +From pgsql-performance-owner@postgresql.org Wed Apr 7 16:54:46 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6562DD1BB4C + for ; + Wed, 7 Apr 2004 16:54:44 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 80705-02 + for ; + Wed, 7 Apr 2004 16:54:42 -0300 (ADT) +Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) + by svr1.postgresql.org (Postfix) with ESMTP id DEEB6D1BA98 + for ; + Wed, 7 Apr 2004 16:54:39 -0300 (ADT) +Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) + by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i37JqcjX010326; + Wed, 7 Apr 2004 13:52:38 -0600 (MDT) +Date: Wed, 7 Apr 2004 13:52:35 -0600 (MDT) +From: "scott.marlowe" +To: Andrew McMillan +Cc: huang yaqin , +Subject: Re: good pc but bad performance,why? +In-Reply-To: <1081337381.522.57.camel@lamb.mcmillan.net.nz> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-IHS-MailScanner: Found to be clean +X-IHS-MailScanner-SpamCheck: +X-IHS-MailScanner-Envelope-Sender: scott.marlowe@ihs.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/89 +X-Sequence-Number: 6389 + +On Wed, 7 Apr 2004, Andrew McMillan wrote: + +> On Wed, 2004-04-07 at 20:56, huang yaqin wrote: +> > Hello, Richard Huxton, +> > +> > You said turning fsync off may cause losing data, that's terrible. +> > I use SCSI disk, and file system is ext3. I tune postgresql.conf and can't get any improvement. So what can I do? +> > Does SCSI disk and IDE disk have difference? +> +> Yes, turning off fsync means that the database is not guaranteeing +> consistency of writes to disk any longer. On the other hand your IDE +> system probably never was, because IDE drives just typically turn on +> write caching in hardware without telling anyone. +> +> SCSI typically doesn't turn on write caching in the physical drive by +> default, as Tom Lane pointed out earlier. Good SCSI has a battery +> backed up cache, and then it is OK to turn on write caching, because the +> controller has enough battery to complete all writes in the event of a +> power failure. + +Actually, almost all SCSI drives turn on write caching by default, they +just don't lie about fsync, so you still have a one update per revolution +limit, but other things can be happening while that write is being +commited due to the multi-threaded nature of both the SCSI interface and +the kernel drivers associated with them + +It would appear the linux kernel hackers are trying to implement the +multi-threaded features of the latest ATA spec, so that, at some future +date, you could have IDE drives that cache AND tell the truth of their +sync AND can do more than one thing at a time. + +> One thing I recommend is to use ext2 (or almost anything but ext3). +> There is no real need (or benefit) from having the database on a +> journalled filesystem - the journalling is only trying to give similar +> sorts of guarantees to what the fsync in PostgreSQL is doing. + +Is this true? I was under the impression that without at least meta-data +journaling postgresql could still be corrupted by power failure. + +> The suggestion someone else made regarding use of software raid is +> probably also a good one if you are trying to use the on-board RAID at +> the moment. + +Some onboard RAID controllers are fairly good (dell's 2600 series have an +adaptec on board that can have battery backed cache that is ok, the lsi +megaraid based one is faster under linux though.) But some of them are +pretty poor performers. + +> Finally, I would say that because you are seeing poor performance on one +> box and great performance on another, you should look at the hardware, +> or at the hardware drivers, for the problem - not so much at PostgreSQL. + +More than likely, the biggest issue is that the SCSI drives are performing +proper fsync, while the IDE drives are lying. Definitely a time to look +at a good caching RAID controller. + + +From pgsql-performance-owner@postgresql.org Wed Apr 7 17:28:15 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8CABCD1D062 + for ; + Wed, 7 Apr 2004 17:28:11 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 95511-02 + for ; + Wed, 7 Apr 2004 17:28:10 -0300 (ADT) +Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) + by svr1.postgresql.org (Postfix) with ESMTP id 71729D1C9DA + for ; + Wed, 7 Apr 2004 17:28:07 -0300 (ADT) +Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) + by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i37KRWjX014298; + Wed, 7 Apr 2004 14:27:32 -0600 (MDT) +Date: Wed, 7 Apr 2004 14:27:29 -0600 (MDT) +From: "scott.marlowe" +To: Nid +Cc: +Subject: Re: Postgresql educational sources +In-Reply-To: <00dd01c41cd3$ed6e1bf0$0201a8c0@game> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-IHS-MailScanner: Found to be clean +X-IHS-MailScanner-SpamCheck: +X-IHS-MailScanner-Envelope-Sender: scott.marlowe@ihs.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/90 +X-Sequence-Number: 6390 + +On Wed, 7 Apr 2004, Nid wrote: + +> Rather than ask some general, unanswerable question on how to tune my +> database...I thought I ask where I might find an introduction to...or +> manual/tutorial for the depths of managing a postgres db. Books? +> Websites? Assume a basic to intermediate knowledge of DBs in general +> with a desire to learn about postgres from the ground up. If it makes a +> difference I'm using a postgres db in a Red Hat Linux OS environment. +> Thanks! + +The online (adminstration) docs are quite good, and for tuning, look at +the excellent tuning document on varlena: + +http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html + + + + +From pgsql-performance-owner@postgresql.org Wed Apr 7 18:05:54 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 52AC9D1B893 + for ; + Wed, 7 Apr 2004 18:05:53 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 09569-05 + for ; + Wed, 7 Apr 2004 18:05:17 -0300 (ADT) +Received: from hotmail.com (bay8-f42.bay8.hotmail.com [64.4.27.42]) + by svr1.postgresql.org (Postfix) with ESMTP id 8C599D1B9EB + for ; + Wed, 7 Apr 2004 18:05:14 -0300 (ADT) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Wed, 7 Apr 2004 14:05:15 -0700 +Received: from 69.65.137.210 by by8fd.bay8.hotmail.msn.com with HTTP; + Wed, 07 Apr 2004 21:05:15 GMT +X-Originating-IP: [69.65.137.210] +X-Originating-Email: [el_vigia_ec@hotmail.com] +X-Sender: el_vigia_ec@hotmail.com +From: "Jaime Casanova" +To: pgsql-performance@postgresql.org +Subject: statistics +Date: Wed, 07 Apr 2004 21:05:15 +0000 +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed +Message-ID: +X-OriginalArrivalTime: 07 Apr 2004 21:05:15.0524 (UTC) + FILETIME=[06316C40:01C41CE4] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/91 +X-Sequence-Number: 6391 + +What the statistics are? Where can i view it? where can i find info about +its field and why are they valuable information to performance? + +thanx in advance, + +Jaime Casanova + +_________________________________________________________________ +Protect your PC - get McAfee.com VirusScan Online +http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963 + + +From pgsql-performance-owner@postgresql.org Wed Apr 7 19:12:56 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 19E4BD1B4D3 + for ; + Wed, 7 Apr 2004 19:12:53 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 37984-01 + for ; + Wed, 7 Apr 2004 19:12:53 -0300 (ADT) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id BD2EBD1B459 + for ; + Wed, 7 Apr 2004 19:12:49 -0300 (ADT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i37MCck07003; + Wed, 7 Apr 2004 18:12:38 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200404072212.i37MCck07003@candle.pha.pa.us> +Subject: Re: good pc but bad performance,why? +In-Reply-To: +To: "scott.marlowe" +Date: Wed, 7 Apr 2004 18:12:38 -0400 (EDT) +Cc: Andrew McMillan , + huang yaqin , pgsql-performance@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL108 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/92 +X-Sequence-Number: 6392 + +scott.marlowe wrote: +> > One thing I recommend is to use ext2 (or almost anything but ext3). +> > There is no real need (or benefit) from having the database on a +> > journalled filesystem - the journalling is only trying to give similar +> > sorts of guarantees to what the fsync in PostgreSQL is doing. +> +> Is this true? I was under the impression that without at least meta-data +> journaling postgresql could still be corrupted by power failure. + +It is false. ext2 isn't crash-safe, and PostgreSQL needs an intact file +system for WAL recovery. + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-performance-owner@postgresql.org Wed Apr 7 20:48:41 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C1FCAD1D090 + for ; + Wed, 7 Apr 2004 20:48:39 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 70073-01 + for ; + Wed, 7 Apr 2004 20:48:40 -0300 (ADT) +Received: from anchor-post-31.mail.demon.net (anchor-post-31.mail.demon.net + [194.217.242.89]) + by svr1.postgresql.org (Postfix) with ESMTP id AC568D1D088 + for ; + Wed, 7 Apr 2004 20:48:36 -0300 (ADT) +Received: from tmsl-adsl.demon.co.uk ([80.177.114.181] + helo=bacon.tmsl.demon.co.uk) + by anchor-post-31.mail.demon.net with esmtp (Exim 3.35 #1) + id 1BBMmd-000FuO-0V + for pgsql-performance@postgresql.org; Thu, 08 Apr 2004 00:48:39 +0100 +Date: Thu, 8 Apr 2004 00:48:35 +0100 +From: Paul Thomas +To: "pgsql-performance @ postgresql . org" +Subject: Re: statistics +Message-ID: <20040408004835.A8476@bacon> +References: +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed; charset=ISO-8859-1 +In-Reply-To: ; + from el_vigia_ec@hotmail.com on Wed, Apr 07, 2004 at 22:05:15 + +0100 +X-Mailer: Balsa 1.2.3 +Lines: 60 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/93 +X-Sequence-Number: 6393 + + +On 07/04/2004 22:05 Jaime Casanova wrote: +> What the statistics are? Where can i view it? where can i find info +> about its field and why are they valuable information to performance? +> +> thanx in advance, +> +> Jaime Casanova + + +OK. An idiot's guide to statistics by a full-time idiot... + +Let's start with a simple premise. I'm a RDBMS (forget that I'm actually +an idiot for a moment...) and I've been asked for + +select * from foo where bar = 7; + +How do I go about fulfilling the reequest in the most efficient manner? +(i.e., ASAP!) + +One way might be to read through the whole table and return only those +rows which match the where criteron - a sequential scan on the table. + +But wait a minute, there is an index on column bar. Could I use this +instead? Well, of course, I could use it but I have to keep sight of the +goal of returning the data ASAP and I know that the act of reading +index/reading table/... will have a performance penalty due to a lot more +head movement on the disk. So how do I make chose between a sequential +scan and an index scan? Let's lokk at a couple of extreme scenarios: + +1) let's look at the condition where all or virtually all of the bar +columns are populated wityh the value 7. In this case it would be more +efficient to read sequentially through the table. + +2) the opposite of (1) - very few of the bar columns have the value 7. In +this case using the index could be a winner. + +So generalising, I need to be able to estimate whether doing a sequential +scan is more efficient that an index scan and this comes down to 2 factors: + +a) the cost of moving the disk heads all over the place (random page cost) +b) the spread of values in the selecting column(s) + +(a) is specfified in postgresql.conf (see archives for much discusion +about what the value should be..) +(b) is determined by the dastardly trick of actually sampling the data in +the table!!! That's what analyze does. It samples your table(s) and uses +the result to feeede into it's descision about when to flip between +sequential and index scans. + +Hope this makes some kind of sense... + +-- +Paul Thomas ++------------------------------+---------------------------------------------+ +| Thomas Micro Systems Limited | Software Solutions for +Business | +| Computer Consultants | +http://www.thomas-micro-systems-ltd.co.uk | ++------------------------------+---------------------------------------------+ + +From pgsql-performance-owner@postgresql.org Wed Apr 7 22:31:40 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A98F7D1BB7B + for ; + Wed, 7 Apr 2004 22:31:38 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 97913-07 + for ; + Wed, 7 Apr 2004 22:31:40 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 5690CD1D06C + for ; + Wed, 7 Apr 2004 22:31:36 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i381VImA006789; + Wed, 7 Apr 2004 21:31:18 -0400 (EDT) +To: Bruce Momjian +Cc: "scott.marlowe" , + Andrew McMillan , + huang yaqin , pgsql-performance@postgresql.org +Subject: Re: good pc but bad performance,why? +In-reply-to: <200404072212.i37MCck07003@candle.pha.pa.us> +References: <200404072212.i37MCck07003@candle.pha.pa.us> +Comments: In-reply-to Bruce Momjian + message dated "Wed, 07 Apr 2004 18:12:38 -0400" +Date: Wed, 07 Apr 2004 21:31:18 -0400 +Message-ID: <6788.1081387878@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/94 +X-Sequence-Number: 6394 + +Bruce Momjian writes: +> scott.marlowe wrote: +>>> There is no real need (or benefit) from having the database on a +>>> journalled filesystem - the journalling is only trying to give similar +>>> sorts of guarantees to what the fsync in PostgreSQL is doing. +>> +>> Is this true? I was under the impression that without at least meta-data +>> journaling postgresql could still be corrupted by power failure. + +> It is false. ext2 isn't crash-safe, and PostgreSQL needs an intact file +> system for WAL recovery. + +But it should be okay to set the filesystem to journal only its own +metadata. There's no need for it to journal file contents. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Apr 7 22:33:45 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9617BD1B4D3 + for ; + Wed, 7 Apr 2004 22:33:43 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 96462-08 + for ; + Wed, 7 Apr 2004 22:33:45 -0300 (ADT) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id E7896D1B4BF + for ; + Wed, 7 Apr 2004 22:33:40 -0300 (ADT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i381XYu13325; + Wed, 7 Apr 2004 21:33:34 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200404080133.i381XYu13325@candle.pha.pa.us> +Subject: Re: good pc but bad performance,why? +In-Reply-To: <6788.1081387878@sss.pgh.pa.us> +To: Tom Lane +Date: Wed, 7 Apr 2004 21:33:34 -0400 (EDT) +Cc: "scott.marlowe" , + Andrew McMillan , + huang yaqin , pgsql-performance@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL108 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/95 +X-Sequence-Number: 6395 + +Tom Lane wrote: +> Bruce Momjian writes: +> > scott.marlowe wrote: +> >>> There is no real need (or benefit) from having the database on a +> >>> journalled filesystem - the journalling is only trying to give similar +> >>> sorts of guarantees to what the fsync in PostgreSQL is doing. +> >> +> >> Is this true? I was under the impression that without at least meta-data +> >> journaling postgresql could still be corrupted by power failure. +> +> > It is false. ext2 isn't crash-safe, and PostgreSQL needs an intact file +> > system for WAL recovery. +> +> But it should be okay to set the filesystem to journal only its own +> metadata. There's no need for it to journal file contents. + +Can you set ext2 to journal metadata? I didn't know it could do that. + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-performance-owner@postgresql.org Wed Apr 7 23:13:40 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B080CD1D06A + for ; + Wed, 7 Apr 2004 23:13:39 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 11913-05 + for ; + Wed, 7 Apr 2004 23:13:41 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 4D3C3D1C9C8 + for ; + Wed, 7 Apr 2004 23:13:37 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i382DYcb007295; + Wed, 7 Apr 2004 22:13:34 -0400 (EDT) +To: Bruce Momjian +Cc: "scott.marlowe" , + Andrew McMillan , + huang yaqin , pgsql-performance@postgresql.org +Subject: Re: good pc but bad performance,why? +In-reply-to: <200404080133.i381XYu13325@candle.pha.pa.us> +References: <200404080133.i381XYu13325@candle.pha.pa.us> +Comments: In-reply-to Bruce Momjian + message dated "Wed, 07 Apr 2004 21:33:34 -0400" +Date: Wed, 07 Apr 2004 22:13:34 -0400 +Message-ID: <7294.1081390414@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/96 +X-Sequence-Number: 6396 + +Bruce Momjian writes: +> Tom Lane wrote: +>> But it should be okay to set the filesystem to journal only its own +>> metadata. There's no need for it to journal file contents. + +> Can you set ext2 to journal metadata? I didn't know it could do that. + +No, ext2 has no journal at all AFAIK. But I believe ext3 has an option +to journal or not journal file contents, and at least on a Postgres-only +volume you'd want to turn that off. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Apr 8 00:13:40 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7989ED1D06E + for ; + Thu, 8 Apr 2004 00:13:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 28571-07 + for ; + Thu, 8 Apr 2004 00:13:22 -0300 (ADT) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id D8668D1D070 + for ; + Thu, 8 Apr 2004 00:13:22 -0300 (ADT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i383C7N28711; + Wed, 7 Apr 2004 23:12:07 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200404080312.i383C7N28711@candle.pha.pa.us> +Subject: Re: good pc but bad performance,why? +In-Reply-To: <7294.1081390414@sss.pgh.pa.us> +To: Tom Lane +Date: Wed, 7 Apr 2004 23:12:07 -0400 (EDT) +Cc: "scott.marlowe" , + Andrew McMillan , + huang yaqin , pgsql-performance@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL108 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/97 +X-Sequence-Number: 6397 + +Tom Lane wrote: +> Bruce Momjian writes: +> > Tom Lane wrote: +> >> But it should be okay to set the filesystem to journal only its own +> >> metadata. There's no need for it to journal file contents. +> +> > Can you set ext2 to journal metadata? I didn't know it could do that. +> +> No, ext2 has no journal at all AFAIK. But I believe ext3 has an option +> to journal or not journal file contents, and at least on a Postgres-only +> volume you'd want to turn that off. + +Right, ext3 has that option. I don't think XFS needs it (it does +meta-data only by default). + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-admin-owner@postgresql.org Thu Apr 8 01:33:15 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 9B942D1D086; Thu, 8 Apr 2004 01:33:13 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 57703-02; Thu, 8 Apr 2004 01:33:09 -0300 (ADT) +Received: from elbereth.noviforum.si (unknown [193.189.169.66]) + by svr1.postgresql.org (Postfix) with ESMTP + id A0AA1D1D09B; Thu, 8 Apr 2004 01:33:09 -0300 (ADT) +Received: from elbereth.noviforum.si (localhost [127.0.0.1]) + by elbereth.noviforum.si (8.12.10/8.12.10) with ESMTP id i384X5Hh028646; + Thu, 8 Apr 2004 06:33:05 +0200 +Received: (from gregab@localhost) + by elbereth.noviforum.si (8.12.10/8.12.10/Submit) id i384X4xU028645; + Thu, 8 Apr 2004 06:33:04 +0200 +Date: Thu, 8 Apr 2004 06:33:04 +0200 +From: Grega Bremec +To: Josh Berkus +Cc: pgsql-admin@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Raw devices vs. Filesystems +Message-ID: <20040408043304.GA28539@elbereth.noviforum.si> +References: + <71E37EF6B7DCC1499CEA0316A25683280105786A@loki.wc.globexplorer.net> + <5719.1081315562@sss.pgh.pa.us> + <20040407071858.GA7973@elbereth.noviforum.si> + <200404070909.16123.josh@agliodbs.com> +Mime-Version: 1.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; boundary="k1lZvvs/B4yU6o8G" +Content-Disposition: inline +In-Reply-To: <200404070909.16123.josh@agliodbs.com> +User-Agent: Mutt/1.4.2i +Organization: Noviforum, Ltd., Software & Media +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/135 +X-Sequence-Number: 13108 + +--k1lZvvs/B4yU6o8G +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +Content-Transfer-Encoding: quoted-printable + +...and on Wed, Apr 07, 2004 at 09:09:16AM -0700, Josh Berkus used the keybo= +ard: +>=20 +> Does it work, though? Without Oracle admin tools? + +Hello, Josh. :) + +Well, as I said, that's why I was asking - I'm willing to give it a go +if nobody can prove me wrong. :) + +> > Now, if both goals can be achieved in one go, hell, I'm willing to try +> > it out myself in an attempt to extract off of it, some performance +> > indicators that could be compared to other database performance tests +> > sent to both this and the PERFORM mailing list. +>=20 +> Hey, any test you wanna run is fine with us. I'm pretty sure that OCFS= +=20 +> belongs to Oracle, though, patent & copyright, so we couldn't actually us= +e it=20 +> in practice. + +I thought you knew - OCFS, OCFS-Tools and OCFSv2 have not only been open- +source for quite a while now - they're released under the GPL. + + http://oss.oracle.com/projects/ocfs/ + http://oss.oracle.com/projects/ocfs-tools/ + http://oss.oracle.com/projects/ocfs2/ + +I don't know what that means to you (probably nothing good, as PostgreSQL +is released under the BSD license), but it most definitely can be considered +a good thing for the end user, as she can download it, compile, and set it +up on her disks, without the need to pay Oracle royalties. :) + +> If your intention in this test is to show the superiority of raw devices,= + let=20 +> me give you a reality check: barring some major corporate backing getting= +=20 +> involved, we can't possibly implement our own PG-FS for database support.= + We=20 +> already have a TODO list which is far too long for our developer pool, an= +d=20 +> implementing a custom FS either takes a large team (OCFS) or several year= +s of=20 +> development (Reiser).=20=20=20 + +Not really - I was just thinking about something not-entirely-a-filesystem +and POK!, OCFS sprang to mind. It omits many POSIX features that slow down +a traditional filesystem, yet it does know the concept of inodes and most +of all, it's _really_ heavy on caching. As such, it sounded quite promising +to me, but trial, I think, is the best test. + +The question does spring up though, that Steve raised in another post - just +for the record, what POSIX semantics can a postmaster live without in a +filesystem? + +Cheers, +--=20 + Grega Bremec + Senior Administrator + Noviforum Ltd., Software & Media + http://www.noviforum.si/ + +--k1lZvvs/B4yU6o8G +Content-Type: application/pgp-signature +Content-Disposition: inline + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.3 (GNU/Linux) + +iD8DBQFAdNYADo/EMYD4+osRAjavAKCNkuX+bSoTf909fhLr0kt3WkcL0gCgkLoK +176SeZStwQ0aPWPRmK5g0Xs= +=kDde +-----END PGP SIGNATURE----- + +--k1lZvvs/B4yU6o8G-- + +From pgsql-performance-owner@postgresql.org Thu Apr 8 04:58:48 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2EED4D1CB3F + for ; + Thu, 8 Apr 2004 04:58:47 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 17860-02 + for ; + Thu, 8 Apr 2004 04:58:45 -0300 (ADT) +Received: from ahmose.CICT_AD.NL (vnd-7521.mxs.adsl.euronet.nl + [62.234.149.33]) + by svr1.postgresql.org (Postfix) with ESMTP id 088CCD1C9FB + for ; + Thu, 8 Apr 2004 04:58:43 -0300 (ADT) +Received: by ahmose.cict_ad.nl with Internet Mail Service (5.5.2657.72) + id <2PZ2B05R>; Thu, 8 Apr 2004 09:59:19 +0200 +Message-ID: <2A07EC2D0BC2774AAD6F74769F60D52A0832C6@ahmose.cict_ad.nl> +From: "Priem, Alexander" +To: pgsql-performance@postgresql.org +Subject: data=writeback +Date: Thu, 8 Apr 2004 09:59:18 +0200 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2657.72) +Content-Type: text/plain +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/99 +X-Sequence-Number: 6399 + +Hi everyone, + +I have done some reading on filesystems and I thought to optimize the +settings for my PostgreSQL system. I use the ext3 filesystem and have the +PostgreSQL data and WAL on different physical drives. I made some +adjustments to my /etc/fstabd file, so it looks like this : + + +LABEL=/ / ext3 +noatime,data=ordered 1 1 +LABEL=/boot /boot ext3 +noatime,data=ordered 1 2 +none /dev/pts devpts gid=5,mode=620 +0 0 +none /proc proc defaults +0 0 +none /dev/shm tmpfs defaults +0 0 +LABEL=/usr/local/pgsql /usr/local/pgsql ext3 +noatime,data=writeback 1 2 +LABEL=/usr/local/pgsql /usr/local/pgsql/wal ext3 +noatime,data=ordered 1 2 +/dev/sda5 swap swap defaults +0 0 +/dev/cdrom /mnt/cdrom udf,iso9660 +noauto,owner,kudzu,ro 0 0 +/dev/fd0 /mnt/floppy auto +noauto,owner,kudzu 0 0 + + +Does this look OK? My knowledge of filesystems and their (journalling) +options is not very broad... + +Thanks in advance, +Alexander Priem. + + + + +From pgsql-performance-owner@postgresql.org Thu Apr 8 05:54:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5A0BBD1BAF7 + for ; + Thu, 8 Apr 2004 05:54:49 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 33130-06 + for ; + Thu, 8 Apr 2004 05:54:47 -0300 (ADT) +Received: from lamb.mcmillan.net.nz (218-101-13-8.paradise.net.nz + [218.101.13.8]) + by svr1.postgresql.org (Postfix) with ESMTP id B8020D1BAAD + for ; + Thu, 8 Apr 2004 05:54:45 -0300 (ADT) +Received: from lamb.mcmillan.net.nz (lamb.mcmillan.net.nz [127.0.0.1]) + by lamb.mcmillan.net.nz (Postfix) with ESMTP + id D2DCDAD98581; Thu, 8 Apr 2004 20:54:39 +1200 (NZST) +Subject: Re: good pc but bad performance,why? +From: Andrew McMillan +To: Tom Lane +Cc: pgsql-performance@postgresql.org +In-Reply-To: <7294.1081390414@sss.pgh.pa.us> +References: <200404080133.i381XYu13325@candle.pha.pa.us> + <7294.1081390414@sss.pgh.pa.us> +Content-Type: text/plain +Message-Id: <1081414478.2428.13.camel@lamb.mcmillan.net.nz> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Thu, 08 Apr 2004 20:54:39 +1200 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/100 +X-Sequence-Number: 6400 + +On Thu, 2004-04-08 at 14:13, Tom Lane wrote: +> Bruce Momjian writes: +> > Tom Lane wrote: +> >> But it should be okay to set the filesystem to journal only its own +> >> metadata. There's no need for it to journal file contents. +> +> > Can you set ext2 to journal metadata? I didn't know it could do that. +> +> No, ext2 has no journal at all AFAIK. But I believe ext3 has an option +> to journal or not journal file contents, and at least on a Postgres-only +> volume you'd want to turn that off. + +No, it certainly doesn't. + +To be honest I was not aware that PostgreSQL was susceptible to failure +on non[metadata] journalled filesystems - I was [somewhat vaguely] of +the understanding that it would work fine on any filesystem. + +And obviously, from my original post, we can see that I believed +metadata journalling was wasted on it. + +Is the 'noatime' option worthwhile? Are you saying that PostgreSQL +should always be run on a metadata journalled filesystem then, and that +VFAT, ext2, etc are ++ungood? + +Thanks, + Andrew McMillan. + +------------------------------------------------------------------------- +Andrew @ Catalyst .Net .NZ Ltd, PO Box 11-053, Manners St, Wellington +WEB: http://catalyst.net.nz/ PHYS: Level 2, 150-154 Willis St +DDI: +64(4)916-7201 MOB: +64(21)635-694 OFFICE: +64(4)499-2267 + A foolish consistency is the hobgoblin of little minds - Shaw +------------------------------------------------------------------------- + + +From pgsql-performance-owner@postgresql.org Thu Apr 8 06:01:29 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 251C2D1D091 + for ; + Thu, 8 Apr 2004 06:01:28 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 39976-03 + for ; + Thu, 8 Apr 2004 06:01:26 -0300 (ADT) +Received: from my.endian.it (unknown [62.146.87.34]) + by svr1.postgresql.org (Postfix) with ESMTP id 350E1D1D08E + for ; + Thu, 8 Apr 2004 06:01:24 -0300 (ADT) +Received: from [192.168.1.6] (host36-118.pool80180.interbusiness.it + [80.180.118.36]) (authenticated (0 bits)) + by my.endian.it (8.11.6/8.11.6) with ESMTP id i389XRl17246 + for ; Thu, 8 Apr 2004 11:33:27 +0200 +Subject: Re: data=writeback +From: Chris +To: pgsql-performance@postgresql.org +In-Reply-To: <2A07EC2D0BC2774AAD6F74769F60D52A0832C6@ahmose.cict_ad.nl> +References: <2A07EC2D0BC2774AAD6F74769F60D52A0832C6@ahmose.cict_ad.nl> +Content-Type: text/plain +Message-Id: <1081414889.5037.29.camel@dell> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 (1.4.5-7) +Date: Thu, 08 Apr 2004 11:01:29 +0200 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/101 +X-Sequence-Number: 6401 + +> LABEL=/usr/local/pgsql /usr/local/pgsql ext3 +> noatime,data=writeback 1 2 +> LABEL=/usr/local/pgsql /usr/local/pgsql/wal ext3 +> noatime,data=ordered 1 2 + +The same label mounted on two different mount points is probably I typo? + +I'm not sure if data=writeback is ok. I was wondering about the same +thing after reading the "good pc but bad performance,why?" thread. + +This is from man mount: + + writeback + Data ordering is not preserved - data may be written into + the main file system after its metadata has been commit- + ted to the journal. This is rumoured to be the highest- + throughput option. It guarantees internal file system + integrity, however it can allow old data to appear in + files after a crash and journal recovery. + +How does this relate to fflush()? Does fflush still garantee +all data has ben written? + +Bye, Chris. + + + +From pgsql-performance-owner@postgresql.org Thu Apr 8 06:25:44 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1456BD1D09E + for ; + Thu, 8 Apr 2004 06:25:43 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 47768-03 + for ; + Thu, 8 Apr 2004 06:25:41 -0300 (ADT) +Received: from ahmose.CICT_AD.NL (vnd-7521.mxs.adsl.euronet.nl + [62.234.149.33]) + by svr1.postgresql.org (Postfix) with ESMTP id 1C4AFD1BAEA + for ; + Thu, 8 Apr 2004 06:25:40 -0300 (ADT) +Received: by ahmose.cict_ad.nl with Internet Mail Service (5.5.2657.72) + id <2PZ2B06F>; Thu, 8 Apr 2004 11:26:17 +0200 +Message-ID: <2A07EC2D0BC2774AAD6F74769F60D52A0832C8@ahmose.cict_ad.nl> +From: "Priem, Alexander" +To: 'Chris' , pgsql-performance@postgresql.org +Subject: Re: data=writeback +Date: Thu, 8 Apr 2004 11:26:17 +0200 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2657.72) +Content-Type: text/plain +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/102 +X-Sequence-Number: 6402 + +> > LABEL=/usr/local/pgsql /usr/local/pgsql ext3 +> > noatime,data=writeback 1 2 +> > LABEL=/usr/local/pgsql /usr/local/pgsql/wal ext3 +> > noatime,data=ordered 1 2 +> +> The same label mounted on two different mount points is probably I typo? + + +No, the same label mounted on two different mount points is not a typo. This +is the way it is in my /etc/fstab. + +Note that I did not create this file myself, it was created by the RedHat +Enterprise Linux 3 ES installer. I created different partitions for the data +directory (/usr/local/pgsql) and the wal directory (/usr/local/pgsql/wal) +using the installer and this is how the /etc/fstab file ended up. + +Why, is this bad? They use the same label, but use different mount points? +Can this cause problems? + + +From pgsql-performance-owner@postgresql.org Thu Apr 8 06:46:07 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9E4DFD1CCC5 + for ; + Thu, 8 Apr 2004 06:46:05 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 54959-03 + for ; + Thu, 8 Apr 2004 06:46:04 -0300 (ADT) +Received: from ebrsrv01.ebravo.it (host166-198.pool21757.interbusiness.it + [217.57.198.166]) + by svr1.postgresql.org (Postfix) with ESMTP id 5C03BD1BAF7 + for ; + Thu, 8 Apr 2004 06:46:02 -0300 (ADT) +Received: from streppone.it ([192.168.11.103]) (authenticated bits=0) + by ebrsrv01.ebravo.it (8.12.1/8.12.5) with ESMTP id i389k2j4007706 + for ; Thu, 8 Apr 2004 11:46:02 +0200 +Message-ID: <40751ED5.1010208@streppone.it> +Date: Thu, 08 Apr 2004 11:43:49 +0200 +From: Cosimo Streppone +User-Agent: Mozilla Thunderbird 0.5 (X11/20040208) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: select count(*) on large tables +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/104 +X-Sequence-Number: 6404 + +Hello, + +I've followed the last discussion about the particular case of +"select count(*)"s on large tables being somewhat slow. + +I've seen also this issue already on the todo list, so I know +it is not a simple question. +This problem arises for me on very large tables, which I mean +starting from 1 million rows and above. + +The alternative solution I tried, that has an optimal +speed up, unfortunately is not a way out, and it is based +on "EXPLAIN SELECT count(*)" output parsing, which +is obviously *not* reliable. + +The times always get better doing a vacuum (and eventually +reindex) of the table, and they slowly lower again. + +Is there an estimate time for this issue to be resolved? +Can I help in some way (code, test cases, ...)? + +-- +Cosimo + + +From pgsql-performance-owner@postgresql.org Thu Apr 8 06:44:27 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 99E53D1D2EA + for ; + Thu, 8 Apr 2004 06:44:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 52007-06 + for ; + Thu, 8 Apr 2004 06:44:23 -0300 (ADT) +Received: from my.endian.it (unknown [62.146.87.34]) + by svr1.postgresql.org (Postfix) with ESMTP id 20221D1D08A + for ; + Thu, 8 Apr 2004 06:44:22 -0300 (ADT) +Received: from [192.168.1.6] (host36-118.pool80180.interbusiness.it + [80.180.118.36]) (authenticated (0 bits)) + by my.endian.it (8.11.6/8.11.6) with ESMTP id i38AGRl18561 + for ; Thu, 8 Apr 2004 12:16:27 +0200 +Subject: Re: data=writeback +From: Chris +To: pgsql-performance@postgresql.org +In-Reply-To: <2A07EC2D0BC2774AAD6F74769F60D52A0832C8@ahmose.cict_ad.nl> +References: <2A07EC2D0BC2774AAD6F74769F60D52A0832C8@ahmose.cict_ad.nl> +Content-Type: text/plain +Message-Id: <1081417469.5037.50.camel@dell> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 (1.4.5-7) +Date: Thu, 08 Apr 2004 11:44:29 +0200 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/103 +X-Sequence-Number: 6403 + + +> > > LABEL=/usr/local/pgsql /usr/local/pgsql ext3 +> > > noatime,data=writeback 1 2 +> > > LABEL=/usr/local/pgsql /usr/local/pgsql/wal ext3 +> > > noatime,data=ordered 1 2 +> > +> > The same label mounted on two different mount points is probably I typo? +> +> +> No, the same label mounted on two different mount points is not a typo. This +> is the way it is in my /etc/fstab. +> +> Note that I did not create this file myself, it was created by the RedHat +> Enterprise Linux 3 ES installer. I created different partitions for the data +> directory (/usr/local/pgsql) and the wal directory (/usr/local/pgsql/wal) +> using the installer and this is how the /etc/fstab file ended up. +> +> Why, is this bad? They use the same label, but use different mount points? +> Can this cause problems? + +Mmm... how can the mounter distinguish the two partitions? + +Maybe I'm missing a concept here, but I thought labels must uniquely +identify partitions? + +Seems suspicious to me... + +Does it work? When you give just "mount" at the command line what output +do you get? + +Bye, Chris. + + + +From pgsql-performance-owner@postgresql.org Thu Apr 8 07:09:36 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5BFEDD1C9BE + for ; + Thu, 8 Apr 2004 07:09:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 65534-01 + for ; + Thu, 8 Apr 2004 07:09:34 -0300 (ADT) +Received: from ahmose.CICT_AD.NL (vnd-7521.mxs.adsl.euronet.nl + [62.234.149.33]) + by svr1.postgresql.org (Postfix) with ESMTP id 2BD14D1C4EB + for ; + Thu, 8 Apr 2004 07:09:33 -0300 (ADT) +Received: by ahmose.cict_ad.nl with Internet Mail Service (5.5.2657.72) + id <2PZ2B06Z>; Thu, 8 Apr 2004 12:10:11 +0200 +Message-ID: <2A07EC2D0BC2774AAD6F74769F60D52A0832C9@ahmose.cict_ad.nl> +From: "Priem, Alexander" +To: 'Chris' , pgsql-performance@postgresql.org +Subject: Re: data=writeback +Date: Thu, 8 Apr 2004 12:10:10 +0200 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2657.72) +Content-Type: text/plain +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/105 +X-Sequence-Number: 6405 + +> > > > LABEL=/usr/local/pgsql /usr/local/pgsql ext3 +> > > > noatime,data=writeback 1 2 +> > > > LABEL=/usr/local/pgsql /usr/local/pgsql/wal ext3 +> > > > noatime,data=ordered 1 2 +> > > +> > > The same label mounted on two different mount points is probably I +> > > typo? +> > +> > +> > No, the same label mounted on two different mount points is not a +> > typo. This is the way it is in my /etc/fstab. +> > +> > Note that I did not create this file myself, it was created by the +> > RedHat Enterprise Linux 3 ES installer. I created different partitions +> > for the data directory (/usr/local/pgsql) and the wal directory +> > (/usr/local/pgsql/wal) using the installer and this is how the +> > /etc/fstab file ended up. +> > +> > Why, is this bad? They use the same label, but use different mount +> > points? Can this cause problems? +> +> Mmm... how can the mounter distinguish the two partitions? +> +> Maybe I'm missing a concept here, but I thought labels must uniquely +identify partitions? +> +> Seems suspicious to me... +> +> Does it work? When you give just "mount" at the command line what output +do you get? +> +> Bye, Chris. + +When I give "mount" at the command line, everything looks just fine : + +/dev/sda2 on / type ext3 (rw,noatime,data=ordered) +none on /proc type proc (rw) +usbdevfs on /proc/bus/usb type usbdevfs (rw) +/dev/sda1 on /boot type ext3 (rw,noatime,data=ordered) +none on /dev/pts type devpts (rw,gid=5,mode=620) +none on /dev/shm type tmpfs (rw) +/dev/sdb1 on /usr/local/pgsql type ext3 (rw,noatime,data=writeback) +/dev/sda3 on /usr/local/pgsql/wal type ext3 (rw,noatime,data=ordered) + +It looks like the labels are not really used, just the mount-points. Or +could this cause other problems I am not aware of? Everything seems to be +working just fine, for several months now... + + + +From pgsql-performance-owner@postgresql.org Thu Apr 8 07:54:31 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 662E4D1D080 + for ; + Thu, 8 Apr 2004 07:54:30 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 75913-05 + for ; + Thu, 8 Apr 2004 07:54:30 -0300 (ADT) +Received: from zigo.dhs.org (as2-4-3.an.g.bonet.se [194.236.34.191]) + by svr1.postgresql.org (Postfix) with ESMTP id 362B9D1D088 + for ; + Thu, 8 Apr 2004 07:54:28 -0300 (ADT) +Received: from zigo.zigo.dhs.org (zigo.zigo.dhs.org [192.168.0.1]) + by zigo.dhs.org (Postfix) with ESMTP + id BD53086FA; Thu, 8 Apr 2004 12:54:29 +0200 (CEST) +Date: Thu, 8 Apr 2004 12:54:29 +0200 (CEST) +From: Dennis Bjorklund +To: Cosimo Streppone +Cc: pgsql-performance@postgresql.org +Subject: Re: select count(*) on large tables +In-Reply-To: <40751ED5.1010208@streppone.it> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=ISO-8859-1 +Content-Transfer-Encoding: 8BIT +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/106 +X-Sequence-Number: 6406 + +On Thu, 8 Apr 2004, Cosimo Streppone wrote: + +> The alternative solution I tried, that has an optimal +> speed up, unfortunately is not a way out, and it is based +> on "EXPLAIN SELECT count(*)" output parsing, which +> is obviously *not* reliable. + +Try this to get the estimate: + + SELECT relname, reltuples from pg_class order by relname; + +> The times always get better doing a vacuum (and eventually +> reindex) of the table, and they slowly lower again. + +Yes, the estimate is updated by the analyze. + +> Is there an estimate time for this issue to be resolved? + +It's not so easy to "fix". The naive fixes makes other operations slower, +most notably makes things less concurrent which is bad since it wont scale +as good for many users then. + +You can always keep the count yourself and have some triggers that update +the count on each insert and delete on the table. It will of course make +all inserts and deletes slower, but if you count all rows often maybe it's +worth it. Most people do not need to count all rows in a table anyway. You +usually count all rows such as this and that (some condition). + +-- +/Dennis Bj�rklund + + +From pgsql-performance-owner@postgresql.org Thu Apr 8 08:54:32 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0B0B8D1D098 + for ; + Thu, 8 Apr 2004 08:54:30 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 90672-09 + for ; + Thu, 8 Apr 2004 08:54:29 -0300 (ADT) +Received: from 3times25.net (66-23-202-190.clients.speedfactory.net + [66.23.202.190]) + by svr1.postgresql.org (Postfix) with ESMTP id 0FA5AD1B441 + for ; + Thu, 8 Apr 2004 08:54:27 -0300 (ADT) +Received: from 3times25.net (localhost [127.0.0.1]) + by 3times25.net (Postfix) with ESMTP + id 7D5E74C167; Thu, 8 Apr 2004 07:56:53 -0400 (EDT) +Message-ID: <40753E05.7030300@3times25.net> +Date: Thu, 08 Apr 2004 07:56:53 -0400 +From: Geoffrey +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040113 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Andrew McMillan +Cc: Tom Lane , pgsql-performance@postgresql.org +Subject: Re: good pc but bad performance,why? +References: <200404080133.i381XYu13325@candle.pha.pa.us> + <7294.1081390414@sss.pgh.pa.us> + <1081414478.2428.13.camel@lamb.mcmillan.net.nz> +In-Reply-To: <1081414478.2428.13.camel@lamb.mcmillan.net.nz> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/107 +X-Sequence-Number: 6407 + +Andrew McMillan wrote: +> On Thu, 2004-04-08 at 14:13, Tom Lane wrote: +> +>> Bruce Momjian writes: +>> +>>> Tom Lane wrote: +>>> +>>>> But it should be okay to set the filesystem to journal only its +>>>> own metadata. There's no need for it to journal file contents. +>>>> +>> +>>> Can you set ext2 to journal metadata? I didn't know it could do +>>> that. +>> +>> No, ext2 has no journal at all AFAIK. But I believe ext3 has an +>> option to journal or not journal file contents, and at least on a +>> Postgres-only volume you'd want to turn that off. +> +> +> No, it certainly doesn't. + +You can mount ext3 filesystems as ext2 and they will function just as ext2. + +-- +Until later, Geoffrey Registered Linux User #108567 +Building secure systems in spite of Microsoft + +From pgsql-performance-owner@postgresql.org Thu Apr 8 09:29:03 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E8673D1D887 + for ; + Thu, 8 Apr 2004 09:29:01 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 05175-07 + for ; + Thu, 8 Apr 2004 09:29:01 -0300 (ADT) +Received: from my.endian.it (unknown [62.146.87.34]) + by svr1.postgresql.org (Postfix) with ESMTP id 4F222D1D4D5 + for ; + Thu, 8 Apr 2004 09:28:59 -0300 (ADT) +Received: from 1006.org (localhost.localdomain [127.0.0.1]) + by my.endian.it (8.11.6/8.11.6) with SMTP id i38D16l21293 + for ; Thu, 8 Apr 2004 15:01:06 +0200 +Received: from host72-55.pool8248.interbusiness.it ([82.48.55.72]) + (SquirrelMail authenticated user list@1006.org) + by www.endian.it with HTTP; Thu, 8 Apr 2004 15:01:06 +0200 (CEST) +Message-ID: <49386.82.48.55.72.1081429266.squirrel@www.endian.it> +Date: Thu, 8 Apr 2004 15:01:06 +0200 (CEST) +Subject: Re: data=writeback +From: +To: +In-Reply-To: <2A07EC2D0BC2774AAD6F74769F60D52A0832C9@ahmose.cict_ad.nl> +References: <2A07EC2D0BC2774AAD6F74769F60D52A0832C9@ahmose.cict_ad.nl> +X-Priority: 3 +Importance: Normal +X-MSMail-Priority: Normal +X-Mailer: SquirrelMail (version 1.2.7) +MIME-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/108 +X-Sequence-Number: 6408 + +> When I give "mount" at the command line, everything looks just fine : +> +> /dev/sda2 on / type ext3 (rw,noatime,data=ordered) +> none on /proc type proc (rw) +> usbdevfs on /proc/bus/usb type usbdevfs (rw) +> /dev/sda1 on /boot type ext3 (rw,noatime,data=ordered) +> none on /dev/pts type devpts (rw,gid=5,mode=620) +> none on /dev/shm type tmpfs (rw) +> /dev/sdb1 on /usr/local/pgsql type ext3 (rw,noatime,data=writeback) +> /dev/sda3 on /usr/local/pgsql/wal type ext3 (rw,noatime,data=ordered) +> +> It looks like the labels are not really used, just the mount-points. Or +> could this cause other problems I am not aware of? Everything seems to +> be working just fine, for several months now... + +Probably /dev/sdb1 and /dev/sda3 have the same labels and mount +simply mounts them in a consistent way according to some logic +we're not aware of. + +I'd say: if it works don't touch it ;) + +What remains unresolved is the question whether data=writeback is ok +or not. We'll see if somebody has more information on that one... + +Bye, Chris. + + + + + + + +From pgsql-performance-owner@postgresql.org Thu Apr 8 11:09:09 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id F0D04D1D09F + for ; + Thu, 8 Apr 2004 11:09:05 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 44223-10 + for ; + Thu, 8 Apr 2004 11:09:06 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 677F3D1D097 + for ; + Thu, 8 Apr 2004 11:09:03 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i38E976Y013442; + Thu, 8 Apr 2004 10:09:07 -0400 (EDT) +To: Cosimo Streppone +Cc: pgsql-performance@postgresql.org +Subject: Re: select count(*) on large tables +In-reply-to: <40751ED5.1010208@streppone.it> +References: <40751ED5.1010208@streppone.it> +Comments: In-reply-to Cosimo Streppone + message dated "Thu, 08 Apr 2004 11:43:49 +0200" +Date: Thu, 08 Apr 2004 10:09:07 -0400 +Message-ID: <13441.1081433347@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/109 +X-Sequence-Number: 6409 + +Cosimo Streppone writes: +> Is there an estimate time for this issue to be resolved? + +Approximately never. It's a fundamental feature of Postgres' design. + +As noted by Dennis, you can look at the pg_class statistics if a recent +estimate is good enough, or you can build user-level tracking tools if +you'd rather have fast count(*) than concurrent update capability. But +don't sit around waiting for the developers to "fix this bug", because +it isn't a bug and it isn't going to be fixed. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Apr 8 11:52:38 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E80BFD1DB35 + for ; + Thu, 8 Apr 2004 11:52:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 69849-02 + for ; + Thu, 8 Apr 2004 11:52:34 -0300 (ADT) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id 3EF09D1DB59 + for ; + Thu, 8 Apr 2004 11:52:30 -0300 (ADT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i38EqXV20923; + Thu, 8 Apr 2004 10:52:33 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200404081452.i38EqXV20923@candle.pha.pa.us> +Subject: Re: data=writeback +In-Reply-To: <49386.82.48.55.72.1081429266.squirrel@www.endian.it> +To: list@1006.org +Date: Thu, 8 Apr 2004 10:52:33 -0400 (EDT) +Cc: pgsql-performance@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL108 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/110 +X-Sequence-Number: 6410 + +list@1006.org wrote: +> > When I give "mount" at the command line, everything looks just fine : +> > +> > /dev/sda2 on / type ext3 (rw,noatime,data=ordered) +> > none on /proc type proc (rw) +> > usbdevfs on /proc/bus/usb type usbdevfs (rw) +> > /dev/sda1 on /boot type ext3 (rw,noatime,data=ordered) +> > none on /dev/pts type devpts (rw,gid=5,mode=620) +> > none on /dev/shm type tmpfs (rw) +> > /dev/sdb1 on /usr/local/pgsql type ext3 (rw,noatime,data=writeback) +> > /dev/sda3 on /usr/local/pgsql/wal type ext3 (rw,noatime,data=ordered) +> > +> > It looks like the labels are not really used, just the mount-points. Or +> > could this cause other problems I am not aware of? Everything seems to +> > be working just fine, for several months now... +> +> Probably /dev/sdb1 and /dev/sda3 have the same labels and mount +> simply mounts them in a consistent way according to some logic +> we're not aware of. +> +> I'd say: if it works don't touch it ;) +> +> What remains unresolved is the question whether data=writeback is ok +> or not. We'll see if somebody has more information on that one... + +Should be fine. We don't continue until fsync() writes all the data. +We don't care what order it is written in, just that is all written +before we continue. + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-performance-owner@postgresql.org Thu Apr 8 11:56:16 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7BDB8D1DB81 + for ; + Thu, 8 Apr 2004 11:56:11 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 68010-07 + for ; + Thu, 8 Apr 2004 11:56:11 -0300 (ADT) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id 9E9B9D1D8AE + for ; + Thu, 8 Apr 2004 11:56:07 -0300 (ADT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i38Eu5S21317; + Thu, 8 Apr 2004 10:56:05 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200404081456.i38Eu5S21317@candle.pha.pa.us> +Subject: Re: good pc but bad performance,why? +In-Reply-To: <1081414478.2428.13.camel@lamb.mcmillan.net.nz> +To: Andrew McMillan +Date: Thu, 8 Apr 2004 10:56:05 -0400 (EDT) +Cc: Tom Lane , pgsql-performance@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL108 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/111 +X-Sequence-Number: 6411 + +Andrew McMillan wrote: +> On Thu, 2004-04-08 at 14:13, Tom Lane wrote: +> > Bruce Momjian writes: +> > > Tom Lane wrote: +> > >> But it should be okay to set the filesystem to journal only its own +> > >> metadata. There's no need for it to journal file contents. +> > +> > > Can you set ext2 to journal metadata? I didn't know it could do that. +> > +> > No, ext2 has no journal at all AFAIK. But I believe ext3 has an option +> > to journal or not journal file contents, and at least on a Postgres-only +> > volume you'd want to turn that off. +> +> No, it certainly doesn't. +> +> To be honest I was not aware that PostgreSQL was susceptible to failure +> on non[metadata] journalled filesystems - I was [somewhat vaguely] of +> the understanding that it would work fine on any filesystem. + +We expect the filesystem to come back intact. If it doesn't from an +ext2 crash, we can't WAL recover in all cases. + +> And obviously, from my original post, we can see that I believed +> metadata journalling was wasted on it. + +No. UFS file systems don't do journaling, but do metadata fsync, which +is all we need. + +> Is the 'noatime' option worthwhile? Are you saying that PostgreSQL + +noatime might help, not sure, but my guess is that most inode fsync's +are modifications of mtime, which can't be turned off with amount +option. + +> should always be run on a metadata journalled filesystem then, and that +> VFAT, ext2, etc are ++ungood? + +Yep. Not sure about VFAT but we do need the filesystem to return after +a crash, obviously, or we can't even get to the xlog directory or the +/data files to do WAL recovery. + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-performance-owner@postgresql.org Thu Apr 8 12:06:36 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5AF22D1D07E + for ; + Thu, 8 Apr 2004 12:06:34 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 67575-09 + for ; + Thu, 8 Apr 2004 12:06:30 -0300 (ADT) +Received: from bramble.mmrd.com (unknown [65.217.53.66]) + by svr1.postgresql.org (Postfix) with ESMTP id 75554D1CCBF + for ; + Thu, 8 Apr 2004 12:06:29 -0300 (ADT) +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 i38F7acM023307; + Thu, 8 Apr 2004 11:07:37 -0400 +Received: from gnvex001.mmrd.com (gnvex001.mmrd.com [192.168.3.55]) + by thorn.mmrd.com (8.11.6/8.11.6) with ESMTP id i38F6Cl09664; + Thu, 8 Apr 2004 11:06:13 -0400 +Received: from camel.mmrd.com ([172.25.5.213]) by gnvex001.mmrd.com with SMTP + (Microsoft Exchange Internet Mail Service Version 5.5.2657.72) + id FVMA763Q; Thu, 8 Apr 2004 11:06:10 -0400 +Subject: Re: Postgresql educational sources +From: Robert Treat +To: "scott.marlowe" +Cc: Nid , pgsql-performance@postgresql.org +In-Reply-To: +References: +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +X-Mailer: Ximian Evolution 1.0.8 +Date: 08 Apr 2004 11:06:11 -0400 +Message-Id: <1081436772.2470.55.camel@camel> +Mime-Version: 1.0 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/112 +X-Sequence-Number: 6412 + +On Wed, 2004-04-07 at 16:27, scott.marlowe wrote: +> On Wed, 7 Apr 2004, Nid wrote: +> +> > Rather than ask some general, unanswerable question on how to tune my +> > database...I thought I ask where I might find an introduction to...or +> > manual/tutorial for the depths of managing a postgres db. Books? +> > Websites? Assume a basic to intermediate knowledge of DBs in general +> > with a desire to learn about postgres from the ground up. If it makes a +> > difference I'm using a postgres db in a Red Hat Linux OS environment. +> > Thanks! +> +> The online (adminstration) docs are quite good, and for tuning, look at +> the excellent tuning document on varlena: +> +> http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html +> + +Actually I might rather suggest looking at +http://techdocs.postgresql.org/ which has a slew of +links/articles/tutorials regarding development and administration of +postgresql databases (including a link to Scott's aforementioned doc) + +Robert Treat +-- +Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL + + +From pgsql-performance-owner@postgresql.org Thu Apr 8 14:33:35 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 254DCD1D2A4 + for ; + Thu, 8 Apr 2004 14:33:34 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 24329-09 + for ; + Thu, 8 Apr 2004 14:33:32 -0300 (ADT) +Received: from secure.icanx.com (secure.icanx.com [64.246.58.55]) + by svr1.postgresql.org (Postfix) with ESMTP id E192CD1D09A + for ; + Thu, 8 Apr 2004 14:33:30 -0300 (ADT) +Received: from 63-229-201-197.mpls.qwest.net ([63.229.201.197] + helo=[192.168.2.102]) by secure.icanx.com with esmtp (Exim 4.24) + id 1BBdPY-0001VQ-2D + for pgsql-performance@postgresql.org; Thu, 08 Apr 2004 13:33:56 -0400 +Mime-Version: 1.0 (Apple Message framework v613) +Content-Transfer-Encoding: 7bit +Message-Id: +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +To: pgsql-performance@postgresql.org +From: Mark Lubratt +Subject: tsearch query plan +Date: Thu, 8 Apr 2004 12:33:28 -0500 +X-Mailer: Apple Mail (2.613) +X-AntiAbuse: This header was added to track abuse, + please include it with any abuse report +X-AntiAbuse: Primary Hostname - secure.icanx.com +X-AntiAbuse: Original Domain - postgresql.org +X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] +X-AntiAbuse: Sender Address Domain - indeq.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/113 +X-Sequence-Number: 6413 + +Hello, + +I've just started using the tsearch2 system. I'm VERY impressed by the +speed. + +I've got one question about query planning. Is it understandable to +have the query plan estimation be off by a couple of orders of +magnitude? Or, is it the fact that the cost estimation is small to +begin with that the error between the actual and the estimated is +"normal"? + +Here is my explain analyze run immediately after a vacuum full analyze: + +kjv=# vacuum full analyze; +VACUUM +kjv=# explain analyze select * from kjv where idxFTI @@ +'corinth'::tsquery; + QUERY PLAN +------------------------------------------------------------------------ +--------------------------------------------- + Index Scan using idxfti_idx on kjv (cost=0.00..125.44 rows=32 +width=193) (actual time=0.796..1.510 rows=6 loops=1) + Index Cond: (idxfti @@ '\'corinth\''::tsquery) + Filter: (idxfti @@ '\'corinth\''::tsquery) + Total runtime: 1.679 ms +(4 rows) + +Thanks! +Mark + + +From pgsql-performance-owner@postgresql.org Thu Apr 8 19:42:28 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1A8A5D1BAAD + for ; + Thu, 8 Apr 2004 19:42:27 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 46580-07 + for ; + Thu, 8 Apr 2004 19:42:26 -0300 (ADT) +Received: from hotmail.com (bay8-f117.bay8.hotmail.com [64.4.27.117]) + by svr1.postgresql.org (Postfix) with ESMTP id 790EAD1B4D3 + for ; + Thu, 8 Apr 2004 19:42:23 -0300 (ADT) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Thu, 8 Apr 2004 15:42:25 -0700 +Received: from 65.248.167.226 by by8fd.bay8.hotmail.msn.com with HTTP; + Thu, 08 Apr 2004 22:42:25 GMT +X-Originating-IP: [65.248.167.226] +X-Originating-Email: [el_vigia_ec@hotmail.com] +X-Sender: el_vigia_ec@hotmail.com +From: "Jaime Casanova" +To: paul@tmsl.demon.co.uk, pgsql-performance@postgresql.org +Subject: Re: statistics +Date: Thu, 08 Apr 2004 22:42:25 +0000 +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed +Message-ID: +X-OriginalArrivalTime: 08 Apr 2004 22:42:25.0700 (UTC) + FILETIME=[C3A96E40:01C41DBA] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/114 +X-Sequence-Number: 6414 + +Thanks for the answer. + +I know the question was to primitive (it claims: i have no idea about +databases). +But i simply didn't find the answer and if a don't ask i won't learn. + +Someday i will talk with Tom Lane about how to improve the planner but until +that day comes i have a lot of technical things to learn. + +_________________________________________________________________ +Add photos to your messages with MSN 8. Get 2 months FREE*. +http://join.msn.com/?page=features/featuredemail + + +From pgsql-performance-owner@postgresql.org Thu Apr 8 20:33:29 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9DB24D1BAAD + for ; + Thu, 8 Apr 2004 20:33:27 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 60163-05 + for ; + Thu, 8 Apr 2004 20:33:28 -0300 (ADT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 69855D1B49F + for ; + Thu, 8 Apr 2004 20:33:25 -0300 (ADT) +Received: from [63.195.55.98] (HELO 192.168.1.29) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4801472; Thu, 08 Apr 2004 16:34:48 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Mark Lubratt , + pgsql-performance@postgresql.org +Subject: Re: tsearch query plan +Date: Thu, 8 Apr 2004 16:33:40 -0700 +User-Agent: KMail/1.5.4 +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200404081633.40388.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/115 +X-Sequence-Number: 6415 + +Mark, + +> I've got one question about query planning. Is it understandable to +> have the query plan estimation be off by a couple of orders of +> magnitude? Or, is it the fact that the cost estimation is small to +> begin with that the error between the actual and the estimated is +> "normal"? + +Well, your example is not "a couple orders of magnitude". 6 vs. 32 is +actually pretty good accuracy. + +Now, 6 vs 192 would potentially be a problem, let alone 32 vs 13,471. + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Fri Apr 9 00:28:44 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id BFCE4D1CCC5 + for ; + Fri, 9 Apr 2004 00:28:41 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 29961-04 + for ; + Fri, 9 Apr 2004 00:28:39 -0300 (ADT) +Received: from secure.icanx.com (secure.icanx.com [64.246.58.55]) + by svr1.postgresql.org (Postfix) with ESMTP id 113E7D1CCC2 + for ; + Fri, 9 Apr 2004 00:28:40 -0300 (ADT) +Received: from 63-229-201-197.mpls.qwest.net ([63.229.201.197] + helo=[192.168.2.102]) by secure.icanx.com with esmtp (Exim 4.24) + id 1BBmhU-0004nz-FQ; Thu, 08 Apr 2004 23:29:04 -0400 +Mime-Version: 1.0 (Apple Message framework v613) +In-Reply-To: <200404081633.40388.josh@agliodbs.com> +References: + <200404081633.40388.josh@agliodbs.com> +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: +Content-Transfer-Encoding: 7bit +From: Mark Lubratt +Subject: Re: tsearch query plan +Date: Thu, 8 Apr 2004 22:28:37 -0500 +To: pgsql-performance@postgresql.org, josh@agliodbs.com +X-Mailer: Apple Mail (2.613) +X-AntiAbuse: This header was added to track abuse, + please include it with any abuse report +X-AntiAbuse: Primary Hostname - secure.icanx.com +X-AntiAbuse: Original Domain - postgresql.org +X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] +X-AntiAbuse: Sender Address Domain - indeq.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/116 +X-Sequence-Number: 6416 + + +On Apr 8, 2004, at 6:33 PM, Josh Berkus wrote: + +> Mark, +> +>> I've got one question about query planning. Is it understandable to +>> have the query plan estimation be off by a couple of orders of +>> magnitude? Or, is it the fact that the cost estimation is small to +>> begin with that the error between the actual and the estimated is +>> "normal"? +> +> Well, your example is not "a couple orders of magnitude". 6 vs. 32 is +> actually pretty good accuracy. +> +> Now, 6 vs 192 would potentially be a problem, let alone 32 vs 13,471. +> + +I guess I was looking more at the cost estimate and not so much at the +rows estimate. I agree that the row estimate wasn't too bad. But the +cost estimate seems way out of line. + +I'm somewhat new to examining explain analyze output and I'm looking at +this as more of an education, since the speed is certainly good anyway. + I just expected the cost estimate to be more in line especially +immediately after an analyze. + +-Mark + + +From pgsql-performance-owner@postgresql.org Fri Apr 9 02:26:59 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9FAE5D1D282 + for ; + Fri, 9 Apr 2004 02:26:56 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 53271-08 + for ; + Fri, 9 Apr 2004 02:26:54 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 8C01DD1C9DA + for ; + Fri, 9 Apr 2004 02:26:54 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i395QqlA021350; + Fri, 9 Apr 2004 01:26:52 -0400 (EDT) +To: Mark Lubratt +Cc: pgsql-performance@postgresql.org, josh@agliodbs.com +Subject: Re: tsearch query plan +In-reply-to: +References: + <200404081633.40388.josh@agliodbs.com> + +Comments: In-reply-to Mark Lubratt + message dated "Thu, 08 Apr 2004 22:28:37 -0500" +Date: Fri, 09 Apr 2004 01:26:51 -0400 +Message-ID: <21349.1081488411@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/117 +X-Sequence-Number: 6417 + +Mark Lubratt writes: +> I guess I was looking more at the cost estimate and not so much at the +> rows estimate. I agree that the row estimate wasn't too bad. But the +> cost estimate seems way out of line. + +The cost estimates are not even in the same units as the actual runtime. +Cost is in an arbitrary scale in which 1 unit = 1 sequential disk block +fetch. It is unknown what this might equate to on your machine ... but +it's quite unlikely that it's 1.0 millisecond. The thing to look at +when considering EXPLAIN results is whether the ratios of different cost +estimates are proportional to the actual runtimes. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Apr 9 12:02:39 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 251C8D1D06F + for ; + Fri, 9 Apr 2004 12:02:37 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 23290-07 + for ; + Fri, 9 Apr 2004 12:02:14 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 5FFDAD1D078 + for ; + Fri, 9 Apr 2004 12:02:14 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i39F2CM7025870; + Fri, 9 Apr 2004 11:02:12 -0400 (EDT) +To: "Andrew Matthews" +Cc: pgsql-performance@postgresql.org +Subject: Re: Wierd issues +In-reply-to: + <79AEF92046759442A4AA04C2AB08C0B80834E2@exchange.corp.dslextreme.com> +References: + <79AEF92046759442A4AA04C2AB08C0B80834E2@exchange.corp.dslextreme.com> +Comments: In-reply-to "Andrew Matthews" + message dated "Mon, 05 Apr 2004 18:41:08 -0700" +Date: Fri, 09 Apr 2004 11:02:11 -0400 +Message-ID: <25869.1081522931@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/118 +X-Sequence-Number: 6418 + +"Andrew Matthews" writes: +> [ PG 7.3.4 much slower than 7.2.1 ] +> +> Both have same databases, Both have had vacume full ran on them. + +You did ANALYZE too, right? + +The bulk of the time is evidently going into the seqscan on users in +each case: + +> -> Seq Scan on users u (cost=0.00..1938.51 rows=71283 width=4) (actual time=0.81..30119.58 rows=70809 loops=1) + +> -> Seq Scan on users u (cost=0.00..1888.85 rows=71548 width=4) (actual time=18.38..2277152.51 rows=71028 loops=1) +> Filter: (get_pwd(username, '127.0.0.1'::character varying, '101'::character varying, 'MD5'::character varying) IS NOT NULL) + +I have to suspect that the inefficiency is inside this get_pwd() +function, but you didn't tell us anything about that... + + regards, tom lane + +From pgsql-admin-owner@postgresql.org Fri Apr 9 13:02:35 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 2D087D1BBA1; Fri, 9 Apr 2004 13:02:32 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 41593-09; Fri, 9 Apr 2004 13:02:29 -0300 (ADT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP + id 88701D1BA90; Fri, 9 Apr 2004 13:02:28 -0300 (ADT) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4806184; Fri, 09 Apr 2004 09:03:48 -0700 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: Grega Bremec +Subject: Re: [PERFORM] Raw devices vs. Filesystems +Date: Fri, 9 Apr 2004 09:02:00 -0700 +User-Agent: KMail/1.4.3 +Cc: pgsql-admin@postgresql.org, pgsql-performance@postgresql.org +References: + <71E37EF6B7DCC1499CEA0316A25683280105786A@loki.wc.globexplorer.net> + <200404070909.16123.josh@agliodbs.com> + <20040408043304.GA28539@elbereth.noviforum.si> +In-Reply-To: <20040408043304.GA28539@elbereth.noviforum.si> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200404090902.00934.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/182 +X-Sequence-Number: 13155 + +Grega, + +> Well, as I said, that's why I was asking - I'm willing to give it a go +> if nobody can prove me wrong. :) + +Why not? If you have time? + +> I thought you knew - OCFS, OCFS-Tools and OCFSv2 have not only been open- +> source for quite a while now - they're released under the GPL. + +Keen! Wonder if we can make them regret it. + +Seriously, if Oracle opened this stuff, it's probably becuase they used some +GPL components in it. It also probably means that it won't work for +anything but Oracle ... + +> I don't know what that means to you (probably nothing good, as PostgreSQL +> is released under the BSD license), + +Well, it just means that we can't ship OCFS with PostgreSQL. + +> The question does spring up though, that Steve raised in another post - +> just for the record, what POSIX semantics can a postmaster live without in +> a filesystem? + +You might want to ask that question again on Hackers. I don't know the +answer, myself. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Fri Apr 9 21:27:53 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 240EAD1D105 + for ; + Fri, 9 Apr 2004 13:12:51 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 48057-08 + for ; + Fri, 9 Apr 2004 13:12:44 -0300 (ADT) +Received: from exchange.rampageusa.net (exchange.dslextreme.com + [66.51.198.16]) + by svr1.postgresql.org (Postfix) with ESMTP id 6AC87D1D299 + for ; + Fri, 9 Apr 2004 13:12:43 -0300 (ADT) +Received: from exstatica ([66.51.209.71]) by exchange.rampageusa.net with + Microsoft SMTPSVC(6.0.3790.0); Fri, 9 Apr 2004 09:11:50 -0700 +From: "Andrew Matthews" +To: "'Tom Lane'" +Cc: +Subject: Re: Wierd issues +Date: Fri, 9 Apr 2004 09:12:38 -0700 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Mailer: Microsoft Office Outlook, Build 11.0.5510 +Thread-Index: AcQeQ4U5gf8WxlkmSSeVfxxW2VCIBgACdxnQ +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +In-reply-to: <25869.1081522931@sss.pgh.pa.us> +Message-ID: +X-OriginalArrivalTime: 09 Apr 2004 16:11:51.0025 (UTC) + FILETIME=[5DEB8E10:01C41E4D] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/125 +X-Sequence-Number: 6425 + +Yes I did do analyze.... the here is the get_pwd function + +-- Function: public.get_pwd(varchar, varchar, varchar, varchar) + +-- DROP FUNCTION public.get_pwd(varchar, varchar, varchar, varchar); + +CREATE OR REPLACE FUNCTION public.get_pwd(varchar, varchar, varchar, +varchar) + RETURNS varchar AS +' +DECLARE + p_username ALIAS for $1; + p_server ALIAS for $2; + p_service ALIAS for $3; + p_pwd_type ALIAS for $4; + + l_resource_id integer; + l_server_id integer; + l_service_id integer; + l_allow_deny char(1); + l_user_id integer; + l_account_id integer; + l_passwd varchar(40); +begin + + -- get server identifier + select id + into l_server_id + from servers s + where address = p_server; + + if NOT FOUND then + -- try to get default server + select id + into l_server_id + from servers s + where address = \'default\'; + end if; + + if l_server_id isnull then + return NULL; + end if; + + -- get service identifier + select id + into l_service_id + from services s + where radius_service = p_service; + + if l_service_id isnull then + return NULL; + end if; + + -- get resource identifier (server/service combination) + select id + into l_resource_id + from resources r + where service_id = l_service_id + and server_id = l_server_id; + + -- could not find resource via server_id, now look via server\'s group if +any + if l_resource_id isnull then + select id + into l_resource_id + from resources r + where service_id = l_service_id + and server_group_id = (select server_group_id from servers where id = +l_server_id); + end if; + + -- could not determine resource user wants to access, so deny by returning +NULL passwd + if l_resource_id isnull then + return NULL; + end if; + + -- at this point we have a valid resource_id + -- determine if valid username + select u.id, u.account_id + into l_user_id, l_account_id + from users u, accounts a + where u.username = upper(p_username) -- always uppercase in DB + and u.del_id = 0 + and u.status = \'A\' + and a.status = \'A\' + and u.account_id = a.id; + + -- if active user not found then return NULL for passwd + if l_user_id isnull then + return null; + end if; + + -- user specific control + select allow_deny + into l_allow_deny + from users_acl + where resource_id = l_resource_id + and user_id = l_user_id; + + if l_allow_deny = \'D\' then + return NULL; + elsif l_allow_deny isnull then -- no user-specific control + select max(allow_deny) -- \'D\' is > \'A\' hence deny takes precedence +if conflict across groups + into l_allow_deny + from users_acl + where resource_id = l_resource_id + and user_group_id in (select user_group_id from +user_group_assignments + where user_id = l_user_id); + elsif l_allow_deny = \'A\' then + -- do nothing; -- get and return passwd below + end if; + + if l_allow_deny isnull or l_allow_deny = \'D\' then + return NULL; + elsif l_allow_deny = \'A\' then + select password + into l_passwd + from user_pwds + where password_type = upper(p_pwd_type) + and user_id = l_user_id; + + return l_passwd; + else + return null; + end if; + +end; + +' + LANGUAGE 'plpgsql' VOLATILE; + +-----Original Message----- +From: Tom Lane [mailto:tgl@sss.pgh.pa.us] +Sent: Friday, April 09, 2004 8:02 AM +To: Andrew Matthews +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Wierd issues + +"Andrew Matthews" writes: +> [ PG 7.3.4 much slower than 7.2.1 ] +> +> Both have same databases, Both have had vacume full ran on them. + +You did ANALYZE too, right? + +The bulk of the time is evidently going into the seqscan on users in +each case: + +> -> Seq Scan on users u (cost=0.00..1938.51 +rows=71283 width=4) (actual time=0.81..30119.58 rows=70809 loops=1) + +> -> Seq Scan on users u (cost=0.00..1888.85 +rows=71548 width=4) (actual time=18.38..2277152.51 rows=71028 loops=1) +> Filter: (get_pwd(username, +'127.0.0.1'::character varying, '101'::character varying, 'MD5'::character +varying) IS NOT NULL) + +I have to suspect that the inefficiency is inside this get_pwd() +function, but you didn't tell us anything about that... + + regards, tom lane + + + +From pgsql-performance-owner@postgresql.org Fri Apr 9 13:50:43 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 30712D1CCC2 + for ; + Fri, 9 Apr 2004 13:50:41 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 62545-05 + for ; + Fri, 9 Apr 2004 13:50:40 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 538FBD1CA77 + for ; + Fri, 9 Apr 2004 13:50:39 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i39GoZtX026676; + Fri, 9 Apr 2004 12:50:35 -0400 (EDT) +To: Ken Geis +Cc: Richard Huxton , + pgsql-performance@postgresql.org +Subject: Re: plan problem +In-reply-to: <4073C3DF.2070307@speakeasy.org> +References: <40731252.2030002@speakeasy.org> + <200404070938.11482.dev@archonet.com> + <4073C3DF.2070307@speakeasy.org> +Comments: In-reply-to Ken Geis + message dated "Wed, 07 Apr 2004 02:03:27 -0700" +Date: Fri, 09 Apr 2004 12:50:35 -0400 +Message-ID: <26675.1081529435@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/120 +X-Sequence-Number: 6420 + +Ken Geis writes: +> Does anyone think that the planner issue has merit to address? Can +> someone help me figure out what code I would look at? + +The planner doesn't currently attempt to "drill down" into a sub-select- +in-FROM to find statistics about the variables emitted by the sub-select. +So it's just falling back to a default estimate of the number of +distinct values coming out of the sub-select. + +The "drilling down" part is not hard; the difficulty comes from trying +to figure out whether and how the stats from the underlying column would +need to be adjusted for the behavior of the sub-select itself. As an +example, the result of (SELECT DISTINCT foo FROM bar) would usually have +much different stats from the raw bar.foo column. In your example, the +LIMIT clause potentially affects the stats by reducing the number of +distinct values. + +Now in most situations where the sub-select wouldn't change the stats, +there's no issue anyway because the planner will flatten the sub-select +into the main query. So we really have to figure out the adjustment +part before we can think about doing much here. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Apr 9 14:28:34 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0C53FD1D1B8 + for ; + Fri, 9 Apr 2004 14:28:33 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 78801-01 + for ; + Fri, 9 Apr 2004 14:28:31 -0300 (ADT) +Received: from fddlnint05.fds.com (fddlnint05.fds.com [208.15.91.52]) + by svr1.postgresql.org (Postfix) with ESMTP id 632B5D1D070 + for ; + Fri, 9 Apr 2004 14:28:30 -0300 (ADT) +Subject: Upgrading question (recycled transaction log) +To: pgsql-performance@postgresql.org +X-Mailer: Lotus Notes Release 6.0 September 26, 2002 +Message-ID: + +From: "Patrick Hatcher" +Date: Fri, 9 Apr 2004 10:18:12 -0700 +X-MIMETrack: Serialize by Router on FDDLNINT05/FSG/SVR/FDD(Release 5.0.4 |June + 8, 2000) at 04/09/2004 01:21:51 PM +MIME-Version: 1.0 +Content-type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/121 +X-Sequence-Number: 6421 + +Doing an upgrade from 7.3.6 to 7.4.2 and I keep seeing the recycled +transaction log about every 2 mins. For future upgrades, is there +something that can be set so that I don't have as many recycles? It seems +to slow down the importing of data. +Here's my current settings: + +#--------------------------------------------------------------------------- +# WRITE AHEAD LOG +#--------------------------------------------------------------------------- + +# - Settings - + +#fsync = true # turns forced synchronization on or off +#wal_sync_method = fsync # the default varies across platforms: + # fsync, fdatasync, open_sync, or +open_datasync +wal_buffers = 32 # min 4, 8KB each + +# - Checkpoints - + +checkpoint_segments = 30 # in logfile segments, min 1, 16MB each +checkpoint_timeout = 600 # range 30-3600, in seconds +#checkpoint_warning = 30 # 0 is off, in seconds +#commit_delay = 0 # range 0-100000, in microseconds +#commit_siblings = 5 # range 1-1000 + + + +TIA +Patrick Hatcher + + + +From pgsql-performance-owner@postgresql.org Fri Apr 9 15:03:32 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C0F68D1D1B8 + for ; + Fri, 9 Apr 2004 15:03:29 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 90375-03 + for ; + Fri, 9 Apr 2004 15:03:29 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id C004BD1D07F + for ; + Fri, 9 Apr 2004 15:03:27 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i39I3RjZ027369; + Fri, 9 Apr 2004 14:03:27 -0400 (EDT) +To: "Patrick Hatcher" +Cc: pgsql-performance@postgresql.org +Subject: Re: Upgrading question (recycled transaction log) +In-reply-to: + +References: + +Comments: In-reply-to "Patrick Hatcher" + message dated "Fri, 09 Apr 2004 10:18:12 -0700" +Date: Fri, 09 Apr 2004 14:03:27 -0400 +Message-ID: <27368.1081533807@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/122 +X-Sequence-Number: 6422 + +"Patrick Hatcher" writes: +> Doing an upgrade from 7.3.6 to 7.4.2 and I keep seeing the recycled +> transaction log about every 2 mins. For future upgrades, is there +> something that can be set so that I don't have as many recycles? + +Increasing checkpoint_segments ... but you seem to have that pretty high +already. + + regards, tom lane + +From pgsql-admin-owner@postgresql.org Fri Apr 9 17:10:48 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E5ACFD1B486 + for ; + Fri, 9 Apr 2004 17:10:46 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 32905-01 + for ; + Fri, 9 Apr 2004 17:10:45 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 47879D1BB49 + for ; Fri, 9 Apr 2004 17:10:43 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i39KAgSx032994 + for ; Fri, 9 Apr 2004 20:10:42 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i39JoZwQ029628 + for pgsql-admin@postgresql.org; Fri, 9 Apr 2004 19:50:35 GMT +From: Christopher Browne +X-Newsgroups: comp.databases.postgresql.admin +Subject: Re: [PERFORM] Raw devices vs. Filesystems +Date: Fri, 09 Apr 2004 15:34:44 -0400 +Organization: cbbrowne Computing Inc +Lines: 31 +Message-ID: +References: + <71E37EF6B7DCC1499CEA0316A25683280105786A@loki.wc.globexplorer.net> + <200404070909.16123.josh@agliodbs.com> + <20040408043304.GA28539@elbereth.noviforum.si> + <200404090902.00934.josh@agliodbs.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@news.hub.org +X-message-flag: Outlook is rather hackable, isn't it? +X-Home-Page: http://www.cbbrowne.com/info/ +X-Affero: http://svcs.affero.net/rm.php?r=cbbrowne +User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Security Through + Obscurity, + linux) +Cancel-Lock: sha1:Qy8p2wVqpwk1Hpbfyh9IDhTL0QM= +To: pgsql-admin@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/186 +X-Sequence-Number: 13159 + +josh@agliodbs.com (Josh Berkus) wrote: +>> Well, as I said, that's why I was asking - I'm willing to give it a go +>> if nobody can prove me wrong. :) +> +> Why not? If you have time? + +True enough. + +>> I thought you knew - OCFS, OCFS-Tools and OCFSv2 have not only been +>> open- source for quite a while now - they're released under the +>> GPL. +> +> Keen! Wonder if we can make them regret it. +> +> Seriously, if Oracle opened this stuff, it's probably becuase they +> used some GPL components in it. It also probably means that it +> won't work for anything but Oracle ... + +It could be that the experiment shows that OCFS isn't all that +helpful. Or that it helps cover inadequacies in certain aspects of +how Oracle accesses filesystems. + +If it _does_ show that it is helpful, then that may suggest a +filesystem implementation strategy useful for the BSD folks. + +The main "failure case" would be if the exercise shows that using OCFS +is pretty futile. +-- +select 'cbbrowne' || '@' || 'acm.org'; +http://www3.sympatico.ca/cbbrowne/linux.html +Do you know where your towel is? + +From pgsql-performance-owner@postgresql.org Fri Apr 9 16:45:56 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8894FD1BB49 + for ; + Fri, 9 Apr 2004 16:45:55 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 14641-10 + for ; + Fri, 9 Apr 2004 16:45:55 -0300 (ADT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id C879AD1BA90 + for ; + Fri, 9 Apr 2004 16:45:53 -0300 (ADT) +Received: from [63.195.55.98] (HELO 192.168.1.29) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4807612 for pgsql-performance@postgresql.org; + Fri, 09 Apr 2004 12:47:17 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Performance data for OpenFTS? +Date: Fri, 9 Apr 2004 12:46:04 -0700 +User-Agent: KMail/1.5.4 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200404091246.04438.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/123 +X-Sequence-Number: 6423 + +Hey, + +Has anyone done performance tests for OpenFTS on a really large database? I +was speaking at PerlMongers and somebody asked. + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Mon Apr 12 06:27:59 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 30C28D1B4BE + for ; + Mon, 12 Apr 2004 06:27:58 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 19488-06 + for ; + Mon, 12 Apr 2004 06:27:23 -0300 (ADT) +Received: from mwinf0101.wanadoo.fr (smtp1.wanadoo.fr [193.252.22.30]) + by svr1.postgresql.org (Postfix) with ESMTP id 876C5D1D070 + for ; + Mon, 12 Apr 2004 06:27:08 -0300 (ADT) +Received: from [192.168.0.2] (AMontsouris-108-1-29-248.w81-53.abo.wanadoo.fr + [81.53.158.248]) + by mwinf0101.wanadoo.fr (SMTP Server) with ESMTP id AA0C0C0000B9 + for ; + Mon, 12 Apr 2004 11:26:57 +0200 (CEST) +Mime-Version: 1.0 (Apple Message framework v613) +Content-Transfer-Encoding: quoted-printable +Message-Id: <8A2105D4-8C63-11D8-80FD-000A95DE2550@ifrance.com> +Content-Type: text/plain; charset=ISO-8859-1; delsp=yes; format=flowed +To: pgsql-performance@postgresql.org +From: =?ISO-8859-1?Q?Pailloncy_Jean-G=E9rard?= +Subject: Index Backward Scan fast / Index Scan slow ! +Date: Mon, 12 Apr 2004 11:26:55 +0200 +X-Mailer: Apple Mail (2.613) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/126 +X-Sequence-Number: 6426 + +Hi, + +I test many times the foolowing query. + +dps=3D# explain analyze select next_index_time from url order by=20=20 +next_index_time desc limit 1; +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 +QUERY PLAN +------------------------------------------------------------------------=20 +------------------------------------------------------------------------=20 +---- + Limit (cost=3D0.00..2.62 rows=3D1 width=3D4) (actual time=3D56.615..56.6= +16=20=20 +rows=3D1 loops=3D1) + -> Index Scan Backward using url_next_index_time on url=20=20=20 +(cost=3D0.00..768529.55 rows=3D293588 width=3D4) (actual time=3D56.610..56.= +610=20=20 +rows=3D1 loops=3D1) + Total runtime: 56.669 ms +(3 rows) + +dps=3D# explain analyze select next_index_time from url order by=20=20 +next_index_time asc limit 1; +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 +QUERY PLAN +------------------------------------------------------------------------=20 +------------------------------------------------------------------------=20 +- + Limit (cost=3D0.00..2.62 rows=3D1 width=3D4) (actual=20=20 +time=3D94879.636..94879.637 rows=3D1 loops=3D1) + -> Index Scan using url_next_index_time on url=20=20=20 +(cost=3D0.00..768529.55 rows=3D293588 width=3D4) (actual=20=20 +time=3D94879.631..94879.631 rows=3D1 loops=3D1) + Total runtime: 94879.688 ms +(3 rows) + +How to optimize the last query ? (~ 2000 times slower than the first=20=20 +one) +I suppose there is some odd distribution of data in the index ? +Is the solution to reindex data ? + +Cordialement, +Jean-G=E9rard Pailloncy + +From pgsql-performance-owner@postgresql.org Mon Apr 12 08:52:22 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 54E6AD1CCB7 + for ; + Mon, 12 Apr 2004 08:52:22 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 57198-06 + for ; + Mon, 12 Apr 2004 08:52:23 -0300 (ADT) +Received: from trade-india.com (unknown [61.16.154.82]) + by svr1.postgresql.org (Postfix) with SMTP id EFB68D1DC69 + for ; + Mon, 12 Apr 2004 08:52:17 -0300 (ADT) +Received: (qmail 15532 invoked from network); 12 Apr 2004 11:40:01 -0000 +Received: from valium.trade-india-local.com (HELO trade-india.com) + (192.168.0.72) + by system66.trade-india-local.com with SMTP; 12 Apr 2004 11:40:01 -0000 +Message-ID: <407A8369.9090205@trade-india.com> +Date: Mon, 12 Apr 2004 17:24:17 +0530 +From: Rajesh Kumar Mallah +Organization: Infocom Network Limited +User-Agent: Mozilla Thunderbird 0.5 (X11/20040208) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Effect of too many columns +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/127 +X-Sequence-Number: 6427 + + +Greetings, + +Is there any performance penalty of having too many columns in +a table in terms of read and write speeds. + +To order to keep operational queries simple (avoid joins) we plan to +add columns in the main customer dimension table. + +Adding more columns also means increase in concurrency in the table +as more and more applications will access the same table. + +Any ideas if its better to split the table application wise or is it ok? + + + +Regds +mallah. + +From pgsql-performance-owner@postgresql.org Mon Apr 12 09:13:59 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8E48BD1BAF8 + for ; + Mon, 12 Apr 2004 09:13:58 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 61632-05 + for ; + Mon, 12 Apr 2004 09:14:00 -0300 (ADT) +Received: from wolff.to (wolff.to [66.93.249.74]) + by svr1.postgresql.org (Postfix) with SMTP id A9395D1BAA5 + for ; + Mon, 12 Apr 2004 09:13:56 -0300 (ADT) +Received: (qmail 20507 invoked by uid 500); 12 Apr 2004 12:17:40 -0000 +Date: Mon, 12 Apr 2004 07:17:40 -0500 +From: Bruno Wolff III +To: Rajesh Kumar Mallah +Cc: pgsql-performance@postgresql.org +Subject: Re: Effect of too many columns +Message-ID: <20040412121740.GC20278@wolff.to> +Mail-Followup-To: Rajesh Kumar Mallah , + pgsql-performance@postgresql.org +References: <407A8369.9090205@trade-india.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <407A8369.9090205@trade-india.com> +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/128 +X-Sequence-Number: 6428 + +On Mon, Apr 12, 2004 at 17:24:17 +0530, + Rajesh Kumar Mallah wrote: +> +> Greetings, +> +> Is there any performance penalty of having too many columns in +> a table in terms of read and write speeds. +> +> To order to keep operational queries simple (avoid joins) we plan to +> add columns in the main customer dimension table. +> +> Adding more columns also means increase in concurrency in the table +> as more and more applications will access the same table. +> +> Any ideas if its better to split the table application wise or is it ok? + +This is normally a bad idea. If you properly implement constraints in +what is effectively a materialized view, you might end up with a slower +system, depending on your mix of queries. (Generally updating will take +more resources.) So you probably want to test your new design under a +simulated normal load to see if it actually speeds things up in your +case before making the change. + +From pgsql-performance-owner@postgresql.org Mon Apr 12 09:28:47 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 70ACED1BB8C + for ; + Mon, 12 Apr 2004 09:28:44 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 69334-03 + for ; + Mon, 12 Apr 2004 09:28:46 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 7AB38D1BAAD + for ; + Mon, 12 Apr 2004 09:28:42 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3CCSJIh008580; + Mon, 12 Apr 2004 08:28:19 -0400 (EDT) +To: =?ISO-8859-1?Q?Pailloncy_Jean-G=E9rard?= +Cc: pgsql-performance@postgresql.org +Subject: Re: Index Backward Scan fast / Index Scan slow ! +In-reply-to: <8A2105D4-8C63-11D8-80FD-000A95DE2550@ifrance.com> +References: <8A2105D4-8C63-11D8-80FD-000A95DE2550@ifrance.com> +Comments: In-reply-to =?ISO-8859-1?Q?Pailloncy_Jean-G=E9rard?= + + message dated "Mon, 12 Apr 2004 11:26:55 +0200" +Date: Mon, 12 Apr 2004 08:28:19 -0400 +Message-ID: <8579.1081772899@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/129 +X-Sequence-Number: 6429 + +=?ISO-8859-1?Q?Pailloncy_Jean-G=E9rard?= writes: +> How to optimize the last query ? (~ 2000 times slower than the first +> one) +> I suppose there is some odd distribution of data in the index ? + +Looks to me like a whole lot of dead rows at the left end of the index. +Have you VACUUMed this table lately? It would be interesting to see +what VACUUM VERBOSE has to say about it. + +> Is the solution to reindex data ? + +In 7.4 a VACUUM should be sufficient ... or at least, if it isn't +I'd like to know why not before you destroy the evidence by reindexing. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Apr 12 11:39:39 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 85B32D1D070 + for ; + Mon, 12 Apr 2004 11:39:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 13530-01 + for ; + Mon, 12 Apr 2004 11:39:37 -0300 (ADT) +Received: from ECCMCBH.cmc.int.ec.gc.ca (ecdor130.cmc.ec.gc.ca + [199.212.17.130]) + by svr1.postgresql.org (Postfix) with ESMTP id C173BD1BB8C + for ; + Mon, 12 Apr 2004 11:39:23 -0300 (ADT) +Received: by eccmcbh.cmc.ec.gc.ca with Internet Mail Service (5.5.2653.19) + id <2A89N0WZ>; Mon, 12 Apr 2004 10:39:24 -0400 +Message-ID: +From: "Shea,Dan [CIS]" +To: Postgres Performance +Subject: Deleting certain duplicates +Date: Mon, 12 Apr 2004 10:39:22 -0400 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2653.19) +Content-Type: text/plain; + charset="iso-8859-1" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/130 +X-Sequence-Number: 6430 + +We have a large database which recently increased dramatically due to a +change in our insert program allowing all entries. +PWFPM_DEV=# select relname,relfilenode,reltuples from pg_class where relname += 'forecastelement'; + relname | relfilenode | reltuples +-----------------+-------------+------------- + forecastelement | 361747866 | 4.70567e+08 + + Column | Type | Modifiers +----------------+-----------------------------+----------- + version | character varying(99) | + origin | character varying(10) | + timezone | character varying(99) | + region_id | character varying(20) | + wx_element | character varying(99) | + value | character varying(99) | + flag | character(3) | + units | character varying(99) | + valid_time | timestamp without time zone | + issue_time | timestamp without time zone | + next_forecast | timestamp without time zone | + reception_time | timestamp without time zone | + +The program is supposed to check to ensure that all fields but the +reception_time are unique using a select statement, and if so, insert it. +Due an error in a change, reception time was included in the select to check +for duplicates. The reception_time is created by a program creating the dat +file to insert. +Essentially letting all duplicate files to be inserted. + +I tried the delete query below. +PWFPM_DEV=# delete from forecastelement where oid not in (select min(oid) +from forecastelement group by +version,origin,timezone,region_id,wx_element,value,flag,units,valid_time,iss +ue_time,next_forecast); +It ran for 3 days creating what I assume is an index in pgsql_tmp of the +group by statement. +The query ended up failing with "dateERROR:write failed". +Well the long weekend is over and we do not have the luxury of trying this +again. +So I was thinking maybe of doing the deletion in chunks, perhaps based on +reception time. +Are there any suggestions for a better way to do this, or using multiple +queries to delete selectively a week at a time based on the reception_time. +I would say there are a lot of duplicate entries between mid march to the +first week of April. + + + +From pgsql-performance-owner@postgresql.org Mon Apr 12 12:18:47 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8146FD1E1DD + for ; + Mon, 12 Apr 2004 12:18:45 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 27226-05 + for ; + Mon, 12 Apr 2004 12:18:43 -0300 (ADT) +Received: from ECCMCBH.cmc.int.ec.gc.ca (ecdor130.cmc.ec.gc.ca + [199.212.17.130]) + by svr1.postgresql.org (Postfix) with ESMTP id A18D5D1E2A5 + for ; + Mon, 12 Apr 2004 12:18:42 -0300 (ADT) +Received: by eccmcbh.cmc.ec.gc.ca with Internet Mail Service (5.5.2653.19) + id <2A893B6P>; Mon, 12 Apr 2004 11:18:40 -0400 +Message-ID: +From: "Shea,Dan [CIS]" +To: "Shea,Dan [CIS]" , + Postgres Performance +Subject: Re: Deleting certain duplicates +Date: Mon, 12 Apr 2004 11:18:31 -0400 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2653.19) +Content-Type: text/plain; + charset="iso-8859-1" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/131 +X-Sequence-Number: 6431 + +The index is +Indexes: + "forecastelement_rwv_idx" btree (region_id, wx_element, valid_time) + +-----Original Message----- +From: Shea,Dan [CIS] [mailto:Dan.Shea@ec.gc.ca] +Sent: Monday, April 12, 2004 10:39 AM +To: Postgres Performance +Subject: [PERFORM] Deleting certain duplicates + + +We have a large database which recently increased dramatically due to a +change in our insert program allowing all entries. +PWFPM_DEV=# select relname,relfilenode,reltuples from pg_class where relname += 'forecastelement'; + relname | relfilenode | reltuples +-----------------+-------------+------------- + forecastelement | 361747866 | 4.70567e+08 + + Column | Type | Modifiers +----------------+-----------------------------+----------- + version | character varying(99) | + origin | character varying(10) | + timezone | character varying(99) | + region_id | character varying(20) | + wx_element | character varying(99) | + value | character varying(99) | + flag | character(3) | + units | character varying(99) | + valid_time | timestamp without time zone | + issue_time | timestamp without time zone | + next_forecast | timestamp without time zone | + reception_time | timestamp without time zone | + +The program is supposed to check to ensure that all fields but the +reception_time are unique using a select statement, and if so, insert it. +Due an error in a change, reception time was included in the select to check +for duplicates. The reception_time is created by a program creating the dat +file to insert. +Essentially letting all duplicate files to be inserted. + +I tried the delete query below. +PWFPM_DEV=# delete from forecastelement where oid not in (select min(oid) +from forecastelement group by +version,origin,timezone,region_id,wx_element,value,flag,units,valid_time,iss +ue_time,next_forecast); +It ran for 3 days creating what I assume is an index in pgsql_tmp of the +group by statement. +The query ended up failing with "dateERROR:write failed". +Well the long weekend is over and we do not have the luxury of trying this +again. +So I was thinking maybe of doing the deletion in chunks, perhaps based on +reception time. +Are there any suggestions for a better way to do this, or using multiple +queries to delete selectively a week at a time based on the reception_time. +I would say there are a lot of duplicate entries between mid march to the +first week of April. + + + +---------------------------(end of broadcast)--------------------------- +TIP 8: explain analyze is your friend + +From pgsql-performance-owner@postgresql.org Mon Apr 12 12:40:36 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A6CF0D1D2C6 + for ; + Mon, 12 Apr 2004 12:40:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 43328-04 + for ; + Mon, 12 Apr 2004 12:40:32 -0300 (ADT) +Received: from mail.autorevenue.com (ip-208.178.167.106.gblx.net + [208.178.167.106]) + by svr1.postgresql.org (Postfix) with ESMTP id 882DDD1D1B8 + for ; + Mon, 12 Apr 2004 12:40:31 -0300 (ADT) +Received: from jeremydunn ([192.168.1.79]) (authenticated) + by mail.autorevenue.com (8.11.6/8.11.6) with ESMTP id i3CFeVY24818 + for ; Mon, 12 Apr 2004 11:40:31 -0400 +Reply-To: +From: "Jeremy Dunn" +To: "Postgresql Performance" +Subject: index v. seqscan for certain values +Date: Mon, 12 Apr 2004 11:40:28 -0400 +Organization: AutoRevenue +Message-ID: <000901c420a4$7b733650$4f01a8c0@jeremydunn> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_000A_01C42082.F4619650" +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.2627 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +Importance: Normal +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/132 +X-Sequence-Number: 6432 + +This is a multi-part message in MIME format. + +------=_NextPart_000_000A_01C42082.F4619650 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit + +I've searched the archives and can't find an answer to this seemingly +simple question. Apologies if it's too common. + +The table in question has ~1.3M rows. It has 85 columns, 5 of which +have single-column indexes. + +The column in question (CID) has 183 distinct values. For these values, +the largest has ~38,000 rows, and the smallest has 1 row. About 30 +values have < 100 rows, and about 10 values have > 20,000 rows. + +The database is 7.2.3 running on RedHat 7.1. (we are in process of +upgrading to PG 7.4.2) All of the query plan options are enabled, and +the cpu costs are set to the default values. ( cpu_tuple_cost is 0.01, +cpu_index_tuple_cost is 0.001). The database is VACUUM'd every night. + +The problem: +A simply query: + select count(*) from xxx where CID= +where is a CID value which has relatively few rows, returns a +plan using the index on that column. + + explain analyze select count(*) from xxx where cid=869366; + Aggregate (cost=19136.33..19136.33 rows=1 width=0) (actual +time=78.49..78.49 rows=1 loops=1) + -> Index Scan using xxx_cid on emailrcpts (cost=0.00..19122.21 +rows=5648 width=0) (actual time=63.40..78.46 rows=1 loops=1) + Total runtime: 78.69 msec + +The same plan is true for values which have up to about 20,000 rows: + + explain analyze select count(*) from xxx where cid=6223341; + Aggregate (cost=74384.19..74384.19 rows=1 width=0) (actual +time=11614.89..11614.89 rows=1 loops=1) + -> Index Scan using xxx_cid on emailrcpts (cost=0.00..74329.26 +rows=21974 width=0) (actual time=35.75..11582.10 rows=20114 loops=1) + Total runtime: 11615.05 msec + +However for the values that have > 20,000 rows, the plan changes to a +sequential scan, which is proportionately much slower. + + explain analyze select count(*) from xxx where cid=7191032; + Aggregate (cost=97357.61..97357.61 rows=1 width=0) (actual +time=46427.81..46427.82 rows=1 loops=1) + -> Seq Scan on xxx (cost=0.00..97230.62 rows=50792 width=0) +(actual time=9104.45..46370.27 rows=37765 loops=1) + Total runtime: 46428.00 msec + + +The question: why does the planner consider a sequential scan to be +better for these top 10 values? In terms of elapsed time it is more +than twice as slow, proportionate to an index scan for the same number +of rows. + +What I tried: + +A) alter table xxx alter column cid set statistics 500; + analyze xxx; +This does not affect the results. + +B) dropped/rebuilt the index, with no improvement. + +C) decreasing cpu_index_tuple_cost by a factor of up to 1000, with no +success + +D) force an index scan for the larger values by using a very high value +for cpu_tuple_cost (e.g. .5) but this doesn't seem like a wise thing to +do. + +Your thoughts appreciated in advance! + +- Jeremy + +7+ years experience in Oracle performance-tuning +relatively new to postgresql + +------=_NextPart_000_000A_01C42082.F4619650 +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + +Message + + + +
I've sear= +ched the=20 +archives and can't find an answer to this seemingly simple question. = +=20 +Apologies if it's too common.
+
 
+
The table= + in=20 +question has ~1.3M rows.  It has 85 columns, 5 of which have single-co= +lumn=20 +indexes.
+
 
+
The colum= +n in=20 +question (CID) has 183 distinct values.  For these values, the largest= + has=20 +~38,000 rows, and the smallest has 1 row.  About 30 values have < 1= +00=20 +rows, and about 10 values have > 20,000 rows.
+
 
+
The datab= +ase is=20 +7.2.3 running on RedHat 7.1. (we are in process of upgrading to=20 +PG 7.4.2)    All of the query plan options are enabled,= + and=20 +the cpu costs are set to the default values. ( cpu_tuple_cost is 0.01,= +=20 +cpu_index_tuple_cost is 0.001).  The database is VACUUM'd every=20 +night.
+
 
+
The=20 +problem:
+
A simply= +=20 +query:
+
    select count(*) from xxx where CID=3D<smalval>= +
+
where=20 +<smalval> is a CID value which has relatively few rows, returns a pla= +n=20 +using the index on that column.
+
 
+
 &nb= +sp; explain=20 +analyze select count(*) from xxx where cid=3D869366;
   Aggrega= +te =20 +(cost=3D19136.33..19136.33 rows=3D1 width=3D0) (actual time=3D78.49..78.49 = +rows=3D1=20 +loops=3D1)
     ->  Index Scan using xxx_cid= + on=20 +emailrcpts  (cost=3D0.00..19122.21 rows=3D5648 width=3D0) (actual=20 +time=3D63.40..78.46 rows=3D1 loops=3D1)
   Total runtime: 78.6= +9=20 +msec
+
 
+
The same = +plan is=20 +true for values which have up to about 20,000 rows:
+
 
+
 &nb= +sp; explain=20 +analyze select count(*) from xxx where cid=3D6223341;
   Aggrega= +te =20 +(cost=3D74384.19..74384.19 rows=3D1 width=3D0) (actual time=3D11614.89..116= +14.89 rows=3D1=20 +loops=3D1)
     ->  Index Scan using xxx_cid= + on=20 +emailrcpts  (cost=3D0.00..74329.26 rows=3D21974 width=3D0) (actual=20 +time=3D35.75..11582.10 rows=3D20114 loops=3D1)
   Total runtim= +e: 11615.05=20 +msec
+
However f= +or the=20 +values that have > 20,000 rows, the plan changes to a sequential scan, w= +hich=20 +is proportionately much slower.
+
 
+
&nb= +sp; =20 +explain analyze select count(*) from xxx where cid=3D7191032;
  = +=20 +Aggregate  (cost=3D97357.61..97357.61 rows=3D1 width=3D0) (actu= +al=20 +time=3D46427.81..46427.82 rows=3D1 loops=3D1)
    ->=20 +  Seq Scan on xxx=20 +(cost=3D0.00..97230.62 rows=3D50792 width=3D0) (actual time=3D9104.4= +5..46370.27=20 +rows=3D37765 loops=3D1)
  &nb= +sp;=20 +Total runtime: 46428.00 msec
+
 
+
 
+
The quest= +ion: why=20 +does the planner consider a sequential scan to be better for these top 10= +=20 +values?  In terms of elapsed time it is more than twice as slow,=20 +proportionate to an index scan for the same number of rows. +
 
+
What I=20 +tried:
+
 
+
A) alter table xxx alter column cid set statistics 500;  &n= +bsp;=20 +
+
    analyze xxx;
+
This does= + not affect=20 +the results.
+
 
+
B)=20 + dropped/rebuilt the index, with no improvement.
+
 
+
C) decrea= +sing=20 +cpu_index_tuple_cost by a factor of up to 1000, with no=20 +success
+
 
+
D) force = +an index=20 +scan for the larger values by using a very high value for cpu_tuple_cost (e= +.g.=20 +.5) but this doesn't seem like a wise thing to do.
+
 
+
Your thou= +ghts=20 +appreciated in advance!
+
 
+
-=20 +Jeremy 
+
 
+
7+ years=20 +experience in Oracle performance-tuning
+
relatively new to postgresql
+
+
+ +------=_NextPart_000_000A_01C42082.F4619650-- + + +From pgsql-performance-owner@postgresql.org Mon Apr 12 13:09:29 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A8D88D1D501 + for ; + Mon, 12 Apr 2004 13:09:27 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 66924-04 + for ; + Mon, 12 Apr 2004 13:09:21 -0300 (ADT) +Received: from internet.potentialtech.com (h-66-167-251-6.phlapafg.covad.net + [66.167.251.6]) + by svr1.postgresql.org (Postfix) with ESMTP id 31698D1BAAD + for ; + Mon, 12 Apr 2004 13:09:20 -0300 (ADT) +Received: from potentialtech.com (pa-plum1c-102.pit.adelphia.net + [24.53.179.102]) by internet.potentialtech.com (Postfix) with ESMTP + id 34A2769A71; Mon, 12 Apr 2004 12:09:19 -0400 (EDT) +Message-ID: <407ABF2B.80306@potentialtech.com> +Date: Mon, 12 Apr 2004 12:09:15 -0400 +From: Bill Moran +User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.4) Gecko/20031005 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: jdunn@autorevenue.com +Cc: Postgresql Performance +Subject: Re: index v. seqscan for certain values +References: <000901c420a4$7b733650$4f01a8c0@jeremydunn> +In-Reply-To: <000901c420a4$7b733650$4f01a8c0@jeremydunn> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/133 +X-Sequence-Number: 6433 + +Quick bit of input, since you didn't mention it. + +How often do you run ANALYZE? I found it interesting that a database I +was doing tests on sped up by a factor of 20 after ANALYZE. If your +data changes a lot, you should probably schedule ANALYZE to run with +VACUUM. + +Jeremy Dunn wrote: +> I've searched the archives and can't find an answer to this seemingly +> simple question. Apologies if it's too common. +> +> The table in question has ~1.3M rows. It has 85 columns, 5 of which +> have single-column indexes. +> +> The column in question (CID) has 183 distinct values. For these values, +> the largest has ~38,000 rows, and the smallest has 1 row. About 30 +> values have < 100 rows, and about 10 values have > 20,000 rows. +> +> The database is 7.2.3 running on RedHat 7.1. (we are in process of +> upgrading to PG 7.4.2) All of the query plan options are enabled, and +> the cpu costs are set to the default values. ( cpu_tuple_cost is 0.01, +> cpu_index_tuple_cost is 0.001). The database is VACUUM'd every night. +> +> The problem: +> A simply query: +> select count(*) from xxx where CID= +> where is a CID value which has relatively few rows, returns a +> plan using the index on that column. +> +> explain analyze select count(*) from xxx where cid=869366; +> Aggregate (cost=19136.33..19136.33 rows=1 width=0) (actual +> time=78.49..78.49 rows=1 loops=1) +> -> Index Scan using xxx_cid on emailrcpts (cost=0.00..19122.21 +> rows=5648 width=0) (actual time=63.40..78.46 rows=1 loops=1) +> Total runtime: 78.69 msec +> +> The same plan is true for values which have up to about 20,000 rows: +> +> explain analyze select count(*) from xxx where cid=6223341; +> Aggregate (cost=74384.19..74384.19 rows=1 width=0) (actual +> time=11614.89..11614.89 rows=1 loops=1) +> -> Index Scan using xxx_cid on emailrcpts (cost=0.00..74329.26 +> rows=21974 width=0) (actual time=35.75..11582.10 rows=20114 loops=1) +> Total runtime: 11615.05 msec +> However for the values that have > 20,000 rows, the plan changes to a +> sequential scan, which is proportionately much slower. +> +> explain analyze select count(*) from xxx where cid=7191032; +> Aggregate (cost=97357.61..97357.61 rows=1 width=0) (actual +> time=46427.81..46427.82 rows=1 loops=1) +> -> Seq Scan on xxx (cost=0.00..97230.62 rows=50792 width=0) +> (actual time=9104.45..46370.27 rows=37765 loops=1) +> Total runtime: 46428.00 msec +> +> +> The question: why does the planner consider a sequential scan to be +> better for these top 10 values? In terms of elapsed time it is more +> than twice as slow, proportionate to an index scan for the same number +> of rows. +> +> What I tried: +> +> A) alter table xxx alter column cid set statistics 500; +> analyze xxx; +> This does not affect the results. +> +> B) dropped/rebuilt the index, with no improvement. +> +> C) decreasing cpu_index_tuple_cost by a factor of up to 1000, with no +> success +> +> D) force an index scan for the larger values by using a very high value +> for cpu_tuple_cost (e.g. .5) but this doesn't seem like a wise thing to do. +> +> Your thoughts appreciated in advance! +> +> - Jeremy +> +> 7+ years experience in Oracle performance-tuning +> relatively new to postgresql + + +-- +Bill Moran +Potential Technologies +http://www.potentialtech.com + + +From pgsql-performance-owner@postgresql.org Mon Apr 12 14:08:11 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 403D3D1BA90 + for ; + Mon, 12 Apr 2004 14:08:10 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 84146-06 + for ; + Mon, 12 Apr 2004 14:08:09 -0300 (ADT) +Received: from mail.autorevenue.com (ip-208.178.167.106.gblx.net + [208.178.167.106]) + by svr1.postgresql.org (Postfix) with ESMTP id C0D37D1B515 + for ; + Mon, 12 Apr 2004 14:08:07 -0300 (ADT) +Received: from jeremydunn ([192.168.1.79]) (authenticated) + by mail.autorevenue.com (8.11.6/8.11.6) with ESMTP id i3CH87Y26971 + for ; Mon, 12 Apr 2004 13:08:07 -0400 +Reply-To: +From: "Jeremy Dunn" +To: "'Postgresql Performance'" +Subject: Re: index v. seqscan for certain values +Date: Mon, 12 Apr 2004 13:08:05 -0400 +Organization: AutoRevenue +Message-ID: <001801c420b0$b8b79b30$4f01a8c0@jeremydunn> +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.2800.1165 +In-Reply-To: <407ABF2B.80306@potentialtech.com> +Importance: Normal +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/134 +X-Sequence-Number: 6434 + +Sorry I should have written that we do VACUUM VERBOSE ANALYZE every +night. + +- Jeremy + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Bill Moran +Sent: Monday, April 12, 2004 12:09 PM +To: jdunn@autorevenue.com +Cc: Postgresql Performance +Subject: Re: [PERFORM] index v. seqscan for certain values + + +Quick bit of input, since you didn't mention it. + +How often do you run ANALYZE? I found it interesting that a database I +was doing tests on sped up by a factor of 20 after ANALYZE. If your +data changes a lot, you should probably schedule ANALYZE to run with +VACUUM. + +Jeremy Dunn wrote: +> I've searched the archives and can't find an answer to this seemingly +> simple question. Apologies if it's too common. +> +> The table in question has ~1.3M rows. It has 85 columns, 5 of which +> have single-column indexes. +> +> The column in question (CID) has 183 distinct values. For these +> values, +> the largest has ~38,000 rows, and the smallest has 1 row. About 30 +> values have < 100 rows, and about 10 values have > 20,000 rows. +> +> The database is 7.2.3 running on RedHat 7.1. (we are in process of +> upgrading to PG 7.4.2) All of the query plan options are enabled, +and +> the cpu costs are set to the default values. ( cpu_tuple_cost is 0.01, +> cpu_index_tuple_cost is 0.001). The database is VACUUM'd every night. +> +> The problem: +> A simply query: +> select count(*) from xxx where CID= +> where is a CID value which has relatively few rows, returns +> a +> plan using the index on that column. +> +> explain analyze select count(*) from xxx where cid=869366; +> Aggregate (cost=19136.33..19136.33 rows=1 width=0) (actual +> time=78.49..78.49 rows=1 loops=1) +> -> Index Scan using xxx_cid on emailrcpts (cost=0.00..19122.21 +> rows=5648 width=0) (actual time=63.40..78.46 rows=1 loops=1) +> Total runtime: 78.69 msec +> +> The same plan is true for values which have up to about 20,000 rows: +> +> explain analyze select count(*) from xxx where cid=6223341; +> Aggregate (cost=74384.19..74384.19 rows=1 width=0) (actual +> time=11614.89..11614.89 rows=1 loops=1) +> -> Index Scan using xxx_cid on emailrcpts (cost=0.00..74329.26 +> rows=21974 width=0) (actual time=35.75..11582.10 rows=20114 loops=1) +> Total runtime: 11615.05 msec +> However for the values that have > 20,000 rows, the plan changes to a +> sequential scan, which is proportionately much slower. +> +> explain analyze select count(*) from xxx where cid=7191032; +> Aggregate (cost=97357.61..97357.61 rows=1 width=0) (actual +> time=46427.81..46427.82 rows=1 loops=1) +> -> Seq Scan on xxx (cost=0.00..97230.62 rows=50792 width=0) +> (actual time=9104.45..46370.27 rows=37765 loops=1) +> Total runtime: 46428.00 msec +> +> +> The question: why does the planner consider a sequential scan to be +> better for these top 10 values? In terms of elapsed time it is more +> than twice as slow, proportionate to an index scan for the same number + +> of rows. +> +> What I tried: +> +> A) alter table xxx alter column cid set statistics 500; +> analyze xxx; +> This does not affect the results. +> +> B) dropped/rebuilt the index, with no improvement. +> +> C) decreasing cpu_index_tuple_cost by a factor of up to 1000, with no +> success +> +> D) force an index scan for the larger values by using a very high +> value +> for cpu_tuple_cost (e.g. .5) but this doesn't seem like a wise thing +to do. +> +> Your thoughts appreciated in advance! +> +> - Jeremy +> +> 7+ years experience in Oracle performance-tuning +> relatively new to postgresql + + +-- +Bill Moran +Potential Technologies +http://www.potentialtech.com + + +---------------------------(end of broadcast)--------------------------- +TIP 4: Don't 'kill -9' the postmaster + + + +From pgsql-performance-owner@postgresql.org Mon Apr 12 14:40:02 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 141D2D1D300 + for ; + Mon, 12 Apr 2004 14:39:58 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 98945-05 + for ; + Mon, 12 Apr 2004 14:39:52 -0300 (ADT) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id 6DFD2D1D282 + for ; + Mon, 12 Apr 2004 14:39:51 -0300 (ADT) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id 3FCBA356E5; Mon, 12 Apr 2004 10:39:51 -0700 (PDT) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id 3E2DA3569F; Mon, 12 Apr 2004 10:39:51 -0700 (PDT) +Date: Mon, 12 Apr 2004 10:39:51 -0700 (PDT) +From: Stephan Szabo +To: Jeremy Dunn +Cc: Postgresql Performance +Subject: Re: index v. seqscan for certain values +In-Reply-To: <000901c420a4$7b733650$4f01a8c0@jeremydunn> +Message-ID: <20040412103711.G16827@megazone.bigpanda.com> +References: <000901c420a4$7b733650$4f01a8c0@jeremydunn> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/135 +X-Sequence-Number: 6435 + + +On Mon, 12 Apr 2004, Jeremy Dunn wrote: + +> explain analyze select count(*) from xxx where cid=6223341; +> Aggregate (cost=74384.19..74384.19 rows=1 width=0) (actual +> time=11614.89..11614.89 rows=1 loops=1) +> -> Index Scan using xxx_cid on emailrcpts (cost=0.00..74329.26 +> rows=21974 width=0) (actual time=35.75..11582.10 rows=20114 loops=1) +> Total runtime: 11615.05 msec +> +> However for the values that have > 20,000 rows, the plan changes to a +> sequential scan, which is proportionately much slower. +> +> explain analyze select count(*) from xxx where cid=7191032; +> Aggregate (cost=97357.61..97357.61 rows=1 width=0) (actual +> time=46427.81..46427.82 rows=1 loops=1) +> -> Seq Scan on xxx (cost=0.00..97230.62 rows=50792 width=0) +> (actual time=9104.45..46370.27 rows=37765 loops=1) +> Total runtime: 46428.00 msec +> +> The question: why does the planner consider a sequential scan to be +> better for these top 10 values? In terms of elapsed time it is more +> than twice as slow, proportionate to an index scan for the same number +> of rows. + +One thing to do is to set enable_seqscan=off and run the above and compare +the estimated and real costs. It may be possible to lower +random_page_cost to a still reasonable number in order to move the point +of the switchover to seqscan. + +From pgsql-performance-owner@postgresql.org Mon Apr 12 14:51:34 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A9881D1C9FB + for ; + Mon, 12 Apr 2004 14:51:32 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 04791-04 + for ; + Mon, 12 Apr 2004 14:51:30 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id AA3ADD1C9C7 + for ; + Mon, 12 Apr 2004 14:51:28 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3CHpSpd012038; + Mon, 12 Apr 2004 13:51:28 -0400 (EDT) +To: jdunn@autorevenue.com +Cc: "Postgresql Performance" +Subject: Re: index v. seqscan for certain values +In-reply-to: <000901c420a4$7b733650$4f01a8c0@jeremydunn> +References: <000901c420a4$7b733650$4f01a8c0@jeremydunn> +Comments: In-reply-to "Jeremy Dunn" + message dated "Mon, 12 Apr 2004 11:40:28 -0400" +Date: Mon, 12 Apr 2004 13:51:28 -0400 +Message-ID: <12037.1081792288@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/136 +X-Sequence-Number: 6436 + +"Jeremy Dunn" writes: +> The question: why does the planner consider a sequential scan to be +> better for these top 10 values? + +At some point a seqscan *will* be better. In the limit, if the key +being sought is common enough to occur on every page of the table, +it's certain that a seqscan will require less I/O than an indexscan +(because reading the index isn't actually saving you any heap fetches). +In practice the breakeven point is less than that because Unix kernels +are better at handling sequential than random access. + +Your gripe appears to be basically that the planner's idea of the +breakeven point is off a bit. It looks to me like it's within about +a factor of 2 of being right, though, which is not all that bad when +it's using generic cost parameters. + +> A) alter table xxx alter column cid set statistics 500; +> analyze xxx; +> This does not affect the results. + +It probably improved the accuracy of the row count estimates, no? +The estimate you show for cid=7191032 is off by more than 25% (37765 vs +50792), which seems like a lot of error for one of the most common +values in the table. (I hope that was with default stats target and +not 500.) That leads directly to a 25% overestimate of the cost of +an indexscan, while having IIRC no impact on the cost of a seqscan. +Since the cost ratio was more than 25%, this didn't change the selected +plan, but you want to fix that error as best you can before you move +on to tweaking cost parameters. + +> C) decreasing cpu_index_tuple_cost by a factor of up to 1000, with no +> success + +Wrong thing. You should be tweaking random_page_cost. Looks to me like +a value near 2 might be appropriate for your setup. Also it is likely +appropriate to increase effective_cache_size, which is awfully small in +the default configuration. I'd set that to something related to your +available RAM before trying to home in on a suitable random_page_cost. + +AFAIK hardly anyone bothers with changing the cpu_xxx costs ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Apr 12 16:02:16 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3FB29D1DC69 + for ; + Mon, 12 Apr 2004 16:02:14 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 33042-04 + for ; + Mon, 12 Apr 2004 16:02:08 -0300 (ADT) +Received: from mwinf0102.wanadoo.fr (smtp1.wanadoo.fr [193.252.22.30]) + by svr1.postgresql.org (Postfix) with ESMTP id C9D1DD1D085 + for ; + Mon, 12 Apr 2004 16:02:05 -0300 (ADT) +Received: from [192.168.0.2] (AMontsouris-108-1-29-248.w81-53.abo.wanadoo.fr + [81.53.158.248]) + by mwinf0102.wanadoo.fr (SMTP Server) with ESMTP id 0BA6A1BE7A42 + for ; + Mon, 12 Apr 2004 21:02:06 +0200 (CEST) +Mime-Version: 1.0 (Apple Message framework v613) +In-Reply-To: <8579.1081772899@sss.pgh.pa.us> +References: <8A2105D4-8C63-11D8-80FD-000A95DE2550@ifrance.com> + <8579.1081772899@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Message-Id: +Content-Transfer-Encoding: quoted-printable +From: =?ISO-8859-1?Q?Pailloncy_Jean-G=E9rard?= +Subject: Re: Index Backward Scan fast / Index Scan slow ! +Date: Mon, 12 Apr 2004 21:02:02 +0200 +To: pgsql-performance@postgresql.org +X-Mailer: Apple Mail (2.613) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/137 +X-Sequence-Number: 6437 + +Hi, + +>> How to optimize the last query ? (~ 2000 times slower than the first +>> one) +>> I suppose there is some odd distribution of data in the index ? +> +> Looks to me like a whole lot of dead rows at the left end of the index. +> Have you VACUUMed this table lately? + From pg_autovacuum: +[2004-04-10 05:45:39 AM] Performing: ANALYZE "public"."url" +[2004-04-10 11:13:25 AM] Performing: ANALYZE "public"."url" +[2004-04-10 03:12:14 PM] Performing: VACUUM ANALYZE "public"."url" +[2004-04-11 04:58:29 AM] Performing: ANALYZE "public"."url" +[2004-04-11 03:48:25 PM] Performing: ANALYZE "public"."url" +[2004-04-11 09:21:31 PM] Performing: ANALYZE "public"."url" +[2004-04-12 03:24:06 AM] Performing: ANALYZE "public"."url" +[2004-04-12 07:20:08 AM] Performing: VACUUM ANALYZE "public"."url" + +> It would be interesting to see +> what VACUUM VERBOSE has to say about it. +dps=3D# VACUUM VERBOSE url; +INFO: vacuuming "public.url" +INFO: index "url_pkey" now contains 348972 row versions in 2344 pages +DETAIL: 229515 index row versions were removed. +41 index pages have been deleted, 41 are currently reusable. +CPU 0.32s/1.40u sec elapsed 70.66 sec. +INFO: index "url_crc" now contains 215141 row versions in 497 pages +DETAIL: 108343 index row versions were removed. +0 index pages have been deleted, 0 are currently reusable. +CPU 0.06s/0.96u sec elapsed 9.13 sec. +INFO: index "url_seed" now contains 348458 row versions in 2987 pages +DETAIL: 229515 index row versions were removed. +345 index pages have been deleted, 345 are currently reusable. +CPU 0.40s/2.38u sec elapsed 74.26 sec. +INFO: index "url_referrer" now contains 349509 row versions in 1964=20 +pages +DETAIL: 229515 index row versions were removed. +65 index pages have been deleted, 65 are currently reusable. +CPU 0.34s/1.53u sec elapsed 127.37 sec. +INFO: index "url_next_index_time" now contains 349519 row versions in=20 +3534 pages +DETAIL: 229515 index row versions were removed. +3071 index pages have been deleted, 2864 are currently reusable. +CPU 0.32s/0.67u sec elapsed 76.25 sec. +INFO: index "url_status" now contains 349520 row versions in 3465 pages +DETAIL: 229515 index row versions were removed. +2383 index pages have been deleted, 2256 are currently reusable. +CPU 0.35s/0.85u sec elapsed 89.25 sec. +INFO: index "url_bad_since_time" now contains 349521 row versions in=20 +2017 pages +DETAIL: 229515 index row versions were removed. +38 index pages have been deleted, 38 are currently reusable. +CPU 0.54s/1.46u sec elapsed 83.77 sec. +INFO: index "url_hops" now contains 349620 row versions in 3558 pages +DETAIL: 229515 index row versions were removed. +1366 index pages have been deleted, 1356 are currently reusable. +CPU 0.43s/0.91u sec elapsed 132.14 sec. +INFO: index "url_siteid" now contains 350551 row versions in 3409 pages +DETAIL: 229515 index row versions were removed. +2310 index pages have been deleted, 2185 are currently reusable. +CPU 0.35s/1.01u sec elapsed 85.08 sec. +INFO: index "url_serverid" now contains 350552 row versions in 3469=20 +pages +DETAIL: 229515 index row versions were removed. +1014 index pages have been deleted, 1009 are currently reusable. +CPU 0.54s/1.01u sec elapsed 120.40 sec. +INFO: index "url_url" now contains 346563 row versions in 6494 pages +DETAIL: 213608 index row versions were removed. +0 index pages have been deleted, 0 are currently reusable. +CPU 1.35s/2.07u sec elapsed 285.05 sec. +INFO: index "url_last_mod_time" now contains 346734 row versions in=20 +1106 pages +DETAIL: 213608 index row versions were removed. +27 index pages have been deleted, 17 are currently reusable. +CPU 0.17s/0.95u sec elapsed 17.92 sec. +INFO: "url": removed 229515 row versions in 4844 pages +DETAIL: CPU 0.53s/1.26u sec elapsed 375.64 sec. +INFO: "url": found 229515 removable, 310913 nonremovable row versions=20 +in 26488 pages +DETAIL: 29063 dead row versions cannot be removed yet. +There were 3907007 unused item pointers. +192 pages are entirely empty. +CPU 7.78s/17.09u sec elapsed 3672.29 sec. +INFO: vacuuming "pg_toast.pg_toast_127397204" +INFO: index "pg_toast_127397204_index" now contains 0 row versions in=20 +1 pages +DETAIL: 0 index pages have been deleted, 0 are currently reusable. +CPU 0.00s/0.00u sec elapsed 0.06 sec. +INFO: "pg_toast_127397204": found 0 removable, 0 nonremovable row=20 +versions in 0 pages +DETAIL: 0 dead row versions cannot be removed yet. +There were 0 unused item pointers. +0 pages are entirely empty. +CPU 0.00s/0.00u sec elapsed 0.07 sec. +VACUUM + +>> Is the solution to reindex data ? +> +> In 7.4 a VACUUM should be sufficient ... or at least, if it isn't +> I'd like to know why not before you destroy the evidence by reindexing. +Yes, of course. + +Cordialement, +Jean-G=E9rard Pailloncy + + +From pgsql-performance-owner@postgresql.org Mon Apr 12 16:03:48 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E21A9D1B486 + for ; + Mon, 12 Apr 2004 16:03:45 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 34274-08 + for ; + Mon, 12 Apr 2004 16:03:45 -0300 (ADT) +Received: from mwinf0102.wanadoo.fr (smtp1.wanadoo.fr [193.252.22.30]) + by svr1.postgresql.org (Postfix) with ESMTP id 11E68D1B4BE + for ; + Mon, 12 Apr 2004 16:03:44 -0300 (ADT) +Received: from [192.168.0.2] (AMontsouris-108-1-29-248.w81-53.abo.wanadoo.fr + [81.53.158.248]) + by mwinf0102.wanadoo.fr (SMTP Server) with ESMTP id 03B201BE7B05 + for ; + Mon, 12 Apr 2004 21:03:45 +0200 (CEST) +Mime-Version: 1.0 (Apple Message framework v613) +Content-Type: text/plain; charset=ISO-8859-1; delsp=yes; format=flowed +Resent-Date: Mon, 12 Apr 2004 21:03:42 +0200 +Message-Id: <1D4DEBDC-8CB4-11D8-80FD-000A95DE2550@ifrance.com> +Content-Transfer-Encoding: quoted-printable +Resent-To: pgsql-performance@postgresql.org +Resent-Message-Id: +From: =?ISO-8859-1?Q?Pailloncy_Jean-G=E9rard?= +Subject: =?ISO-8859-1?Q?Re:__Index_Backward_Scan_fast_/_Index_Sc?= + =?ISO-8859-1?Q?an_slow_!__=28Modifi=E9_par_Pailloncy_Jean-G=E9ra?= + =?ISO-8859-1?Q?rd=29?= +Resent-From: =?ISO-8859-1?Q?Pailloncy_Jean-G=E9rard?= +Date: Mon, 12 Apr 2004 21:02:02 +0200 +To: pgsql-performance@postgresql.org +X-Mailer: Apple Mail (2.613) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/138 +X-Sequence-Number: 6438 + +Hi, + +> In 7.4 a VACUUM should be sufficient ... or at least, if it isn't +Atfer VACUUM: +dps=3D# explain analyze select next_index_time from url order by=20=20 +next_index_time desc limit 1; +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 +QUERY PLAN +------------------------------------------------------------------------=20 +------------------------------------------------------------------------=20 +-- + Limit (cost=3D0.00..2.62 rows=3D1 width=3D4) (actual time=3D0.098..0.099= +=20=20 +rows=3D1 loops=3D1) + -> Index Scan Backward using url_next_index_time on url=20=20=20 +(cost=3D0.00..814591.03 rows=3D310913 width=3D4) (actual time=3D0.096..0.09= +6=20=20 +rows=3D1 loops=3D1) + Total runtime: 0.195 ms +(3 rows) + +dps=3D# explain analyze select next_index_time from url order by=20=20 +next_index_time asc limit 1; +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 +QUERY PLAN +------------------------------------------------------------------------=20 +------------------------------------------------------------------------=20 +- + Limit (cost=3D0.00..2.62 rows=3D1 width=3D4) (actual=20=20 +time=3D13504.105..13504.106 rows=3D1 loops=3D1) + -> Index Scan using url_next_index_time on url=20=20=20 +(cost=3D0.00..814591.03 rows=3D310913 width=3D4) (actual=20=20 +time=3D13504.099..13504.099 rows=3D1 loops=3D1) + Total runtime: 13504.158 ms +(3 rows) + +Better, but...... + +Cordialement, +Jean-G=E9rard Pailloncy + + +From pgsql-performance-owner@postgresql.org Mon Apr 12 16:05:07 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 06D73D1E822 + for ; + Mon, 12 Apr 2004 16:05:06 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 33395-07 + for ; + Mon, 12 Apr 2004 16:05:05 -0300 (ADT) +Received: from mail.autorevenue.com (ip-208.178.167.106.gblx.net + [208.178.167.106]) + by svr1.postgresql.org (Postfix) with ESMTP id 5FB0BD1DCA5 + for ; + Mon, 12 Apr 2004 16:05:03 -0300 (ADT) +Received: from jeremydunn ([192.168.1.79]) (authenticated) + by mail.autorevenue.com (8.11.6/8.11.6) with ESMTP id i3CJ54Y29381 + for ; Mon, 12 Apr 2004 15:05:04 -0400 +Reply-To: +From: "Jeremy Dunn" +To: "'Postgresql Performance'" +Subject: Re: index v. seqscan for certain values +Date: Mon, 12 Apr 2004 15:05:02 -0400 +Organization: AutoRevenue +Message-ID: <001d01c420c1$0ed23290$4f01a8c0@jeremydunn> +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.2800.1165 +In-Reply-To: <12037.1081792288@sss.pgh.pa.us> +Importance: Normal +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/139 +X-Sequence-Number: 6439 + +> "Jeremy Dunn" writes: +> > The question: why does the planner consider a sequential scan to be +> > better for these top 10 values? +> +> At some point a seqscan *will* be better. In the limit, if +> the key being sought is common enough to occur on every page +> of the table, it's certain that a seqscan will require less +> I/O than an indexscan (because reading the index isn't +> actually saving you any heap fetches). In practice the +> breakeven point is less than that because Unix kernels are +> better at handling sequential than random access. +> +> Your gripe appears to be basically that the planner's idea of +> the breakeven point is off a bit. It looks to me like it's +> within about a factor of 2 of being right, though, which is +> not all that bad when it's using generic cost parameters. + +Agreed. However, given that count(*) is a question that can be answered +_solely_ using the index (without reference to the actual data blocks), +I'd expect that the break-even point would be considerably higher than +the < 3% (~38,000 / ~1.3M) I'm currently getting. Does PG not use +solely the index in this situation?? + +> > A) alter table xxx alter column cid set statistics 500; +> > analyze xxx; +> > This does not affect the results. +> +> It probably improved the accuracy of the row count estimates, +> no? The estimate you show for cid=7191032 is off by more than +> 25% (37765 vs 50792), which seems like a lot of error for one +> of the most common values in the table. (I hope that was +> with default stats target and not 500.) That leads directly +> to a 25% overestimate of the cost of an indexscan, while +> having IIRC no impact on the cost of a seqscan. Since the +> cost ratio was more than 25%, this didn't change the selected +> plan, but you want to fix that error as best you can before +> you move on to tweaking cost parameters. + +Actually it made them worse! Yes, this was the default statistics (10). +When I just tried it again with a value of 300, analyze, then run the +query, I get a *worse* result for an estimate. I don't understand this. + + + alter table xxx alter column cid set statistics 300; + analyze emailrcpts; + set random_page_cost to 2; + explain analyze select count(*) from xxx where cid=7191032; + + Aggregate (cost=20563.28..20563.28 rows=1 width=0) (actual +time=7653.90..7653.90 rows=1 loops=1) + -> Index Scan using xxx_cid on xxx (cost=0.00..20535.82 rows=10983 +width=0) (actual time=72.24..7602.38 rows=37765 loops=1) + Total runtime: 7654.14 msec + +Now it estimates I have only 10,983 rows (~3x too low) instead of the +old estimate 50,792 (1.3x too high). Why is that ?? + +Anyway, a workable solution seems to be using a lower value for +Random_Page_Cost. Thanks to everyone who replied with this answer. + +> Also it is likely appropriate to increase +> effective_cache_size, which is awfully small in the default +> configuration. I'd set that to something related to your +> available RAM before trying to home in on a suitable random_page_cost. + +We have ours set to the default value of 1000, which does seem low for a +system with 1GB of RAM. We'll up this once we figure out what's +available. Then tweak the Random_Page_Cost appropriately at that point. + +I'd still like to understand the strangeness above, if anyone can shed +light. + +- Jeremy + + +From pgsql-performance-owner@postgresql.org Mon Apr 12 16:52:14 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4702AD1B486 + for ; + Mon, 12 Apr 2004 16:52:13 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 55203-01 + for ; + Mon, 12 Apr 2004 16:52:13 -0300 (ADT) +Received: from wolff.to (wolff.to [66.93.249.74]) + by svr1.postgresql.org (Postfix) with SMTP id D5836D1D1B8 + for ; + Mon, 12 Apr 2004 16:52:10 -0300 (ADT) +Received: (qmail 24169 invoked by uid 500); 12 Apr 2004 19:55:52 -0000 +Date: Mon, 12 Apr 2004 14:55:52 -0500 +From: Bruno Wolff III +To: Jeremy Dunn +Cc: 'Postgresql Performance' +Subject: Re: index v. seqscan for certain values +Message-ID: <20040412195552.GA24133@wolff.to> +Mail-Followup-To: Jeremy Dunn , + 'Postgresql Performance' +References: <12037.1081792288@sss.pgh.pa.us> + <001d01c420c1$0ed23290$4f01a8c0@jeremydunn> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <001d01c420c1$0ed23290$4f01a8c0@jeremydunn> +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/140 +X-Sequence-Number: 6440 + +On Mon, Apr 12, 2004 at 15:05:02 -0400, + Jeremy Dunn wrote: +> +> Agreed. However, given that count(*) is a question that can be answered +> _solely_ using the index (without reference to the actual data blocks), +> I'd expect that the break-even point would be considerably higher than +> the < 3% (~38,000 / ~1.3M) I'm currently getting. Does PG not use +> solely the index in this situation?? + +That isn't true. In order to check visibility you need to look at the +data blocks. + +From pgsql-performance-owner@postgresql.org Mon Apr 12 17:55:10 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id AE3E7D1D084 + for ; + Mon, 12 Apr 2004 17:55:08 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 75529-07 + for ; + Mon, 12 Apr 2004 17:55:09 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id A39D4D1D070 + for ; + Mon, 12 Apr 2004 17:55:06 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3CKslMK013681; + Mon, 12 Apr 2004 16:54:47 -0400 (EDT) +To: =?ISO-8859-1?Q?Pailloncy_Jean-G=E9rard?= +Cc: pgsql-performance@postgresql.org +Subject: Re: =?ISO-8859-1?Q?Re:__Index_Backward_Scan_fast_/_Index_Sc?= + =?ISO-8859-1?Q?an_slow_!__=28Modifi=E9_par_Pailloncy_Jean-G=E9ra?= + =?ISO-8859-1?Q?rd=29?= +In-reply-to: <1D4DEBDC-8CB4-11D8-80FD-000A95DE2550@ifrance.com> +References: <1D4DEBDC-8CB4-11D8-80FD-000A95DE2550@ifrance.com> +Comments: In-reply-to =?ISO-8859-1?Q?Pailloncy_Jean-G=E9rard?= + + message dated "Mon, 12 Apr 2004 21:02:02 +0200" +Date: Mon, 12 Apr 2004 16:54:47 -0400 +Message-ID: <13680.1081803287@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/141 +X-Sequence-Number: 6441 + +=?ISO-8859-1?Q?Pailloncy_Jean-G=E9rard?= writes: +>> In 7.4 a VACUUM should be sufficient ... or at least, if it isn't +> Atfer VACUUM: +> Better, but...... + +... but not much :-(. Okay, could we see VACUUM VERBOSE results for +this table? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Apr 12 18:02:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7FE58D1C9BE + for ; + Mon, 12 Apr 2004 18:02:48 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 81172-01 + for ; + Mon, 12 Apr 2004 18:02:48 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 3C7DBD1BAF8 + for ; + Mon, 12 Apr 2004 18:02:46 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3CL2l77013763; + Mon, 12 Apr 2004 17:02:47 -0400 (EDT) +To: jdunn@autorevenue.com +Cc: "'Postgresql Performance'" +Subject: Re: index v. seqscan for certain values +In-reply-to: <001d01c420c1$0ed23290$4f01a8c0@jeremydunn> +References: <001d01c420c1$0ed23290$4f01a8c0@jeremydunn> +Comments: In-reply-to "Jeremy Dunn" + message dated "Mon, 12 Apr 2004 15:05:02 -0400" +Date: Mon, 12 Apr 2004 17:02:47 -0400 +Message-ID: <13762.1081803767@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/142 +X-Sequence-Number: 6442 + +"Jeremy Dunn" writes: +> Agreed. However, given that count(*) is a question that can be answered +> _solely_ using the index (without reference to the actual data blocks), + +As Bruno noted, that is not the case in Postgres; we must visit the +table rows anyway. + +> When I just tried it again with a value of 300, analyze, then run the +> query, I get a *worse* result for an estimate. I don't understand this. + +That's annoying. How repeatable are these results --- if you do ANALYZE +over again several times, how much does the row count estimate change +each time? (It should change somewhat, since ANALYZE is taking a random +sample, but one would like to think not a whole lot.) Is the variance +more or less at the higher stats target? Take a look at a few different +CID values to get a sense of the accuracy, don't look at just one ... + +(Actually, you might find it more profitable to look at the pg_stats +entry for the CID column rather than reverse-engineering the stats via +ANALYZE. Look at how well the most-common-values list and associated +frequency numbers track reality.) + +Also, can you think of any reason for the distribution of CID values +to be nonuniform within the table? For instance, do rows get inserted +in order of increasing CID, or is there any clustering of rows with the +same CID? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Apr 12 18:24:32 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6F049D1D26C + for ; + Mon, 12 Apr 2004 18:24:31 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 89033-06 + for ; + Mon, 12 Apr 2004 18:24:32 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 9297CD1D1C4 + for ; + Mon, 12 Apr 2004 18:24:23 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3CLNkjT013961; + Mon, 12 Apr 2004 17:23:47 -0400 (EDT) +To: =?ISO-8859-1?Q?Pailloncy_Jean-G=E9rard?= +Cc: pgsql-performance@postgresql.org +Subject: Re: Index Backward Scan fast / Index Scan slow ! +In-reply-to: +References: <8A2105D4-8C63-11D8-80FD-000A95DE2550@ifrance.com> + <8579.1081772899@sss.pgh.pa.us> + +Comments: In-reply-to =?ISO-8859-1?Q?Pailloncy_Jean-G=E9rard?= + + message dated "Mon, 12 Apr 2004 21:02:02 +0200" +Date: Mon, 12 Apr 2004 17:23:46 -0400 +Message-ID: <13960.1081805026@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/143 +X-Sequence-Number: 6443 + +[ Ah, I just got to your message with the VACUUM VERBOSE results ... ] + +=?ISO-8859-1?Q?Pailloncy_Jean-G=E9rard?= writes: +> dps=# VACUUM VERBOSE url; +> INFO: index "url_next_index_time" now contains 349519 row versions in +> 3534 pages +> DETAIL: 229515 index row versions were removed. +> 3071 index pages have been deleted, 2864 are currently reusable. +> CPU 0.32s/0.67u sec elapsed 76.25 sec. + +Hm, this is odd. That says you've got 349519 live index entries in only +463 actively-used index pages, or an average of 754 per page, which +AFAICS could not fit in an 8K page. Are you using a nondefault value of +BLCKSZ? If so what? + +If you *are* using default BLCKSZ then this index must be corrupt, and +what you probably need to do is REINDEX it. But before you do that, +could you send me a copy of the index file? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Apr 12 21:17:36 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 18542D1E137 + for ; + Mon, 12 Apr 2004 21:17:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 47709-01 + for ; + Mon, 12 Apr 2004 21:17:36 -0300 (ADT) +Received: from mail4.speakeasy.net (mail4.speakeasy.net [216.254.0.204]) + by svr1.postgresql.org (Postfix) with ESMTP id 9866ED1E129 + for ; + Mon, 12 Apr 2004 21:17:32 -0300 (ADT) +Received: (qmail 10051 invoked by uid 64014); 13 Apr 2004 00:17:36 -0000 +Received: from kgeis@speakeasy.org by mail4.speakeasy.net with + AmikaGuardian-Server-2.1.2; 13 Apr 2004 00:17:36 -0000 +X-AmikaGuardian-Id: mail4.speakeasy.net108181545526110043 +X-AmikaGuardian-Action: Do Nothing() +Received: from adsl-67-113-18-226.dsl.snfc21.pacbell.net (HELO speakeasy.org) + (kgeis@[67.113.18.226]) (envelope-sender ) + by mail4.speakeasy.net (qmail-ldap-1.03) with AES256-SHA encrypted SMTP + for ; 13 Apr 2004 00:17:35 -0000 +Message-ID: <407B319B.7000400@speakeasy.org> +Date: Mon, 12 Apr 2004 17:17:31 -0700 +From: Ken Geis +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.7b) Gecko/20040316 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Tracking down performance issue +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/144 +X-Sequence-Number: 6444 + +I'm running 7.4.2 on an older Linux box (450MHzAMD K-6-III, 450M RAM) +running kernel 2.6.5. My client is a Java/JDBC program on Windows. + +I'm having trouble seeing where the bottleneck in my performance is. +The client uses about 30% CPU. The server uses 70% CPU plus 1.5% I/O +wait. The I/O wait is very low because I'm doing a PK index scan where +the index and data are on different disks and the table is clustered on +the PK index. The network is 100Mb, and it's at 7% of capacity. + +I tried making the client operate on two threads on two database +connections. That bumped the server utilization to 80% and barely +changed the I/O wait. The throughput decreased by a third. + +The only thing I can think of is memory bandwidth. Does anyone have +tips on how I can investigate more? + + +From pgsql-performance-owner@postgresql.org Tue Apr 13 08:12:40 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 24943D1E180 + for ; + Tue, 13 Apr 2004 08:12:39 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 52470-04 + for ; + Tue, 13 Apr 2004 08:12:40 -0300 (ADT) +Received: from mwinf0204.wanadoo.fr (smtp2.wanadoo.fr [193.252.22.29]) + by svr1.postgresql.org (Postfix) with ESMTP id E8EDFD1E084 + for ; + Tue, 13 Apr 2004 08:12:36 -0300 (ADT) +Received: from [192.168.0.2] (AMontsouris-108-1-19-199.w80-15.abo.wanadoo.fr + [80.15.148.199]) by mwinf0204.wanadoo.fr (SMTP Server) with ESMTP + id 29481A0000B3; Tue, 13 Apr 2004 13:12:39 +0200 (CEST) +In-Reply-To: <13960.1081805026@sss.pgh.pa.us> +References: <8A2105D4-8C63-11D8-80FD-000A95DE2550@ifrance.com> + <8579.1081772899@sss.pgh.pa.us> + + <13960.1081805026@sss.pgh.pa.us> +Mime-Version: 1.0 (Apple Message framework v613) +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Message-Id: <77EC9C09-8D3B-11D8-A5A0-000A95DE2550@ifrance.com> +Content-Transfer-Encoding: quoted-printable +Cc: pgsql-performance@postgresql.org +From: =?ISO-8859-1?Q?Pailloncy_Jean-G=E9rard?= +Subject: Re: Index Backward Scan fast / Index Scan slow ! +Date: Tue, 13 Apr 2004 13:12:36 +0200 +To: Tom Lane +X-Mailer: Apple Mail (2.613) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/145 +X-Sequence-Number: 6445 + +> Hm, this is odd. That says you've got 349519 live index entries in=20 +> only +> 463 actively-used index pages, or an average of 754 per page, which +> AFAICS could not fit in an 8K page. Are you using a nondefault value=20 +> of +> BLCKSZ? If so what? +Sorry, I forgot to specify I use BLCKSZ of 32768, the same blokck's=20 +size for newfs, the same for RAID slice's size. +I test the drive sometimes ago, and found a speed win if the slice size=20 +the disk block size and the read block size was the same. + +I do not think that a different BLCKSZ should exhibit a slowdown as the=20 +one I found. + +> If you *are* using default BLCKSZ then this index must be corrupt, and +> what you probably need to do is REINDEX it. But before you do that, +> could you send me a copy of the index file? +Do you want the index file now, or may I try something before? + +Cordialement, +Jean-G=E9rard Pailloncy + + +From pgsql-performance-owner@postgresql.org Tue Apr 13 10:47:14 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 473C7D1E944 + for ; + Tue, 13 Apr 2004 10:47:13 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 04431-05 + for ; + Tue, 13 Apr 2004 10:47:15 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 10398D1E129 + for ; + Tue, 13 Apr 2004 10:47:09 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3DDlCUq022097; + Tue, 13 Apr 2004 09:47:12 -0400 (EDT) +To: =?ISO-8859-1?Q?Pailloncy_Jean-G=E9rard?= +Cc: pgsql-performance@postgresql.org +Subject: Re: Index Backward Scan fast / Index Scan slow ! +In-reply-to: <77EC9C09-8D3B-11D8-A5A0-000A95DE2550@ifrance.com> +References: <8A2105D4-8C63-11D8-80FD-000A95DE2550@ifrance.com> + <8579.1081772899@sss.pgh.pa.us> + + <13960.1081805026@sss.pgh.pa.us> + <77EC9C09-8D3B-11D8-A5A0-000A95DE2550@ifrance.com> +Comments: In-reply-to =?ISO-8859-1?Q?Pailloncy_Jean-G=E9rard?= + + message dated "Tue, 13 Apr 2004 13:12:36 +0200" +Date: Tue, 13 Apr 2004 09:47:11 -0400 +Message-ID: <22096.1081864031@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/146 +X-Sequence-Number: 6446 + +=?ISO-8859-1?Q?Pailloncy_Jean-G=E9rard?= writes: +>> Are you using a nondefault value of +>> BLCKSZ? If so what? + +> Sorry, I forgot to specify I use BLCKSZ of 32768, + +Okay, the numbers are sensible then. The index density seems a bit low +(754 entries/page where the theoretical ideal would be about 1365) but +not really out-of-line. + +>> could you send me a copy of the index file? + +> Do you want the index file now, or may I try something before? + +If you're going to reindex, please do send me a copy of the file first. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Apr 13 11:26:57 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id ADDF5D1C9C8 + for ; + Tue, 13 Apr 2004 11:26:56 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 28489-02 + for ; + Tue, 13 Apr 2004 11:26:56 -0300 (ADT) +Received: from trade-india.com (ns5.trade-india.com [66.234.10.13]) + by svr1.postgresql.org (Postfix) with SMTP id 7799BD1C9C4 + for ; + Tue, 13 Apr 2004 11:26:52 -0300 (ADT) +Received: (qmail 14006 invoked from network); 13 Apr 2004 10:57:54 -0000 +Received: from unknown (HELO trade-india.com) (203.145.130.142) + by ns5.trade-india.com with SMTP; 13 Apr 2004 10:57:54 -0000 +Message-ID: <407BF8B5.3010101@trade-india.com> +Date: Tue, 13 Apr 2004 19:57:01 +0530 +From: Rajesh Kumar Mallah +User-Agent: Mozilla Thunderbird 0.5 (X11/20040208) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "Shea,Dan [CIS]" +Cc: Postgres Performance +Subject: Re: Deleting certain duplicates +References: +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/147 +X-Sequence-Number: 6447 + +Shea,Dan [CIS] wrote: + +>The index is +>Indexes: +> "forecastelement_rwv_idx" btree (region_id, wx_element, valid_time) +> +>-----Original Message----- +>From: Shea,Dan [CIS] [mailto:Dan.Shea@ec.gc.ca] +>Sent: Monday, April 12, 2004 10:39 AM +>To: Postgres Performance +>Subject: [PERFORM] Deleting certain duplicates +> +> +>We have a large database which recently increased dramatically due to a +>change in our insert program allowing all entries. +>PWFPM_DEV=# select relname,relfilenode,reltuples from pg_class where relname +>= 'forecastelement'; +> relname | relfilenode | reltuples +>-----------------+-------------+------------- +> forecastelement | 361747866 | 4.70567e+08 +> +> Column | Type | Modifiers +>----------------+-----------------------------+----------- +> version | character varying(99) | +> origin | character varying(10) | +> timezone | character varying(99) | +> region_id | character varying(20) | +> wx_element | character varying(99) | +> value | character varying(99) | +> flag | character(3) | +> units | character varying(99) | +> valid_time | timestamp without time zone | +> issue_time | timestamp without time zone | +> next_forecast | timestamp without time zone | +> reception_time | timestamp without time zone | +> +>The program is supposed to check to ensure that all fields but the +>reception_time are unique using a select statement, and if so, insert it. +>Due an error in a change, reception time was included in the select to check +>for duplicates. The reception_time is created by a program creating the dat +>file to insert. +>Essentially letting all duplicate files to be inserted. +> +>I tried the delete query below. +>PWFPM_DEV=# delete from forecastelement where oid not in (select min(oid) +>from forecastelement group by +>version,origin,timezone,region_id,wx_element,value,flag,units,valid_time,iss +>ue_time,next_forecast); +>It ran for 3 days creating what I assume is an index in pgsql_tmp of the +>group by statement. +>The query ended up failing with "dateERROR:write failed". +>Well the long weekend is over and we do not have the luxury of trying this +>again. +>So I was thinking maybe of doing the deletion in chunks, perhaps based on +>reception time. +> +> + +its more of an sql question though. + +to deduplicate on basis of + +version,origin,timezone,region_id,wx_element,value,flag,units,valid_time, +issue_time,next_forecast + +You could do this. + +begin work; +create temp_table as select distinct on +(version,origin,timezone,region_id,wx_element,value,flag,units,valid_time, +issue_time,next_forecast) * from forecastelement ; +truncate table forecastelement ; +drop index ; +insert into forecastelement select * from temp_table ; +commit; +create indexes +Analyze forecastelement ; + +note that distinct on will keep only one row out of all rows having +distinct values +of the specified columns. kindly go thru the distinct on manual before +trying +the queries. + +regds +mallah. + +>Are there any suggestions for a better way to do this, or using multiple +>queries to delete selectively a week at a time based on the reception_time. +>I would say there are a lot of duplicate entries between mid march to the +>first week of April. +> +> +> +>---------------------------(end of broadcast)--------------------------- +>TIP 8: explain analyze is your friend +> +>---------------------------(end of broadcast)--------------------------- +>TIP 3: if posting/reading through Usenet, please send an appropriate +> subscribe-nomail command to majordomo@postgresql.org so that your +> message can get through to the mailing list cleanly +> +> +> + + +From pgsql-performance-owner@postgresql.org Tue Apr 13 11:41:35 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C1FB2D1E944 + for ; + Tue, 13 Apr 2004 11:41:32 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 32517-05 + for ; + Tue, 13 Apr 2004 11:41:34 -0300 (ADT) +Received: from mail.autorevenue.com (ip-208.178.167.106.gblx.net + [208.178.167.106]) + by svr1.postgresql.org (Postfix) with ESMTP id 91238D1E969 + for ; + Tue, 13 Apr 2004 11:41:28 -0300 (ADT) +Received: from jeremydunn ([192.168.1.79]) (authenticated) + by mail.autorevenue.com (8.11.6/8.11.6) with ESMTP id i3DEfWY18193 + for ; Tue, 13 Apr 2004 10:41:32 -0400 +Reply-To: +From: "Jeremy Dunn" +To: "'Postgresql Performance'" +Subject: Re: index v. seqscan for certain values +Date: Tue, 13 Apr 2004 10:41:30 -0400 +Organization: AutoRevenue +Message-ID: <000801c42165$68a67750$4f01a8c0@jeremydunn> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.2627 +In-reply-to: <13762.1081803767@sss.pgh.pa.us> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +Importance: Normal +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/148 +X-Sequence-Number: 6448 + +> > When I just tried it again with a value of 300, analyze, +> then run the query, I get a *worse* result for an estimate. I don't +understand +> > this. +> +> That's annoying. How repeatable are these results --- if you +> do ANALYZE over again several times, how much does the row +> count estimate change each time? (It should change somewhat, +> since ANALYZE is taking a random sample, but one would like +> to think not a whole lot.) Is the variance more or less at +> the higher stats target? Take a look at a few different CID +> values to get a sense of the accuracy, don't look at just one ... + +Yes, it's repeatable. I tried a bunch of times, and there are only +small variations in the stats for the higher stat targets. + +> (Actually, you might find it more profitable to look at the +> pg_stats entry for the CID column rather than +> reverse-engineering the stats via ANALYZE. Look at how well +> the most-common-values list and associated frequency numbers +> track reality.) + +I checked the accuracy of the stats for various values, and there is a +wide variation. I see some values where the estimate is 1.75x the +actual; and others where the estimate is .44x the actual. + +> Also, can you think of any reason for the distribution of CID +> values to be nonuniform within the table? For instance, do +> rows get inserted in order of increasing CID, or is there any +> clustering of rows with the same CID? + +This is almost certainly the answer. The data is initially inserted in +chunks for each CID, and later on there is a more normal distribution of +insert/update/deletes across all CIDs; and then again a new CID will +come with a large chunk of rows, etc. + +Interestingly, I tried increasing the stat size for the CID column to +2000, analyzing, and checking the accuracy of the stats again. Even +with this relatively high value, the accuracy of the stats is not that +close. The value giving .44x previously nows gives an estimate .77x of +actual. Another value which was at 1.38x of actual is now at .71x of +actual! + +Then just for kicks I set the statistics size to 100,000 (!), analyzed, +and ran the query again. For the same CID I still got an estimated row +count that is .71x the actual rows returned. Why is this not better? I +wonder how high I'd have to set the statistics collector to get really +good data, given the uneven data distribution of this table. Is there +any other technique that works better to get good estimates, given +uneven distribution of values? + +So I think this explains the inaccurate stats; and the solution as far +as I'm concerned is to increase the two params mentioned yesterday +(effective_cache_size & random_page_cost). + +Thanks again for the help! +- Jeremy + + +From pgsql-performance-owner@postgresql.org Tue Apr 13 14:55:53 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 67287D1DD2C + for ; + Tue, 13 Apr 2004 14:55:52 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 18160-06 + for ; + Tue, 13 Apr 2004 14:55:51 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 2AAE6D1DC7D + for ; + Tue, 13 Apr 2004 14:55:50 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3DHtnBn024671; + Tue, 13 Apr 2004 13:55:50 -0400 (EDT) +To: jdunn@autorevenue.com +Cc: "'Postgresql Performance'" +Subject: Re: index v. seqscan for certain values +In-reply-to: <000801c42165$68a67750$4f01a8c0@jeremydunn> +References: <000801c42165$68a67750$4f01a8c0@jeremydunn> +Comments: In-reply-to "Jeremy Dunn" + message dated "Tue, 13 Apr 2004 10:41:30 -0400" +Date: Tue, 13 Apr 2004 13:55:49 -0400 +Message-ID: <24670.1081878949@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/149 +X-Sequence-Number: 6449 + +"Jeremy Dunn" writes: +> Interestingly, I tried increasing the stat size for the CID column to +> 2000, analyzing, and checking the accuracy of the stats again. + +There's a hard limit of 1000, I believe. Didn't it give you a warning +saying so? + +At 1000 the ANALYZE sample size would be 300000 rows, or about a quarter +of your table. I would have thought this would give frequency estimates +with much better precision than you seem to be seeing --- but my +statistics are rusty enough that I'm not sure about it. Possibly the +nonuniform clumping of CID has something to do with the poor results. + +Any stats majors on the list? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Apr 13 15:02:59 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6C8EDD1E98D + for ; + Tue, 13 Apr 2004 15:02:58 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 20498-08 + for ; + Tue, 13 Apr 2004 15:02:55 -0300 (ADT) +Received: from bramble.mmrd.com (unknown [65.217.53.66]) + by svr1.postgresql.org (Postfix) with ESMTP id 71FE0D1E98C + for ; + Tue, 13 Apr 2004 15:02:53 -0300 (ADT) +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 i3DI5GcM010301 + for ; Tue, 13 Apr 2004 14:05:25 -0400 +Received: from gnvex001.mmrd.com (gnvex001.mmrd.com [192.168.3.55]) + by thorn.mmrd.com (8.11.6/8.11.6) with ESMTP id i3DI2el06362 + for ; Tue, 13 Apr 2004 14:02:41 -0400 +Received: from camel.mmrd.com ([172.25.5.213]) by gnvex001.mmrd.com with SMTP + (Microsoft Exchange Internet Mail Service Version 5.5.2657.72) + id FVMA9AJ9; Tue, 13 Apr 2004 14:02:38 -0400 +Subject: query slows down with more accurate stats +From: Robert Treat +To: pgsql-performance@postgresql.org +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +X-Mailer: Ximian Evolution 1.0.8 +Date: 13 Apr 2004 14:02:39 -0400 +Message-Id: <1081879359.25537.526.camel@camel> +Mime-Version: 1.0 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/150 +X-Sequence-Number: 6450 + +In the process of optimizing some queries, I have found the following +query seems to degrade in performance the more accurate I make the +statistics on the table... whether by using increased alter table ... +set statistics or by using vacuum.. + +SELECT + count( cl.caller_id ), + npanxx.city, + npanxx.state +FROM + cl + LEFT OUTER JOIN npanxx + on substr( cl.caller_id, 1, 3 ) = npanxx.npa + and substr( cl.caller_id, 4, 3 ) = npanxx.nxx + LEFT OUTER JOIN cp + ON cl.caller_id = cp.caller_id +WHERE + cl.ivr_system_id = 130 + AND + cl.call_time > '2004-03-01 06:00:00.0 CST' + AND + cl.call_time < '2004-04-01 06:00:00.0 CST' + AND + cp.age >= 18 + AND + cp.age <= 24 + AND + cp.gender = 'm' +GROUP BY + npanxx.city, + npanxx.state + + +live=# analyze cl; +ANALYZE +live=# select reltuples from pg_class where relname = 'cl'; + reltuples +----------- + 53580 +(1 row) + +live=# select count(*) from cl; + count +--------- + 1140166 +(1 row) + +The plan i get under these conditions is actually pretty good... + + HashAggregate (cost=28367.22..28367.66 rows=174 width=32) (actual time=1722.060..1722.176 rows=29 loops=1) + -> Nested Loop (cost=0.00..28365.92 rows=174 width=32) (actual time=518.592..1716.254 rows=558 loops=1) + -> Nested Loop Left Join (cost=0.00..20837.33 rows=1248 width=32) (actual time=509.991..1286.755 rows=13739 loops=1) + -> Index Scan using cl_ivr_system_id on cl (cost=0.00..13301.15 rows=1248 width=14) (actual time=509.644..767.421 rows=13739 loops=1) + Index Cond: (ivr_system_id = 130) + Filter: ((call_time > '2004-03-01 07:00:00-05'::timestamp with time zone) AND (call_time < '2004-04-01 07:00:00-05'::timestamp with time zone)) + -> Index Scan using npanxx_pkey on npanxx (cost=0.00..6.02 rows=1 width=32) (actual time=0.025..0.027 rows=1 loops=13739) + Index Cond: ((substr(("outer".caller_id)::text, 1, 3) = (npanxx.npa)::text) AND (substr(("outer".caller_id)::text, 4, 3) = (npanxx.nxx)::text)) + -> Index Scan using cp_pkey on cp (cost=0.00..6.02 rows=1 width=14) (actual time=0.027..0.027 rows=0 loops=13739) + Index Cond: (("outer".caller_id)::text = (cp.caller_id)::text) + Filter: ((age >= 18) AND (age <= 24) AND (gender = 'm'::bpchar)) + Total runtime: 1722.489 ms +(12 rows) + + +but when i do + +live=# vacuum cl; +VACUUM +live=# select reltuples from pg_class where relname = 'cl'; + reltuples +------------- + 1.14017e+06 +(1 row) + +(or alternatively increase the stats target on the table) + +I now get the following plan: + + HashAggregate (cost=80478.74..80482.41 rows=1471 width=32) (actual time=8132.261..8132.422 rows=29 loops=1) + -> Merge Join (cost=79951.95..80467.70 rows=1471 width=32) (actual time=7794.338..8130.041 rows=558 loops=1) + Merge Cond: ("outer"."?column4?" = "inner"."?column2?") + -> Sort (cost=55719.06..55745.42 rows=10546 width=32) (actual time=4031.827..4052.526 rows=13739 loops=1) + Sort Key: (cl.caller_id)::text + -> Merge Right Join (cost=45458.30..55014.35 rows=10546 width=32) (actual time=2944.441..3796.787 rows=13739 loops=1) + Merge Cond: ((("outer".npa)::text = "inner"."?column2?") AND (("outer".nxx)::text = "inner"."?column3?")) + -> Index Scan using npanxx_pkey on npanxx (cost=0.00..8032.99 rows=132866 width=32) (actual time=0.200..461.767 rows=130262 loops=1) + -> Sort (cost=45458.30..45484.67 rows=10546 width=14) (actual time=2942.994..2967.935 rows=13739 loops=1) + Sort Key: substr((cl.caller_id)::text, 1, 3), substr((cl.caller_id)::text, 4, 3) + -> Seq Scan on cl (cost=0.00..44753.60 rows=10546 width=14) (actual time=1162.423..2619.662 rows=13739 loops=1) + Filter: ((ivr_system_id = 130) AND (call_time > '2004-03-01 07:00:00-05'::timestamp with time zone) AND (call_time < '2004-04-01 07:00:00-05'::timestamp with time zone)) + -> Sort (cost=24232.89..24457.06 rows=89667 width=14) (actual time=3761.703..3900.340 rows=98010 loops=1) + Sort Key: (cp.caller_id)::text + -> Seq Scan on cp (cost=0.00..15979.91 rows=89667 width=14) (actual time=0.128..1772.215 rows=100302 loops=1) + Filter: ((age >= 18) AND (age <= 24) AND (gender = 'm'::bpchar)) + Total runtime: 8138.607 ms +(17 rows) + + +so i guess i am wondering if there is something I should be doing to +help get the better plan at the more accurate stats levels and/or why it +doesn't stick with the original plan (I noticed disabling merge joins +does seem to push it back to the original plan). + +alternatively if anyone has any general suggestions on speeding up the +query I'd be open to that too :-) + + +Robert Treat +-- +Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL + + +From pgsql-performance-owner@postgresql.org Tue Apr 13 15:04:40 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9948ED1E180 + for ; + Tue, 13 Apr 2004 15:04:30 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 19433-08 + for ; + Tue, 13 Apr 2004 15:04:25 -0300 (ADT) +Received: from mail.autorevenue.com (ip-208.178.167.106.gblx.net + [208.178.167.106]) + by svr1.postgresql.org (Postfix) with ESMTP id C7892D1CCA7 + for ; + Tue, 13 Apr 2004 15:04:21 -0300 (ADT) +Received: from jeremydunn ([192.168.1.79]) (authenticated) + by mail.autorevenue.com (8.11.6/8.11.6) with ESMTP id i3DI4LY31234 + for ; Tue, 13 Apr 2004 14:04:21 -0400 +Reply-To: +From: "Jeremy Dunn" +To: "'Postgresql Performance'" +Subject: Re: index v. seqscan for certain values +Date: Tue, 13 Apr 2004 14:04:19 -0400 +Organization: AutoRevenue +Message-ID: <000f01c42181$be1b6260$4f01a8c0@jeremydunn> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.2627 +In-reply-to: <24670.1081878949@sss.pgh.pa.us> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +Importance: Normal +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/151 +X-Sequence-Number: 6451 + + +> There's a hard limit of 1000, I believe. Didn't it give you +> a warning saying so? + +No warning at 2000, and no warning at 100,000 either! + +Remember we are still on 7.2.x. The docs here +http://www.postgresql.org/docs/7.2/static/sql-altertable.html don't say +anything about a limit. + +This is good to know, if it's true. Can anyone confirm? + +- Jeremy + + +From pgsql-performance-owner@postgresql.org Tue Apr 13 15:35:29 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id F38E2D1D08B + for ; + Tue, 13 Apr 2004 15:35:26 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 35890-02 + for ; + Tue, 13 Apr 2004 15:35:26 -0300 (ADT) +Received: from bramble.mmrd.com (unknown [65.217.53.66]) + by svr1.postgresql.org (Postfix) with ESMTP id 93FC0D1D08A + for ; + Tue, 13 Apr 2004 15:35:24 -0300 (ADT) +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 i3DIbrcM010790; + Tue, 13 Apr 2004 14:37:53 -0400 +Received: from gnvex001.mmrd.com (gnvex001.mmrd.com [192.168.3.55]) + by thorn.mmrd.com (8.11.6/8.11.6) with ESMTP id i3DIZHl07552; + Tue, 13 Apr 2004 14:35:17 -0400 +Received: from camel.mmrd.com ([172.25.5.213]) by gnvex001.mmrd.com with SMTP + (Microsoft Exchange Internet Mail Service Version 5.5.2657.72) + id FVMA9A4C; Tue, 13 Apr 2004 14:35:15 -0400 +Subject: Re: index v. seqscan for certain values +From: Robert Treat +To: jdunn@autorevenue.com +Cc: "'Postgresql Performance'" +In-Reply-To: <000f01c42181$be1b6260$4f01a8c0@jeremydunn> +References: <000f01c42181$be1b6260$4f01a8c0@jeremydunn> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +X-Mailer: Ximian Evolution 1.0.8 +Date: 13 Apr 2004 14:35:16 -0400 +Message-Id: <1081881316.25537.562.camel@camel> +Mime-Version: 1.0 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/152 +X-Sequence-Number: 6452 + +On Tue, 2004-04-13 at 14:04, Jeremy Dunn wrote: +> +> > There's a hard limit of 1000, I believe. Didn't it give you +> > a warning saying so? +> +> No warning at 2000, and no warning at 100,000 either! +> +> Remember we are still on 7.2.x. The docs here +> http://www.postgresql.org/docs/7.2/static/sql-altertable.html don't say +> anything about a limit. +> +> This is good to know, if it's true. Can anyone confirm? +> + +transform=# alter table data_pull alter column msg set statistics +100000; +WARNING: lowering statistics target to 1000 +ERROR: column "msg" of relation "data_pull" does not exist +transform=# select version(); + version +---------------------------------------------------------------- + PostgreSQL 7.4beta4 on i686-pc-linux-gnu, compiled by GCC 2.96 +(1 row) + + +Robert Treat +-- +Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL + + +From pgsql-performance-owner@postgresql.org Tue Apr 13 16:10:53 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 95B34D1DA83 + for ; + Tue, 13 Apr 2004 15:50:11 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 41839-07 + for ; + Tue, 13 Apr 2004 15:50:05 -0300 (ADT) +Received: from leo.supplyfx.com (h-67-100-199-42.lsanca54.covad.net + [67.100.199.42]) + by svr1.postgresql.org (Postfix) with ESMTP id 6A376D1E995 + for ; + Tue, 13 Apr 2004 15:49:59 -0300 (ADT) +Received: from [10.0.100.21] (leo6.supplyfx.com [10.0.100.21]) + by leo.supplyfx.com (Postfix) with ESMTP + id CC92E105567; Tue, 13 Apr 2004 11:49:59 -0700 (PDT) +In-Reply-To: <24670.1081878949@sss.pgh.pa.us> +References: <000801c42165$68a67750$4f01a8c0@jeremydunn> + <24670.1081878949@sss.pgh.pa.us> +Mime-Version: 1.0 (Apple Message framework v612) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <53A6FF52-8D7B-11D8-92CF-000A95AB8896@quotefx.net> +Content-Transfer-Encoding: 7bit +Cc: Qing Zhao +From: Qing Zhao +Subject: configure shmmax on MAC OS X +Date: Tue, 13 Apr 2004 11:49:43 -0700 +To: 'Postgresql Performance' +X-Mailer: Apple Mail (2.612) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/153 +X-Sequence-Number: 6453 + + +Hi, all, + +I have got a new MaC OS G5 with 8GB RAM. So i tried to increase +the shmmax in Kernel so that I can take advantage of the RAM. + +I searched the web and read the manual for PG7.4 chapter 16.5.1. +After that, I edited /etc/rc file: + +sysctl -w kern.sysv.shmmax=4294967296 // byte +sysctl -w kern.sysv.shmmin=1 +sysctl -w kern.sysv.shmmni=32 +sysctl -w kern.sysv.shmseg=8 +sysctl -w kern.sysv.shmall=1048576 //4kpage + +for 4G shared RAM. + +Then I changed postgresql.conf: +shared_buffer=100000 //could be bigger? + +and restart the machine and postgres server. To my surprise, postgres +server wouldn't +start, saying that the requested shared memory exceeds kernel's shmmax. + +My suspision is that the change i made in /etc/rc does not take +effect.Is there a way +to check it? Is there an +up limit for how much RAM can be allocated for shared buffer in MAC OS +X? Or +is there something wrong with my calculation in numbers? + +Thanks a lot! + +Qing + + +From pgsql-performance-owner@postgresql.org Tue Apr 13 16:18:45 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 08788D1E97A + for ; + Tue, 13 Apr 2004 16:18:45 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 55132-07 + for ; + Tue, 13 Apr 2004 16:18:43 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 76A80D1E935 + for ; + Tue, 13 Apr 2004 16:18:41 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3DJIglK025558; + Tue, 13 Apr 2004 15:18:42 -0400 (EDT) +To: Robert Treat +Cc: pgsql-performance@postgresql.org +Subject: Re: query slows down with more accurate stats +In-reply-to: <1081879359.25537.526.camel@camel> +References: <1081879359.25537.526.camel@camel> +Comments: In-reply-to Robert Treat + message dated "13 Apr 2004 14:02:39 -0400" +Date: Tue, 13 Apr 2004 15:18:42 -0400 +Message-ID: <25556.1081883922@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/154 +X-Sequence-Number: 6454 + +Robert Treat writes: +> live=# analyze cl; +> ANALYZE +> live=# select reltuples from pg_class where relname = 'cl'; +> reltuples +> ----------- +> 53580 +> (1 row) +> live=# vacuum cl; +> VACUUM +> live=# select reltuples from pg_class where relname = 'cl'; +> reltuples +> ------------- +> 1.14017e+06 +> (1 row) + +Well, the first problem is why is ANALYZE's estimate of the total row +count so bad :-( ? I suspect you are running into the situation where +the initial pages of the table are thinly populated and ANALYZE +mistakenly assumes the rest are too. Manfred is working on a revised +sampling method for ANALYZE that should fix this problem in 7.5 and +beyond, but for now it seems like a VACUUM FULL might be in order. + +> so i guess i am wondering if there is something I should be doing to +> help get the better plan at the more accurate stats levels and/or why it +> doesn't stick with the original plan (I noticed disabling merge joins +> does seem to push it back to the original plan). + +With the larger number of estimated rows it's figuring the nestloop will +be too expensive. The row estimate for the cl scan went up from 1248 +to 10546, so the estimated cost for the nestloop plan would go to about +240000 units vs 80000 for the mergejoin plan. This is obviously off +rather badly when the true runtimes are 1.7 vs 8.1 seconds :-(. + +I think this is an example of a case where we really need better +estimation of nestloop costs --- it's drastically overestimating the +relative cost of the nestloop because it's not accounting for the cache +benefits of the repeated index searches. You could probably force the +nestloop to be chosen by lowering random_page_cost, but that's just a +kluge solution ... the real problem is the model is wrong. + +I have a to-do item to work on this, and will try to bump up its +priority a bit. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Apr 13 16:25:34 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D9D70D1E986 + for ; + Tue, 13 Apr 2004 16:25:32 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 57187-10 + for ; + Tue, 13 Apr 2004 16:25:30 -0300 (ADT) +Received: from visionlink.org (mail.visionlink.org [206.168.220.27]) + by svr1.postgresql.org (Postfix) with SMTP id 84206D1E1F3 + for ; + Tue, 13 Apr 2004 16:25:27 -0300 (ADT) +Received: from [65.100.170.137] (HELO [192.168.1.200]) by visionlink.org + (Stalker SMTP Server 1.8b8) with ESMTP id S.0002538979; + Tue, 13 Apr 2004 13:25:26 -0600 +Mime-Version: 1.0 +X-Sender: bohmer@mail.visionlink.org +Message-Id: +In-Reply-To: <53A6FF52-8D7B-11D8-92CF-000A95AB8896@quotefx.net> +References: <000801c42165$68a67750$4f01a8c0@jeremydunn> + <24670.1081878949@sss.pgh.pa.us> + <53A6FF52-8D7B-11D8-92CF-000A95AB8896@quotefx.net> +Date: Tue, 13 Apr 2004 13:25:25 -0600 +To: Qing Zhao +From: Jeff Bohmer +Subject: Re: configure shmmax on MAC OS X +Cc: pgsql-performance@postgresql.org +Content-Type: text/plain; charset="us-ascii" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/155 +X-Sequence-Number: 6455 + + +On OS X, I've always made these changes in: + +/System/Library/StartupItems/SystemTuning/SystemTuning + +and manually checked it with sysctl after reboot. Works for me. + +100k buffers is probably overkill. There can be a performance penalty with too many buffers. See this lists' archives for more. 10k would probably be a better start. + +- Jeff + + +>Hi, all, +> +>I have got a new MaC OS G5 with 8GB RAM. So i tried to increase +>the shmmax in Kernel so that I can take advantage of the RAM. +> +>I searched the web and read the manual for PG7.4 chapter 16.5.1. +>After that, I edited /etc/rc file: +> +>sysctl -w kern.sysv.shmmax=4294967296 // byte +>sysctl -w kern.sysv.shmmin=1 +>sysctl -w kern.sysv.shmmni=32 +>sysctl -w kern.sysv.shmseg=8 +>sysctl -w kern.sysv.shmall=1048576 //4kpage +> +>for 4G shared RAM. +> +>Then I changed postgresql.conf: +>shared_buffer=100000 //could be bigger? +> +>and restart the machine and postgres server. To my surprise, postgres server wouldn't +>start, saying that the requested shared memory exceeds kernel's shmmax. +> +>My suspision is that the change i made in /etc/rc does not take effect.Is there a way +>to check it? Is there an +>up limit for how much RAM can be allocated for shared buffer in MAC OS X? Or +>is there something wrong with my calculation in numbers? +> +>Thanks a lot! +> +>Qing +> +> +>---------------------------(end of broadcast)--------------------------- +>TIP 3: if posting/reading through Usenet, please send an appropriate +> subscribe-nomail command to majordomo@postgresql.org so that your +> message can get through to the mailing list cleanly + + +-- + +Jeff Bohmer +VisionLink, Inc. +_________________________________ +303.402.0170 +www.visionlink.org +_________________________________ +People. Tools. Change. Community. + +From pgsql-performance-owner@postgresql.org Tue Apr 13 16:55:29 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 01E4BD1E935 + for ; + Tue, 13 Apr 2004 16:55:26 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 73329-04 + for ; + Tue, 13 Apr 2004 16:55:16 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 2D9C5D1C9BE + for ; + Tue, 13 Apr 2004 16:55:14 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3DJtFjF025966; + Tue, 13 Apr 2004 15:55:15 -0400 (EDT) +To: Qing Zhao +Cc: "'Postgresql Performance'" +Subject: Re: configure shmmax on MAC OS X +In-reply-to: <53A6FF52-8D7B-11D8-92CF-000A95AB8896@quotefx.net> +References: <000801c42165$68a67750$4f01a8c0@jeremydunn> + <24670.1081878949@sss.pgh.pa.us> + <53A6FF52-8D7B-11D8-92CF-000A95AB8896@quotefx.net> +Comments: In-reply-to Qing Zhao + message dated "Tue, 13 Apr 2004 11:49:43 -0700" +Date: Tue, 13 Apr 2004 15:55:15 -0400 +Message-ID: <25965.1081886115@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/156 +X-Sequence-Number: 6456 + +Qing Zhao writes: +> My suspision is that the change i made in /etc/rc does not take +> effect.Is there a way to check it? + +sysctl has an option to show the values currently in effect. + +I believe that /etc/rc is the correct place to set shmmax on OSX 10.3 or +later ... but we have seen prior reports of people having trouble +getting the setting to "take". There may be some other constraint +involved. + +> sysctl -w kern.sysv.shmmax=4294967296 // byte + +Hmm, does sysctl work for values that exceed the range of int? + +There's no particularly good reason to try to set shmmax as high as you +are trying anyhow; you really don't need more than a couple hundred meg +in Postgres shared memory. It's better to leave the kernel to manage +the bulk of your RAM. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Apr 13 17:10:49 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 850B2D1D299 + for ; + Tue, 13 Apr 2004 17:10:48 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 79362-04 + for ; + Tue, 13 Apr 2004 17:10:43 -0300 (ADT) +Received: from leo.supplyfx.com (h-67-100-199-42.lsanca54.covad.net + [67.100.199.42]) + by svr1.postgresql.org (Postfix) with ESMTP id 32C28D1C9FB + for ; + Tue, 13 Apr 2004 17:10:41 -0300 (ADT) +Received: from [10.0.100.21] (leo6.supplyfx.com [10.0.100.21]) + by leo.supplyfx.com (Postfix) with ESMTP + id 7E1A5105808; Tue, 13 Apr 2004 13:10:42 -0700 (PDT) +In-Reply-To: <25965.1081886115@sss.pgh.pa.us> +References: <000801c42165$68a67750$4f01a8c0@jeremydunn> + <24670.1081878949@sss.pgh.pa.us> + <53A6FF52-8D7B-11D8-92CF-000A95AB8896@quotefx.net> + <25965.1081886115@sss.pgh.pa.us> +Mime-Version: 1.0 (Apple Message framework v612) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <993AFE3A-8D86-11D8-92CF-000A95AB8896@quotefx.net> +Content-Transfer-Encoding: 7bit +Cc: "'Postgresql Performance'" +From: Qing Zhao +Subject: Re: configure shmmax on MAC OS X +Date: Tue, 13 Apr 2004 13:10:24 -0700 +To: Tom Lane +X-Mailer: Apple Mail (2.612) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/157 +X-Sequence-Number: 6457 + +Tom: + +I used sysctl -A to see the kernel state, I got: +kern.sysv.shmmax: -1 + +It looks the value is too big! + +Thanks! + +Qing +On Apr 13, 2004, at 12:55 PM, Tom Lane wrote: + +> Qing Zhao writes: +>> My suspision is that the change i made in /etc/rc does not take +>> effect.Is there a way to check it? +> +> sysctl has an option to show the values currently in effect. +> +> I believe that /etc/rc is the correct place to set shmmax on OSX 10.3 +> or +> later ... but we have seen prior reports of people having trouble +> getting the setting to "take". There may be some other constraint +> involved. +> +>> sysctl -w kern.sysv.shmmax=4294967296 // byte +> +> Hmm, does sysctl work for values that exceed the range of int? +> +> There's no particularly good reason to try to set shmmax as high as you +> are trying anyhow; you really don't need more than a couple hundred meg +> in Postgres shared memory. It's better to leave the kernel to manage +> the bulk of your RAM. +> +> regards, tom lane +> + + +From pgsql-performance-owner@postgresql.org Tue Apr 13 17:49:17 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D02F7D1DD17 + for ; + Tue, 13 Apr 2004 17:49:13 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 95521-03 + for ; + Tue, 13 Apr 2004 17:49:13 -0300 (ADT) +Received: from mail6.speakeasy.net (mail6.speakeasy.net [216.254.0.206]) + by svr1.postgresql.org (Postfix) with ESMTP id AFD06D1DA83 + for ; + Tue, 13 Apr 2004 17:49:10 -0300 (ADT) +Received: (qmail 24287 invoked from network); 13 Apr 2004 20:49:12 -0000 +Received: from mail.kinesis-cem.com (HELO pdarley) ([64.81.9.230]) + (envelope-sender ) + by mail6.speakeasy.net (qmail-ldap-1.03) with SMTP + for ; 13 Apr 2004 20:49:12 -0000 +From: "Peter Darley" +To: "Pgsql-Performance" +Subject: View columns calculated +Date: Tue, 13 Apr 2004 13:49:53 -0700 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +Importance: Normal +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/158 +X-Sequence-Number: 6458 + +Folks, + I have a question about views: I want to have a fairly wide view (lots of +columns) where most of the columns have some heavyish calculations in them, +but I'm concerned that it will have to calculate every column even when I'm +not selecting them. So, the question is, if I have 5 columns in a view but +only select 1 column, is the system smart enough to not calculate the unused +columns, or am I taking a performance hit over a smaller view that doesn't +have the extra 4 columns? +Thanks, +Peter Darley + + +From pgsql-performance-owner@postgresql.org Tue Apr 13 17:59:31 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5C5B0D1E96B + for ; + Tue, 13 Apr 2004 17:59:28 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 99637-08 + for ; + Tue, 13 Apr 2004 17:59:27 -0300 (ADT) +Received: from hosting.commandprompt.com (128.commandprompt.com + [207.173.200.128]) + by svr1.postgresql.org (Postfix) with ESMTP id 62A72D1E98F + for ; + Tue, 13 Apr 2004 17:59:24 -0300 (ADT) +Received: from commandprompt.com (dsl093-038-087.pdx1.dsl.speakeasy.net + [66.93.38.87]) (authenticated) + by hosting.commandprompt.com (8.11.6/8.11.6) with ESMTP id i3DKxIP32349; + Tue, 13 Apr 2004 13:59:18 -0700 +Message-ID: <407C54A1.6090908@commandprompt.com> +Date: Tue, 13 Apr 2004 13:59:13 -0700 +From: "Joshua D. Drake" +Organization: Command Prompt, Inc. +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: Qing Zhao , + "'Postgresql Performance'" +Subject: Re: configure shmmax on MAC OS X +References: <000801c42165$68a67750$4f01a8c0@jeremydunn> + <24670.1081878949@sss.pgh.pa.us> + <53A6FF52-8D7B-11D8-92CF-000A95AB8896@quotefx.net> + <25965.1081886115@sss.pgh.pa.us> +In-Reply-To: <25965.1081886115@sss.pgh.pa.us> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/159 +X-Sequence-Number: 6459 + +Hello, + +I found that if you SHMALL value was less than your SHMMAX value, +the value wouldn't take. + +J + + +Tom Lane wrote: + +> Qing Zhao writes: +> +>>My suspision is that the change i made in /etc/rc does not take +>>effect.Is there a way to check it? +> +> +> sysctl has an option to show the values currently in effect. +> +> I believe that /etc/rc is the correct place to set shmmax on OSX 10.3 or +> later ... but we have seen prior reports of people having trouble +> getting the setting to "take". There may be some other constraint +> involved. +> +> +>>sysctl -w kern.sysv.shmmax=4294967296 // byte +> +> +> Hmm, does sysctl work for values that exceed the range of int? +> +> There's no particularly good reason to try to set shmmax as high as you +> are trying anyhow; you really don't need more than a couple hundred meg +> in Postgres shared memory. It's better to leave the kernel to manage +> the bulk of your RAM. +> +> regards, tom lane +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 4: Don't 'kill -9' the postmaster + +From pgsql-performance-owner@postgresql.org Tue Apr 13 18:23:41 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8D580D1DCF5 + for ; + Tue, 13 Apr 2004 18:23:38 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 08836-07 + for ; + Tue, 13 Apr 2004 18:23:38 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id B975CD1DB87 + for ; + Tue, 13 Apr 2004 18:23:35 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3DLNaUe026712; + Tue, 13 Apr 2004 17:23:36 -0400 (EDT) +To: "Peter Darley" +Cc: "Pgsql-Performance" +Subject: Re: View columns calculated +In-reply-to: +References: +Comments: In-reply-to "Peter Darley" + message dated "Tue, 13 Apr 2004 13:49:53 -0700" +Date: Tue, 13 Apr 2004 17:23:36 -0400 +Message-ID: <26711.1081891416@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/160 +X-Sequence-Number: 6460 + +"Peter Darley" writes: +> I have a question about views: I want to have a fairly wide view (lots of +> columns) where most of the columns have some heavyish calculations in them, +> but I'm concerned that it will have to calculate every column even when I'm +> not selecting them. So, the question is, if I have 5 columns in a view but +> only select 1 column, is the system smart enough to not calculate the unused +> columns, + +It depends on what the rest of your view looks like. If the view is +simple enough to be "flattened" into the parent query then the unused +columns will disappear into the ether. If it's not flattenable then +they will get evaluated. You can check by seeing whether an EXPLAIN +shows a separate "subquery scan" node corresponding to the view. +(Without bothering to look at the code, an unflattenable view is one +that uses GROUP BY, DISTINCT, aggregates, ORDER BY, LIMIT, UNION, +INTERSECT, EXCEPT, probably a couple other things.) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Apr 14 09:39:23 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C1601D1E106 + for ; + Wed, 14 Apr 2004 09:39:22 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 92244-10 + for ; + Wed, 14 Apr 2004 09:39:24 -0300 (ADT) +Received: from mwinf0103.wanadoo.fr (smtp1.wanadoo.fr [193.252.22.30]) + by svr1.postgresql.org (Postfix) with ESMTP id 8E456D1DC64 + for ; + Wed, 14 Apr 2004 09:39:20 -0300 (ADT) +Received: from [192.168.0.2] (AMontsouris-108-1-33-122.w81-48.abo.wanadoo.fr + [81.48.85.122]) + by mwinf0103.wanadoo.fr (SMTP Server) with ESMTP id 9A0DC1BF94E8 + for ; + Wed, 14 Apr 2004 14:39:23 +0200 (CEST) +Mime-Version: 1.0 (Apple Message framework v613) +Content-Transfer-Encoding: quoted-printable +Message-Id: +Content-Type: text/plain; charset=ISO-8859-1; delsp=yes; format=flowed +To: pgsql-performance@postgresql.org +From: =?ISO-8859-1?Q?Pailloncy_Jean-G=E9rard?= +Subject: +Date: Wed, 14 Apr 2004 14:39:21 +0200 +X-Mailer: Apple Mail (2.613) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/161 +X-Sequence-Number: 6461 + +I run the following command three times to prevent cache/disk results. + +[...] +dps=3D> explain analyze SELECT rec_id FROM url WHERE crc32!=3D0 AND=20=20 +crc32=3D764518963 AND status IN (200,304,206) ORDER BY rec_id LIMIT 1; + QUERY PLAN +------------------------------------------------------------------------=20 +----------------------------------------------------- + Limit (cost=3D173.14..173.14 rows=3D1 width=3D4) (actual time=3D0.357..0= +.358=20=20 +rows=3D1 loops=3D1) + -> Sort (cost=3D173.14..173.22 rows=3D32 width=3D4) (actual=20=20 +time=3D0.354..0.354 rows=3D1 loops=3D1) + Sort Key: rec_id + -> Index Scan using url_crc on url (cost=3D0.00..172.34=20=20 +rows=3D32 width=3D4) (actual time=3D0.039..0.271 rows=3D50 loops=3D1) + Index Cond: (crc32 =3D 764518963) + Filter: ((crc32 <> 0) AND ((status =3D 200) OR (status =3D= +=20=20 +304) OR (status =3D 206))) + Total runtime: 0.410 ms +(7 rows) + +dps=3D> explain analyze SELECT rec_id FROM url WHERE crc32!=3D0 AND=20=20 +crc32=3D764518963 AND status IN (200,304,206) ORDER BY crc32,rec_id LIMIT= +=20=20 +1; + QUERY PLAN +------------------------------------------------------------------------=20 +----------------------------------------------------- + Limit (cost=3D173.14..173.14 rows=3D1 width=3D8) (actual time=3D0.378..0= +.378=20=20 +rows=3D1 loops=3D1) + -> Sort (cost=3D173.14..173.22 rows=3D32 width=3D8) (actual=20=20 +time=3D0.375..0.375 rows=3D1 loops=3D1) + Sort Key: crc32, rec_id + -> Index Scan using url_crc on url (cost=3D0.00..172.34=20=20 +rows=3D32 width=3D8) (actual time=3D0.038..0.278 rows=3D50 loops=3D1) + Index Cond: (crc32 =3D 764518963) + Filter: ((crc32 <> 0) AND ((status =3D 200) OR (status =3D= +=20=20 +304) OR (status =3D 206))) + Total runtime: 0.432 ms +(7 rows) +dps=3D> explain analyze SELECT rec_id FROM url WHERE crc32!=3D0 AND=20=20 +crc32=3D419903683 AND status IN (200,304,206) ORDER BY rec_id LIMIT 1; + QUERY PLAN +------------------------------------------------------------------------=20 +------------------------------------------------------ + Limit (cost=3D0.00..37.03 rows=3D1 width=3D4) (actual time=3D156.712..15= +6.713=20=20 +rows=3D1 loops=3D1) + -> Index Scan using url_pkey on url (cost=3D0.00..14996.82 rows=3D405= +=20=20 +width=3D4) (actual time=3D156.707..156.707 rows=3D1 loops=3D1) + Filter: ((crc32 <> 0) AND (crc32 =3D 419903683) AND ((status =3D= +=20=20 +200) OR (status =3D 304) OR (status =3D 206))) + Total runtime: 156.769 ms +(4 rows) + +dps=3D> explain analyze SELECT rec_id FROM url WHERE crc32!=3D0 AND=20=20 +crc32=3D419903683 AND status IN (200,304,206) ORDER BY crc32,rec_id LIMIT= +=20=20 +1; + QUERY PLAN +------------------------------------------------------------------------=20 +-------------------------------------------------------- + Limit (cost=3D1910.14..1910.14 rows=3D1 width=3D8) (actual=20=20 +time=3D4.558..4.559 rows=3D1 loops=3D1) + -> Sort (cost=3D1910.14..1911.15 rows=3D405 width=3D8) (actual=20=20 +time=3D4.555..4.555 rows=3D1 loops=3D1) + Sort Key: crc32, rec_id + -> Index Scan using url_crc on url (cost=3D0.00..1892.60=20=20 +rows=3D405 width=3D8) (actual time=3D0.042..2.935 rows=3D719 loops=3D1) + Index Cond: (crc32 =3D 419903683) + Filter: ((crc32 <> 0) AND ((status =3D 200) OR (status =3D= +=20=20 +304) OR (status =3D 206))) + Total runtime: 4.636 ms +(7 rows) + +The value 764518963 is not common, it appears 50 times in the table. +The value 419903683 is the third most common value of the table url. + +dps=3D> select u.crc32, count(*) from url u group by u.crc32 order by=20= +=20 +count(*) desc; + crc32 | count +-------------+------ + 0 | 82202 + -946427862 | 10545 + 419903683 | 719 + 945866756 | 670 +[...] + +How to setup pgsql to correctly select the good index for index scan ? + +I run Pgsql 7.4.x +The database runs under pg_autovacuum daemon. +And a VACUUM FULL VERBOSE ANALYZE was done 10 hours before. + +Cordialement, +Jean-G=E9rard Pailloncy + +From pgsql-performance-owner@postgresql.org Wed Apr 14 10:23:09 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D54ABD1B49B + for ; + Wed, 14 Apr 2004 10:23:07 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 05960-10 + for ; + Wed, 14 Apr 2004 10:23:09 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id E5E57D1E949 + for ; + Wed, 14 Apr 2004 10:23:05 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3EDMgSV004924; + Wed, 14 Apr 2004 09:22:42 -0400 (EDT) +To: =?ISO-8859-1?Q?Pailloncy_Jean-G=E9rard?= +Cc: pgsql-performance@postgresql.org +Subject: Re: +In-reply-to: +References: +Comments: In-reply-to =?ISO-8859-1?Q?Pailloncy_Jean-G=E9rard?= + + message dated "Wed, 14 Apr 2004 14:39:21 +0200" +Date: Wed, 14 Apr 2004 09:22:42 -0400 +Message-ID: <4923.1081948962@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/162 +X-Sequence-Number: 6462 + +=?ISO-8859-1?Q?Pailloncy_Jean-G=E9rard?= writes: +> I run the following command three times to prevent cache/disk results. + +Do you think that's actually representative of how your database will +behave under load? + +If the DB is small enough to be completely cached in RAM, and you +expect it to remain so, then it's sensible to optimize on the basis +of fully-cached test cases. Otherwise I think you are optimizing +the wrong thing. + +If you do want to plan on this basis, you want to set random_page_cost +to 1, make sure effective_cache_size is large, and perhaps increase +the cpu_xxx cost numbers. (What you're essentially doing here is +reducing the estimated cost of a page fetch relative to CPU effort.) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Apr 14 14:53:12 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 40B39D1E104 + for ; + Wed, 14 Apr 2004 14:53:09 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 31479-07 + for ; + Wed, 14 Apr 2004 14:53:07 -0300 (ADT) +Received: from trade-india.com (ns5.trade-india.com [66.234.10.13]) + by svr1.postgresql.org (Postfix) with SMTP id 2AA8DD1E17E + for ; + Wed, 14 Apr 2004 14:53:05 -0300 (ADT) +Received: (qmail 29057 invoked from network); 14 Apr 2004 14:23:59 -0000 +Received: from unknown (HELO trade-india.com) (203.145.130.142) + by ns5.trade-india.com with SMTP; 14 Apr 2004 14:23:59 -0000 +Message-ID: <407D7A89.60508@trade-india.com> +Date: Wed, 14 Apr 2004 23:23:13 +0530 +From: Rajesh Kumar Mallah +User-Agent: Mozilla Thunderbird 0.5 (X11/20040208) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Postgres Performance +Subject: select count(*) very slow on an already vacuumed table. +Content-Type: multipart/alternative; + boundary="------------070309060401080600010502" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/163 +X-Sequence-Number: 6463 + +This is a multi-part message in MIME format. +--------------070309060401080600010502 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit + + +Hi +I have .5 million rows in a table. My problem is select count(*) takes ages. +VACUUM FULL does not help. can anyone please tell me +how to i enhance the performance of the setup. + +Regds +mallah. + +postgresql.conf +---------------------- +max_fsm_pages = 55099264 # min max_fsm_relations*16, 6 +bytes each +max_fsm_relations = 5000 + + +tradein_clients=# explain analyze SELECT count(*) from eyp_rfi; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------- + Aggregate (cost=78311.37..78311.37 rows=1 width=0) (actual +time=42306.902..42306.903 rows=1 loops=1) + -> Seq Scan on eyp_rfi (cost=0.00..77046.49 rows=505949 width=0) +(actual time=0.032..41525.007 rows=505960 loops=1) + Total runtime: 42306.995 ms +(3 rows) + +tradein_clients=# SELECT count(*) from eyp_rfi; + count +-------- + 505960 +(1 row) + +tradein_clients=# VACUUM full verbose eyp_rfi; +INFO: vacuuming "public.eyp_rfi" +INFO: "eyp_rfi": found 0 removable, 505960 nonremovable row versions in +71987 pages +DETAIL: 0 dead row versions cannot be removed yet. +Nonremovable row versions range from 186 to 2036 bytes long. +There were 42587 unused item pointers. +Total free space (including removable row versions) is 21413836 bytes. +0 pages are or will become empty, including 0 at the end of the table. +38693 pages containing 19146684 free bytes are potential move destinations. +CPU 2.62s/0.40u sec elapsed 38.45 sec. +INFO: index "eyp_rfi_date" now contains 505960 row versions in 1197 pages +DETAIL: 0 index row versions were removed. +4 index pages have been deleted, 4 are currently reusable. +CPU 0.05s/0.29u sec elapsed 0.87 sec. +INFO: index "eyp_rfi_receiver_uid" now contains 505960 row versions in +1163 pages +DETAIL: 0 index row versions were removed. +1 index pages have been deleted, 1 are currently reusable. +CPU 0.03s/0.42u sec elapsed 1.33 sec. +INFO: index "eyp_rfi_inhouse" now contains 505960 row versions in 1208 +pages +DETAIL: 0 index row versions were removed. +0 index pages have been deleted, 0 are currently reusable. +CPU 0.04s/0.21u sec elapsed 1.20 sec. +INFO: index "eyp_rfi_rfi_id_key" now contains 505960 row versions in +1201 pages +DETAIL: 0 index row versions were removed. +0 index pages have been deleted, 0 are currently reusable. +CPU 0.03s/0.33u sec elapsed 0.81 sec. +INFO: index "eyp_rfi_list_id_idx" now contains 505960 row versions in +1133 pages +DETAIL: 0 index row versions were removed. +0 index pages have been deleted, 0 are currently reusable. +CPU 0.02s/0.43u sec elapsed 1.12 sec. +INFO: index "eyp_rfi_status" now contains 505960 row versions in 1448 pages +DETAIL: 0 index row versions were removed. +4 index pages have been deleted, 4 are currently reusable. +CPU 0.05s/0.22u sec elapsed 1.08 sec. +INFO: index "eyp_rfi_list_id" now contains 505960 row versions in 1133 +pages +DETAIL: 0 index row versions were removed. +0 index pages have been deleted, 0 are currently reusable. +CPU 0.02s/0.43u sec elapsed 1.00 sec. +INFO: index "eyp_rfi_receiver_email" now contains 505960 row versions +in 2801 pages +DETAIL: 0 index row versions were removed. +0 index pages have been deleted, 0 are currently reusable. +CPU 0.16s/0.52u sec elapsed 10.38 sec. +INFO: index "eyp_rfi_subj" now contains 80663 row versions in 463 pages +DETAIL: 0 index row versions were removed. +0 index pages have been deleted, 0 are currently reusable. +CPU 0.03s/0.14u sec elapsed 3.20 sec. +INFO: index "eyp_rfi_sender" now contains 505960 row versions in 3025 pages +DETAIL: 0 index row versions were removed. +6 index pages have been deleted, 6 are currently reusable. +CPU 0.10s/0.39u sec elapsed 4.99 sec. +INFO: index "eyp_sender_uid_idx" now contains 505960 row versions in +1216 pages +DETAIL: 0 index row versions were removed. +5 index pages have been deleted, 5 are currently reusable. +CPU 0.04s/0.36u sec elapsed 2.61 sec. +INFO: index "eyp_rfi_rec_uid_idx" now contains 505960 row versions in +1166 pages +DETAIL: 0 index row versions were removed. +1 index pages have been deleted, 1 are currently reusable. +CPU 0.05s/0.41u sec elapsed 2.04 sec. +INFO: index "eyp_rfi_index" now contains 505960 row versions in 2051 pages +DETAIL: 0 index row versions were removed. +7 index pages have been deleted, 7 are currently reusable. +CPU 0.10s/0.28u sec elapsed 8.16 sec. +INFO: "eyp_rfi": moved 0 row versions, truncated 71987 to 71987 pages +DETAIL: CPU 2.03s/2.09u sec elapsed 95.24 sec. +INFO: vacuuming "pg_toast.pg_toast_19609" +INFO: "pg_toast_19609": found 0 removable, 105342 nonremovable row +versions in 21038 pages +DETAIL: 0 dead row versions cannot be removed yet. +Nonremovable row versions range from 37 to 2034 bytes long. +There were 145 unused item pointers. +Total free space (including removable row versions) is 16551072 bytes. +0 pages are or will become empty, including 0 at the end of the table. +18789 pages containing 16512800 free bytes are potential move destinations. +CPU 0.70s/0.09u sec elapsed 41.64 sec. +INFO: index "pg_toast_19609_index" now contains 105342 row versions in +296 pages +DETAIL: 0 index row versions were removed. +0 index pages have been deleted, 0 are currently reusable. +CPU 0.00s/0.02u sec elapsed 0.63 sec. +INFO: "pg_toast_19609": moved 0 row versions, truncated 21038 to 21038 +pages +DETAIL: CPU 0.01s/0.01u sec elapsed 10.03 sec. +VACUUM +tradein_clients=# explain analyze SELECT count(*) from eyp_rfi; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------- + Aggregate (cost=78311.50..78311.50 rows=1 width=0) (actual +time=50631.488..50631.489 rows=1 loops=1) + -> Seq Scan on eyp_rfi (cost=0.00..77046.60 rows=505960 width=0) +(actual time=0.030..49906.198 rows=505964 loops=1) + Total runtime: 50631.658 ms +(3 rows) + + +--------------070309060401080600010502 +Content-Type: text/html; charset=us-ascii +Content-Transfer-Encoding: 7bit + + + + + + + + +
+
Hi
+I have .5 million rows in a table. My problem is select count(*) takes +ages.
+VACUUM FULL does not help. can anyone please tell me
+how to i enhance the performance of the setup.
+
+Regds
+mallah.
+
+postgresql.conf
+----------------------
+max_fsm_pages = 55099264                # min max_fsm_relations*16, +6 bytes each
+max_fsm_relations = 5000
+
+
+tradein_clients=# explain analyze SELECT count(*) from eyp_rfi;
+                                                       QUERY PLAN
+-------------------------------------------------------------------------------------------------------------------------
+ Aggregate  (cost=78311.37..78311.37 rows=1 width=0) (actual +time=42306.902..42306.903 rows=1 loops=1)
+   ->  Seq Scan on eyp_rfi  (cost=0.00..77046.49 rows=505949 +width=0) (actual time=0.032..41525.007 rows=505960 loops=1)
+ Total runtime: 42306.995 ms
+(3 rows)
+
+tradein_clients=# SELECT count(*) from eyp_rfi;
+ count
+--------
+ 505960
+(1 row)
+
+tradein_clients=# VACUUM full verbose eyp_rfi;
+INFO:  vacuuming "public.eyp_rfi"
+INFO:  "eyp_rfi": found 0 removable, 505960 nonremovable row versions +in 71987 pages
+DETAIL:  0 dead row versions cannot be removed yet.
+Nonremovable row versions range from 186 to 2036 bytes long.
+There were 42587 unused item pointers.
+Total free space (including removable row versions) is 21413836 bytes.
+0 pages are or will become empty, including 0 at the end of the table.
+38693 pages containing 19146684 free bytes are potential move +destinations.
+CPU 2.62s/0.40u sec elapsed 38.45 sec.
+INFO:  index "eyp_rfi_date" now contains 505960 row versions in 1197 +pages
+DETAIL:  0 index row versions were removed.
+4 index pages have been deleted, 4 are currently reusable.
+CPU 0.05s/0.29u sec elapsed 0.87 sec.
+INFO:  index "eyp_rfi_receiver_uid" now contains 505960 row versions in +1163 pages
+DETAIL:  0 index row versions were removed.
+1 index pages have been deleted, 1 are currently reusable.
+CPU 0.03s/0.42u sec elapsed 1.33 sec.
+INFO:  index "eyp_rfi_inhouse" now contains 505960 row versions in 1208 +pages
+DETAIL:  0 index row versions were removed.
+0 index pages have been deleted, 0 are currently reusable.
+CPU 0.04s/0.21u sec elapsed 1.20 sec.
+INFO:  index "eyp_rfi_rfi_id_key" now contains 505960 row versions in +1201 pages
+DETAIL:  0 index row versions were removed.
+0 index pages have been deleted, 0 are currently reusable.
+CPU 0.03s/0.33u sec elapsed 0.81 sec.
+INFO:  index "eyp_rfi_list_id_idx" now contains 505960 row versions in +1133 pages
+DETAIL:  0 index row versions were removed.
+0 index pages have been deleted, 0 are currently reusable.
+CPU 0.02s/0.43u sec elapsed 1.12 sec.
+INFO:  index "eyp_rfi_status" now contains 505960 row versions in 1448 +pages
+DETAIL:  0 index row versions were removed.
+4 index pages have been deleted, 4 are currently reusable.
+CPU 0.05s/0.22u sec elapsed 1.08 sec.
+INFO:  index "eyp_rfi_list_id" now contains 505960 row versions in 1133 +pages
+DETAIL:  0 index row versions were removed.
+0 index pages have been deleted, 0 are currently reusable.
+CPU 0.02s/0.43u sec elapsed 1.00 sec.
+INFO:  index "eyp_rfi_receiver_email" now contains 505960 row versions +in 2801 pages
+DETAIL:  0 index row versions were removed.
+0 index pages have been deleted, 0 are currently reusable.
+CPU 0.16s/0.52u sec elapsed 10.38 sec.
+INFO:  index "eyp_rfi_subj" now contains 80663 row versions in 463 pages
+DETAIL:  0 index row versions were removed.
+0 index pages have been deleted, 0 are currently reusable.
+CPU 0.03s/0.14u sec elapsed 3.20 sec.
+INFO:  index "eyp_rfi_sender" now contains 505960 row versions in 3025 +pages
+DETAIL:  0 index row versions were removed.
+6 index pages have been deleted, 6 are currently reusable.
+CPU 0.10s/0.39u sec elapsed 4.99 sec.
+INFO:  index "eyp_sender_uid_idx" now contains 505960 row versions in +1216 pages
+DETAIL:  0 index row versions were removed.
+5 index pages have been deleted, 5 are currently reusable.
+CPU 0.04s/0.36u sec elapsed 2.61 sec.
+INFO:  index "eyp_rfi_rec_uid_idx" now contains 505960 row versions in +1166 pages
+DETAIL:  0 index row versions were removed.
+1 index pages have been deleted, 1 are currently reusable.
+CPU 0.05s/0.41u sec elapsed 2.04 sec.
+INFO:  index "eyp_rfi_index" now contains 505960 row versions in 2051 +pages
+DETAIL:  0 index row versions were removed.
+7 index pages have been deleted, 7 are currently reusable.
+CPU 0.10s/0.28u sec elapsed 8.16 sec.
+INFO:  "eyp_rfi": moved 0 row versions, truncated 71987 to 71987 pages
+DETAIL:  CPU 2.03s/2.09u sec elapsed 95.24 sec.
+INFO:  vacuuming "pg_toast.pg_toast_19609"
+INFO:  "pg_toast_19609": found 0 removable, 105342 nonremovable row +versions in 21038 pages
+DETAIL:  0 dead row versions cannot be removed yet.
+Nonremovable row versions range from 37 to 2034 bytes long.
+There were 145 unused item pointers.
+Total free space (including removable row versions) is 16551072 bytes.
+0 pages are or will become empty, including 0 at the end of the table.
+18789 pages containing 16512800 free bytes are potential move +destinations.
+CPU 0.70s/0.09u sec elapsed 41.64 sec.
+INFO:  index "pg_toast_19609_index" now contains 105342 row versions in +296 pages
+DETAIL:  0 index row versions were removed.
+0 index pages have been deleted, 0 are currently reusable.
+CPU 0.00s/0.02u sec elapsed 0.63 sec.
+INFO:  "pg_toast_19609": moved 0 row versions, truncated 21038 to 21038 +pages
+DETAIL:  CPU 0.01s/0.01u sec elapsed 10.03 sec.
+VACUUM
+tradein_clients=# explain analyze SELECT count(*) from eyp_rfi;
+                                                       QUERY PLAN
+-------------------------------------------------------------------------------------------------------------------------
+ Aggregate  (cost=78311.50..78311.50 rows=1 width=0) (actual +time=50631.488..50631.489 rows=1 loops=1)
+   ->  Seq Scan on eyp_rfi  (cost=0.00..77046.60 rows=505960 +width=0) (actual time=0.030..49906.198 rows=505964 loops=1)
+ Total runtime: 50631.658 ms
+(3 rows)
+
+
+ + + +--------------070309060401080600010502-- + +From pgsql-performance-owner@postgresql.org Wed Apr 14 16:09:05 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 604A7D1D16D + for ; + Wed, 14 Apr 2004 16:09:03 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 59189-06 + for ; + Wed, 14 Apr 2004 16:09:02 -0300 (ADT) +Received: from anchor-post-33.mail.demon.net (anchor-post-33.mail.demon.net + [194.217.242.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 22E95D1D174 + for ; + Wed, 14 Apr 2004 16:09:00 -0300 (ADT) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-33.mail.demon.net with esmtp (Exim 3.35 #1) + id 1BDpkq-000PzM-0X; Wed, 14 Apr 2004 20:09:00 +0100 +Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id DA96E1675B; Wed, 14 Apr 2004 20:08:59 +0100 (BST) +From: Richard Huxton +To: Rajesh Kumar Mallah , + Postgres Performance +Subject: Re: select count(*) very slow on an already vacuumed table. +Date: Wed, 14 Apr 2004 20:08:58 +0100 +User-Agent: KMail/1.5 +References: <407D7A89.60508@trade-india.com> +In-Reply-To: <407D7A89.60508@trade-india.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200404142008.58533.dev@archonet.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/164 +X-Sequence-Number: 6464 + +On Wednesday 14 April 2004 18:53, Rajesh Kumar Mallah wrote: +> Hi +> I have .5 million rows in a table. My problem is select count(*) takes +> ages. VACUUM FULL does not help. can anyone please tell me +> how to i enhance the performance of the setup. + +> SELECT count(*) from eyp_rfi; + +If this is the actual query you're running, and you need a guaranteed accurate +result, then you only have one option: write a trigger function to update a +table_count table with every insert/delete to eyp_rfi. + +There is loads of info on this (and why it isn't as simple as you might think) +in the archives. First though: +1. Is this the actual query, or just a representation? +2. Do you need an accurate figure or just something "near enough"? + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Wed Apr 14 17:12:11 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D19FFD1D07E + for ; + Wed, 14 Apr 2004 17:12:06 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 86663-05 + for ; + Wed, 14 Apr 2004 17:12:06 -0300 (ADT) +Received: from cmailm3.svr.pol.co.uk (cmailm3.svr.pol.co.uk [195.92.193.19]) + by svr1.postgresql.org (Postfix) with ESMTP id 0ECBCD1CCB4 + for ; + Wed, 14 Apr 2004 17:12:04 -0300 (ADT) +Received: from modem-3224.llama.dialup.pol.co.uk ([217.135.188.152] + helo=stromboli) by cmailm3.svr.pol.co.uk with esmtp (Exim 4.14) + id 1BDqjs-0005CC-Qj; Wed, 14 Apr 2004 21:12:05 +0100 +From: "Simon Riggs" +To: "Josh Berkus" , + +Subject: Re: PostgreSQL and Linux 2.6 kernel. +Date: Wed, 14 Apr 2004 21:12:18 +0100 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) +In-reply-to: <200404050836.52115.josh@agliodbs.com> +X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 +Importance: Normal +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/165 +X-Sequence-Number: 6465 + +> Josh Berkus wrote: +> Unfortunately, these days only Tom and Neil seem to be +> seriously working on +> the query planner (beg pardon in advance if I've missed +> someone) so I think +> the real answer is that we need another person interested in +> this kind of +> optimization before it's going to get much better. +> + +Hmmmm. Interesting line of thought. + +Is the problem "a person interested" or is there another issue there? + +I was thinking the other day that maybe removing the ability to control +join order through explicitly manipulating the FROM clause might +actually be counter productive, in terms of longer term improvement of +the optimizer. + +Treating the optimizer as a black box is something I'm very used to from +other RDBMS. My question is, how can you explicitly re-write a query now +to "improve" it? If there's no way of manipulating queries without +actually re-writing the optimizer, we're now in a position where we +aren't able to diagnose when the optimizer isn't working effectively. + +For my mind, all the people on this list are potential "optimizer +developers" in the sense that we can all look at queries and see whether +there is a problem with particular join plans. Providing good cases of +poor optimization is just what's needed to assist those few that do +understand the internals to continue improving things. + +I guess what I'm saying is it's not how many people you've got working +on the optimizer, its how many accurate field reports of less-than +perfect optimization reach them. In that case, PostgreSQL is likely in a +better position than Microsoft, since the accessibility of the pg +discussion lists makes such cases much more likely to get aired. + +Any thoughts? + +Best Regards, Simon Riggs + + +From pgsql-performance-owner@postgresql.org Wed Apr 14 17:42:55 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 44401D1DB0A + for ; + Wed, 14 Apr 2004 17:42:54 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 96507-08 + for ; + Wed, 14 Apr 2004 17:42:54 -0300 (ADT) +Received: from trade-india.com (ns5.trade-india.com [66.234.10.13]) + by svr1.postgresql.org (Postfix) with SMTP id 56B4CD1D6CC + for ; + Wed, 14 Apr 2004 17:42:52 -0300 (ADT) +Received: (qmail 27899 invoked from network); 14 Apr 2004 17:13:50 -0000 +Received: from unknown (HELO trade-india.com) (203.145.130.142) + by ns5.trade-india.com with SMTP; 14 Apr 2004 17:13:50 -0000 +Message-ID: <407DA257.6010904@trade-india.com> +Date: Thu, 15 Apr 2004 02:13:03 +0530 +From: Rajesh Kumar Mallah +User-Agent: Mozilla Thunderbird 0.5 (X11/20040208) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Richard Huxton +Cc: Postgres Performance +Subject: Re: select count(*) very slow on an already vacuumed table. +References: <407D7A89.60508@trade-india.com> + <200404142008.58533.dev@archonet.com> +In-Reply-To: <200404142008.58533.dev@archonet.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/166 +X-Sequence-Number: 6466 + +Richard Huxton wrote: + +>On Wednesday 14 April 2004 18:53, Rajesh Kumar Mallah wrote: +> +> +>>Hi +>>I have .5 million rows in a table. My problem is select count(*) takes +>>ages. VACUUM FULL does not help. can anyone please tell me +>>how to i enhance the performance of the setup. +>> +>> +> +> +> +>>SELECT count(*) from eyp_rfi; +>> +>> +> +>If this is the actual query you're running, and you need a guaranteed accurate +>result, then you only have one option: write a trigger function to update a +>table_count table with every insert/delete to eyp_rfi. +> +> + +it is just an example. in general all the queries that involves eyp_rfi +become slow. reloading the table makes the query faster. + +mallah. + +>There is loads of info on this (and why it isn't as simple as you might think) +>in the archives. First though: +>1. Is this the actual query, or just a representation? +>2. Do you need an accurate figure or just something "near enough"? +> +> +> + + +From pgsql-performance-owner@postgresql.org Thu Apr 15 04:17:56 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E398FD1C9DA + for ; + Thu, 15 Apr 2004 04:17:53 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 90604-05 + for ; + Thu, 15 Apr 2004 04:17:51 -0300 (ADT) +Received: from mail.unisoftbg.com (unknown [194.12.229.207]) + by svr1.postgresql.org (Postfix) with ESMTP id A4F44D1BB49 + for ; + Thu, 15 Apr 2004 04:17:44 -0300 (ADT) +Received: (qmail 4808 invoked by uid 507); 15 Apr 2004 07:25:00 -0000 +Received: from unknown (HELO t1.unisoftbg.com) + (pginfo%t1.unisoftbg.com@194.12.229.193) + by 0 with SMTP; 15 Apr 2004 07:25:00 -0000 +Message-ID: <407E25A6.ADFE4815@t1.unisoftbg.com> +Date: Thu, 15 Apr 2004 08:03:18 +0200 +From: pginfo +X-Mailer: Mozilla 4.03 [en] (Win95; I) +MIME-Version: 1.0 +To: "pgsql-performance@postgresql.org" +Subject: linux distro for better pg performance +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=1.5 tagged_above=0.0 required=5.0 tests=BAYES_40, + RCVD_IN_DSBL, TO_ADDRESS_EQ_REAL +X-Spam-Level: * +X-Archive-Number: 200404/168 +X-Sequence-Number: 6468 + +Hi, + +I am using pg from 3 y. and generaly I do not have big problems with it. + +I am searching for best pg distro to run pg (7.4.1). +At the moment I am using RedHat AS 3.0, but I think it have some +performance problems (I am not sure). +My configuration: +P4 2.8 GHz +1 GB RAM +120 GB IDE 7200 disk. +Kernel version 2.4.21-4.EL (it is the installation vesrion for rh 3.0) . + +My problems: + +If I run some query with many reads, I see a massive disk transfer : +procs memory swap io +system cpu + r b swpd free buff cache si so bi bo in cs us sy +id wa + 0 0 0 261724 3252 670748 0 0 0 4 105 19 0 0 +100 0 + 0 0 0 261724 3252 670748 0 0 0 0 101 11 0 0 +100 0 + 0 0 0 261724 3260 670748 0 0 0 4 104 19 0 0 +100 0 + 0 1 0 259684 3268 674112 0 0 964 7 131 57 0 0 +95 4 + 1 0 0 119408 3288 808540 0 0 27960 0 572 630 13 14 +24 49 + 1 1 0 15896 3292 914436 0 0 7984 44744 531 275 11 18 +24 47 + 0 2 0 16292 3296 924996 0 0 4145 6413 384 176 2 +5 0 92 + 0 1 0 19928 3316 928844 0 0 11805 13335 497 388 5 +9 5 81 + 0 3 0 19124 3296 924452 0 0 3153 19164 287 295 5 11 +16 68 + 0 1 0 15956 3304 932984 0 0 536 6812 366 123 4 +6 3 87 + 0 2 0 24956 3300 921416 0 0 1931 22936 + +And if I run top, I see a big iowait % (some times 70-80) and very low +user % (10-15). + +I readet many docs about this problem, but do not find any solution. + +My question: + +If some one is using RH 3.0, pls post some result or suggestions for it +performance with pg . + +What is the best linux distro for pg? + +Can I get better performance by using 15K SCSI disk ? +Or it will be better to have more RAM (2 or 3 GB) ? + +regards, +ivan. + + +From pgsql-performance-owner@postgresql.org Thu Apr 15 04:08:49 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 446A7D1C9C8 + for ; + Thu, 15 Apr 2004 04:08:47 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 85522-05 + for ; + Thu, 15 Apr 2004 04:08:46 -0300 (ADT) +Received: from trade-india.com (unknown [61.16.154.82]) + by svr1.postgresql.org (Postfix) with SMTP id 6E6D2D1C9BE + for ; + Thu, 15 Apr 2004 04:08:41 -0300 (ADT) +Received: (qmail 11990 invoked from network); 15 Apr 2004 06:55:43 -0000 +Received: from valium.trade-india-local.com (HELO trade-india.com) + (192.168.0.72) + by system66.trade-india-local.com with SMTP; 15 Apr 2004 06:55:43 -0000 +Message-ID: <407E3563.6000408@trade-india.com> +Date: Thu, 15 Apr 2004 12:40:27 +0530 +From: Rajesh Kumar Mallah +Organization: Infocom Network Limited +User-Agent: Mozilla Thunderbird 0.5 (X11/20040208) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Richard Huxton +Cc: Postgres Performance +Subject: Re: select count(*) very slow on an already vacuumed table. +References: <407D7A89.60508@trade-india.com> + <200404142008.58533.dev@archonet.com> +In-Reply-To: <200404142008.58533.dev@archonet.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/167 +X-Sequence-Number: 6467 + + + +The problem is that i want to know if i need a Hardware upgrade +at the moment. + +Eg i have another table rfis which contains ~ .6 million records. + + +SELECT count(*) from rfis where sender_uid > 0; ++--------+ +| count | ++--------+ +| 564870 | ++--------+ +Time: 117560.635 ms + +Which is approximate 4804 records per second. Is it an acceptable +performance on the hardware below: + +RAM: 2 GB +DISKS: ultra160 , 10 K , 18 GB +Processor: 2* 2.0 Ghz Xeon + +What kind of upgrades shoud be put on the server for it to become +reasonable fast. + + +Regds +mallah. + + + + +Richard Huxton wrote: + +>On Wednesday 14 April 2004 18:53, Rajesh Kumar Mallah wrote: +> +> +>>Hi +>>I have .5 million rows in a table. My problem is select count(*) takes +>>ages. VACUUM FULL does not help. can anyone please tell me +>>how to i enhance the performance of the setup. +>> +>> +> +> +> +>>SELECT count(*) from eyp_rfi; +>> +>> +> +>If this is the actual query you're running, and you need a guaranteed accurate +>result, then you only have one option: write a trigger function to update a +>table_count table with every insert/delete to eyp_rfi. +> +>There is loads of info on this (and why it isn't as simple as you might think) +>in the archives. First though: +>1. Is this the actual query, or just a representation? +>2. Do you need an accurate figure or just something "near enough"? +> +> +> + + +From pgsql-performance-owner@postgresql.org Thu Apr 15 04:32:57 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 88F58D1D06D + for ; + Thu, 15 Apr 2004 04:32:55 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 95713-04 + for ; + Thu, 15 Apr 2004 04:32:55 -0300 (ADT) +Received: from trade-india.com (unknown [61.16.154.82]) + by svr1.postgresql.org (Postfix) with SMTP id C0D56D1CCDA + for ; + Thu, 15 Apr 2004 04:32:51 -0300 (ADT) +Received: (qmail 13040 invoked from network); 15 Apr 2004 07:19:56 -0000 +Received: from valium.trade-india-local.com (HELO trade-india.com) + (192.168.0.72) + by system66.trade-india-local.com with SMTP; 15 Apr 2004 07:19:56 -0000 +Message-ID: <407E3B10.5060107@trade-india.com> +Date: Thu, 15 Apr 2004 13:04:40 +0530 +From: Rajesh Kumar Mallah +Organization: Infocom Network Limited +User-Agent: Mozilla Thunderbird 0.5 (X11/20040208) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Richard Huxton +Cc: Postgres Performance +Subject: Re: select count(*) very slow on an already vacuumed table. +References: <407D7A89.60508@trade-india.com> + <200404142008.58533.dev@archonet.com> + <407E3563.6000408@trade-india.com> +In-Reply-To: <407E3563.6000408@trade-india.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/169 +X-Sequence-Number: 6469 + + +The relation size for this table is 1.7 GB + +tradein_clients=# SELECT public.relation_size ('general.rfis'); ++------------------+ +| relation_size | ++------------------+ +| 1,762,639,872 | ++------------------+ +(1 row) + +Regds +mallah. + +Rajesh Kumar Mallah wrote: + +> +> +> The problem is that i want to know if i need a Hardware upgrade +> at the moment. +> +> Eg i have another table rfis which contains ~ .6 million records. +> +> +> SELECT count(*) from rfis where sender_uid > 0; +> +--------+ +> | count | +> +--------+ +> | 564870 | +> +--------+ +> Time: 117560.635 ms +> +> Which is approximate 4804 records per second. Is it an acceptable +> performance on the hardware below: +> +> RAM: 2 GB +> DISKS: ultra160 , 10 K , 18 GB +> Processor: 2* 2.0 Ghz Xeon +> +> What kind of upgrades shoud be put on the server for it to become +> reasonable fast. +> +> +> Regds +> mallah. +> +> +> +> +> Richard Huxton wrote: +> +>> On Wednesday 14 April 2004 18:53, Rajesh Kumar Mallah wrote: +>> +>> +>>> Hi +>>> I have .5 million rows in a table. My problem is select count(*) takes +>>> ages. VACUUM FULL does not help. can anyone please tell me +>>> how to i enhance the performance of the setup. +>>> +>> +>> +>> +>> +>>> SELECT count(*) from eyp_rfi; +>>> +>> +>> +>> If this is the actual query you're running, and you need a guaranteed +>> accurate result, then you only have one option: write a trigger +>> function to update a table_count table with every insert/delete to +>> eyp_rfi. +>> +>> There is loads of info on this (and why it isn't as simple as you +>> might think) in the archives. First though: +>> 1. Is this the actual query, or just a representation? +>> 2. Do you need an accurate figure or just something "near enough"? +>> +>> +>> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: you can get off all lists at once with the unregister command +> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) +> + + +From pgsql-performance-owner@postgresql.org Thu Apr 15 04:53:36 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D0925D1CCDA + for ; + Thu, 15 Apr 2004 04:53:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 04793-02 + for ; + Thu, 15 Apr 2004 04:53:35 -0300 (ADT) +Received: from anchor-post-30.mail.demon.net (anchor-post-30.mail.demon.net + [194.217.242.88]) + by svr1.postgresql.org (Postfix) with ESMTP id AB4E2D1CCB0 + for ; + Thu, 15 Apr 2004 04:53:33 -0300 (ADT) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-30.mail.demon.net with esmtp (Exim 3.35 #1) + id 1BE1gk-000Pgu-0U; Thu, 15 Apr 2004 08:53:34 +0100 +Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 221CB1624A; Thu, 15 Apr 2004 08:53:33 +0100 (BST) +From: Richard Huxton +To: Rajesh Kumar Mallah +Subject: Re: select count(*) very slow on an already vacuumed table. +Date: Thu, 15 Apr 2004 08:53:32 +0100 +User-Agent: KMail/1.5 +Cc: Postgres Performance +References: <407D7A89.60508@trade-india.com> + <200404142008.58533.dev@archonet.com> + <407E3563.6000408@trade-india.com> +In-Reply-To: <407E3563.6000408@trade-india.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200404150853.32475.dev@archonet.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/170 +X-Sequence-Number: 6470 + +On Thursday 15 April 2004 08:10, Rajesh Kumar Mallah wrote: +> The problem is that i want to know if i need a Hardware upgrade +> at the moment. +> +> Eg i have another table rfis which contains ~ .6 million records. + +> SELECT count(*) from rfis where sender_uid > 0; + +> Time: 117560.635 ms +> +> Which is approximate 4804 records per second. Is it an acceptable +> performance on the hardware below: +> +> RAM: 2 GB +> DISKS: ultra160 , 10 K , 18 GB +> Processor: 2* 2.0 Ghz Xeon + +Hmm - doesn't seem good, does it? If you run it again, is it much faster +(since the data should be cached then)? What does "vmstat 10" show while +you're running the query? + +One thing you should have done is read the performance tuning guide at: + http://www.varlena.com/varlena/GeneralBits/Tidbits/index.php +The default values are very conservative, and you will need to change them. + +> What kind of upgrades shoud be put on the server for it to become +> reasonable fast. + +If you've only got one disk, then a second disk for OS/logging. Difficult to +say more without knowing numbers of users/activity etc. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Thu Apr 15 07:29:44 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7B449D1D070 + for ; + Thu, 15 Apr 2004 07:29:43 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 58497-08 + for ; + Thu, 15 Apr 2004 07:29:44 -0300 (ADT) +Received: from trade-india.com (unknown [61.16.154.82]) + by svr1.postgresql.org (Postfix) with SMTP id 0CB4AD1C4C3 + for ; + Thu, 15 Apr 2004 07:29:39 -0300 (ADT) +Received: (qmail 21893 invoked from network); 15 Apr 2004 10:16:42 -0000 +Received: from valium.trade-india-local.com (HELO trade-india.com) + (192.168.0.72) + by system66.trade-india-local.com with SMTP; 15 Apr 2004 10:16:42 -0000 +Message-ID: <407E647E.7090207@trade-india.com> +Date: Thu, 15 Apr 2004 16:01:26 +0530 +From: Rajesh Kumar Mallah +Organization: Infocom Network Limited +User-Agent: Mozilla Thunderbird 0.5 (X11/20040208) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Richard Huxton +Cc: Postgres Performance +Subject: Re: select count(*) very slow on an already vacuumed table. +References: <407D7A89.60508@trade-india.com> + <200404142008.58533.dev@archonet.com> + <407E3563.6000408@trade-india.com> + <200404150853.32475.dev@archonet.com> +In-Reply-To: <200404150853.32475.dev@archonet.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/171 +X-Sequence-Number: 6471 + +Richard Huxton wrote: + +>On Thursday 15 April 2004 08:10, Rajesh Kumar Mallah wrote: +> +> +>>The problem is that i want to know if i need a Hardware upgrade +>>at the moment. +>> +>>Eg i have another table rfis which contains ~ .6 million records. +>> +>> +> +> +> +>>SELECT count(*) from rfis where sender_uid > 0; +>> +>> +> +> +> +>>Time: 117560.635 ms +>> +>>Which is approximate 4804 records per second. Is it an acceptable +>>performance on the hardware below: +>> +>>RAM: 2 GB +>>DISKS: ultra160 , 10 K , 18 GB +>>Processor: 2* 2.0 Ghz Xeon +>> +>> +> +>Hmm - doesn't seem good, does it? If you run it again, is it much faster +>(since the data should be cached then)? What does "vmstat 10" show while +>you're running the query? +> +>One thing you should have done is read the performance tuning guide at: +> http://www.varlena.com/varlena/GeneralBits/Tidbits/index.php +>The default values are very conservative, and you will need to change them. +> +> +Hi, + +Thanks for the interest . my config are not the default ones. +i was running iostat while running the query. Looks like one +of the disks doesnt' go past a read performance of 20 ,000 KBytes/sec + +while the other disk it goes as high as 40,000 . What i am ding +currently is +loading the table in both the disks and compare the table scan speeds. + +The performance is definitely better in the newly loaded table in the other +disk . the load in server is 13 because i am simultaneously re-loading +the data +in other table. + + +rt2=# SELECT count(*) from rfis where sender_uid > 0; ++--------+ +| count | ++--------+ +| 564870 | ++--------+ +(1 row) + +Time: 10288.359 ms + +rt2=# + +shall post the comparitive details under normal load soon + + +regds +mallah. + + + + + + + +> +> +>>What kind of upgrades shoud be put on the server for it to become +>>reasonable fast. +>> +>> +> +>If you've only got one disk, then a second disk for OS/logging. Difficult to +>say more without knowing numbers of users/activity etc. +> +> +> + + +From pgsql-performance-owner@postgresql.org Thu Apr 15 09:13:36 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7BDD7D1D06F + for ; + Thu, 15 Apr 2004 09:13:34 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 01833-02 + for ; + Thu, 15 Apr 2004 09:13:35 -0300 (ADT) +Received: from mail.unisoftbg.com (unknown [194.12.229.207]) + by svr1.postgresql.org (Postfix) with ESMTP id 05806D1B515 + for ; + Thu, 15 Apr 2004 09:13:27 -0300 (ADT) +Received: (qmail 15175 invoked by uid 507); 15 Apr 2004 12:20:47 -0000 +Received: from unknown (HELO t1.unisoftbg.com) + (pginfo%t1.unisoftbg.com@194.12.229.193) + by 0 with SMTP; 15 Apr 2004 12:20:47 -0000 +Message-ID: <407E6AF8.7643C61F@t1.unisoftbg.com> +Date: Thu, 15 Apr 2004 12:59:04 +0200 +From: pginfo +X-Mailer: Mozilla 4.03 [en] (Win95; I) +MIME-Version: 1.0 +To: Rajesh Kumar Mallah +Cc: Richard Huxton , + Postgres Performance +Subject: Re: [ SOLVED ] select count(*) very slow on an already +References: <407D7A89.60508@trade-india.com> + <200404142008.58533.dev@archonet.com> + <407E3563.6000408@trade-india.com> + <200404150853.32475.dev@archonet.com> + <407E7391.4060706@trade-india.com> +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/174 +X-Sequence-Number: 6474 + +Hi , +I am not sure, but I remember the same problem. +It was ot 7.3.x version and and I needet to reindex the table. + +I think after 7.4 vacuum also work correct with reindex. + +But I am not sure. + +regards, +ivan. + +Rajesh Kumar Mallah wrote: + +> Hi, +> +> The problem was solved by reloading the Table. +> the query now takes only 3 seconds. But that is +> not a solution. +> +> The problem is that such phenomenon obscures our +> judgement used in optimising queries and database. +> +> If a query runs slow we really cant tell if its a problem +> with query itself , hardware or dead rows. +> +> I already did vacumm full on the table but it still did not +> have that effect on performance. +> In fact the last figures were after doing a vacuum full. +> +> Can there be any more elegent solution to this problem. +> +> Regds +> Mallah. +> +> Richard Huxton wrote: +> +> >On Thursday 15 April 2004 08:10, Rajesh Kumar Mallah wrote: +> > +> > +> >>The problem is that i want to know if i need a Hardware upgrade +> >>at the moment. +> >> +> >>Eg i have another table rfis which contains ~ .6 million records. +> >> +> >> +> > +> > +> > +> >>SELECT count(*) from rfis where sender_uid > 0; +> >> +> >> +> > +> > +> > +> >>Time: 117560.635 ms +> >> +> >>Which is approximate 4804 records per second. Is it an acceptable +> >>performance on the hardware below: +> >> +> >>RAM: 2 GB +> >>DISKS: ultra160 , 10 K , 18 GB +> >>Processor: 2* 2.0 Ghz Xeon +> >> +> >> +> > +> >Hmm - doesn't seem good, does it? If you run it again, is it much faster +> >(since the data should be cached then)? What does "vmstat 10" show while +> >you're running the query? +> > +> >One thing you should have done is read the performance tuning guide at: +> > http://www.varlena.com/varlena/GeneralBits/Tidbits/index.php +> >The default values are very conservative, and you will need to change them. +> > +> > +> > +> >>What kind of upgrades shoud be put on the server for it to become +> >>reasonable fast. +> >> +> >> +> > +> >If you've only got one disk, then a second disk for OS/logging. Difficult to +> >say more without knowing numbers of users/activity etc. +> > +> > +> > +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org + + + + +From pgsql-performance-owner@postgresql.org Thu Apr 15 08:34:04 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id BEC07D1D391 + for ; + Thu, 15 Apr 2004 08:34:02 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 80829-09 + for ; + Thu, 15 Apr 2004 08:34:03 -0300 (ADT) +Received: from trade-india.com (unknown [61.16.154.82]) + by svr1.postgresql.org (Postfix) with SMTP id DA233D1D085 + for ; + Thu, 15 Apr 2004 08:33:57 -0300 (ADT) +Received: (qmail 24925 invoked from network); 15 Apr 2004 11:21:00 -0000 +Received: from valium.trade-india-local.com (HELO trade-india.com) + (192.168.0.72) + by system66.trade-india-local.com with SMTP; 15 Apr 2004 11:21:00 -0000 +Message-ID: <407E7391.4060706@trade-india.com> +Date: Thu, 15 Apr 2004 17:05:45 +0530 +From: Rajesh Kumar Mallah +Organization: Infocom Network Limited +User-Agent: Mozilla Thunderbird 0.5 (X11/20040208) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Richard Huxton +Cc: Postgres Performance +Subject: Re: [ SOLVED ] select count(*) very slow on an already +References: <407D7A89.60508@trade-india.com> + <200404142008.58533.dev@archonet.com> + <407E3563.6000408@trade-india.com> + <200404150853.32475.dev@archonet.com> +In-Reply-To: <200404150853.32475.dev@archonet.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/172 +X-Sequence-Number: 6472 + + +Hi, + +The problem was solved by reloading the Table. +the query now takes only 3 seconds. But that is +not a solution. + +The problem is that such phenomenon obscures our +judgement used in optimising queries and database. + + +If a query runs slow we really cant tell if its a problem +with query itself , hardware or dead rows. + + +I already did vacumm full on the table but it still did not +have that effect on performance. +In fact the last figures were after doing a vacuum full. + +Can there be any more elegent solution to this problem. + +Regds +Mallah. + + + + + +Richard Huxton wrote: + +>On Thursday 15 April 2004 08:10, Rajesh Kumar Mallah wrote: +> +> +>>The problem is that i want to know if i need a Hardware upgrade +>>at the moment. +>> +>>Eg i have another table rfis which contains ~ .6 million records. +>> +>> +> +> +> +>>SELECT count(*) from rfis where sender_uid > 0; +>> +>> +> +> +> +>>Time: 117560.635 ms +>> +>>Which is approximate 4804 records per second. Is it an acceptable +>>performance on the hardware below: +>> +>>RAM: 2 GB +>>DISKS: ultra160 , 10 K , 18 GB +>>Processor: 2* 2.0 Ghz Xeon +>> +>> +> +>Hmm - doesn't seem good, does it? If you run it again, is it much faster +>(since the data should be cached then)? What does "vmstat 10" show while +>you're running the query? +> +>One thing you should have done is read the performance tuning guide at: +> http://www.varlena.com/varlena/GeneralBits/Tidbits/index.php +>The default values are very conservative, and you will need to change them. +> +> +> +>>What kind of upgrades shoud be put on the server for it to become +>>reasonable fast. +>> +>> +> +>If you've only got one disk, then a second disk for OS/logging. Difficult to +>say more without knowing numbers of users/activity etc. +> +> +> + + +From pgsql-performance-owner@postgresql.org Thu Apr 15 09:10:09 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6C396D1D06D + for ; + Thu, 15 Apr 2004 09:10:08 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 01268-02 + for ; + Thu, 15 Apr 2004 09:10:04 -0300 (ADT) +Received: from mail2.aeccom.com (port-212-202-101-158.reverse.qsc.de + [212.202.101.158]) + by svr1.postgresql.org (Postfix) with ESMTP id A3ACAD1D065 + for ; + Thu, 15 Apr 2004 09:09:59 -0300 (ADT) +Received: from aeccom.com (cayambe.core.aeccom.com [192.168.2.12]) + by mail2.aeccom.com (Postfix) with ESMTP id 5BB4734 + for ; + Thu, 15 Apr 2004 14:10:01 +0200 (CEST) +Message-ID: <407E7B99.3050306@aeccom.com> +Date: Thu, 15 Apr 2004 14:10:01 +0200 +From: =?ISO-8859-1?Q?Dirk_Lutzeb=E4ck?= +Organization: AEC/communications GmbH, Berlin +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031016 +X-Accept-Language: de, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Toooo many context switches (maybe SLES8?) +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/173 +X-Sequence-Number: 6473 + +Hi, + +we have a complex modperl database application using postgresql 7.4.1 on +a new Dual Xeon MP Machine with SLES8 which seems to generate too much +context switches (way more than 100.000) on higher load (meaning system +load > 2). System response times significantly slow down then. We have +tuned parameters for weeks now but could not come up with better +results. It seems that we have had better performance on an older Dual +XEON DP Machine running on RedHat 7.3. + +Here is the config: + +database machine on SuSE SLES 8: + + F-S Primergy RX600 + 2x XEON MP 2.5GHz + 8GB RAM + Hardware Raid 1+0 140GB + Kernel 2.4.21-169-smp + + Postgresql 7.4.1 (self compiled) with + max_connections = 170 + shared_buffers = 40000 + effective_cache_size = 800000 + sort_mem = 30000 + vacuum_mem = 420000 + max_fsm_relations = 2000 + max_fsm_pages = 200000 + random_page_cost = 4 + checkpoint_segments = 24 + wal_buffers = 32 + +modperl application machine on RH 7.3: + + F-S Primergy RX200 + 2x XEON DP 2.4 GHz + 4 GB RAM + Kernel 2.4.18-10smp, RedHat 7.3 + Apache 1.3.27 setup: + MinSpareServers 15 + MaxSpareServers 30 + StartServers 15 + MaxClients 80 + MaxRequestsPerChild 100 + +vmstat 1 excerpt: + +procs -----------memory---------- ---swap-- -----io---- --system-- +----cpu---- + r b swpd free buff cache si so bi bo in cs us sy +id wa + 1 0 4868 242372 179488 6942316 0 0 12 8 18 9 6 +2 92 0 + 2 1 4868 242204 179488 6942500 0 0 64 500 701 117921 35 +18 48 0 + 0 1 4868 242032 179392 6941560 0 0 16 316 412 132295 28 +25 47 0 + 1 0 4872 242396 179164 6933776 0 0 128 276 474 69708 21 +24 56 0 + 3 0 4872 242536 179164 6933808 0 0 0 240 412 113643 27 +27 46 0 + 2 0 4872 242872 179092 6931708 0 0 48 1132 521 127916 24 +24 53 0 + 0 0 4876 242876 179092 6927512 0 0 48 532 504 117868 32 +21 47 0 + 0 0 4876 242504 179096 6927560 0 0 0 188 412 127147 34 +20 47 0 + 1 0 4876 242152 179096 6927856 0 0 96 276 529 117684 28 +23 49 0 + 2 0 4876 242864 179096 6928384 0 0 88 560 507 135717 38 +19 43 0 + 1 0 4876 242848 179096 6928520 0 0 64 232 433 151380 32 +20 48 0 + 4 0 4876 242832 179144 6928916 0 0 16 10380 2913 112583 28 +20 52 0 + 4 0 4876 242720 179144 6929240 0 0 196 0 329 154821 32 +18 50 0 + 3 2 4876 243576 179144 6929408 0 0 0 460 451 160287 29 +18 52 0 + 3 0 4876 243292 179180 6929468 0 0 16 436 614 51894 15 +5 80 0 + 0 0 4876 243884 179180 6929580 0 0 0 236 619 154168 29 +21 49 0 + 2 1 4876 243864 179180 6929860 0 0 128 380 493 155903 31 +19 50 0 + 2 0 4876 244720 179180 6930276 0 0 16 1208 561 129336 27 +16 56 0 + 2 0 4876 247204 179180 6930300 0 0 0 0 361 146268 33 +20 47 0 + 3 0 4876 248620 179180 6930372 0 0 0 168 346 155915 32 +12 56 0 + 2 0 4876 250476 179180 6930436 0 0 0 184 328 163842 35 +20 46 0 + 0 0 4876 250496 179180 6930652 0 0 48 260 450 144930 31 +15 53 0 + 1 0 4876 252236 179180 6930732 0 0 16 244 577 167259 35 +15 50 0 + 0 0 4876 252236 179180 6930780 0 0 0 464 622 165488 31 +15 54 0 + 1 0 4876 252268 179180 6930812 0 0 0 132 460 153381 34 +15 52 0 + 2 0 4876 252268 179180 6930964 0 0 0 216 312 141009 31 +19 50 0 + 1 0 4876 252264 179180 6930980 0 0 0 56 275 153143 33 +20 47 0 + 2 0 4876 252212 179180 6931212 0 0 96 296 400 133982 32 +18 50 0 + 1 0 4876 252264 179180 6931332 0 0 0 300 416 136034 32 +18 50 0 + 1 1 4876 252264 179180 6931332 0 0 0 236 377 143300 34 +22 44 0 + 4 0 4876 254876 179180 6931372 0 0 0 124 446 118117 34 +20 45 0 + 1 0 4876 254876 179180 6931492 0 0 16 144 462 140499 38 +16 46 0 + 2 0 4876 255860 179180 6931572 0 0 16 144 674 126250 33 +20 47 0 + 1 0 4876 255860 179180 6931788 0 0 48 264 964 115679 36 +13 51 0 + 3 0 4876 255864 179180 6931804 0 0 0 100 597 127619 36 +19 46 0 + 5 1 4876 255864 179180 6931924 0 0 72 352 559 151620 34 +18 48 0 + 2 0 4876 255860 179184 6932100 0 0 96 120 339 137821 34 +20 47 0 + 0 0 4876 255860 179184 6932156 0 0 8 168 469 125281 36 +21 43 0 + 2 0 4876 256092 179184 6932444 0 0 112 328 446 137939 34 +19 48 0 + 2 0 4876 256092 179184 6932484 0 0 16 184 382 141800 35 +16 49 0 + 3 0 4876 256464 179184 6932716 0 0 16 356 448 134238 30 +18 51 0 + 5 0 4876 256464 179184 6932892 0 0 96 600 476 142838 34 +20 46 0 + 1 0 4876 256464 179184 6933012 0 0 16 176 589 138546 35 +22 43 0 + 2 0 4876 256436 179184 6933096 0 0 60 76 396 93110 42 +17 41 0 + 1 0 4876 256464 179184 6933484 0 0 212 276 442 83060 45 +11 44 0 + 5 0 4876 257612 179184 6933604 0 0 0 472 548 94158 39 +17 45 0 + 0 0 4876 257560 179184 6933708 0 0 96 96 518 116764 38 +19 43 0 + 1 0 4876 257612 179184 6933796 0 0 0 1768 729 139013 29 +19 53 0 + 4 0 4876 257612 179184 6934188 0 0 296 108 332 134703 31 +21 48 0 + 0 1 4876 258584 179184 6934380 0 0 0 492 405 141198 34 +18 48 0 + 1 0 4876 258584 179184 6934492 0 0 0 176 575 134771 37 +16 48 0 + 4 1 4876 257796 179184 6935724 0 0 1176 176 438 151240 33 +20 48 0 + 1 0 4876 261448 179184 6935836 0 0 0 252 489 134348 29 +19 51 0 + 2 0 4876 261448 179184 6935852 0 0 0 512 639 130875 34 +16 49 0 + 2 1 4876 261724 179184 6935924 0 0 0 80 238 144970 33 +20 47 0 + + + + + +From pgsql-performance-owner@postgresql.org Thu Apr 15 10:36:58 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 213A9D1D083 + for ; + Thu, 15 Apr 2004 10:36:58 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 33854-06 + for ; + Thu, 15 Apr 2004 10:36:59 -0300 (ADT) +Received: from internet.potentialtech.com (h-66-167-251-6.phlapafg.covad.net + [66.167.251.6]) + by svr1.postgresql.org (Postfix) with ESMTP id 5E8FBD1C9C4 + for ; + Thu, 15 Apr 2004 10:36:54 -0300 (ADT) +Received: from potentialtech.com (pa-plum1c-102.pit.adelphia.net + [24.53.179.102]) by internet.potentialtech.com (Postfix) with ESMTP + id 345E869A71; Thu, 15 Apr 2004 09:36:57 -0400 (EDT) +Message-ID: <407E8FF6.4050601@potentialtech.com> +Date: Thu, 15 Apr 2004 09:36:54 -0400 +From: Bill Moran +User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.4) Gecko/20031005 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Rajesh Kumar Mallah +Cc: Richard Huxton , + Postgres Performance +Subject: Re: [ SOLVED ] select count(*) very slow on an already +References: <407D7A89.60508@trade-india.com> + <200404142008.58533.dev@archonet.com> + <407E3563.6000408@trade-india.com> + <200404150853.32475.dev@archonet.com> + <407E7391.4060706@trade-india.com> +In-Reply-To: <407E7391.4060706@trade-india.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/175 +X-Sequence-Number: 6475 + +Rajesh Kumar Mallah wrote: +> +> Hi, +> +> The problem was solved by reloading the Table. +> the query now takes only 3 seconds. But that is +> not a solution. + +If dropping/recreating the table improves things, then we can reasonably +assume that the table is pretty active with updates/inserts. Correct? + +> The problem is that such phenomenon obscures our +> judgement used in optimising queries and database. + +Lots of phenomenon obscure that ... + +> If a query runs slow we really cant tell if its a problem +> with query itself , hardware or dead rows. +> +> I already did vacumm full on the table but it still did not +> have that effect on performance. +> In fact the last figures were after doing a vacuum full. + +If the data gets too fragmented, a vacuum may not be enough. Also, read +up on the recommendations _against_ vacuum full (recommending only using +vacuum on databases) With full, vacuum condenses the database, which may +actually hurt performance. A regular vacuum just fixes things up, and +may leave unused space lying around. However, this should apparently +achieve a balance between usage and vacuum. See the docs, they are much +better at describing this than I am. + +> Can there be any more elegent solution to this problem. + +As a guess, look into CLUSTER (a Postgres SQL command). CLUSTER will +basically recreate the table while ordering rows based on an index. +(this might benefit you in other ways as well) Don't forget to analyze +after cluster. If the problem is caused by frequent updates/inserts, +you may find that re-clustering the table on a certain schedule is +worthwhile. + +Be warned, this suggestion is based on an educated guess, I make no +guarantees that it will help your problem. Read the docs on cluster +and come to your own conclusions. + +> +> Regds +> Mallah. +> +> +> +> +> +> Richard Huxton wrote: +> +>> On Thursday 15 April 2004 08:10, Rajesh Kumar Mallah wrote: +>> +>> +>>> The problem is that i want to know if i need a Hardware upgrade +>>> at the moment. +>>> +>>> Eg i have another table rfis which contains ~ .6 million records. +>>> +>> +>> +>> +>> +>>> SELECT count(*) from rfis where sender_uid > 0; +>>> +>> +>> +>> +>> +>>> Time: 117560.635 ms +>>> +>>> Which is approximate 4804 records per second. Is it an acceptable +>>> performance on the hardware below: +>>> +>>> RAM: 2 GB +>>> DISKS: ultra160 , 10 K , 18 GB +>>> Processor: 2* 2.0 Ghz Xeon +>>> +>> +>> Hmm - doesn't seem good, does it? If you run it again, is it much +>> faster (since the data should be cached then)? What does "vmstat 10" +>> show while you're running the query? +>> +>> One thing you should have done is read the performance tuning guide at: +>> http://www.varlena.com/varlena/GeneralBits/Tidbits/index.php +>> The default values are very conservative, and you will need to change +>> them. +>> +>>> What kind of upgrades shoud be put on the server for it to become +>>> reasonable fast. +>>> +>> If you've only got one disk, then a second disk for OS/logging. +>> Difficult to say more without knowing numbers of users/activity etc. + + + +-- +Bill Moran +Potential Technologies +http://www.potentialtech.com + + +From pgsql-performance-owner@postgresql.org Thu Apr 15 10:40:10 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 528ACD1D08B + for ; + Thu, 15 Apr 2004 10:40:09 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 34210-04 + for ; + Thu, 15 Apr 2004 10:40:10 -0300 (ADT) +Received: from tetra.ehpg.net (tetra.ehpg.net [216.218.206.34]) + by svr1.postgresql.org (Postfix) with ESMTP id 1AE91D1D085 + for ; + Thu, 15 Apr 2004 10:40:06 -0300 (ADT) +Received: from adsl-68-120-225-71.dsl.irvnca.pacbell.net (ehpg.net) + [68.120.225.71]by tetra.ehpg.netwith asmtp(Exim 4.21 #1 (Gentoo + Linux 1.4))id 1BE76l-0007lt-96; Thu, 15 Apr 2004 06:40:47 -0700 +Message-ID: <407E909F.9000101@ehpg.net> +Date: Thu, 15 Apr 2004 06:39:43 -0700 +From: "Gavin M. Roy" +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pginfo +Cc: "pgsql-performance@postgresql.org" +Subject: Re: linux distro for better pg performance +References: <407E25A6.ADFE4815@t1.unisoftbg.com> +In-Reply-To: <407E25A6.ADFE4815@t1.unisoftbg.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Antivirus-Scanned: Clean +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/176 +X-Sequence-Number: 6476 + + +>I am searching for best pg distro to run pg (7.4.1). +> +> +This is generally based upon opinion. Honestly though, your kernel +version is more important for performance than the distro. Personally I +use gentoo, love gentoo, and would recommend very few other distros +(Slackware) for servers. RedHat and others seem to include +kitchensinkd, when it's not needed. + +>At the moment I am using RedHat AS 3.0, but I think it have some +>performance problems (I am not sure). +>My configuration: +>P4 2.8 GHz +>1 GB RAM +>120 GB IDE 7200 disk. +> +> +Your IDE drive is the biggest hardward bottleneck here. RPM's and bus +transfers are slower than SCSI or SATA. + +>Kernel version 2.4.21-4.EL (it is the installation vesrion for rh 3.0) . +> +> +Jump to 2.6, it's much better for performance related issues, in my +experience. + +>My problems: +> +>If I run some query with many reads, I see a massive disk transfer : +>procs memory swap io +>system cpu +> r b swpd free buff cache si so bi bo in cs us sy +>id wa +> 0 0 0 261724 3252 670748 0 0 0 4 105 19 0 0 +>100 0 +> 0 0 0 261724 3252 670748 0 0 0 0 101 11 0 0 +>100 0 +> 0 0 0 261724 3260 670748 0 0 0 4 104 19 0 0 +>100 0 +> 0 1 0 259684 3268 674112 0 0 964 7 131 57 0 0 +>95 4 +> 1 0 0 119408 3288 808540 0 0 27960 0 572 630 13 14 +>24 49 +> 1 1 0 15896 3292 914436 0 0 7984 44744 531 275 11 18 +>24 47 +> 0 2 0 16292 3296 924996 0 0 4145 6413 384 176 2 +>5 0 92 +> 0 1 0 19928 3316 928844 0 0 11805 13335 497 388 5 +>9 5 81 +> 0 3 0 19124 3296 924452 0 0 3153 19164 287 295 5 11 +>16 68 +> 0 1 0 15956 3304 932984 0 0 536 6812 366 123 4 +>6 3 87 +> 0 2 0 24956 3300 921416 0 0 1931 22936 +> +>And if I run top, I see a big iowait % (some times 70-80) and very low +>user % (10-15). +> +> +again, this is your harddrive, and the kernel can play into that. + +>I readet many docs about this problem, but do not find any solution. +> +>My question: +> +>If some one is using RH 3.0, pls post some result or suggestions for it +>performance with pg . +> +>What is the best linux distro for pg? +> +> +There's no best, just personal preference. + +>Can I get better performance by using 15K SCSI disk ? +> +> +Absolutely + +>Or it will be better to have more RAM (2 or 3 GB) ? +> +> +Better to have a fast drive, but more ram can be helpful. + +>regards, +>ivan. +> +> +> +HTH, + +Gavin + +From pgsql-performance-owner@postgresql.org Thu Apr 15 13:05:24 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 92D27D1D8AE + for ; + Thu, 15 Apr 2004 13:05:19 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 99399-03 + for ; + Thu, 15 Apr 2004 13:05:22 -0300 (ADT) +Received: from joeconway.com (66-146-172-82.skyriver.net [66.146.172.82]) + by svr1.postgresql.org (Postfix) with ESMTP id D48A6D1D391 + for ; + Thu, 15 Apr 2004 13:05:16 -0300 (ADT) +Received: from [206.19.64.3] (account jconway HELO joeconway.com) + by joeconway.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP-TLS id 1406805; Thu, 15 Apr 2004 08:59:34 -0700 +Message-ID: <407EB1E5.4030600@joeconway.com> +Date: Thu, 15 Apr 2004 09:01:41 -0700 +From: Joe Conway +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.6) Gecko/20040113 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: =?ISO-8859-1?Q?Dirk_Lutzeb=E4ck?= +Cc: pgsql-performance@postgresql.org +Subject: Re: Toooo many context switches (maybe SLES8?) +References: <407E7B99.3050306@aeccom.com> +In-Reply-To: <407E7B99.3050306@aeccom.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/177 +X-Sequence-Number: 6477 + +Dirk Lutzeb�ck wrote: +> postgresql 7.4.1 + +> a new Dual Xeon MP + +> too much context switches (way more than 100.000) on higher load (meaning system +> load > 2). + +I believe this was fixed in 7.4.2, although I can't seem to find it in +the release notes. + +Joe + +From pgsql-performance-owner@postgresql.org Thu Apr 15 13:19:17 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 804BED1E2A7 + for ; + Thu, 15 Apr 2004 13:19:11 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 04111-04 + for ; + Thu, 15 Apr 2004 13:19:12 -0300 (ADT) +Received: from trade-india.com (ns5.trade-india.com [66.234.10.13]) + by svr1.postgresql.org (Postfix) with SMTP id B9774D1E17E + for ; + Thu, 15 Apr 2004 13:19:07 -0300 (ADT) +Received: (qmail 3156 invoked from network); 15 Apr 2004 12:50:07 -0000 +Received: from unknown (HELO trade-india.com) (203.145.130.142) + by ns5.trade-india.com with SMTP; 15 Apr 2004 12:50:07 -0000 +Message-ID: <407EB605.70502@trade-india.com> +Date: Thu, 15 Apr 2004 21:49:17 +0530 +From: Rajesh Kumar Mallah +User-Agent: Mozilla Thunderbird 0.5 (X11/20040208) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Bill Moran +Cc: Richard Huxton , + Postgres Performance +Subject: Re: [ SOLVED ] select count(*) very slow on an already +References: <407D7A89.60508@trade-india.com> + <200404142008.58533.dev@archonet.com> + <407E3563.6000408@trade-india.com> + <200404150853.32475.dev@archonet.com> + <407E7391.4060706@trade-india.com> + <407E8FF6.4050601@potentialtech.com> +In-Reply-To: <407E8FF6.4050601@potentialtech.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/178 +X-Sequence-Number: 6478 + +Bill Moran wrote: + +> Rajesh Kumar Mallah wrote: +> +>> +>> Hi, +>> +>> The problem was solved by reloading the Table. +>> the query now takes only 3 seconds. But that is +>> not a solution. +> +> +> If dropping/recreating the table improves things, then we can reasonably +> assume that the table is pretty active with updates/inserts. Correct? + + + +Yes the table results from an import process and under goes lots +of inserts and updates , but thats before the vacuum full operation. +the table is not accessed during vacuum. What i want to know is +is there any wat to automate the dumping and reload of a table +individually. will the below be safe and effective: + + +begin work; +create table new_tab AS select * from tab; +truncate table tab; +insert into tab select * from new_tab; +drop table new_tab; +commit; +analyze tab; + +i havenot tried it but plan to do so. +but i feel insert would take ages to update +the indexes if any. + +BTW + +is there any way to disable checks and triggers on +a table temporarily while loading data (is updating +reltriggers in pg_class safe?) + + + + + + + + +> +>> The problem is that such phenomenon obscures our +>> judgement used in optimising queries and database. +> +> +> Lots of phenomenon obscure that ... +> +true. but there should not be too many. + +>> If a query runs slow we really cant tell if its a problem +>> with query itself , hardware or dead rows. +>> +>> I already did vacumm full on the table but it still did not +>> have that effect on performance. +>> In fact the last figures were after doing a vacuum full. +> +> +> If the data gets too fragmented, a vacuum may not be enough. Also, read +> up on the recommendations _against_ vacuum full (recommending only using +> vacuum on databases) With full, vacuum condenses the database, which may +> actually hurt performance. A regular vacuum just fixes things up, and +> may leave unused space lying around. However, this should apparently +> achieve a balance between usage and vacuum. See the docs, they are much +> better at describing this than I am. +> +i understand simultaneous vacuum and usage detoriates performance mostly. +but this case is different. + + +>> Can there be any more elegent solution to this problem. +> +> +> As a guess, look into CLUSTER (a Postgres SQL command). CLUSTER will +> basically recreate the table while ordering rows based on an index. +> (this might benefit you in other ways as well) Don't forget to analyze +> after cluster. If the problem is caused by frequent updates/inserts, +> you may find that re-clustering the table on a certain schedule is +> worthwhile. + +i could consider that option also. + +> +> Be warned, this suggestion is based on an educated guess, I make no +> guarantees that it will help your problem. Read the docs on cluster +> and come to your own conclusions. + +Thanks . + +Regds +mallah. + + + +> +>> +>> Regds +>> Mallah. +>> +>> +>> +>> +>> +>> Richard Huxton wrote: +>> +>>> On Thursday 15 April 2004 08:10, Rajesh Kumar Mallah wrote: +>>> +>>> +>>>> The problem is that i want to know if i need a Hardware upgrade +>>>> at the moment. +>>>> +>>>> Eg i have another table rfis which contains ~ .6 million records. +>>>> +>>> +>>> +>>> +>>> +>>> +>>>> SELECT count(*) from rfis where sender_uid > 0; +>>>> +>>> +>>> +>>> +>>> +>>> +>>>> Time: 117560.635 ms +>>>> +>>>> Which is approximate 4804 records per second. Is it an acceptable +>>>> performance on the hardware below: +>>>> +>>>> RAM: 2 GB +>>>> DISKS: ultra160 , 10 K , 18 GB +>>>> Processor: 2* 2.0 Ghz Xeon +>>>> +>>> +>>> +>>> Hmm - doesn't seem good, does it? If you run it again, is it much +>>> faster (since the data should be cached then)? What does "vmstat 10" +>>> show while you're running the query? +>>> +>>> One thing you should have done is read the performance tuning guide at: +>>> http://www.varlena.com/varlena/GeneralBits/Tidbits/index.php +>>> The default values are very conservative, and you will need to +>>> change them. +>>> +>>>> What kind of upgrades shoud be put on the server for it to become +>>>> reasonable fast. +>>>> +>>> +>>> If you've only got one disk, then a second disk for OS/logging. +>>> Difficult to say more without knowing numbers of users/activity etc. +>> +> +> +> + + +From pgsql-performance-owner@postgresql.org Thu Apr 15 13:29:38 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id EAE09D1E939 + for ; + Thu, 15 Apr 2004 13:29:31 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 10683-07 + for ; + Thu, 15 Apr 2004 13:29:33 -0300 (ADT) +Received: from mail2.aeccom.com (port-212-202-101-158.reverse.qsc.de + [212.202.101.158]) + by svr1.postgresql.org (Postfix) with ESMTP id E49B3D1E96B + for ; + Thu, 15 Apr 2004 13:29:26 -0300 (ADT) +Received: from aeccom.com (cayambe.core.aeccom.com [192.168.2.12]) + by mail2.aeccom.com (Postfix) with ESMTP + id F2D1334; Thu, 15 Apr 2004 18:29:31 +0200 (CEST) +Message-ID: <407EB86B.6080801@aeccom.com> +Date: Thu, 15 Apr 2004 18:29:31 +0200 +From: =?ISO-8859-1?Q?Dirk_Lutzeb=E4ck?= +Organization: AEC/communications GmbH, Berlin +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031016 +X-Accept-Language: de, en +MIME-Version: 1.0 +To: Joe Conway +Cc: pgsql-performance@postgresql.org +Subject: Re: Toooo many context switches (maybe SLES8?) +References: <407E7B99.3050306@aeccom.com> <407EB1E5.4030600@joeconway.com> +In-Reply-To: <407EB1E5.4030600@joeconway.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/179 +X-Sequence-Number: 6479 + +Joe, do you know where I should look in the 7.4.2 code to find this out? + +Dirk + + +Joe Conway wrote: + +> Dirk Lutzeb�ck wrote: +> +>> postgresql 7.4.1 +> +>> a new Dual Xeon MP +> +>> too much context switches (way more than 100.000) on higher load +>> (meaning system load > 2). +> +> +> I believe this was fixed in 7.4.2, although I can't seem to find it in +> the release notes. +> +> Joe +> +> + + + +From pgsql-performance-owner@postgresql.org Thu Apr 15 13:42:28 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7CE31D1E94D + for ; + Thu, 15 Apr 2004 13:42:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 10797-10 + for ; + Thu, 15 Apr 2004 13:42:28 -0300 (ADT) +Received: from joeconway.com (66-146-172-82.skyriver.net [66.146.172.82]) + by svr1.postgresql.org (Postfix) with ESMTP id CE411D1E947 + for ; + Thu, 15 Apr 2004 13:42:22 -0300 (ADT) +Received: from [206.19.64.3] (account jconway HELO joeconway.com) + by joeconway.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP-TLS id 1407858; Thu, 15 Apr 2004 09:36:40 -0700 +Message-ID: <407EBA89.6080007@joeconway.com> +Date: Thu, 15 Apr 2004 09:38:33 -0700 +From: Joe Conway +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.6) Gecko/20040113 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: =?ISO-8859-1?Q?Dirk_Lutzeb=E4ck?= +Cc: pgsql-performance@postgresql.org +Subject: Re: Toooo many context switches (maybe SLES8?) +References: <407E7B99.3050306@aeccom.com> <407EB1E5.4030600@joeconway.com> + <407EB86B.6080801@aeccom.com> +In-Reply-To: <407EB86B.6080801@aeccom.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/180 +X-Sequence-Number: 6480 + +Dirk Lutzeb�ck wrote: +> Joe, do you know where I should look in the 7.4.2 code to find this out? + +I think I was wrong. I just looked in CVS and found the commit I was +thinking about: + +http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/storage/lmgr/s_lock.c.diff?r1=1.22&r2=1.23 +http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/include/storage/s_lock.h.diff?r1=1.123&r2=1.124 + +========================= +Revision 1.23 / (download) - [select for diffs] , Sat Dec 27 20:58:58 +2003 UTC (3 months, 2 weeks ago) by tgl +Changes since 1.22: +5 -1 lines +Diff to previous 1.22 + +Improve spinlock code for recent x86 processors: insert a PAUSE +instruction in the s_lock() wait loop, and use test before test-and-set +in TAS() macro to avoid unnecessary bus traffic. Patch from Manfred +Spraul, reworked a bit by Tom. +========================= + +I thought this had been committed to the 7.4 stable branch as well, but +it appears not. + +Joe + + +From pgsql-performance-owner@postgresql.org Thu Apr 15 14:17:18 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0558AD1E2A7 + for ; + Thu, 15 Apr 2004 14:17:14 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 26735-07 + for ; + Thu, 15 Apr 2004 14:17:12 -0300 (ADT) +Received: from wolff.to (wolff.to [66.93.249.74]) + by svr1.postgresql.org (Postfix) with SMTP id 7530ED1E1F3 + for ; + Thu, 15 Apr 2004 14:17:06 -0300 (ADT) +Received: (qmail 15299 invoked by uid 500); 15 Apr 2004 17:20:59 -0000 +Date: Thu, 15 Apr 2004 12:20:59 -0500 +From: Bruno Wolff III +To: Simon Riggs +Cc: Josh Berkus , pgsql-performance@postgresql.org +Subject: Re: PostgreSQL and Linux 2.6 kernel. +Message-ID: <20040415172059.GA15119@wolff.to> +Mail-Followup-To: Simon Riggs , + Josh Berkus , pgsql-performance@postgresql.org +References: <200404050836.52115.josh@agliodbs.com> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/181 +X-Sequence-Number: 6481 + +On Wed, Apr 14, 2004 at 21:12:18 +0100, + Simon Riggs wrote: +> +> I guess what I'm saying is it's not how many people you've got working +> on the optimizer, its how many accurate field reports of less-than +> perfect optimization reach them. In that case, PostgreSQL is likely in a +> better position than Microsoft, since the accessibility of the pg +> discussion lists makes such cases much more likely to get aired. +> +> Any thoughts? + +I have seen exactly this happen a number of times over the last several +years. However there is still only one Tom Lane implementing the +improvements. + +From pgsql-performance-owner@postgresql.org Thu Apr 15 14:39:40 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A38C9D1D6CC + for ; + Thu, 15 Apr 2004 14:39:39 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 31037-10 + for ; + Thu, 15 Apr 2004 14:39:42 -0300 (ADT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 17B6AD1D2F7 + for ; + Thu, 15 Apr 2004 14:39:37 -0300 (ADT) +Received: from [64.81.245.111] (HELO 192.168.1.102) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4862483; Thu, 15 Apr 2004 10:41:04 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Joe Conway , + Dirk =?iso-8859-1?q?Lutzeb=E4ck?= +Subject: Re: Toooo many context switches (maybe SLES8?) +Date: Thu, 15 Apr 2004 10:40:01 -0700 +User-Agent: KMail/1.5.4 +Cc: pgsql-performance@postgresql.org +References: <407E7B99.3050306@aeccom.com> <407EB1E5.4030600@joeconway.com> +In-Reply-To: <407EB1E5.4030600@joeconway.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200404151040.01160.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/182 +X-Sequence-Number: 6482 + +Joe, + +> I believe this was fixed in 7.4.2, although I can't seem to find it in +> the release notes. + +Depends on the cause of the issue. If it's the same issue that I'm currently +struggling with, it's not fixed. + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Thu Apr 15 14:44:34 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5F1CED1DB96 + for ; + Thu, 15 Apr 2004 14:44:33 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 37464-04 + for ; + Thu, 15 Apr 2004 14:44:36 -0300 (ADT) +Received: from anchor-post-30.mail.demon.net (anchor-post-30.mail.demon.net + [194.217.242.88]) + by svr1.postgresql.org (Postfix) with ESMTP id 17CA6D1D8AE + for ; + Thu, 15 Apr 2004 14:44:31 -0300 (ADT) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-30.mail.demon.net with esmtp (Exim 3.35 #1) + id 1BEAuh-000Mo9-0U; Thu, 15 Apr 2004 18:44:36 +0100 +Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 0B9D516BFB; Thu, 15 Apr 2004 18:44:35 +0100 (BST) +From: Richard Huxton +To: Rajesh Kumar Mallah , + Bill Moran +Subject: Re: [ SOLVED ] select count(*) very slow on an already +Date: Thu, 15 Apr 2004 18:44:33 +0100 +User-Agent: KMail/1.5 +Cc: Postgres Performance +References: <407D7A89.60508@trade-india.com> + <407E8FF6.4050601@potentialtech.com> + <407EB605.70502@trade-india.com> +In-Reply-To: <407EB605.70502@trade-india.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200404151844.33672.dev@archonet.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/183 +X-Sequence-Number: 6483 + +On Thursday 15 April 2004 17:19, Rajesh Kumar Mallah wrote: +> Bill Moran wrote: +> > Rajesh Kumar Mallah wrote: +> >> Hi, +> >> +> >> The problem was solved by reloading the Table. +> >> the query now takes only 3 seconds. But that is +> >> not a solution. +> > +> > If dropping/recreating the table improves things, then we can reasonably +> > assume that the table is pretty active with updates/inserts. Correct? +> +> Yes the table results from an import process and under goes lots +> of inserts and updates , but thats before the vacuum full operation. +> the table is not accessed during vacuum. What i want to know is +> is there any wat to automate the dumping and reload of a table +> individually. will the below be safe and effective: + +Shouldn't be necessary assuming you vacuum (not full) regularly. However, +looking back at your original posting, the vacuum output doesn't seem to show +any rows that need removing. + +# VACUUM full verbose eyp_rfi; +INFO: vacuuming "public.eyp_rfi" +INFO: "eyp_rfi": found 0 removable, 505960 nonremovable row versions in +71987 pages +DETAIL: 0 dead row versions cannot be removed yet. + +Since your select count(*) showed 505960 rows, I can't see how +dropping/replacing could make a difference on a sequential scan. Since we're +not using any indexes I don't see how it could be related to that. + +> begin work; +> create table new_tab AS select * from tab; +> truncate table tab; +> insert into tab select * from new_tab; +> drop table new_tab; +> commit; +> analyze tab; +> +> i havenot tried it but plan to do so. +> but i feel insert would take ages to update +> the indexes if any. + +It will have to update them, which will take time. + +> BTW +> +> is there any way to disable checks and triggers on +> a table temporarily while loading data (is updating +> reltriggers in pg_class safe?) + +You can take a look at pg_restore and copy how it does it. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Tue Apr 20 10:58:15 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2EB0DD1D083 + for ; + Thu, 15 Apr 2004 14:48:14 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 37464-05 + for ; + Thu, 15 Apr 2004 14:48:17 -0300 (ADT) +Received: from ctg-msnexc01.staff.berbee.com (msn-office1.binc.net + [64.73.12.254]) + by svr1.postgresql.org (Postfix) with ESMTP id D46C1D1D07E + for ; + Thu, 15 Apr 2004 14:48:11 -0300 (ADT) +Received: from localhost ([172.30.254.220] RDNS failed) by + ctg-msnexc01.staff.berbee.com with Microsoft SMTPSVC(6.0.3790.0); + Thu, 15 Apr 2004 12:48:16 -0500 +From: "Jeremy M. Guthrie" +Reply-To: jeremy.guthrie@berbee.com +Organization: Berbee Information Networks +To: pgsql-performance@postgresql.org +Subject: Any way to 'analyze' indexes to get updated sizes? +Date: Thu, 15 Apr 2004 12:48:14 -0500 +User-Agent: KMail/1.6.1 +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: Text/Plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Message-Id: <200404151248.16067.jeremy.guthrie@berbee.com> +X-OriginalArrivalTime: 15 Apr 2004 17:48:16.0425 (UTC) + FILETIME=[D4C40990:01C42311] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/297 +X-Sequence-Number: 6597 + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +Is there a way to analyze indexes to provide updated sizes? Is a vacuum th= +e=20 +only way to determine the size of an index? Analyze updates the stats so I= +=20 +can see table space sizes but I cannot find an alternative to vacuum for=20 +indexes. + +- --=20 + +- -------------------------------------------------- +Jeremy M. Guthrie jeremy.guthrie@berbee.com +Network Engineer Phone: 608-298-1061 +Berbee Fax: 608-288-3007 +5520 Research Park Drive NOC: 608-298-1102 +Madison, WI 53711 +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.3 (GNU/Linux) + +iD8DBQFAfsreqtjaBHGZBeURAm3+AJ9F34SESTf8i/oEuKvKfXoh+NcOxwCcDcM9 +HP5LHM3Qidb4wa2/rW5H0cI=3D +=3DmJCz +-----END PGP SIGNATURE----- + +From pgsql-performance-owner@postgresql.org Thu Apr 15 15:28:28 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 85393D1D2F7 + for ; + Thu, 15 Apr 2004 15:28:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 52231-08 + for ; + Thu, 15 Apr 2004 15:28:27 -0300 (ADT) +Received: from mx1.neopolitan.us (mx1.neopolitan.us [65.87.16.224]) + by svr1.postgresql.org (Postfix) with ESMTP id 4D85AD1E97A + for ; + Thu, 15 Apr 2004 15:28:20 -0300 (ADT) +Received: from [65.87.16.98] (HELO [10.0.0.210]) + by mx1.neopolitan.us (CommuniGate Pro SMTP 4.1.8) + with ESMTP-TLS id 3945316 for pgsql-performance@postgresql.org; + Thu, 15 Apr 2004 11:28:26 -0700 +Subject: Re: linux distro for better pg performance +From: "J. Andrew Rogers" +To: "pgsql-performance@postgresql.org" +In-Reply-To: <407E909F.9000101@ehpg.net> +References: <407E25A6.ADFE4815@t1.unisoftbg.com> <407E909F.9000101@ehpg.net> +Content-Type: text/plain +Organization: +Message-Id: <1082053706.10823.38.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.2.2 (1.2.2-5) +Date: 15 Apr 2004 11:28:26 -0700 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/184 +X-Sequence-Number: 6484 + +On Thu, 2004-04-15 at 06:39, Gavin M. Roy wrote: +> Your IDE drive is the biggest hardward bottleneck here. RPM's and bus +> transfers are slower than SCSI or SATA. + + +Individual disk throughput generally has very little bearing on database +performance compared to other factors. In fact, IDE bandwidth +performance is perfectly adequate for databases, and for database +purposes indistinguishable from SATA. I would say that average access +and read/write completion times, especially under load, are by far the +most limiting factors, and disk RPM is only one component of this. In +fact, disk RPM is a very expensive way to get marginally better +throughput in this regard, and I would suggest 10k rather than 15k +drives for the money. + +There are really only two features that are worth buying in your disk +subsystem which many people ignore: TCQ and independently managed I/O +with a large battery-backed write-back cache. Currently, the only place +to really get this is with SCSI RAID. You can get 10k SATA drives, so +when you are buying SCSI you are really buying these features. + +Do these features make a difference? Far more than you would imagine. +On one postgres server I just upgraded, we went from a 3Ware 8x7200-RPM +RAID-10 configuration to an LSI 320-2 SCSI 3x10k RAID-5, with 256M +cache, and got a 3-5x performance improvement in the disk subsystem +under full database load. SCSI RAID can service a lot of I/O requests +far more efficiently than current IDE/SATA RAID controllers, and it +shows in the stats. Under these types of loads, the actually bandwidth +utilized by the disks doesn't come anywhere close to even their rated +performance, never mind the theoretical performance of the bus. Service +times for IDE/SATA RAID increases dramatically under load, whereas SCSI +tends not to under the same load. + +Considering that very good SCSI RAID controllers (e.g. the LSI 320-2 +that I mention above) are only marginally more expensive than nominally +equivalent IDE/SATA controller solutions, using SCSI RAID with 10k +drives is pretty much the price-performance sweet spot if you use your +disk system hard (like we do). For databases with low disk I/O +intensity, stay with IDE/SATA and save a little money. For databases +that have high disk I/O intensity, use SCSI. The price premium for SCSI +is about 50%, but the performance difference is an integer factor under +load. + + +j. andrew rogers + + + + + + +From pgsql-performance-owner@postgresql.org Thu Apr 15 15:30:06 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id BE976D1E981 + for ; + Thu, 15 Apr 2004 15:30:00 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 50970-09 + for ; + Thu, 15 Apr 2004 15:30:02 -0300 (ADT) +Received: from secure.icanx.com (secure.icanx.com [64.246.58.55]) + by svr1.postgresql.org (Postfix) with ESMTP id EB726D1E971 + for ; + Thu, 15 Apr 2004 15:29:55 -0300 (ADT) +Received: from 63-229-201-197.mpls.qwest.net ([63.229.201.197] + helo=[192.168.2.102]) by secure.icanx.com with esmtp (Exim 4.24) + id 1BEBce-0003Dq-Nl + for pgsql-performance@postgresql.org; Thu, 15 Apr 2004 14:30:00 -0400 +Mime-Version: 1.0 (Apple Message framework v613) +In-Reply-To: <200404151844.33672.dev@archonet.com> +References: <407D7A89.60508@trade-india.com> + <407E8FF6.4050601@potentialtech.com> + <407EB605.70502@trade-india.com> + <200404151844.33672.dev@archonet.com> +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: +Content-Transfer-Encoding: 7bit +From: Mark Lubratt +Subject: Re: [ SOLVED ] select count(*) very slow on an already +Date: Thu, 15 Apr 2004 13:29:57 -0500 +To: pgsql-performance@postgresql.org +X-Mailer: Apple Mail (2.613) +X-AntiAbuse: This header was added to track abuse, + please include it with any abuse report +X-AntiAbuse: Primary Hostname - secure.icanx.com +X-AntiAbuse: Original Domain - postgresql.org +X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [47 12] +X-AntiAbuse: Sender Address Domain - indeq.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/185 +X-Sequence-Number: 6485 + + +On Apr 15, 2004, at 12:44 PM, Richard Huxton wrote: + +> On Thursday 15 April 2004 17:19, Rajesh Kumar Mallah wrote: +>> Bill Moran wrote: +> +>> BTW +>> +>> is there any way to disable checks and triggers on +>> a table temporarily while loading data (is updating +>> reltriggers in pg_class safe?) +> +> You can take a look at pg_restore and copy how it does it. +> +> + +Does SET CONSTRAINT take care of checks within the transaction? +Triggers would be a different matter... + +Mark + + +From pgsql-performance-owner@postgresql.org Thu Apr 15 15:48:43 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 06C5DD1CCDA + for ; + Thu, 15 Apr 2004 15:48:41 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 60462-10 + for ; + Thu, 15 Apr 2004 15:48:44 -0300 (ADT) +Received: from internet.potentialtech.com (h-66-167-251-6.phlapafg.covad.net + [66.167.251.6]) + by svr1.postgresql.org (Postfix) with ESMTP id 31662D1B4BE + for ; + Thu, 15 Apr 2004 15:48:39 -0300 (ADT) +Received: from potentialtech.com (pa-plum1c-102.pit.adelphia.net + [24.53.179.102]) by internet.potentialtech.com (Postfix) with ESMTP + id 4CCEC69A71; Thu, 15 Apr 2004 14:48:45 -0400 (EDT) +Message-ID: <407ED909.1020404@potentialtech.com> +Date: Thu, 15 Apr 2004 14:48:41 -0400 +From: Bill Moran +User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.4) Gecko/20031005 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Rajesh Kumar Mallah +Cc: Postgres Performance +Subject: Re: [ SOLVED ] select count(*) very slow on an already +References: <407D7A89.60508@trade-india.com> + <200404142008.58533.dev@archonet.com> + <407E3563.6000408@trade-india.com> + <200404150853.32475.dev@archonet.com> + <407E7391.4060706@trade-india.com> + <407E8FF6.4050601@potentialtech.com> + <407EB605.70502@trade-india.com> +In-Reply-To: <407EB605.70502@trade-india.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/186 +X-Sequence-Number: 6486 + +Rajesh Kumar Mallah wrote: +> Bill Moran wrote: +> +>> Rajesh Kumar Mallah wrote: +>> +>>> Hi, +>>> +>>> The problem was solved by reloading the Table. +>>> the query now takes only 3 seconds. But that is +>>> not a solution. +>> +>> If dropping/recreating the table improves things, then we can reasonably +>> assume that the table is pretty active with updates/inserts. Correct? +> +> Yes the table results from an import process and under goes lots +> of inserts and updates , but thats before the vacuum full operation. +> the table is not accessed during vacuum. What i want to know is +> is there any wat to automate the dumping and reload of a table +> individually. will the below be safe and effective: + +The CLUSTER command I described is one way of doing this. It +essentially automates the task of copying the table, dropping +the old one, and recreating it. + +>> If the data gets too fragmented, a vacuum may not be enough. Also, read +>> up on the recommendations _against_ vacuum full (recommending only using +>> vacuum on databases) With full, vacuum condenses the database, which may +>> actually hurt performance. A regular vacuum just fixes things up, and +>> may leave unused space lying around. However, this should apparently +>> achieve a balance between usage and vacuum. See the docs, they are much +>> better at describing this than I am. +>> +> i understand simultaneous vacuum and usage detoriates performance mostly. +> but this case is different. + +Just want to make sure we're on the same page here. I'm not talking about +vacuuming simultaneous with anything. I'm simply saying that "vacuum full" +isn't always the best choice. You should probably only be doing "vacuum". +The reason and details for this are in the admin docs. + +-- +Bill Moran +Potential Technologies +http://www.potentialtech.com + + +From pgsql-performance-owner@postgresql.org Thu Apr 15 16:24:43 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 850BBD1D2F7 + for ; + Thu, 15 Apr 2004 16:24:41 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 77246-04 + for ; + Thu, 15 Apr 2004 16:24:44 -0300 (ADT) +Received: from ECCMCBH.cmc.int.ec.gc.ca (ecdor130.cmc.ec.gc.ca + [199.212.17.130]) + by svr1.postgresql.org (Postfix) with ESMTP id C0E69D1B4BE + for ; + Thu, 15 Apr 2004 16:24:32 -0300 (ADT) +Received: by eccmcbh.cmc.ec.gc.ca with Internet Mail Service (5.5.2653.19) + id <2A89W2DH>; Thu, 15 Apr 2004 15:24:32 -0400 +Message-ID: +From: "Shea,Dan [CIS]" +To: 'Bill Moran' +Cc: Postgres Performance +Subject: Re: [ SOLVED ] select count(*) very slow on an already +Date: Thu, 15 Apr 2004 15:24:32 -0400 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2653.19) +Content-Type: text/plain +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/187 +X-Sequence-Number: 6487 + +Bill, if you had alot of updates and deletions and wanted to optimize your +table, can you just issue the cluster command. +Will the cluster command rewrite the table without the obsolete data that a +vacuum flags or do you need to issue a vacuum first? +Dan. + +-----Original Message----- +From: Bill Moran [mailto:wmoran@potentialtech.com] +Sent: Thursday, April 15, 2004 2:49 PM +To: Rajesh Kumar Mallah +Cc: Postgres Performance +Subject: Re: [PERFORM] [ SOLVED ] select count(*) very slow on an +already + + +Rajesh Kumar Mallah wrote: +> Bill Moran wrote: +> +>> Rajesh Kumar Mallah wrote: +>> +>>> Hi, +>>> +>>> The problem was solved by reloading the Table. +>>> the query now takes only 3 seconds. But that is +>>> not a solution. +>> +>> If dropping/recreating the table improves things, then we can reasonably +>> assume that the table is pretty active with updates/inserts. Correct? +> +> Yes the table results from an import process and under goes lots +> of inserts and updates , but thats before the vacuum full operation. +> the table is not accessed during vacuum. What i want to know is +> is there any wat to automate the dumping and reload of a table +> individually. will the below be safe and effective: + +The CLUSTER command I described is one way of doing this. It +essentially automates the task of copying the table, dropping +the old one, and recreating it. + +>> If the data gets too fragmented, a vacuum may not be enough. Also, read +>> up on the recommendations _against_ vacuum full (recommending only using +>> vacuum on databases) With full, vacuum condenses the database, which may +>> actually hurt performance. A regular vacuum just fixes things up, and +>> may leave unused space lying around. However, this should apparently +>> achieve a balance between usage and vacuum. See the docs, they are much +>> better at describing this than I am. +>> +> i understand simultaneous vacuum and usage detoriates performance mostly. +> but this case is different. + +Just want to make sure we're on the same page here. I'm not talking about +vacuuming simultaneous with anything. I'm simply saying that "vacuum full" +isn't always the best choice. You should probably only be doing "vacuum". +The reason and details for this are in the admin docs. + +-- +Bill Moran +Potential Technologies +http://www.potentialtech.com + + +---------------------------(end of broadcast)--------------------------- +TIP 3: if posting/reading through Usenet, please send an appropriate + subscribe-nomail command to majordomo@postgresql.org so that your + message can get through to the mailing list cleanly + +From pgsql-performance-owner@postgresql.org Thu Apr 15 16:35:24 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id BEBB3D1E99F + for ; + Thu, 15 Apr 2004 16:35:21 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 77165-09 + for ; + Thu, 15 Apr 2004 16:35:25 -0300 (ADT) +Received: from cmailg2.svr.pol.co.uk (cmailg2.svr.pol.co.uk [195.92.195.172]) + by svr1.postgresql.org (Postfix) with ESMTP id 4BA61D1E9A2 + for ; + Thu, 15 Apr 2004 16:35:19 -0300 (ADT) +Received: from modem-2043.lion.dialup.pol.co.uk ([217.135.167.251] + helo=stromboli) by cmailg2.svr.pol.co.uk with esmtp (Exim 4.14) + id 1BECdq-0006VF-LH; Thu, 15 Apr 2004 20:35:18 +0100 +From: "Simon Riggs" +To: "Bruno Wolff III" +Cc: "Josh Berkus" , + +Subject: Re: PostgreSQL and Linux 2.6 kernel. +Date: Thu, 15 Apr 2004 20:35:34 +0100 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) +In-reply-to: <20040415172059.GA15119@wolff.to> +X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 +Importance: Normal +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/188 +X-Sequence-Number: 6488 + +> Bruno Wolff +> Simon Riggs wrote: +> > +> > I guess what I'm saying is it's not how many people you've +> got working +> > on the optimizer, its how many accurate field reports of less-than +> > perfect optimization reach them. In that case, PostgreSQL +> is likely in a +> > better position than Microsoft, since the accessibility of the pg +> > discussion lists makes such cases much more likely to get aired. +> > +> > Any thoughts? +> +> I have seen exactly this happen a number of times over the +> last several +> years. However there is still only one Tom Lane implementing the +> improvements. +> + +...and very few Mr.Microsofts too. + +[I'm uncomfortable with, and it was not my intent, to discuss such an +issue with direct reference to particular individuals. There is no +intent to critiscise or malign anybody named] + +Regards, Simon + + +From pgsql-performance-owner@postgresql.org Thu Apr 15 16:38:05 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D8CBFD1D085 + for ; + Thu, 15 Apr 2004 16:38:01 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 77321-07 + for ; + Thu, 15 Apr 2004 16:38:05 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 24945D1D06D + for ; + Thu, 15 Apr 2004 16:37:59 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3FJbL3C020499; + Thu, 15 Apr 2004 15:37:21 -0400 (EDT) +To: Joe Conway +Cc: =?ISO-8859-1?Q?Dirk_Lutzeb=E4ck?= , + pgsql-performance@postgresql.org +Subject: Re: Toooo many context switches (maybe SLES8?) +In-reply-to: <407EBA89.6080007@joeconway.com> +References: <407E7B99.3050306@aeccom.com> <407EB1E5.4030600@joeconway.com> + <407EB86B.6080801@aeccom.com> <407EBA89.6080007@joeconway.com> +Comments: In-reply-to Joe Conway + message dated "Thu, 15 Apr 2004 09:38:33 -0700" +Date: Thu, 15 Apr 2004 15:37:21 -0400 +Message-ID: <20498.1082057841@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/189 +X-Sequence-Number: 6489 + +Joe Conway writes: +>> Improve spinlock code for recent x86 processors: insert a PAUSE +>> instruction in the s_lock() wait loop, and use test before test-and-set +>> in TAS() macro to avoid unnecessary bus traffic. Patch from Manfred +>> Spraul, reworked a bit by Tom. + +> I thought this had been committed to the 7.4 stable branch as well, but +> it appears not. + +I am currently chasing what seems to be the same issue: massive context +swapping on a dual Xeon system. I tried back-patching the above-mentioned +patch ... it helps a little but by no means solves the problem ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Apr 20 10:58:20 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3914BD1D25B + for ; + Thu, 15 Apr 2004 17:04:31 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 88416-09 + for ; + Thu, 15 Apr 2004 17:04:30 -0300 (ADT) +Received: from mailout11.sul.t-online.com (mailout11.sul.t-online.com + [194.25.134.85]) + by svr1.postgresql.org (Postfix) with ESMTP id 03E24D1D083 + for ; + Thu, 15 Apr 2004 17:04:24 -0300 (ADT) +Received: from fwd03.aul.t-online.de by mailout11.sul.t-online.com with smtp + id 1BED5M-00010G-06; Thu, 15 Apr 2004 22:03:44 +0200 +Received: from aeccom.com + (ZknwbMZrZe57WMjZzTNOinFhX4rdoiy+yeQm4pJ8W4cxP3xVE-aZ8n@[217.231.158.140]) + by fwd03.sul.t-online.com + with esmtp id 1BED5I-1IbFnE0; Thu, 15 Apr 2004 22:03:40 +0200 +Message-ID: <407EEA9B.7010807@aeccom.com> +Date: Thu, 15 Apr 2004 22:03:39 +0200 +From: Dirk.Lutzebaeck@t-online.de (Dirk Lutzebaeck) +Reply-To: lutzeb@aeccom.com +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.1) Gecko/20031030 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: Joe Conway , pgsql-performance@postgresql.org +Subject: Re: Toooo many context switches (maybe SLES8?) +References: <407E7B99.3050306@aeccom.com> <407EB1E5.4030600@joeconway.com> + <407EB86B.6080801@aeccom.com> <407EBA89.6080007@joeconway.com> + <20498.1082057841@sss.pgh.pa.us> +In-Reply-To: <20498.1082057841@sss.pgh.pa.us> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Seen: false +X-ID: ZknwbMZrZe57WMjZzTNOinFhX4rdoiy+yeQm4pJ8W4cxP3xVE-aZ8n +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/298 +X-Sequence-Number: 6598 + +Could this be related to the O(1) scheduler backpatches from 2.6 to 2.4 +kernel on newer 2.4er distros (RedHat, SuSE)? + + +Tom Lane wrote: + +>Joe Conway writes: +> +> +>>>Improve spinlock code for recent x86 processors: insert a PAUSE +>>>instruction in the s_lock() wait loop, and use test before test-and-set +>>>in TAS() macro to avoid unnecessary bus traffic. Patch from Manfred +>>>Spraul, reworked a bit by Tom. +>>> +>>> +> +> +> +>>I thought this had been committed to the 7.4 stable branch as well, but +>>it appears not. +>> +>> +> +>I am currently chasing what seems to be the same issue: massive context +>swapping on a dual Xeon system. I tried back-patching the above-mentioned +>patch ... it helps a little but by no means solves the problem ... +> +> regards, tom lane +> +> +> + + + +From pgsql-performance-owner@postgresql.org Thu Apr 15 17:13:29 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 360FED1D062 + for ; + Thu, 15 Apr 2004 17:13:28 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 92020-08 + for ; + Thu, 15 Apr 2004 17:13:32 -0300 (ADT) +Received: from internet.potentialtech.com (h-66-167-251-6.phlapafg.covad.net + [66.167.251.6]) + by svr1.postgresql.org (Postfix) with ESMTP id 83B0BD1D07E + for ; + Thu, 15 Apr 2004 17:13:26 -0300 (ADT) +Received: from potentialtech.com (pa-plum1c-102.pit.adelphia.net + [24.53.179.102]) by internet.potentialtech.com (Postfix) with ESMTP + id 655C569A71; Thu, 15 Apr 2004 16:13:33 -0400 (EDT) +Message-ID: <407EECEA.7010500@potentialtech.com> +Date: Thu, 15 Apr 2004 16:13:30 -0400 +From: Bill Moran +User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.4) Gecko/20031005 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "Shea,Dan [CIS]" +Cc: Postgres Performance +Subject: Re: [ SOLVED ] select count(*) very slow on an already +References: +In-Reply-To: +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/190 +X-Sequence-Number: 6490 + +Shea,Dan [CIS] wrote: +> Bill, if you had alot of updates and deletions and wanted to optimize your +> table, can you just issue the cluster command. +> Will the cluster command rewrite the table without the obsolete data that a +> vacuum flags or do you need to issue a vacuum first? + + From the reference docs: + +"During the cluster operation, a temporary copy of the table is created that +contains the table data in the index order. Temporary copies of each index +on the table are created as well. Therefore, you need free space on disk at +least equal to the sum of the table size and the index sizes. + +"CLUSTER preserves GRANT, inheritance, index, foreign key, and other ancillary +information about the table. + +"Because the optimizer records statistics about the ordering of tables, it is +advisable to run ANALYZE on the newly clustered table. Otherwise, the optimizer +may make poor choices of query plans." + +The primary reason CLUSTER exists is to allow you to physically reorder a table +based on a key. This should provide a performance improvement if data with +the same key is accessed all at once. (i.e. if you do "SELECT * FROM table WHERE +key=5" and it returns 100 rows, those 100 rows are guaranteed to be all on the +same part of the disk after CLUSTER, thus a performance improvement should result.) + +Updates and inserts will add data in the next available space in a table with no +regard for any keys, and _may_ require running all over the disk to retrieve +the data in the previous example query. + +I doubt if CLUSTER is an end-all optimization tool. The specific reason I +suggested it was because the original poster was asking for an easier way to +drop/recreate a table (as prior experimentation had shown this to improve +performance) I can't think of anything easier than "CLUSTER ON +" + +Since CLUSTER recreates the table, it implicitly removes the dead tuples. +However, it's going to be a LOT slower than vacuum, so if dead tuples are the +main problem, vacuum is still the way to go. + +-- +Bill Moran +Potential Technologies +http://www.potentialtech.com + + +From pgsql-performance-owner@postgresql.org Thu Apr 15 17:37:11 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id CF02FD1D08C + for ; + Thu, 15 Apr 2004 17:37:10 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 96731-10 + for ; + Thu, 15 Apr 2004 17:37:14 -0300 (ADT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id A4BB7D1C9BE + for ; + Thu, 15 Apr 2004 17:37:07 -0300 (ADT) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4863796; Thu, 15 Apr 2004 13:38:36 -0700 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: Tom Lane , Joe Conway +Subject: Re: Toooo many context switches (maybe SLES8?) +Date: Thu, 15 Apr 2004 13:37:00 -0700 +User-Agent: KMail/1.4.3 +Cc: Dirk =?iso-8859-1?q?Lutzeb=E4ck?= , + pgsql-performance@postgresql.org +References: <407E7B99.3050306@aeccom.com> <407EBA89.6080007@joeconway.com> + <20498.1082057841@sss.pgh.pa.us> +In-Reply-To: <20498.1082057841@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200404151337.00273.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/191 +X-Sequence-Number: 6491 + +Folks, + +> I am currently chasing what seems to be the same issue: massive context +> swapping on a dual Xeon system. I tried back-patching the above-mentioned +> patch ... it helps a little but by no means solves the problem ... + +BTW, I'm currently pursuing the possibility that this has something to do with +the ServerWorks chipset on those motherboards. If anyone knows a high-end +hardware+linux kernel geek I can corner, I'd appreciate it. + +Maybe I should contact OSDL ... + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Thu Apr 15 17:40:01 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 96785D1E812 + for ; + Thu, 15 Apr 2004 17:39:58 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 07239-03 + for ; + Thu, 15 Apr 2004 17:39:59 -0300 (ADT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 74D12D1E1F3 + for ; + Thu, 15 Apr 2004 17:39:52 -0300 (ADT) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4863804; Thu, 15 Apr 2004 13:41:22 -0700 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: "Simon Riggs" , +Subject: Re: PostgreSQL and Linux 2.6 kernel. +Date: Thu, 15 Apr 2004 13:39:45 -0700 +User-Agent: KMail/1.4.3 +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200404151339.45615.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/192 +X-Sequence-Number: 6492 + +Simon, + +> Is the problem "a person interested" or is there another issue there? + +IMHO, it's "a person interested". + +> Treating the optimizer as a black box is something I'm very used to from +> other RDBMS. My question is, how can you explicitly re-write a query now +> to "improve" it? If there's no way of manipulating queries without +> actually re-writing the optimizer, we're now in a position where we +> aren't able to diagnose when the optimizer isn't working effectively. + +Well, there is ... all of the various query cost parameters. + +> For my mind, all the people on this list are potential "optimizer +> developers" in the sense that we can all look at queries and see whether +> there is a problem with particular join plans. Providing good cases of +> poor optimization is just what's needed to assist those few that do +> understand the internals to continue improving things. + +... which is what this list is for. + +But, ultimately, improvements on the planner are still bottlenecked by having +only one developer actually hacking the changes. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Thu Apr 15 18:38:52 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9ABB5D1B515 + for ; + Thu, 15 Apr 2004 18:38:51 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 22561-05 + for ; + Thu, 15 Apr 2004 18:38:56 -0300 (ADT) +Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) + by svr1.postgresql.org (Postfix) with ESMTP id AF9D9D1B4BE + for ; + Thu, 15 Apr 2004 18:38:49 -0300 (ADT) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by smtp.istop.com (Postfix) with ESMTP + id 41D7717C465; Thu, 15 Apr 2004 17:38:24 -0400 (EDT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1BEEYy-0002cV-00; Thu, 15 Apr 2004 17:38:24 -0400 +To: Bruno Wolff III +Cc: Simon Riggs , + Josh Berkus , pgsql-performance@postgresql.org +Subject: Re: PostgreSQL and Linux 2.6 kernel. +References: <200404050836.52115.josh@agliodbs.com> + + <20040415172059.GA15119@wolff.to> +In-Reply-To: <20040415172059.GA15119@wolff.to> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 15 Apr 2004 17:38:23 -0400 +Message-ID: <873c74c46o.fsf@stark.xeocode.com> +Lines: 11 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/193 +X-Sequence-Number: 6493 + + +Bruno Wolff III writes: + +> I have seen exactly this happen a number of times over the last several +> years. However there is still only one Tom Lane implementing the +> improvements. + +Ob: Well clearly the problem is we need more Tom Lanes. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Thu Apr 15 19:21:09 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1C037D1CCB0 + for ; + Thu, 15 Apr 2004 19:21:08 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 33709-09 + for ; + Thu, 15 Apr 2004 19:21:12 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 17146D1C9C8 + for ; + Thu, 15 Apr 2004 19:21:05 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3FMLBaA021757; + Thu, 15 Apr 2004 18:21:11 -0400 (EDT) +To: Greg Stark +Cc: pgsql-performance@postgresql.org +Subject: Re: PostgreSQL and Linux 2.6 kernel. +In-reply-to: <873c74c46o.fsf@stark.xeocode.com> +References: <200404050836.52115.josh@agliodbs.com> + + <20040415172059.GA15119@wolff.to> + <873c74c46o.fsf@stark.xeocode.com> +Comments: In-reply-to Greg Stark + message dated "15 Apr 2004 17:38:23 -0400" +Date: Thu, 15 Apr 2004 18:21:11 -0400 +Message-ID: <21756.1082067671@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/195 +X-Sequence-Number: 6495 + +Greg Stark writes: +> Ob: Well clearly the problem is we need more Tom Lanes. + +ObHHGReference: "Haven't you heard? I come in six-packs!" + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Apr 15 19:19:01 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D67A1D1D083 + for ; + Thu, 15 Apr 2004 19:19:00 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 37004-03 + for ; + Thu, 15 Apr 2004 19:19:06 -0300 (ADT) +Received: from 3times25.net (66-23-202-190.clients.speedfactory.net + [66.23.202.190]) + by svr1.postgresql.org (Postfix) with ESMTP id DE2BBD1D06D + for ; + Thu, 15 Apr 2004 19:18:58 -0300 (ADT) +Received: from 3times25.net (localhost [127.0.0.1]) + by 3times25.net (Postfix) with ESMTP + id 49A0C4B9F6; Thu, 15 Apr 2004 18:23:19 -0400 (EDT) +Message-ID: <407F0B57.9040206@3times25.net> +Date: Thu, 15 Apr 2004 18:23:19 -0400 +From: Geoffrey +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040113 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Greg Stark +Cc: Bruno Wolff III , + Simon Riggs , Josh Berkus , + pgsql-performance@postgresql.org +Subject: Re: PostgreSQL and Linux 2.6 kernel. +References: <200404050836.52115.josh@agliodbs.com> + + <20040415172059.GA15119@wolff.to> + <873c74c46o.fsf@stark.xeocode.com> +In-Reply-To: <873c74c46o.fsf@stark.xeocode.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/194 +X-Sequence-Number: 6494 + +Greg Stark wrote: +> Bruno Wolff III writes: +> +> +>>I have seen exactly this happen a number of times over the last several +>>years. However there is still only one Tom Lane implementing the +>>improvements. +> +> +> Ob: Well clearly the problem is we need more Tom Lanes. +> + +my $pgGuru = "Tom Lane"; my @morepgGurus; my $howmany = 10; + +while($howmany--) { push @morepgGurus, $pgGuru; } + +-- +Until later, Geoffrey Registered Linux User #108567 +Building secure systems in spite of Microsoft + +From pgsql-performance-owner@postgresql.org Thu Apr 15 20:02:06 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 278B5D1D300 + for ; + Thu, 15 Apr 2004 20:02:05 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 50208-03 + for ; + Thu, 15 Apr 2004 20:02:10 -0300 (ADT) +Received: from email04.aon.at (WARSL404PIP2.highway.telekom.at [195.3.96.113]) + by svr1.postgresql.org (Postfix) with SMTP id C9045D1D2F7 + for ; + Thu, 15 Apr 2004 20:02:02 -0300 (ADT) +Received: (qmail 284980 invoked from network); 15 Apr 2004 23:02:10 -0000 +Received: from m155p007.dipool.highway.telekom.at (HELO PASCAL) ([62.46.9.71]) + (envelope-sender ) + by qmail7rs.highway.telekom.at (qmail-ldap-1.03) with SMTP + for ; 15 Apr 2004 23:02:10 -0000 +From: Manfred Koizar +To: Tom Lane +Cc: jdunn@autorevenue.com, + "'Postgresql Performance'" +Subject: Re: index v. seqscan for certain values +Date: Fri, 16 Apr 2004 01:04:24 +0200 +Message-ID: <571u701m7fkc97oi1ul8qfuf8e94kvi8lg@email.aon.at> +References: <000801c42165$68a67750$4f01a8c0@jeremydunn> + <24670.1081878949@sss.pgh.pa.us> +In-Reply-To: <24670.1081878949@sss.pgh.pa.us> +X-Mailer: Forte Agent 1.93/32.576 English (American) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/196 +X-Sequence-Number: 6496 + +On Tue, 13 Apr 2004 13:55:49 -0400, Tom Lane wrote: +>Possibly the +>nonuniform clumping of CID has something to do with the poor results. + +It shouldn't. The sampling algorithm is designed to give each tuple the +same chance of ending up in the sample, and tuples are selected +independently. (IOW each one of the {N \chooose n} possible samples has +the same probability.) There are known problems with nonuniform +distribution of dead vs. live and large vs. small tuples, but AFAICS the +order of values does not matter. + +Servus + Manfred + +From pgsql-performance-owner@postgresql.org Thu Apr 15 20:30:36 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id F18AFD1D07E + for ; + Thu, 15 Apr 2004 20:30:33 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 56339-06 + for ; + Thu, 15 Apr 2004 20:30:39 -0300 (ADT) +Received: from email10.aon.at (warsl404pip7.highway.telekom.at [195.3.96.91]) + by svr1.postgresql.org (Postfix) with SMTP id 801DCD1B8B7 + for ; + Thu, 15 Apr 2004 20:30:31 -0300 (ADT) +Received: (qmail 143146 invoked from network); 15 Apr 2004 23:30:39 -0000 +Received: from m155p007.dipool.highway.telekom.at (HELO PASCAL) ([62.46.9.71]) + (envelope-sender ) + by 172.18.5.237 (qmail-ldap-1.03) with SMTP + for ; 15 Apr 2004 23:30:39 -0000 +From: Manfred Koizar +To: Tom Lane +Cc: Robert Treat , + pgsql-performance@postgresql.org +Subject: Re: query slows down with more accurate stats +Date: Fri, 16 Apr 2004 01:32:53 +0200 +Message-ID: +References: <1081879359.25537.526.camel@camel> + <25556.1081883922@sss.pgh.pa.us> +In-Reply-To: <25556.1081883922@sss.pgh.pa.us> +X-Mailer: Forte Agent 1.93/32.576 English (American) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/197 +X-Sequence-Number: 6497 + +[Just a quick note here; a more thorough discussion of my test results +will be posted to -hackers] + +On Tue, 13 Apr 2004 15:18:42 -0400, Tom Lane wrote: +>Well, the first problem is why is ANALYZE's estimate of the total row +>count so bad :-( ? I suspect you are running into the situation where +>the initial pages of the table are thinly populated and ANALYZE +>mistakenly assumes the rest are too. Manfred is working on a revised +>sampling method for ANALYZE that should fix this problem + +The new method looks very promising with respect to row count +estimation: I got estimation errors of +/- 1% where the old method was +off by up to 60%. (My test methods might be a bit biased though :-)) + +My biggest concern at the moment is that the new sampling method +violates the contract of returning each possible sample with he same +probability: getting several tuples from the same page is more likely +than with the old method. + +Servus + Manfred + +From pgsql-performance-owner@postgresql.org Thu Apr 15 21:18:47 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 273E3D1E971 + for ; + Thu, 15 Apr 2004 21:18:46 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 66774-10 + for ; + Thu, 15 Apr 2004 21:18:51 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id D50FFD1B8B7 + for ; + Thu, 15 Apr 2004 21:18:43 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3G0InlS022643; + Thu, 15 Apr 2004 20:18:49 -0400 (EDT) +To: Manfred Koizar +Cc: Robert Treat , + pgsql-performance@postgresql.org +Subject: Re: query slows down with more accurate stats +In-reply-to: +References: <1081879359.25537.526.camel@camel> + <25556.1081883922@sss.pgh.pa.us> + +Comments: In-reply-to Manfred Koizar + message dated "Fri, 16 Apr 2004 01:32:53 +0200" +Date: Thu, 15 Apr 2004 20:18:49 -0400 +Message-ID: <22642.1082074729@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/198 +X-Sequence-Number: 6498 + +Manfred Koizar writes: +> My biggest concern at the moment is that the new sampling method +> violates the contract of returning each possible sample with he same +> probability: getting several tuples from the same page is more likely +> than with the old method. + +Hm, are you sure? I recall objecting to your original proposal because +I thought that would happen, but after further thought it seemed not. + +Also, I'm not at all sure that the old method satisfies that constraint +completely in the presence of nonuniform numbers of tuples per page, +so we'd not necessarily be going backwards anyhow ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Apr 15 22:05:03 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3D183D1E990 + for ; + Thu, 15 Apr 2004 22:05:01 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 81278-08 + for ; + Thu, 15 Apr 2004 22:05:07 -0300 (ADT) +Received: from hosting.commandprompt.com (128.commandprompt.com + [207.173.200.128]) + by svr1.postgresql.org (Postfix) with ESMTP id C6CF5D1E98F + for ; + Thu, 15 Apr 2004 22:04:58 -0300 (ADT) +Received: from commandprompt.com (clbb-248.saw.net [64.146.135.248]) + (authenticated) + by hosting.commandprompt.com (8.11.6/8.11.6) with ESMTP id i3G150u02206; + Thu, 15 Apr 2004 18:05:01 -0700 +Message-ID: <407F31D6.6010104@commandprompt.com> +Date: Thu, 15 Apr 2004 18:07:34 -0700 +From: "Joshua D. Drake" +Organization: Command Prompt, Inc. +User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Geoffrey +Cc: Greg Stark , Bruno Wolff III , + Simon Riggs , Josh Berkus , + pgsql-performance@postgresql.org +Subject: Re: PostgreSQL and Linux 2.6 kernel. +References: <200404050836.52115.josh@agliodbs.com> + + <20040415172059.GA15119@wolff.to> + <873c74c46o.fsf@stark.xeocode.com> <407F0B57.9040206@3times25.net> +In-Reply-To: <407F0B57.9040206@3times25.net> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/199 +X-Sequence-Number: 6499 + + +> +> my $pgGuru = "Tom Lane"; my @morepgGurus; my $howmany = 10; +> +> while($howmany--) { push @morepgGurus, $pgGuru; } +> +This is just wrong... + +-- +Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC +Postgresql support, programming shared hosting and dedicated hosting. ++1-503-667-4564 - jd@commandprompt.com - http://www.commandprompt.com +PostgreSQL Replicator -- production quality replication for PostgreSQL + + +From pgsql-performance-owner@postgresql.org Thu Apr 15 23:27:16 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3CE90D1E947 + for ; + Thu, 15 Apr 2004 23:27:15 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 00702-07 + for ; + Thu, 15 Apr 2004 23:27:20 -0300 (ADT) +Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) + by svr1.postgresql.org (Postfix) with ESMTP id 6C85CD1E1F3 + for ; + Thu, 15 Apr 2004 23:27:12 -0300 (ADT) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by smtp.istop.com (Postfix) with ESMTP + id DF7C217C33C; Thu, 15 Apr 2004 22:27:21 -0400 (EDT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1BEJ4b-0003ch-00; Thu, 15 Apr 2004 22:27:21 -0400 +To: "Joshua D. Drake" +Cc: Geoffrey , Greg Stark , + Bruno Wolff III , + Simon Riggs , Josh Berkus , + pgsql-performance@postgresql.org +Subject: Re: PostgreSQL and Linux 2.6 kernel. +References: <200404050836.52115.josh@agliodbs.com> + + <20040415172059.GA15119@wolff.to> <873c74c46o.fsf@stark.xeocode.com> + <407F0B57.9040206@3times25.net> <407F31D6.6010104@commandprompt.com> +In-Reply-To: <407F31D6.6010104@commandprompt.com> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 15 Apr 2004 22:27:20 -0400 +Message-ID: <87wu4gac8n.fsf@stark.xeocode.com> +Lines: 18 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/200 +X-Sequence-Number: 6500 + + +"Joshua D. Drake" writes: + +> > while($howmany--) { push @morepgGurus, $pgGuru; } +> +> This is just wrong... + +yeah, it would have been much clearer written as: + push @morepgGurus, ($pgGuru)x$howmany; + +Or at least the perlish: + for (1..$howmany) +instead of C style while syntax. + +Ok. I stop now. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Fri Apr 16 04:24:35 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1CA25D1DB0A + for ; + Fri, 16 Apr 2004 04:24:34 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 91072-04 + for ; + Fri, 16 Apr 2004 04:24:31 -0300 (ADT) +Received: from cmailm1.svr.pol.co.uk (cmailm1.svr.pol.co.uk [195.92.193.18]) + by svr1.postgresql.org (Postfix) with ESMTP id 5A209D1D2DC + for ; + Fri, 16 Apr 2004 04:24:32 -0300 (ADT) +Received: from modem-1925.llama.dialup.pol.co.uk ([217.135.183.133] + helo=stromboli) by cmailm1.svr.pol.co.uk with esmtp (Exim 4.14) + id 1BENiC-0002hc-DM; Fri, 16 Apr 2004 08:24:32 +0100 +From: "Simon Riggs" +To: "Josh Berkus" , + +Subject: Re: PostgreSQL and Linux 2.6 kernel. +Date: Fri, 16 Apr 2004 08:24:46 +0100 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) +In-reply-to: <200404151339.45615.josh@agliodbs.com> +X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 +Importance: Normal +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/201 +X-Sequence-Number: 6501 + + +>Josh Berkus +> > Treating the optimizer as a black box is something I'm very +> used to from +> > other RDBMS. My question is, how can you explicitly +> re-write a query now +> > to "improve" it? If there's no way of manipulating queries without +> > actually re-writing the optimizer, we're now in a position where we +> > aren't able to diagnose when the optimizer isn't working +> effectively. +> +> Well, there is ... all of the various query cost parameters. + +They are very blunt instruments for such a delicate task. + +Surely someone of your experience might have benefit from something +more? + +My feeling is, I would, though I want those tools as *a developer* +rather than for tuning specific queries for people, which is always so +sensitive to upgrades etc. + +> But, ultimately, improvements on the planner are still +> bottlenecked by having +> only one developer actually hacking the changes. +> + +Do we have a clear list of optimizations we'd like to be working on? + +The TODO items aren't very related to specific optimizations... + +The only ones I was aware of was deferred subselect evaluation for +DBT-3. + + + +...sounds like there's more to discuss here, so I'll duck out now and +get back to my current project... + +Best Regards, Simon Riggs + + +From pgsql-performance-owner@postgresql.org Fri Apr 16 05:22:14 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1445BD1C4C3 + for ; + Fri, 16 Apr 2004 05:22:13 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 11556-02 + for ; + Fri, 16 Apr 2004 05:22:10 -0300 (ADT) +Received: from trade-india.com (unknown [61.16.154.82]) + by svr1.postgresql.org (Postfix) with SMTP id 149F9D1BCB8 + for ; + Fri, 16 Apr 2004 05:22:07 -0300 (ADT) +Received: (qmail 7040 invoked from network); 16 Apr 2004 08:08:56 -0000 +Received: from valium.trade-india-local.com (HELO trade-india.com) + (192.168.0.72) + by system66.trade-india-local.com with SMTP; 16 Apr 2004 08:08:56 -0000 +Message-ID: <407F9816.2080407@trade-india.com> +Date: Fri, 16 Apr 2004 13:53:50 +0530 +From: Rajesh Kumar Mallah +Organization: Infocom Network Limited +User-Agent: Mozilla Thunderbird 0.5 (X11/20040208) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Richard Huxton +Cc: Bill Moran , + Postgres Performance +Subject: Re: [ SOLVED ] select count(*) very slow on an already +References: <407D7A89.60508@trade-india.com> + <407E8FF6.4050601@potentialtech.com> + <407EB605.70502@trade-india.com> + <200404151844.33672.dev@archonet.com> +In-Reply-To: <200404151844.33672.dev@archonet.com> +Content-Type: multipart/alternative; + boundary="------------020309060308030400050407" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/202 +X-Sequence-Number: 6502 + +This is a multi-part message in MIME format. +--------------020309060308030400050407 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit + + + +I am running an update on the same table + +update rfis set inquiry_status='APPROVED' where inquiry_status='a'; + +Its running for past 20 mins. and top output is below. +The PID which is executing the query above is 6712. Can anyone +tell me why it is in an uninterruptable sleep and does it relate +to the apparent poor performance? Is it problem with the disk +hardware. I know at nite this query will run reasonably fast. + +I am running on a decent hardware . + + + +Regds +mallah. + + + + 1:41pm up 348 days, 21:10, 1 user, load average: 11.59, 13.69, 11.49 +85 processes: 83 sleeping, 1 running, 0 zombie, 1 stopped +CPU0 states: 8.1% user, 2.3% system, 0.0% nice, 89.0% idle +CPU1 states: 3.3% user, 2.3% system, 0.0% nice, 93.2% idle +CPU2 states: 7.4% user, 1.4% system, 0.0% nice, 90.0% idle +CPU3 states: 9.3% user, 7.4% system, 0.0% nice, 82.2% idle +Mem: 2064796K av, 2053964K used, 10832K free, 0K shrd, 22288K +buff +Swap: 2048244K av, 88660K used, 1959584K free 1801532K +cached + + PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME COMMAND +* 6712 postgres 16 0 86592 84M 83920 D 11.1 4.1 1:36 postmaster* +13103 postgres 15 0 54584 53M 52556 S 3.5 2.6 0:01 postmaster +13034 root 16 0 1072 1072 848 R 2.1 0.0 0:02 top +13064 postgres 15 0 67256 65M 64516 D 2.1 3.2 0:01 postmaster +13088 postgres 16 0 43324 42M 40812 D 2.1 2.0 0:00 postmaster +13076 postgres 15 0 49016 47M 46628 S 1.9 2.3 0:00 postmaster +26931 postgres 15 0 84880 82M 83888 S 1.7 4.1 3:52 postmaster +13107 postgres 15 0 18400 17M 16488 S 1.5 0.8 0:00 postmaster +13068 postgres 15 0 44632 43M 42324 D 1.3 2.1 0:00 postmaster +13074 postgres 15 0 68852 67M 66508 D 1.3 3.3 0:00 postmaster +13108 postgres 15 0 11692 11M 10496 S 1.3 0.5 0:00 postmaster +13075 postgres 15 0 50860 49M 47680 S 1.1 2.4 0:04 postmaster +13066 postgres 15 0 56112 54M 53724 S 0.9 2.7 0:01 postmaster +13109 postgres 15 0 14528 14M 13272 S 0.9 0.7 0:00 postmaster +24454 postgres 15 0 2532 2380 1372 S 0.7 0.1 11:58 postmaster + 12 root 15 0 0 0 0 SW 0.5 0.0 816:30 bdflush +24455 postgres 15 0 1600 1476 1380 S 0.5 0.0 9:11 postmaster +12528 postgres 15 0 84676 82M 79920 S 0.3 4.0 0:02 postmaster +12575 postgres 15 0 76660 74M 75796 D 0.3 3.7 0:09 postmaster +13038 postgres 15 0 48952 47M 46436 D 0.3 2.3 0:00 postmaster +13069 postgres 15 0 57464 56M 54852 S 0.3 2.7 0:00 postmaster +13102 postgres 15 0 17864 17M 16504 D 0.3 0.8 0:00 postmaster + + + + + + + + + + + + + + + + + + + +Richard Huxton wrote: + +>On Thursday 15 April 2004 17:19, Rajesh Kumar Mallah wrote: +> +> +>>Bill Moran wrote: +>> +>> +>>>Rajesh Kumar Mallah wrote: +>>> +>>> +>>>>Hi, +>>>> +>>>>The problem was solved by reloading the Table. +>>>>the query now takes only 3 seconds. But that is +>>>>not a solution. +>>>> +>>>> +>>>If dropping/recreating the table improves things, then we can reasonably +>>>assume that the table is pretty active with updates/inserts. Correct? +>>> +>>> +>>Yes the table results from an import process and under goes lots +>>of inserts and updates , but thats before the vacuum full operation. +>>the table is not accessed during vacuum. What i want to know is +>>is there any wat to automate the dumping and reload of a table +>>individually. will the below be safe and effective: +>> +>> +> +>Shouldn't be necessary assuming you vacuum (not full) regularly. However, +>looking back at your original posting, the vacuum output doesn't seem to show +>any rows that need removing. +> +># VACUUM full verbose eyp_rfi; +>INFO: vacuuming "public.eyp_rfi" +>INFO: "eyp_rfi": found 0 removable, 505960 nonremovable row versions in +>71987 pages +>DETAIL: 0 dead row versions cannot be removed yet. +> +>Since your select count(*) showed 505960 rows, I can't see how +>dropping/replacing could make a difference on a sequential scan. Since we're +>not using any indexes I don't see how it could be related to that. +> +> +> +>>begin work; +>>create table new_tab AS select * from tab; +>>truncate table tab; +>>insert into tab select * from new_tab; +>>drop table new_tab; +>>commit; +>>analyze tab; +>> +>>i havenot tried it but plan to do so. +>>but i feel insert would take ages to update +>>the indexes if any. +>> +>> +> +>It will have to update them, which will take time. +> +> +> +>>BTW +>> +>>is there any way to disable checks and triggers on +>>a table temporarily while loading data (is updating +>>reltriggers in pg_class safe?) +>> +>> +> +>You can take a look at pg_restore and copy how it does it. +> +> +> + + +--------------020309060308030400050407 +Content-Type: text/html; charset=us-ascii +Content-Transfer-Encoding: 7bit + + + + + + + + +
+
+I am running an update on the same table
+
+update rfis set inquiry_status='APPROVED' where inquiry_status='a';
+
+Its running for past 20 mins. and top output is below.
+The PID which is executing the query above is 6712. Can anyone
+tell me why it is in an uninterruptable sleep and does it relate
+to the apparent poor performance? Is it problem with the disk
+hardware. I know at nite this query will run reasonably fast.
+
+I am running on a decent hardware .
+
+
+
+Regds
+mallah.
+
+
+
+ 1:41pm  up 348 days, 21:10,  1 user,  load average: 11.59, 13.69, 11.49
+85 processes: 83 sleeping, 1 running, 0 zombie, 1 stopped
+CPU0 states:  8.1% user,  2.3% system,  0.0% nice, 89.0% idle
+CPU1 states:  3.3% user,  2.3% system,  0.0% nice, 93.2% idle
+CPU2 states:  7.4% user,  1.4% system,  0.0% nice, 90.0% idle
+CPU3 states:  9.3% user,  7.4% system,  0.0% nice, 82.2% idle
+Mem:  2064796K av, 2053964K used,   10832K free,       0K shrd,   +22288K buff
+Swap: 2048244K av,   88660K used, 1959584K free                 +1801532K cached
+
+  PID USER     PRI  NI  SIZE  RSS SHARE STAT %CPU %MEM   TIME COMMAND
+ 6712 postgres  16   0 86592  84M 83920 D    11.1  4.1   1:36 +postmaster
+13103 postgres  15   0 54584  53M 52556 S     3.5  2.6   0:01 postmaster
+13034 root      16   0  1072 1072   848 R     2.1  0.0   0:02 top
+13064 postgres  15   0 67256  65M 64516 D     2.1  3.2   0:01 postmaster
+13088 postgres  16   0 43324  42M 40812 D     2.1  2.0   0:00 postmaster
+13076 postgres  15   0 49016  47M 46628 S     1.9  2.3   0:00 postmaster
+26931 postgres  15   0 84880  82M 83888 S     1.7  4.1   3:52 postmaster
+13107 postgres  15   0 18400  17M 16488 S     1.5  0.8   0:00 postmaster
+13068 postgres  15   0 44632  43M 42324 D     1.3  2.1   0:00 postmaster
+13074 postgres  15   0 68852  67M 66508 D     1.3  3.3   0:00 postmaster
+13108 postgres  15   0 11692  11M 10496 S     1.3  0.5   0:00 postmaster
+13075 postgres  15   0 50860  49M 47680 S     1.1  2.4   0:04 postmaster
+13066 postgres  15   0 56112  54M 53724 S     0.9  2.7   0:01 postmaster
+13109 postgres  15   0 14528  14M 13272 S     0.9  0.7   0:00 postmaster
+24454 postgres  15   0  2532 2380  1372 S     0.7  0.1  11:58 postmaster
+   12 root      15   0     0    0     0 SW    0.5  0.0 816:30 bdflush
+24455 postgres  15   0  1600 1476  1380 S     0.5  0.0   9:11 postmaster
+12528 postgres  15   0 84676  82M 79920 S     0.3  4.0   0:02 postmaster
+12575 postgres  15   0 76660  74M 75796 D     0.3  3.7   0:09 postmaster
+13038 postgres  15   0 48952  47M 46436 D     0.3  2.3   0:00 postmaster
+13069 postgres  15   0 57464  56M 54852 S     0.3  2.7   0:00 postmaster
+13102 postgres  15   0 17864  17M 16504 D     0.3  0.8   0:00 postmaster
+
+

+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Richard Huxton wrote: +
+
On Thursday 15 April 2004 17:19, Rajesh Kumar Mallah wrote:
+  
+
+
Bill Moran wrote:
+    
+
+
Rajesh Kumar Mallah wrote:
+      
+
+
Hi,
+
+The problem was solved by reloading the Table.
+the query now takes only 3 seconds. But that is
+not a solution.
+        
+
+
If dropping/recreating the table improves things, then we can reasonably
+assume that the table is pretty active with updates/inserts.  Correct?
+      
+
+
Yes the table results from an import process and under goes lots
+of inserts and updates , but thats before the vacuum full operation.
+the table is not accessed during vacuum. What i want to know is
+is there any wat to automate the dumping and reload of a table
+individually. will the below be safe and effective:
+    
+
+

+Shouldn't be necessary assuming you vacuum (not full) regularly. However, 
+looking back at your original posting, the vacuum output doesn't seem to show 
+any rows that need removing.
+
+# VACUUM full verbose eyp_rfi;
+INFO:  vacuuming "public.eyp_rfi"
+INFO:  "eyp_rfi": found 0 removable, 505960 nonremovable row versions in 
+71987 pages
+DETAIL:  0 dead row versions cannot be removed yet.
+
+Since your select count(*) showed 505960 rows, I can't see how 
+dropping/replacing could make a difference on a sequential scan. Since we're 
+not using any indexes I don't see how it could be related to that.
+
+  
+
+
begin work;
+create table new_tab AS select * from tab;
+truncate table tab;
+insert into tab select * from new_tab;
+drop table new_tab;
+commit;
+analyze tab;
+
+i havenot tried it but plan to do so.
+but i feel insert would take ages to update
+the indexes if any.
+    
+
+

+It will have to update them, which will take time.
+
+  
+
+
BTW
+
+is there any way to disable checks and triggers on
+a table temporarily while loading data (is updating
+reltriggers in pg_class safe?)
+    
+
+

+You can take a look at pg_restore and copy how it does it.
+
+  
+
+
+ + + +--------------020309060308030400050407-- + +From pgsql-performance-owner@postgresql.org Fri Apr 16 07:13:59 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 80028D1E129 + for ; + Fri, 16 Apr 2004 07:13:58 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 48368-05 + for ; + Fri, 16 Apr 2004 07:13:56 -0300 (ADT) +Received: from email01.aon.at (warsl404pip8.highway.telekom.at [195.3.96.102]) + by svr1.postgresql.org (Postfix) with SMTP id 678BAD1E159 + for ; + Fri, 16 Apr 2004 07:13:56 -0300 (ADT) +Received: (qmail 327992 invoked from network); 16 Apr 2004 10:13:56 -0000 +Received: from m154p002.dipool.highway.telekom.at (HELO PASCAL) ([62.46.9.34]) + (envelope-sender ) + by qmail1rs.highway.telekom.at (qmail-ldap-1.03) with SMTP + for ; 16 Apr 2004 10:13:56 -0000 +From: Manfred Koizar +To: Tom Lane +Cc: Robert Treat , + pgsql-performance@postgresql.org +Subject: Re: query slows down with more accurate stats +Date: Fri, 16 Apr 2004 12:16:11 +0200 +Message-ID: +References: <1081879359.25537.526.camel@camel> + <25556.1081883922@sss.pgh.pa.us> + + <22642.1082074729@sss.pgh.pa.us> +In-Reply-To: <22642.1082074729@sss.pgh.pa.us> +X-Mailer: Forte Agent 1.93/32.576 English (American) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/203 +X-Sequence-Number: 6503 + +On Thu, 15 Apr 2004 20:18:49 -0400, Tom Lane wrote: +>> getting several tuples from the same page is more likely +>> than with the old method. +> +>Hm, are you sure? + +Almost sure. Let's look at a corner case: What is the probability of +getting a sample with no two tuples from the same page? To simplify the +problem assume that each page contains the same number of tuples c. + +If the number of pages is B and the sample size is n, a perfect sampling +method collects a sample where all tuples come from different pages with +probability (in OpenOffice.org syntax): + + p = prod from{i = 0} to{n - 1} {{c(B - i)} over {cB - i}} + +or in C: + + p = 1.0; + for (i = 0; i < n; ++i) + p *= c*(B - i) / (c*B - i) + +This probability grows with increasing B. + +>Also, I'm not at all sure that the old method satisfies that constraint +>completely in the presence of nonuniform numbers of tuples per page, +>so we'd not necessarily be going backwards anyhow ... + +Yes, it boils down to a decision whether we want to replace one not +quite perfect sampling method with another not quite perfect method. +I'm still working on putting together the pros and cons ... + +Servus + Manfred + +From pgsql-performance-owner@postgresql.org Fri Apr 16 10:03:30 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C5AE2D1B49B + for ; + Fri, 16 Apr 2004 10:03:29 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 04641-04 + for ; + Fri, 16 Apr 2004 10:03:27 -0300 (ADT) +Received: from mail2.aeccom.com (port-212-202-101-158.reverse.qsc.de + [212.202.101.158]) + by svr1.postgresql.org (Postfix) with ESMTP id 896D5D1B8B7 + for ; + Fri, 16 Apr 2004 10:03:25 -0300 (ADT) +Received: from aeccom.com (cayambe.core.aeccom.com [192.168.2.12]) + by mail2.aeccom.com (Postfix) with ESMTP + id 24A4259; Fri, 16 Apr 2004 15:03:28 +0200 (CEST) +Message-ID: <407FD9A0.6040608@aeccom.com> +Date: Fri, 16 Apr 2004 15:03:28 +0200 +From: =?ISO-8859-1?Q?Dirk_Lutzeb=E4ck?= +Organization: AEC/communications GmbH, Berlin +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031016 +X-Accept-Language: de, en +MIME-Version: 1.0 +To: Tom Lane , josh@agliodbs.com, + pgsql-performance@postgresql.org +Cc: Sven Geisler +Subject: RESOLVED: Re: Wierd context-switching issue on Xeon +References: <200311251419.36771.josh@agliodbs.com> + <200404150827.03950.josh@agliodbs.com> + <407EB5B0.3030706@aeccom.com> + <200404151039.17763.josh@agliodbs.com> + <407EE93F.3090705@aeccom.com> <21280.1082064326@sss.pgh.pa.us> + <407F9FE9.3060104@aeccom.com> <407FAF0F.2070304@aeccom.com> +In-Reply-To: <407FAF0F.2070304@aeccom.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/204 +X-Sequence-Number: 6504 + +Tom, Josh, + +I think we have the problem resolved after I found the following note +from Tom: + + > A large number of semops may mean that you have excessive contention +on some lockable + > resource, but I don't have enough info to guess what resource. + +This was the key to look at: we were missing all indices on table which +is used heavily and does lots of locking. After recreating the missing +indices the production system performed normal. No, more excessive +semop() calls, load way below 1.0, CS over 20.000 very rare, more in +thousands realm and less. + +This is quite a relief but I am sorry that the problem was so stupid and +you wasted some time although Tom said he had also seem excessive +semop() calls on another Dual XEON system. + +Hyperthreading was turned off so far but will be turned on again the +next days. I don't expect any problems then. + +I'm not sure if this semop() problem is still an issue but the database +behaves a bit out of bounds in this situation, i.e. consuming system +resources with semop() calls 95% while tables are locked very often and +longer. + +Thanks for your help, + +Dirk + +At last here is the current vmstat 1 excerpt where the problem has been +resolved: + + + +procs -----------memory---------- ---swap-- -----io---- --system-- +----cpu---- + r b swpd free buff cache si so bi bo in cs us sy +id wa + 1 0 2308 232508 201924 6976532 0 0 136 464 628 812 5 +1 94 0 + 0 0 2308 232500 201928 6976628 0 0 96 296 495 484 4 +0 95 0 + 0 1 2308 232492 201928 6976628 0 0 0 176 347 278 1 +0 99 0 + 0 0 2308 233484 201928 6976596 0 0 40 580 443 351 8 +2 90 0 + 1 0 2308 233484 201928 6976696 0 0 76 692 792 651 9 +2 88 0 + 0 0 2308 233484 201928 6976696 0 0 0 20 132 34 0 +0 100 0 + 0 0 2308 233484 201928 6976696 0 0 0 76 177 90 0 +0 100 0 + 0 1 2308 233484 201928 6976696 0 0 0 216 321 250 4 +0 96 0 + 0 0 2308 233484 201928 6976696 0 0 0 116 417 240 8 +0 92 0 + 0 0 2308 233484 201928 6976784 0 0 48 600 403 270 8 +0 92 0 + 0 0 2308 233464 201928 6976860 0 0 76 452 1064 2611 14 +1 84 0 + 0 0 2308 233460 201932 6976900 0 0 32 256 587 587 12 +1 87 0 + 0 0 2308 233460 201932 6976932 0 0 32 188 379 287 5 +0 94 0 + 0 0 2308 233460 201932 6976932 0 0 0 0 103 8 0 +0 100 0 + 0 0 2308 233460 201932 6976932 0 0 0 0 102 14 0 +0 100 0 + 0 1 2308 233444 201948 6976932 0 0 0 348 300 180 1 +0 99 0 + 1 0 2308 233424 201948 6976948 0 0 16 380 739 906 4 +2 93 0 + 0 0 2308 233424 201948 6977032 0 0 68 260 724 987 7 +0 92 0 + 0 0 2308 231924 201948 6977128 0 0 96 344 1130 753 11 +1 88 0 + 1 0 2308 231924 201948 6977248 0 0 112 324 687 628 3 +0 97 0 + 0 0 2308 231924 201948 6977248 0 0 0 192 575 430 5 +0 95 0 + 1 0 2308 231924 201948 6977248 0 0 0 264 208 124 0 +0 100 0 + 0 0 2308 231924 201948 6977264 0 0 16 272 380 230 3 +2 95 0 + 0 0 2308 231924 201948 6977264 0 0 0 0 104 8 0 +0 100 0 + 0 0 2308 231924 201948 6977264 0 0 0 48 258 92 1 +0 99 0 + 0 0 2308 231816 201948 6977484 0 0 212 268 456 384 2 +0 98 0 + 0 0 2308 231816 201948 6977484 0 0 0 88 453 770 0 +0 99 0 + 0 0 2308 231452 201948 6977680 0 0 196 476 615 676 5 +0 94 0 + 0 0 2308 231452 201948 6977680 0 0 0 228 431 400 2 +0 98 0 + 0 0 2308 231452 201948 6977680 0 0 0 0 237 58 3 +0 97 0 + 0 0 2308 231448 201952 6977680 0 0 0 0 365 84 2 +0 97 0 + 0 0 2308 231448 201952 6977680 0 0 0 40 246 108 1 +0 99 0 + 0 0 2308 231448 201952 6977776 0 0 96 352 606 1026 4 +2 94 0 + 0 0 2308 231448 201952 6977776 0 0 0 240 295 266 5 +0 95 0 + + + +From pgsql-performance-owner@postgresql.org Fri Apr 16 10:40:12 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B86FBD1BB93 + for ; + Fri, 16 Apr 2004 10:40:11 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 21839-03 + for ; + Fri, 16 Apr 2004 10:40:10 -0300 (ADT) +Received: from ECCMCBH.cmc.int.ec.gc.ca (ecdor130.cmc.ec.gc.ca + [199.212.17.130]) + by svr1.postgresql.org (Postfix) with ESMTP id E9F54D1B4BE + for ; + Fri, 16 Apr 2004 10:40:04 -0300 (ADT) +Received: by eccmcbh.cmc.ec.gc.ca with Internet Mail Service (5.5.2653.19) + id <2A89X7DM>; Fri, 16 Apr 2004 09:40:07 -0400 +Message-ID: +From: "Shea,Dan [CIS]" +To: 'Bill Moran' +Cc: Postgres Performance +Subject: Re: [ SOLVED ] select count(*) very slow on an already +Date: Fri, 16 Apr 2004 09:40:06 -0400 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2653.19) +Content-Type: text/plain +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/205 +X-Sequence-Number: 6505 + +Just a note, I was trying the cluster command and was short on space. I +figured I had enough space for the new table and index. It failed on me +twice. +The reason is that I noticed for the command to complete, it needed the +space of the new table and 2x the space of the new index. +It looks like it creates the new table, then a new index. Afterwards it +looked like it creates another index in the DB pgsql_tmp. So for me this is +an important consideration, since the new index size was about 7GB. +I had not anticipated the second index size so that is why it failed. I +ended up creating a link of pgsql_tmp to another parttion to successfully +complete. + +Dan. + +-----Original Message----- +From: Bill Moran [mailto:wmoran@potentialtech.com] +Sent: Thursday, April 15, 2004 4:14 PM +To: Shea,Dan [CIS] +Cc: Postgres Performance +Subject: Re: [PERFORM] [ SOLVED ] select count(*) very slow on an +already + + +Shea,Dan [CIS] wrote: +> Bill, if you had alot of updates and deletions and wanted to optimize your +> table, can you just issue the cluster command. +> Will the cluster command rewrite the table without the obsolete data that +a +> vacuum flags or do you need to issue a vacuum first? + + From the reference docs: + +"During the cluster operation, a temporary copy of the table is created that +contains the table data in the index order. Temporary copies of each index +on the table are created as well. Therefore, you need free space on disk at +least equal to the sum of the table size and the index sizes. + +"CLUSTER preserves GRANT, inheritance, index, foreign key, and other +ancillary +information about the table. + +"Because the optimizer records statistics about the ordering of tables, it +is +advisable to run ANALYZE on the newly clustered table. Otherwise, the +optimizer +may make poor choices of query plans." + +The primary reason CLUSTER exists is to allow you to physically reorder a +table +based on a key. This should provide a performance improvement if data with +the same key is accessed all at once. (i.e. if you do "SELECT * FROM table +WHERE +key=5" and it returns 100 rows, those 100 rows are guaranteed to be all on +the +same part of the disk after CLUSTER, thus a performance improvement should +result.) + +Updates and inserts will add data in the next available space in a table +with no +regard for any keys, and _may_ require running all over the disk to retrieve +the data in the previous example query. + +I doubt if CLUSTER is an end-all optimization tool. The specific reason I +suggested it was because the original poster was asking for an easier way to +drop/recreate a table (as prior experimentation had shown this to improve +performance) I can't think of anything easier than "CLUSTER ON +" + +Since CLUSTER recreates the table, it implicitly removes the dead tuples. +However, it's going to be a LOT slower than vacuum, so if dead tuples are +the +main problem, vacuum is still the way to go. + +-- +Bill Moran +Potential Technologies +http://www.potentialtech.com + +From pgsql-performance-owner@postgresql.org Fri Apr 16 10:49:41 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C5DC4D1B8B7 + for ; + Fri, 16 Apr 2004 10:49:39 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 15586-10 + for ; + Fri, 16 Apr 2004 10:49:39 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id E4621D1B515 + for ; + Fri, 16 Apr 2004 10:49:37 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3GDncmY028604; + Fri, 16 Apr 2004 09:49:38 -0400 (EDT) +To: =?ISO-8859-1?Q?Dirk_Lutzeb=E4ck?= +Cc: josh@agliodbs.com, pgsql-performance@postgresql.org, + Sven Geisler +Subject: Re: RESOLVED: Re: Wierd context-switching issue on Xeon +In-reply-to: <407FD9A0.6040608@aeccom.com> +References: <200311251419.36771.josh@agliodbs.com> + <200404150827.03950.josh@agliodbs.com> + <407EB5B0.3030706@aeccom.com> + <200404151039.17763.josh@agliodbs.com> + <407EE93F.3090705@aeccom.com> <21280.1082064326@sss.pgh.pa.us> + <407F9FE9.3060104@aeccom.com> <407FAF0F.2070304@aeccom.com> + <407FD9A0.6040608@aeccom.com> +Comments: In-reply-to =?ISO-8859-1?Q?Dirk_Lutzeb=E4ck?= + message dated "Fri, 16 Apr 2004 15:03:28 +0200" +Date: Fri, 16 Apr 2004 09:49:38 -0400 +Message-ID: <28603.1082123378@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/206 +X-Sequence-Number: 6506 + +=?ISO-8859-1?Q?Dirk_Lutzeb=E4ck?= writes: +> This was the key to look at: we were missing all indices on table which +> is used heavily and does lots of locking. After recreating the missing +> indices the production system performed normal. No, more excessive +> semop() calls, load way below 1.0, CS over 20.000 very rare, more in +> thousands realm and less. + +Hmm ... that's darn interesting. AFAICT the test case I am looking at +for Josh's client has no such SQL-level problem ... but I will go back +and double check ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Apr 16 11:34:55 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 447A6D1B4B2 + for ; + Fri, 16 Apr 2004 11:34:54 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 42366-02 + for ; + Fri, 16 Apr 2004 11:34:52 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id E1FADD1E106 + for ; + Fri, 16 Apr 2004 11:34:50 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3GEYoLm029061; + Fri, 16 Apr 2004 10:34:50 -0400 (EDT) +To: Manfred Koizar +Cc: Robert Treat , + pgsql-performance@postgresql.org +Subject: Re: query slows down with more accurate stats +In-reply-to: +References: <1081879359.25537.526.camel@camel> + <25556.1081883922@sss.pgh.pa.us> + + <22642.1082074729@sss.pgh.pa.us> + +Comments: In-reply-to Manfred Koizar + message dated "Fri, 16 Apr 2004 12:16:11 +0200" +Date: Fri, 16 Apr 2004 10:34:49 -0400 +Message-ID: <29060.1082126089@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/207 +X-Sequence-Number: 6507 + +Manfred Koizar writes: +> If the number of pages is B and the sample size is n, a perfect sampling +> method collects a sample where all tuples come from different pages with +> probability (in OpenOffice.org syntax): +> p = prod from{i = 0} to{n - 1} {{c(B - i)} over {cB - i}} + +So? You haven't proven that either sampling method fails to do the +same. + +The desired property can also be phrased as "every tuple should be +equally likely to be included in the final sample". What we actually +have in the case of your revised algorithm is "every page is equally +likely to be sampled, and of the pages included in the sample, every +tuple is equally likely to be chosen". Given that there are B total +pages of which we sample b pages that happen to contain T tuples (in any +distribution), the probability that a particular tuple gets chosen is + (b/B) * (n/T) +assuming that the two selection steps are independent and unbiased. + +Now b, B, and n are not dependent on which tuple we are talking about. +You could argue that a tuple on a heavily populated page is +statistically likely to see a higher T when it's part of the page sample +pool than a tuple on a near-empty page is likely to see, and therefore +there is some bias against selection of the former tuple. But given a +sample over a reasonably large number of pages, the contribution of any +one page to T should be fairly small and so this effect ought to be +small. In fact, because T directly determines our estimate of the total +number of tuples in the relation, your experiments showing that the new +method gives a reliable tuple count estimate directly prove that T is +pretty stable regardless of exactly which pages get included in the +sample. So I think this method is effectively unbiased at the tuple +level. The variation in probability of selection of individual tuples +can be no worse than the variation in the overall tuple count estimate. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Apr 16 12:17:16 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 89691D1E96D + for ; + Fri, 16 Apr 2004 12:17:14 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 51321-08 + for ; + Fri, 16 Apr 2004 12:17:08 -0300 (ADT) +Received: from flake.decibel.org (flake.decibel.org [66.143.173.58]) + by svr1.postgresql.org (Postfix) with SMTP id 98BA2D1E970 + for ; + Fri, 16 Apr 2004 12:17:07 -0300 (ADT) +Received: (qmail 45700 invoked by uid 1001); 16 Apr 2004 15:17:06 -0000 +Date: Fri, 16 Apr 2004 10:17:06 -0500 +From: "Jim C. Nasby" +To: pgsql-performance@postgresql.org +Subject: Poor performance of group by query +Message-ID: <20040416151706.GE87362@nasby.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +X-Operating-System: FreeBSD 4.9-RELEASE-p3 i386 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/208 +X-Sequence-Number: 6508 + +Anyone have any ideas why this query would be so slow? + +stats=# explain analyze SELECT work_units, min(raw_rank) AS rank FROM Trank_work_overall GROUP BY work_units; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------- + HashAggregate (cost=1050.12..1085.98 rows=14347 width=16) (actual time=163149.981..163227.758 rows=17849 loops=1) + -> Seq Scan on trank_work_overall (cost=0.00..804.41 rows=49141 width=16) (actual time=0.071..328.682 rows=49091 loops=1) + Total runtime: 163296.212 ms + +(3 rows) + +stats=# \d Trank_work_overall +Table "pg_temp_1.trank_work_overall" + Column | Type | Modifiers +------------+--------+----------- + raw_rank | bigint | + work_units | bigint | + +stats=# + +FreeBSD fritz.distributed.net 5.2.1-RELEASE FreeBSD 5.2.1-RELEASE #1: +Wed Apr 7 18:42:52 CDT 2004 +root@fritz.distributed.net:/usr/obj/usr/src/sys/FRITZ amd64 + +The machine is a dual opteron with 4G of memory. The query in question +was not hitting the disk at all. PostgreSQL 7.4.2 compiled with -O3. + +Also, if I set enable_hashagg = false, it runs in less than a second. +-- +Jim C. Nasby, Database Consultant jim@nasby.net +Member: Triangle Fraternity, Sports Car Club of America +Give your computer some brain candy! www.distributed.net Team #1828 + +Windows: "Where do you want to go today?" +Linux: "Where do you want to go tomorrow?" +FreeBSD: "Are you guys coming, or what?" + +From pgsql-performance-owner@postgresql.org Fri Apr 16 12:28:09 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 78652D1B8DF + for ; + Fri, 16 Apr 2004 12:28:08 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 62499-03 + for ; + Fri, 16 Apr 2004 12:28:00 -0300 (ADT) +Received: from mail.vistashare.com (www.vistashare.net [65.207.67.162]) + by svr1.postgresql.org (Postfix) with ESMTP id 1FA36D1B4B2 + for ; + Fri, 16 Apr 2004 12:28:04 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mail.vistashare.com (Postfix) with ESMTP id 770581180 + for ; + Fri, 16 Apr 2004 11:28:01 -0400 (EDT) +From: Chris Kratz +Organization: VistaShare +To: pgsql-performance@postgresql.org +Subject: Long running queries degrade performance +Date: Fri, 16 Apr 2004 11:28:00 -0400 +User-Agent: KMail/1.6.2 +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +Message-Id: <200404161128.00851.chris.kratz@vistashare.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/209 +X-Sequence-Number: 6509 + +Hello all, + +My apologies if this is not the right mailing list to ask this question, but +we are wondering about general performance tuning principles for our main db +server. + +We have a web app with a postgres backend. Most queries have subsecond +response times through the web even with high usage. Every once in awhile +someone will run either an ad-hoc query or some other long running db +process. For some reason, it seems that a small number 3-4 of these jobs +running in parallel absolutely floors our server. In monitoring the jobs, +linux (Kernel 2.4) drops the long running jobs priority, but even so they +seem to hog the system resources making subsequent requests for everyone else +very slow. Our database at this point is almost entirely processor and +memory bound because it isn't too large to fit most of the working data into +memory yet. There is generally little disk activity when this occurs. + +These long running processes are almost always complex select statements, not +generally inserts or updates. We continue to monitor and rework the +bottlenecks, but what is a little scary to us is how easily the database +becomes almost completely unresponsive with several large jobs running, +especially since we have a large number of users. And it only takes one user +trying to view a page with one of these selects clicking multiple times +because it doesn't come back quickly to bring our system to it's knees for +hours. + +We are looking to move to Kernel 2.6 and possibly a dedicated multiprocessor +machine for postgres towards the end of this year. But, I am wondering if +there is anything we can do now to increase the interactive performance while +there are long running selects running as well. Are there ways to adjust the +priority of backend processes, or things to tweak to maximize interactive +throughput for the quick jobs while the long running ones run in the +background? Or if worse comes to worse to actually kill long running +processes without taking down the whole db as we have had to do on occasion. + +Our server is a modest 2.4Ghz P4 with mirrored UW SCSI drives and 1G of +memory. The db on disk is around 800M and this machine also hosts our web +app, so there is some contention for the processor. + +Does anyone have any suggestions or thoughts on things we could look at? Is a +multiprocessor box the only answer, or are there other things we should be +looking at hardware wise. Thank you for your time. +-- +Chris Kratz +Systems Analyst/Programmer +VistaShare LLC +www.vistashare.com + +From pgsql-performance-owner@postgresql.org Fri Apr 16 12:37:25 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9D39BD1D08C + for ; + Fri, 16 Apr 2004 12:37:23 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 58571-09 + for ; + Fri, 16 Apr 2004 12:37:17 -0300 (ADT) +Received: from bramble.mmrd.com (unknown [65.217.53.66]) + by svr1.postgresql.org (Postfix) with ESMTP id 561F0D1D085 + for ; + Fri, 16 Apr 2004 12:37:21 -0300 (ADT) +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 i3GFeYcM009750; + Fri, 16 Apr 2004 11:40:35 -0400 +Received: from gnvex001.mmrd.com (gnvex001.mmrd.com [192.168.3.55]) + by thorn.mmrd.com (8.11.6/8.11.6) with ESMTP id i3GFbFl10132; + Fri, 16 Apr 2004 11:37:17 -0400 +Received: from camel.mmrd.com ([172.25.5.213]) by gnvex001.mmrd.com with SMTP + (Microsoft Exchange Internet Mail Service Version 5.5.2657.72) + id FVMA9Y9C; Fri, 16 Apr 2004 11:37:13 -0400 +Subject: Re: query slows down with more accurate stats +From: Robert Treat +To: Tom Lane +Cc: pgsql-performance@postgresql.org +In-Reply-To: <25556.1081883922@sss.pgh.pa.us> +References: <1081879359.25537.526.camel@camel> + <25556.1081883922@sss.pgh.pa.us> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +X-Mailer: Ximian Evolution 1.0.8 +Date: 16 Apr 2004 11:37:15 -0400 +Message-Id: <1082129835.23419.869.camel@camel> +Mime-Version: 1.0 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/210 +X-Sequence-Number: 6510 + +On Tue, 2004-04-13 at 15:18, Tom Lane wrote: +> Robert Treat writes: +> Well, the first problem is why is ANALYZE's estimate of the total row +> count so bad :-( ? I suspect you are running into the situation where +> the initial pages of the table are thinly populated and ANALYZE +> mistakenly assumes the rest are too. + +That was my thinking, which is somewhat confirmed after a vacuum full on +the table; now analyze gives pretty accurate states. Of course the +downside is that now the query is consistently slower. + +> > so i guess i am wondering if there is something I should be doing to +> > help get the better plan at the more accurate stats levels and/or why it +> > doesn't stick with the original plan (I noticed disabling merge joins +> > does seem to push it back to the original plan). +> +> With the larger number of estimated rows it's figuring the nestloop will +> be too expensive. The row estimate for the cl scan went up from 1248 +> to 10546, so the estimated cost for the nestloop plan would go to about +> 240000 units vs 80000 for the mergejoin plan. This is obviously off +> rather badly when the true runtimes are 1.7 vs 8.1 seconds :-(. +> +> I think this is an example of a case where we really need better +> estimation of nestloop costs --- it's drastically overestimating the +> relative cost of the nestloop because it's not accounting for the cache +> benefits of the repeated index searches. You could probably force the +> nestloop to be chosen by lowering random_page_cost, but that's just a +> kluge solution ... the real problem is the model is wrong. +> + +Unfortunately playing with random_page_cost doesn't seem to be enough to +get it to favor the nested loop... though setting it down to 2 does help +overall. played with index_cpu_tuple_cost a bit but that seemed even +less useful. aggravating when you know there is a better plan it could +pick but no (clean) way to get it to do so... + +> I have a to-do item to work on this, and will try to bump up its +> priority a bit. +> + +I'll keep an eye out, thanks Tom. + + +Robert Treat +-- +Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL + + +From pgsql-performance-owner@postgresql.org Fri Apr 16 12:45:13 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2A4FED1E95F + for ; + Fri, 16 Apr 2004 12:45:10 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 67660-07 + for ; + Fri, 16 Apr 2004 12:44:59 -0300 (ADT) +Received: from flake.decibel.org (flake.decibel.org [66.143.173.58]) + by svr1.postgresql.org (Postfix) with SMTP id E9431D1DACE + for ; + Fri, 16 Apr 2004 12:45:02 -0300 (ADT) +Received: (qmail 47123 invoked by uid 1001); 16 Apr 2004 15:45:02 -0000 +Date: Fri, 16 Apr 2004 10:45:02 -0500 +From: "Jim C. Nasby" +To: pgsql-performance@postgresql.org +Subject: Horribly slow hash join +Message-ID: <20040416154502.GF87362@nasby.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +X-Operating-System: FreeBSD 4.9-RELEASE-p3 i386 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/211 +X-Sequence-Number: 6511 + +Note the time for the hash join step: + + +------------------------------------------------------------------------------------------------------------------------------------------ + Hash Join (cost=357.62..26677.99 rows=93668 width=62) (actual time=741.159..443381.011 rows=49091 loops=1) + Hash Cond: ("outer".work_today = "inner".work_units) + -> Hash Join (cost=337.11..24784.11 rows=93668 width=54) (actual time=731.374..417188.519 rows=49091 loops=1) + Hash Cond: ("outer".work_total = "inner".work_units) + -> Seq Scan on email_rank (cost=0.00..22240.04 rows=254056 width=46) (actual time=582.145..1627.759 rows=49091 loops=1) + Filter: (project_id = 8) + -> Hash (cost=292.49..292.49 rows=17849 width=16) (actual time=148.944..148.944 rows=0 loops=1) + -> Seq Scan on rank_tie_overall o (cost=0.00..292.49 rows=17849 width=16) (actual time=0.059..75.984 rows=17849 loops=1) + -> Hash (cost=17.81..17.81 rows=1081 width=16) (actual time=8.996..8.996 rows=0 loops=1) + -> Seq Scan on rank_tie_today d (cost=0.00..17.81 rows=1081 width=16) (actual time=0.080..4.635 rows=1081 loops=1) + Total runtime: 619047.032 ms + +By comparison: +stats=# set enable_hashjoin=false; +SET +stats=# explain analyze select * from email_rank, rank_tie_overall o, rank_tie_today d WHERE email_rank.work_today = d.work_units AND email_rank.work_total = o.work_units AND email_rank.project_id = :ProjectID; + QUERY PLAN +--------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Merge Join (cost=55391.69..56823.23 rows=93668 width=80) (actual time=2705.344..3349.318 rows=49091 loops=1) + Merge Cond: ("outer".work_units = "inner".work_today) + -> Index Scan using work_units_today on rank_tie_today d (cost=0.00..23.89 rows=1081 width=16) (actual time=0.150..4.874 rows=1081 loops=1) + -> Sort (cost=55391.69..55625.86 rows=93668 width=64) (actual time=2705.153..2888.039 rows=49091 loops=1) + Sort Key: email_rank.work_today + -> Merge Join (cost=45047.64..47656.93 rows=93668 width=64) (actual time=1685.414..2494.342 rows=49091 loops=1) + Merge Cond: ("outer".work_units = "inner".work_total) + -> Index Scan using work_units_overall on rank_tie_overall o (cost=0.00..361.34 rows=17849 width=16) (actual time=0.122..79.383 rows=17849 loops=1) + -> Sort (cost=45047.64..45682.78 rows=254056 width=48) (actual time=1685.228..1866.215 rows=49091 loops=1) + Sort Key: email_rank.work_total + -> Seq Scan on email_rank (cost=0.00..22240.04 rows=254056 width=48) (actual time=786.515..1289.101 rows=49091 loops=1) + Filter: (project_id = 8) + Total runtime: 3548.087 ms + +Even though the second case is only a select, it seems clear that +something's wrong... +-- +Jim C. Nasby, Database Consultant jim@nasby.net +Member: Triangle Fraternity, Sports Car Club of America +Give your computer some brain candy! www.distributed.net Team #1828 + +Windows: "Where do you want to go today?" +Linux: "Where do you want to go tomorrow?" +FreeBSD: "Are you guys coming, or what?" + +From pgsql-performance-owner@postgresql.org Fri Apr 16 12:46:13 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DED26D1E96F + for ; + Fri, 16 Apr 2004 12:46:09 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 70059-08 + for ; + Fri, 16 Apr 2004 12:46:03 -0300 (ADT) +Received: from gw.tssi.com (gw.tssi.com [198.147.197.1]) + by svr1.postgresql.org (Postfix) with ESMTP id 4A4C1D1E96C + for ; + Fri, 16 Apr 2004 12:46:07 -0300 (ADT) +Received: from gw.tssi.com (nolan@gw.tssi.com [127.0.0.1] (may be forged)) + by gw.tssi.com (8.12.6/8.12.6) with ESMTP id i3GFk48S010495; + Fri, 16 Apr 2004 10:46:05 -0500 +Received: (from nolan@localhost) + by gw.tssi.com (8.12.6/8.12.6/Submit) id i3GFk3p3010490; + Fri, 16 Apr 2004 10:46:03 -0500 +From: Mike Nolan +Message-Id: <200404161546.i3GFk3p3010490@gw.tssi.com> +Subject: Re: Long running queries degrade performance +To: chris.kratz@vistashare.com (Chris Kratz) +Date: Fri, 16 Apr 2004 10:46:02 -0500 (CDT) +Cc: pgsql-performance@postgresql.org +In-Reply-To: <200404161128.00851.chris.kratz@vistashare.com> from "Chris + Kratz" at Apr 16, 2004 11:28:00 AM +X-Mailer: ELM [version 2.5 PL3] +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/212 +X-Sequence-Number: 6512 + +> We have a web app with a postgres backend. Most queries have subsecond +> response times through the web even with high usage. Every once in awhile +> someone will run either an ad-hoc query or some other long running db +> process. + +Are you sure it is postgres where the delay is occurring? I ask this +because I also have a web-based front end to postgres, and while most of +the time the queries respond in about a second every now and then I see +one that takes much longer, sometimes 10-15 seconds. + +I've seen this behavior on both my development system and on the +production server. + +The same query a while later might respond quickly again. + +I'm not sure where to look for the delay, either, and it is intermittent +enough that I'm not even sure what monitoring techniques to use. +-- +Mike Nolan + +From pgsql-performance-owner@postgresql.org Fri Apr 16 13:34:18 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DB0F2D1E17E + for ; + Fri, 16 Apr 2004 13:34:14 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 90550-02 + for ; + Fri, 16 Apr 2004 13:34:09 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 0B994D1DB0A + for ; + Fri, 16 Apr 2004 13:34:13 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3GGYBfq000451; + Fri, 16 Apr 2004 12:34:12 -0400 (EDT) +To: "Jim C. Nasby" +Cc: pgsql-performance@postgresql.org +Subject: Re: Horribly slow hash join +In-reply-to: <20040416154502.GF87362@nasby.net> +References: <20040416154502.GF87362@nasby.net> +Comments: In-reply-to "Jim C. Nasby" + message dated "Fri, 16 Apr 2004 10:45:02 -0500" +Date: Fri, 16 Apr 2004 12:34:11 -0400 +Message-ID: <450.1082133251@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/213 +X-Sequence-Number: 6513 + +"Jim C. Nasby" writes: +> Note the time for the hash join step: + +Have you ANALYZEd these tables lately? + +It looks to me like it's hashing on some column that has only a small +number of distinct values, so that the hash doesn't actually help to +avoid comparisons. The planner should know better than to choose such +a plan, but if it's working with obsolete stats ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Apr 16 13:37:04 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B0412D1E95F + for ; + Fri, 16 Apr 2004 13:37:00 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 91508-02 + for ; + Fri, 16 Apr 2004 13:36:55 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id D4A94D1E95D + for ; + Fri, 16 Apr 2004 13:36:58 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3GGavuh000478; + Fri, 16 Apr 2004 12:36:57 -0400 (EDT) +To: "Jim C. Nasby" +Cc: pgsql-performance@postgresql.org +Subject: Re: Poor performance of group by query +In-reply-to: <20040416151706.GE87362@nasby.net> +References: <20040416151706.GE87362@nasby.net> +Comments: In-reply-to "Jim C. Nasby" + message dated "Fri, 16 Apr 2004 10:17:06 -0500" +Date: Fri, 16 Apr 2004 12:36:57 -0400 +Message-ID: <477.1082133417@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/214 +X-Sequence-Number: 6514 + +"Jim C. Nasby" writes: +> Anyone have any ideas why this query would be so slow? + +That seems very bizarre. Would you be willing to send me a dump of the +table off-list? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Apr 16 13:40:35 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B934AD1E928 + for ; + Fri, 16 Apr 2004 13:40:34 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 86690-07 + for ; + Fri, 16 Apr 2004 13:40:24 -0300 (ADT) +Received: from silmaril.syscor.priv (h24-108-208-253.sbm.shawcable.net + [24.108.208.253]) + by svr1.postgresql.org (Postfix) with ESMTP id 96F6BD1E298 + for ; + Fri, 16 Apr 2004 13:40:26 -0300 (ADT) +Received: from syscor.com (strider.syscor.priv [192.168.1.3]) + by silmaril.syscor.priv (8.12.8/8.12.8) with ESMTP id i3GGeZXR016250 + for ; Fri, 16 Apr 2004 09:40:36 -0700 +Message-ID: <40800CC2.3050707@syscor.com> +Date: Fri, 16 Apr 2004 09:41:38 -0700 +From: Ron St-Pierre +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.4) Gecko/20030624 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Index Problem? +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/215 +X-Sequence-Number: 6515 + +I am using postgres 7.4.1 and have a problem with a plpgsql function. +When I run the function on the production server it takes approx 33 +minutes to run. I dumped the DB and copied it to a similarly configured +box and ran the function and it ran in about 10 minutes. Can anyone +offer advice on tuning the function or my database? Here are the +lengthy, gory details. + +F u n c t i o n +It updates seven columns of a table 1 to 4 times daily. Current data = +42,000 rows, new data = 30,000 rows. + + CREATE TYPE employeeType AS (empID INTEGER, updateDate DATE, bDate +INTEGER, val1 NUMERIC, val2 NUMERIC, val3 NUMERIC, val4 NUMERIC, favNum +NUMERIC); + + CREATE OR REPLACE FUNCTION updateEmployeeData() RETURNS SETOF +employeeType AS ' + DECLARE + rec RECORD; + BEGIN + FOR rec IN SELECT empID, updateDate, bDate, val1, val2 , +val3, val4, favNum FROM newData LOOP + RETURN NEXT rec; + UPDATE currentData SET val1=rec.val1, val2=rec.val2, +val3=rec.val2, val4=rec.val4, favNum=rec.favNum, updateDate=rec.updateDate + WHERE empID=rec.empID; + END LOOP; + RETURN; + END; + ' LANGUAGE 'plpgsql'; + +The emp table has 60 columns, all indexed, about two-thirds are numeric, +but they are not affected by this update. The other 50+ columns are +updated in the middle of the night and the amount of time that update +takes isn't a concern. + +Late last night I dumped the table, dropped it and re-created it from +the dump (on the production server - when no one was looking). When I +re-ran the function it took almost 11 minutes, which was pretty much in +line with my results from the dev server. + +D e t a i l s +v 7.4.1 +Debian stable +1 GB ram +shared_buffers = 2048 +sort_mem = 1024 +SHMMAX 360000000 (360,000,000) +VACUUM FULL ANALYZE is run every night, and I ran it yesterday between +running the function and it made no difference in running time. +top shows the postmaster using minimal cpu (0-40%) and miniscule memory. +vmstat shows a fair amount of IO (bo=1000->4000). + +Yesterday on the dev server we upgraded to the 2.6 kernel and +unfortunately only noticed a small increase in update time (about one +minute). +So does anyone have any suggestions for me on speeding this up? Is it +the index? The function is run daily during the mid afternoon to early +evening and really drags the performance of the server down (it also +hosts a web site). + +Thanks +Ron + + + +From pgsql-performance-owner@postgresql.org Fri Apr 16 13:46:49 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D0BEED1E947 + for ; + Fri, 16 Apr 2004 13:46:47 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 84539-10 + for ; + Fri, 16 Apr 2004 13:46:42 -0300 (ADT) +Received: from flake.decibel.org (flake.decibel.org [66.143.173.58]) + by svr1.postgresql.org (Postfix) with SMTP id 141F8D1E8AD + for ; + Fri, 16 Apr 2004 13:46:45 -0300 (ADT) +Received: (qmail 50223 invoked by uid 1001); 16 Apr 2004 16:46:44 -0000 +Date: Fri, 16 Apr 2004 11:46:44 -0500 +From: "Jim C. Nasby" +To: Tom Lane +Cc: pgsql-performance@postgresql.org +Subject: Re: Horribly slow hash join +Message-ID: <20040416164644.GH87362@nasby.net> +References: <20040416154502.GF87362@nasby.net> <450.1082133251@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <450.1082133251@sss.pgh.pa.us> +X-Operating-System: FreeBSD 4.9-RELEASE-p3 i386 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/216 +X-Sequence-Number: 6516 + +Yes, stats are up to date, and the values should be fairly unique. + +Combined with the hash aggregate problem I saw (see my other email to +the list), do you think there could be some issue with the performance +of the hash function on FreeBSD 5.2 on AMD64? + +I'll post the table you requested someplace you can grab it. + +On Fri, Apr 16, 2004 at 12:34:11PM -0400, Tom Lane wrote: +> "Jim C. Nasby" writes: +> > Note the time for the hash join step: +> +> Have you ANALYZEd these tables lately? +> +> It looks to me like it's hashing on some column that has only a small +> number of distinct values, so that the hash doesn't actually help to +> avoid comparisons. The planner should know better than to choose such +> a plan, but if it's working with obsolete stats ... +> +> regards, tom lane +> + +-- +Jim C. Nasby, Database Consultant jim@nasby.net +Member: Triangle Fraternity, Sports Car Club of America +Give your computer some brain candy! www.distributed.net Team #1828 + +Windows: "Where do you want to go today?" +Linux: "Where do you want to go tomorrow?" +FreeBSD: "Are you guys coming, or what?" + +From pgsql-performance-owner@postgresql.org Fri Apr 16 13:57:57 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 79C9BD1CCCC + for ; + Fri, 16 Apr 2004 13:57:56 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 95481-04 + for ; + Fri, 16 Apr 2004 13:57:51 -0300 (ADT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 31332D1C9C8 + for ; + Fri, 16 Apr 2004 13:57:54 -0300 (ADT) +Received: from [64.81.245.111] (HELO 192.168.1.102) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4875295; Fri, 16 Apr 2004 09:59:17 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Dirk =?iso-8859-1?q?Lutzeb=E4ck?= , + Tom Lane , pgsql-performance@postgresql.org +Subject: Re: RESOLVED: Re: Wierd context-switching issue on Xeon +Date: Fri, 16 Apr 2004 09:58:14 -0700 +User-Agent: KMail/1.5.4 +Cc: Sven Geisler +References: <200311251419.36771.josh@agliodbs.com> + <407FAF0F.2070304@aeccom.com> <407FD9A0.6040608@aeccom.com> +In-Reply-To: <407FD9A0.6040608@aeccom.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200404160958.14902.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/217 +X-Sequence-Number: 6517 + +Dirk, + +> I'm not sure if this semop() problem is still an issue but the database +> behaves a bit out of bounds in this situation, i.e. consuming system +> resources with semop() calls 95% while tables are locked very often and +> longer. + +It would be helpful to us if you could test this with the indexes disabled on +the non-Bigmem system. I'd like to eliminate Bigmem as a factor, if +possible. + +-- +-Josh Berkus + +______AGLIO DATABASE SOLUTIONS___________________________ + Josh Berkus + Enterprise vertical business josh@agliodbs.com + and data analysis solutions (415) 752-2387 + and database optimization fax 651-9224 + utilizing Open Source technology San Francisco + + +From pgsql-performance-owner@postgresql.org Fri Apr 16 14:01:44 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D6F5AD1CCCC + for ; + Fri, 16 Apr 2004 14:01:42 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 00364-01 + for ; + Fri, 16 Apr 2004 14:01:36 -0300 (ADT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 4423CD1B515 + for ; + Fri, 16 Apr 2004 14:01:39 -0300 (ADT) +Received: from [64.81.245.111] (HELO 192.168.1.102) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4875322; Fri, 16 Apr 2004 10:03:02 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Ron St-Pierre , + pgsql-performance@postgresql.org +Subject: Re: Index Problem? +Date: Fri, 16 Apr 2004 10:01:52 -0700 +User-Agent: KMail/1.5.4 +References: <40800CC2.3050707@syscor.com> +In-Reply-To: <40800CC2.3050707@syscor.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200404161001.52989.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/218 +X-Sequence-Number: 6518 + +Ron, + +> The emp table has 60 columns, all indexed, about two-thirds are numeric, +> but they are not affected by this update. The other 50+ columns are +> updated in the middle of the night and the amount of time that update +> takes isn't a concern. + +Well, I'd say that you have an application design problem, but that's not what +you asked for help with ;-) + +> Late last night I dumped the table, dropped it and re-created it from +> the dump (on the production server - when no one was looking). When I +> re-ran the function it took almost 11 minutes, which was pretty much in +> line with my results from the dev server. + +Sounds like you need to run a REINDEX on the table -- and after that, +dramatically increase your max_fsm_pages, and run lazy VACUUM immediately +after the batch update to clean up. + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Fri Apr 16 14:05:05 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8036CD1E0D8 + for ; + Fri, 16 Apr 2004 14:05:02 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 97634-08 + for ; + Fri, 16 Apr 2004 14:04:56 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 4C980D1DB0A + for ; + Fri, 16 Apr 2004 14:04:59 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3GH4wk7000809; + Fri, 16 Apr 2004 13:04:58 -0400 (EDT) +To: "Jim C. Nasby" +Cc: pgsql-performance@postgresql.org +Subject: Re: Horribly slow hash join +In-reply-to: <20040416164644.GH87362@nasby.net> +References: <20040416154502.GF87362@nasby.net> <450.1082133251@sss.pgh.pa.us> + <20040416164644.GH87362@nasby.net> +Comments: In-reply-to "Jim C. Nasby" + message dated "Fri, 16 Apr 2004 11:46:44 -0500" +Date: Fri, 16 Apr 2004 13:04:58 -0400 +Message-ID: <808.1082135098@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/219 +X-Sequence-Number: 6519 + +"Jim C. Nasby" writes: +> Combined with the hash aggregate problem I saw (see my other email to +> the list), do you think there could be some issue with the performance +> of the hash function on FreeBSD 5.2 on AMD64? + +Yeah, I was wondering about that too. Hard to imagine what though. +The hash function should be pretty platform-independent. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Apr 16 14:52:27 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E3E07D1B515 + for ; + Fri, 16 Apr 2004 14:52:24 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 12369-06 + for ; + Fri, 16 Apr 2004 14:52:19 -0300 (ADT) +Received: from ECCMCBH.cmc.int.ec.gc.ca (ecdor130.cmc.ec.gc.ca + [199.212.17.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 6C738D1E98D + for ; + Fri, 16 Apr 2004 14:52:16 -0300 (ADT) +Received: by eccmcbh.cmc.ec.gc.ca with Internet Mail Service (5.5.2653.19) + id <2A89YQS2>; Fri, 16 Apr 2004 13:52:16 -0400 +Message-ID: +From: "Shea,Dan [CIS]" +To: 'Rajesh Kumar Mallah' +Cc: Postgres Performance +Subject: Re: Deleting certain duplicates +Date: Fri, 16 Apr 2004 13:52:15 -0400 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2653.19) +Content-Type: text/plain; + charset="iso-8859-1" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/220 +X-Sequence-Number: 6520 + +Thanks Mallah, +I will keep this example in case I need it again sometime in the future. +Unfortunately, I do not have enough free space at the moment to create a +temp table. + +Dan + +-----Original Message----- +From: Rajesh Kumar Mallah [mailto:mallah@trade-india.com] +Sent: Tuesday, April 13, 2004 10:27 AM +To: Shea,Dan [CIS] +Cc: Postgres Performance +Subject: Re: [PERFORM] Deleting certain duplicates + + +Shea,Dan [CIS] wrote: + +>The index is +>Indexes: +> "forecastelement_rwv_idx" btree (region_id, wx_element, valid_time) +> +>-----Original Message----- +>From: Shea,Dan [CIS] [mailto:Dan.Shea@ec.gc.ca] +>Sent: Monday, April 12, 2004 10:39 AM +>To: Postgres Performance +>Subject: [PERFORM] Deleting certain duplicates +> +> +>We have a large database which recently increased dramatically due to a +>change in our insert program allowing all entries. +>PWFPM_DEV=# select relname,relfilenode,reltuples from pg_class where +relname +>= 'forecastelement'; +> relname | relfilenode | reltuples +>-----------------+-------------+------------- +> forecastelement | 361747866 | 4.70567e+08 +> +> Column | Type | Modifiers +>----------------+-----------------------------+----------- +> version | character varying(99) | +> origin | character varying(10) | +> timezone | character varying(99) | +> region_id | character varying(20) | +> wx_element | character varying(99) | +> value | character varying(99) | +> flag | character(3) | +> units | character varying(99) | +> valid_time | timestamp without time zone | +> issue_time | timestamp without time zone | +> next_forecast | timestamp without time zone | +> reception_time | timestamp without time zone | +> +>The program is supposed to check to ensure that all fields but the +>reception_time are unique using a select statement, and if so, insert it. +>Due an error in a change, reception time was included in the select to +check +>for duplicates. The reception_time is created by a program creating the +dat +>file to insert. +>Essentially letting all duplicate files to be inserted. +> +>I tried the delete query below. +>PWFPM_DEV=# delete from forecastelement where oid not in (select min(oid) +>from forecastelement group by +>version,origin,timezone,region_id,wx_element,value,flag,units,valid_time,is +s +>ue_time,next_forecast); +>It ran for 3 days creating what I assume is an index in pgsql_tmp of the +>group by statement. +>The query ended up failing with "dateERROR:write failed". +>Well the long weekend is over and we do not have the luxury of trying this +>again. +>So I was thinking maybe of doing the deletion in chunks, perhaps based on +>reception time. +> +> + +its more of an sql question though. + +to deduplicate on basis of + +version,origin,timezone,region_id,wx_element,value,flag,units,valid_time, +issue_time,next_forecast + +You could do this. + +begin work; +create temp_table as select distinct on +(version,origin,timezone,region_id,wx_element,value,flag,units,valid_time, +issue_time,next_forecast) * from forecastelement ; +truncate table forecastelement ; +drop index ; +insert into forecastelement select * from temp_table ; +commit; +create indexes +Analyze forecastelement ; + +note that distinct on will keep only one row out of all rows having +distinct values +of the specified columns. kindly go thru the distinct on manual before +trying +the queries. + +regds +mallah. + +>Are there any suggestions for a better way to do this, or using multiple +>queries to delete selectively a week at a time based on the reception_time. +>I would say there are a lot of duplicate entries between mid march to the +>first week of April. +> +> +> +>---------------------------(end of broadcast)--------------------------- +>TIP 8: explain analyze is your friend +> +>---------------------------(end of broadcast)--------------------------- +>TIP 3: if posting/reading through Usenet, please send an appropriate +> subscribe-nomail command to majordomo@postgresql.org so that your +> message can get through to the mailing list cleanly +> +> +> + +From pgsql-performance-owner@postgresql.org Fri Apr 16 14:54:28 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id CDC81D1B8DF + for ; + Fri, 16 Apr 2004 14:54:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 08447-08 + for ; + Fri, 16 Apr 2004 14:54:19 -0300 (ADT) +Received: from silmaril.syscor.priv (h24-108-208-253.sbm.shawcable.net + [24.108.208.253]) + by svr1.postgresql.org (Postfix) with ESMTP id 26A87D1B8B7 + for ; + Fri, 16 Apr 2004 14:54:22 -0300 (ADT) +Received: from syscor.com (strider.syscor.priv [192.168.1.3]) + by silmaril.syscor.priv (8.12.8/8.12.8) with ESMTP id i3GHsaXR016571 + for ; Fri, 16 Apr 2004 10:54:37 -0700 +Message-ID: <40801E1B.4020401@syscor.com> +Date: Fri, 16 Apr 2004 10:55:39 -0700 +From: Ron St-Pierre +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.4) Gecko/20030624 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Index Problem? +References: <40800CC2.3050707@syscor.com> + <200404161001.52989.josh@agliodbs.com> +In-Reply-To: <200404161001.52989.josh@agliodbs.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/221 +X-Sequence-Number: 6521 + +Josh Berkus wrote: + +>Ron, +> +> +> +>>The emp table has 60 columns, all indexed, about two-thirds are numeric, +>>but they are not affected by this update. The other 50+ columns are +>>updated in the middle of the night and the amount of time that update +>>takes isn't a concern. +>> +>> +> +>Well, I'd say that you have an application design problem, but that's not what +>you asked for help with ;-) +> +> +Yeah I agree but I'm not allowed to remove those indexes. + +> +> +>>Late last night I dumped the table, dropped it and re-created it from +>>the dump (on the production server - when no one was looking). When I +>>re-ran the function it took almost 11 minutes, which was pretty much in +>>line with my results from the dev server. +>> +>> +> +>Sounds like you need to run a REINDEX on the table -- and after that, +>dramatically increase your max_fsm_pages, and run lazy VACUUM immediately +>after the batch update to clean up. +> +> +> +On my dev server I increased max_fsm_pages from the default of 20000 to +40000, increased checkpoint_segments from 3 to 5, and the function ran +in about 6-7 minutes which is a nice increase. According to the docs +"Annotated postgresql.conf and Global User Configuration (GUC) Guide" on +varlena I'll have to re-start postgres for the changes to take effect +there (correct?). Also the docs on Varlena show the max_fsm_pages +default to be 10,000 but my default was 20,000, looks like that needs +updating. + +Thanks for your help Josh, I'll see after the weekend what the impact +the changes will have on the production server. + +Ron + + +From pgsql-performance-owner@postgresql.org Fri Apr 16 14:56:26 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2A69DD1D08C + for ; + Fri, 16 Apr 2004 14:56:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 18137-02 + for ; + Fri, 16 Apr 2004 14:56:18 -0300 (ADT) +Received: from mail.vistashare.com (www.vistashare.net [65.207.67.162]) + by svr1.postgresql.org (Postfix) with ESMTP id 34ACAD1C9C8 + for ; + Fri, 16 Apr 2004 14:56:21 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mail.vistashare.com (Postfix) with ESMTP id CC0A5D804; + Fri, 16 Apr 2004 13:56:21 -0400 (EDT) +From: Chris Kratz +Organization: VistaShare +To: pgsql-performance@postgresql.org +Subject: Re: Long running queries degrade performance +Date: Fri, 16 Apr 2004 13:56:20 -0400 +User-Agent: KMail/1.6.2 +Cc: Mike Nolan +References: <200404161546.i3GFk3p3010490@gw.tssi.com> +In-Reply-To: <200404161546.i3GFk3p3010490@gw.tssi.com> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200404161356.20210.chris.kratz@vistashare.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/222 +X-Sequence-Number: 6522 + +Fairly sure, when it is happening, postgres usually is taking up the top slots +for cpu usage as reported by top. Perhaps there is a better way to monitor +this? + +The other thing for us is that others talk about disks being the bottleneck +whereas for us it is almost always the processor. I expected the drives to +kill us early on (we have two uw scsi mirrored drives) but there is very +little disk activity. The disks rarely do much during load for us (at this +point). Most likely this is related more to data volume at this point. + +As far as in your case, is there a lot of disk activity happening? More +likely you have a situation where something else is happening which blocks +the current thread. We ran into two situations recently which exhibited this +behavior. One was adding and dropping tables in a transaction which blocks +any other transaction trying to do the same. And two threads inserting +records with the same primary key value blocks the second till the first +finishes. Both of these were triggered by users double clicking links in our +web app and were fixed by a better implementation. Perhaps something like +that is causing what you are seeing. + +-Chris + +On Friday 16 April 2004 11:46 am, Mike Nolan wrote: +> > We have a web app with a postgres backend. Most queries have subsecond +> > response times through the web even with high usage. Every once in +> > awhile someone will run either an ad-hoc query or some other long running +> > db process. +> +> Are you sure it is postgres where the delay is occurring? I ask this +> because I also have a web-based front end to postgres, and while most of +> the time the queries respond in about a second every now and then I see +> one that takes much longer, sometimes 10-15 seconds. +> +> I've seen this behavior on both my development system and on the +> production server. +> +> The same query a while later might respond quickly again. +> +> I'm not sure where to look for the delay, either, and it is intermittent +> enough that I'm not even sure what monitoring techniques to use. +> -- +> Mike Nolan + +-- +Chris Kratz +Systems Analyst/Programmer +VistaShare LLC +www.vistashare.com + + +From pgsql-performance-owner@postgresql.org Fri Apr 16 16:10:42 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id ADA72D1C9DA + for ; + Fri, 16 Apr 2004 16:10:40 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 45973-05 + for ; + Fri, 16 Apr 2004 16:10:29 -0300 (ADT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 966EED1C9BE + for ; + Fri, 16 Apr 2004 16:10:31 -0300 (ADT) +Received: from [64.81.245.111] (HELO 192.168.1.102) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4876284; Fri, 16 Apr 2004 12:11:55 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Ron St-Pierre , + pgsql-performance@postgresql.org +Subject: Re: Index Problem? +Date: Fri, 16 Apr 2004 12:10:47 -0700 +User-Agent: KMail/1.5.4 +References: <40800CC2.3050707@syscor.com> + <200404161001.52989.josh@agliodbs.com> + <40801E1B.4020401@syscor.com> +In-Reply-To: <40801E1B.4020401@syscor.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200404161210.47995.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/223 +X-Sequence-Number: 6523 + +Ron, + +> Yeah I agree but I'm not allowed to remove those indexes. + +It's not the indexes I'm talking about, it's the table. + +> On my dev server I increased max_fsm_pages from the default of 20000 to +> 40000, + +A better way to set this would be to run VACUUM VERBOSE ANALYZE right after +doing one of your update batches, and see how many dead pages are being +reclaimed, and then set max_fsm_pages to that # + 50% (or more). + +increased checkpoint_segments from 3 to 5, and the function ran +> in about 6-7 minutes which is a nice increase. According to the docs +> "Annotated postgresql.conf and Global User Configuration (GUC) Guide" on +> varlena I'll have to re-start postgres for the changes to take effect +> there (correct?). + +Correct. + +> Also the docs on Varlena show the max_fsm_pages +> default to be 10,000 but my default was 20,000, looks like that needs +> updating. + +I don't think the default has been changed. Anyone? + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Fri Apr 16 17:05:37 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2E4B2D1D25B + for ; + Fri, 16 Apr 2004 17:05:33 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 63140-04 + for ; + Fri, 16 Apr 2004 17:05:27 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 83612D1C9C8 + for ; + Fri, 16 Apr 2004 17:05:28 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3GK5SlO002409; + Fri, 16 Apr 2004 16:05:28 -0400 (EDT) +To: josh@agliodbs.com +Cc: Ron St-Pierre , + pgsql-performance@postgresql.org +Subject: Re: Index Problem? +In-reply-to: <200404161210.47995.josh@agliodbs.com> +References: <40800CC2.3050707@syscor.com> + <200404161001.52989.josh@agliodbs.com> + <40801E1B.4020401@syscor.com> + <200404161210.47995.josh@agliodbs.com> +Comments: In-reply-to Josh Berkus + message dated "Fri, 16 Apr 2004 12:10:47 -0700" +Date: Fri, 16 Apr 2004 16:05:27 -0400 +Message-ID: <2408.1082145927@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/224 +X-Sequence-Number: 6524 + +Josh Berkus writes: +> A better way to set this would be to run VACUUM VERBOSE ANALYZE right after +> doing one of your update batches, and see how many dead pages are being +> reclaimed, and then set max_fsm_pages to that # + 50% (or more). + +Actually, since he's running 7.4, there's an even better way. Do a +"VACUUM VERBOSE" (full-database vacuum --- doesn't matter whether you +ANALYZE or not). At the end of the very voluminous output, you'll see +something like + +INFO: free space map: 240 relations, 490 pages stored; 4080 total pages needed +DETAIL: Allocated FSM size: 1000 relations + 20000 pages = 178 kB shared memory. + +Here, I would need max_fsm_relations = 240 and max_fsm_pages = 4080 to +exactly cover the present freespace needs of my system. I concur with +the suggestion to bump that up a good deal, of course, but that gives +you a real number to start from. + +The DETAIL part of the message shows my current settings (which are the +defaults) and what the FSM is costing me in shared memory space. + +If you have multiple active databases, the best approach to getting +these numbers is to VACUUM in each one, adding VERBOSE when you do the +last one. The FSM report is cluster-wide but you want to be sure the +underlying info is up to date for all databases. + +>> Also the docs on Varlena show the max_fsm_pages +>> default to be 10,000 but my default was 20,000, looks like that needs +>> updating. + +> I don't think the default has been changed. Anyone? + +Yes, I kicked it up for 7.4 because FSM covers indexes too now. +Both the 7.3 and 7.4 defaults are pretty arbitrary of course... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Apr 16 17:25:18 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9A59FD1C9BE + for ; + Fri, 16 Apr 2004 17:25:17 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 63942-09 + for ; + Fri, 16 Apr 2004 17:25:12 -0300 (ADT) +Received: from gw.tssi.com (gw.tssi.com [198.147.197.1]) + by svr1.postgresql.org (Postfix) with ESMTP id 42430D1D6CC + for ; + Fri, 16 Apr 2004 17:25:13 -0300 (ADT) +Received: from gw.tssi.com (nolan@gw.tssi.com [127.0.0.1] (may be forged)) + by gw.tssi.com (8.12.6/8.12.6) with ESMTP id i3GKPE8S013712; + Fri, 16 Apr 2004 15:25:14 -0500 +Received: (from nolan@localhost) + by gw.tssi.com (8.12.6/8.12.6/Submit) id i3GKPDe4013710; + Fri, 16 Apr 2004 15:25:13 -0500 +From: Mike Nolan +Message-Id: <200404162025.i3GKPDe4013710@gw.tssi.com> +Subject: Re: Long running queries degrade performance +To: chris.kratz@vistashare.com (Chris Kratz) +Date: Fri, 16 Apr 2004 15:25:12 -0500 (CDT) +Cc: pgsql-performance@postgresql.org +In-Reply-To: <200404161356.20210.chris.kratz@vistashare.com> from "Chris + Kratz" at Apr 16, 2004 01:56:20 PM +X-Mailer: ELM [version 2.5 PL3] +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/225 +X-Sequence-Number: 6525 + +> Fairly sure, when it is happening, postgres usually is taking up the top slots +> for cpu usage as reported by top. Perhaps there is a better way to monitor +> this? + +Given the intermittent nature of the problem and its relative brevity +(5-10 seconds), I don't know whether top offers the granularity needed to +locate the bottleneck. + +> likely you have a situation where something else is happening which blocks +> the current thread. + +It happens on my development system, and I'm the only one on it. I know +I've seen it on the production server, but I think it is a bit more +common on the development server, though that may be a case of which system +I spend the most time on. (Also, the production server is 1300 miles away +with a DSL connection, so I may just be seeing network delays some of +the time there.) + +> Both of these were triggered by users double clicking links in our +> web app and were fixed by a better implementation. Perhaps something like +> that is causing what you are seeing. + +My web app traps double-clicks in javascript and ignores all but the first one. +That's because some of the users have mice that give double-clicks even +when they only want one click. +-- +Mike Nolan + +From pgsql-performance-owner@postgresql.org Fri Apr 16 17:51:39 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 727E8D1D08C + for ; + Fri, 16 Apr 2004 17:51:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 71868-09 + for ; + Fri, 16 Apr 2004 17:51:26 -0300 (ADT) +Received: from mail.vistashare.com (www.vistashare.net [65.207.67.162]) + by svr1.postgresql.org (Postfix) with ESMTP id B7AF8D1C9C8 + for ; + Fri, 16 Apr 2004 17:51:28 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mail.vistashare.com (Postfix) with ESMTP id 72B11D87B; + Fri, 16 Apr 2004 16:51:30 -0400 (EDT) +From: Chris Kratz +Organization: VistaShare +To: pgsql-performance@postgresql.org +Subject: Re: Long running queries degrade performance +Date: Fri, 16 Apr 2004 16:51:29 -0400 +User-Agent: KMail/1.6.2 +Cc: Mike Nolan +References: <200404162025.i3GKPDe4013710@gw.tssi.com> +In-Reply-To: <200404162025.i3GKPDe4013710@gw.tssi.com> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200404161651.29332.chris.kratz@vistashare.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/226 +X-Sequence-Number: 6526 + +On Friday 16 April 2004 4:25 pm, Mike Nolan wrote: +> Given the intermittent nature of the problem and its relative brevity +> (5-10 seconds), I don't know whether top offers the granularity needed to +> locate the bottleneck. + +Our long running processes run on the order of multiple minutes (sometimes for +over an hour) and it's expected because the sql can be quite complex over +somewhat large datasets. But it's the bringing the server to it's knees, +that I'm trying to figure out how to address if we can. In other words, let +those long running processes run, but somehow still get decent performance +for "quick" requests. + +Yours reminds me of what used to happen in our apps back when I worked in java +and the garbage collector kicked in. Suddenly everything would stop for +10-15s and then continue on. Sort of makes you think the app froze for some +reason. + +> It happens on my development system, and I'm the only one on it. I know +> I've seen it on the production server, but I think it is a bit more +> common on the development server, though that may be a case of which system +> I spend the most time on. (Also, the production server is 1300 miles away +> with a DSL connection, so I may just be seeing network delays some of +> the time there.) + +Interesting. Have you tried running a processor monitor and seeing if you are +getting a cpu or disk spike when you get the blips? Postgres has been pretty +constant for us in it's average runtime for any particular query. We do get +some fluctuation, but I've always attributed that to other things happening +in the background. I sometimes run gkrellm off the server just to "see" +what's happening on a macro scale. It's a great early indicator when we are +getting slammed one way or another (network, memory, processor, disk, etc). +Plus it shows a couple of seconds of history so you can see blips pretty +easily. + +> My web app traps double-clicks in javascript and ignores all but the first +> one. That's because some of the users have mice that give double-clicks +> even when they only want one click. + +Hmmm, never thought of doing that. Might be interesting to do something like +that in a few key places where we have problems. + +> -- +> Mike Nolan + +-- +Chris Kratz +Systems Analyst/Programmer +VistaShare LLC +www.vistashare.com + +From pgsql-performance-owner@postgresql.org Fri Apr 16 18:12:54 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 998F6D1BCB8 + for ; + Fri, 16 Apr 2004 18:12:52 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 80086-09 + for ; + Fri, 16 Apr 2004 18:12:48 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 5C486D1B8B7 + for ; + Fri, 16 Apr 2004 18:12:50 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3GLCqUM002851; + Fri, 16 Apr 2004 17:12:52 -0400 (EDT) +To: Chris Kratz +Cc: pgsql-performance@postgresql.org +Subject: Re: Long running queries degrade performance +In-reply-to: <200404161128.00851.chris.kratz@vistashare.com> +References: <200404161128.00851.chris.kratz@vistashare.com> +Comments: In-reply-to Chris Kratz + message dated "Fri, 16 Apr 2004 11:28:00 -0400" +Date: Fri, 16 Apr 2004 17:12:52 -0400 +Message-ID: <2850.1082149972@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/227 +X-Sequence-Number: 6527 + +Chris Kratz writes: +> ... Or if worse comes to worse to actually kill long running +> processes without taking down the whole db as we have had to do on occasion. + +A quick "kill -INT" suffices to issue a query cancel, which I think is +what you want here. You could also consider putting an upper limit on +how long things can run by means of statement_timeout. + +Those are just band-aids though. Not sure about the underlying problem. +Ordinarily I'd guess that the big-hog queries are causing trouble by +evicting everything the other queries need from cache. But since your +database fits in RAM, that doesn't seem to hold water. + +What PG version are you running? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Apr 16 18:26:34 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8A4A7D1E298 + for ; + Fri, 16 Apr 2004 18:26:32 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 92168-03 + for ; + Fri, 16 Apr 2004 18:26:28 -0300 (ADT) +Received: from mail.vistashare.com (www.vistashare.net [65.207.67.162]) + by svr1.postgresql.org (Postfix) with ESMTP id BDD12D1E2A7 + for ; + Fri, 16 Apr 2004 18:26:30 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mail.vistashare.com (Postfix) with ESMTP id 38CF19586 + for ; + Fri, 16 Apr 2004 17:26:33 -0400 (EDT) +From: Chris Kratz +Organization: VistaShare +To: pgsql-performance@postgresql.org +Subject: Re: Long running queries degrade performance +Date: Fri, 16 Apr 2004 17:26:32 -0400 +User-Agent: KMail/1.6.2 +References: <200404161128.00851.chris.kratz@vistashare.com> + <2850.1082149972@sss.pgh.pa.us> +In-Reply-To: <2850.1082149972@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200404161726.32102.chris.kratz@vistashare.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/228 +X-Sequence-Number: 6528 + +On Friday 16 April 2004 5:12 pm, Tom Lane wrote: +> Chris Kratz writes: +> > ... Or if worse comes to worse to actually kill long running +> > processes without taking down the whole db as we have had to do on +> > occasion. +> +> A quick "kill -INT" suffices to issue a query cancel, which I think is +> what you want here. You could also consider putting an upper limit on +> how long things can run by means of statement_timeout. + +Wow, that's exactly what I've been looking for. I thought I had scoured the +manuals, but must have missed that one. I need to think about the +statement_timeout, the might be a good idea to use as well. + +> Those are just band-aids though. Not sure about the underlying problem. +> Ordinarily I'd guess that the big-hog queries are causing trouble by +> evicting everything the other queries need from cache. But since your +> database fits in RAM, that doesn't seem to hold water. + +That makes some sense, perhaps there is some other cache somewhere that is +causing the problems. I am doing some tuning and have set the following +items in our postgresql.conf: + +shared_buffers = 4096 +max_fsm_relations = 1000 +max_fsm_pages = 20000 +sort_mem = 2048 +effective_cache_size = 64000 + +I believe these are the only performance related items we've modified. One +thing I did today, since we seem to run about 600M of memory available for +file caches. The effective cache size used to be much lower, so perhaps that +was causing some of the problems. + +> What PG version are you running? + +7.3.4 with grand hopes to move to 7.4 this summer. + +> regards, tom lane + +-- +Chris Kratz +Systems Analyst/Programmer +VistaShare LLC +www.vistashare.com + +From pgsql-performance-owner@postgresql.org Fri Apr 16 18:45:33 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A97D5D1D803 + for ; + Fri, 16 Apr 2004 18:45:31 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 92168-09 + for ; + Fri, 16 Apr 2004 18:45:27 -0300 (ADT) +Received: from web13125.mail.yahoo.com (web13125.mail.yahoo.com + [216.136.174.143]) + by svr1.postgresql.org (Postfix) with SMTP id 8289CD1B515 + for ; + Fri, 16 Apr 2004 18:45:28 -0300 (ADT) +Message-ID: <20040416214529.10468.qmail@web13125.mail.yahoo.com> +Received: from [63.78.248.48] by web13125.mail.yahoo.com via HTTP; + Fri, 16 Apr 2004 14:45:29 PDT +Date: Fri, 16 Apr 2004 14:45:29 -0700 (PDT) +From: Litao Wu +Subject: sunquery and estimated rows +To: pgsql-performance@postgresql.org +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/229 +X-Sequence-Number: 6529 + +Hi, + +When I included a subquery, the estimated rows (1240) +is way too high as shown in the following example. +Can someone explain why? Because of this behavior, +some of our queries use hash join instead of nested +loop. + +Thanks, + +select version(); + version +------------------------------------------------------------- + PostgreSQL 7.3.4 on i686-pc-linux-gnu, compiled by +GCC 2.96 +(1 row) +\d test + Table "public.test" + Column | Type | Modifiers +---------+--------------------------+----------- + id | integer | + name | character varying(255) | + d_id | integer | + c_id | integer | + r_id | integer | + u_id | integer | + scope | integer | + active | integer | + created | timestamp with time zone | + typ | integer | +Indexes: test_scope_idx btree (scope) + +reindex table test; +vacuum full analyze test; + +select count(*) from test; + count +------- + 4959 +(1 row) +select count(*) from test where scope=10; + count +------- + 10 +(1 row) + +explain analyze +select * from test +where scope=10; -- so far so good, estimate 12 rows, +actual 10 rows + +QUERY PLAN +---------------------------------------------------------------------------------------------------------------------- + Index Scan using test_scope_idx on test +(cost=0.00..4.35 rows=12 width=59) (actual +time=0.04..0.11 rows=10 loops=1) + Index Cond: (scope = 10) + Total runtime: 0.23 msec +(3 rows) + +explain analyze +select * from test +where scope=(select 10); -- estimate rows is way too +high, do not why???? + +QUERY PLAN +------------------------------------------------------------------------------------------------------------------------- + Index Scan using test_scope_idx on test +(cost=0.00..40.74 rows=1240 width=59) (actual +time=0.06..0.13 rows=10 loops=1) + Index Cond: (scope = $0) + InitPlan + -> Result (cost=0.00..0.01 rows=1 width=0) +(actual time=0.01..0.01 rows=1 loops=1) + Total runtime: 0.22 msec +(5 rows) + + + + + + +__________________________________ +Do you Yahoo!? +Yahoo! Tax Center - File online by April 15th +http://taxes.yahoo.com/filing.html + +From pgsql-performance-owner@postgresql.org Fri Apr 16 18:53:38 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C81C6D1E993 + for ; + Fri, 16 Apr 2004 18:53:37 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 01765-04 + for ; + Fri, 16 Apr 2004 18:53:33 -0300 (ADT) +Received: from silmaril.syscor.priv (h24-108-208-253.sbm.shawcable.net + [24.108.208.253]) + by svr1.postgresql.org (Postfix) with ESMTP id B6110D1E981 + for ; + Fri, 16 Apr 2004 18:53:34 -0300 (ADT) +Received: from syscor.com (strider.syscor.priv [192.168.1.3]) + by silmaril.syscor.priv (8.12.8/8.12.8) with ESMTP id i3GLrqXR017338 + for ; Fri, 16 Apr 2004 14:53:53 -0700 +Message-ID: <4080562F.6050006@syscor.com> +Date: Fri, 16 Apr 2004 14:54:55 -0700 +From: Ron St-Pierre +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.4) Gecko/20030624 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Index Problem? +References: <40800CC2.3050707@syscor.com> + <200404161001.52989.josh@agliodbs.com> + <40801E1B.4020401@syscor.com> + <200404161210.47995.josh@agliodbs.com> + <2408.1082145927@sss.pgh.pa.us> +In-Reply-To: <2408.1082145927@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/230 +X-Sequence-Number: 6530 + +Tom Lane wrote: + +>Josh Berkus writes: +> +> +>>A better way to set this would be to run VACUUM VERBOSE ANALYZE right after +>>doing one of your update batches, and see how many dead pages are being +>>reclaimed, and then set max_fsm_pages to that # + 50% (or more). +>> +>> +> +>Actually, since he's running 7.4, there's an even better way. Do a +>"VACUUM VERBOSE" (full-database vacuum --- doesn't matter whether you +>ANALYZE or not). At the end of the very voluminous output, you'll see +>something like +> +>INFO: free space map: 240 relations, 490 pages stored; 4080 total pages needed +>DETAIL: Allocated FSM size: 1000 relations + 20000 pages = 178 kB shared memory. +> +>Here, I would need max_fsm_relations = 240 and max_fsm_pages = 4080 to +>exactly cover the present freespace needs of my system. I concur with +>the suggestion to bump that up a good deal, of course, but that gives +>you a real number to start from. +> +>The DETAIL part of the message shows my current settings (which are the +>defaults) and what the FSM is costing me in shared memory space. +> +> +> +Okay, after running the function VACUUM VERBOSE is telling me: + INFO: free space map: 136 relations, 25014 pages stored; 22608 total +pages needed + DETAIL: Allocated FSM size: 1000 relations + 20000 pages = 178 kB +shared memory. + +My max_fsm_pages was set to 20,000 and I reset it to 40,000 on the dev +server and the function ran about 20-30% faster, so I'll try the same on +the production server. Thanks for the analysis of the VACUUM info. + +Ron + + +From pgsql-performance-owner@postgresql.org Fri Apr 16 19:24:11 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 20452D1DC5E + for ; + Fri, 16 Apr 2004 19:24:09 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 04663-10 + for ; + Fri, 16 Apr 2004 19:24:03 -0300 (ADT) +Received: from email03.aon.at (warsl404pip6.highway.telekom.at [195.3.96.89]) + by svr1.postgresql.org (Postfix) with SMTP id F103ED1DB96 + for ; + Fri, 16 Apr 2004 19:24:04 -0300 (ADT) +Received: (qmail 365408 invoked from network); 16 Apr 2004 22:24:06 -0000 +Received: from m154p002.dipool.highway.telekom.at (HELO PASCAL) ([62.46.9.34]) + (envelope-sender ) + by qmail3rs.highway.telekom.at (qmail-ldap-1.03) with SMTP + for ; 16 Apr 2004 22:24:06 -0000 +From: Manfred Koizar +To: Tom Lane +Cc: Robert Treat , + pgsql-performance@postgresql.org +Subject: Re: query slows down with more accurate stats +Date: Sat, 17 Apr 2004 00:26:22 +0200 +Message-ID: +References: <1081879359.25537.526.camel@camel> + <25556.1081883922@sss.pgh.pa.us> + + <22642.1082074729@sss.pgh.pa.us> + + <29060.1082126089@sss.pgh.pa.us> +In-Reply-To: <29060.1082126089@sss.pgh.pa.us> +X-Mailer: Forte Agent 1.93/32.576 English (American) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/231 +X-Sequence-Number: 6531 + +On Fri, 16 Apr 2004 10:34:49 -0400, Tom Lane wrote: +>> p = prod from{i = 0} to{n - 1} {{c(B - i)} over {cB - i}} +> +>So? You haven't proven that either sampling method fails to do the +>same. + +On the contrary, I believe that above formula is more or less valid for +both methods. The point is in what I said next: +| This probability grows with increasing B. + +For the one-stage sampling method B is the number of pages of the whole +table. With two-stage sampling we have to use n instead of B and get a +smaller probability (for n < B, of course). So this merely shows that +the two sampling methods are not equivalent. + +>The desired property can also be phrased as "every tuple should be +>equally likely to be included in the final sample". + +Only at first sight. You really expect more from random sampling. +Otherwise I'd just put one random tuple and its n - 1 successors (modulo +N) into the sample. This satisfies your condition but you wouldn't call +it a random sample. + +Random sampling is more like "every possible sample is equally likely to +be collected", and two-stage sampling doesn't satisfy this condition. + +But if in your opinion the difference is not significant, I'll stop +complaining against my own idea. Is there anybody else who cares? + +>You could argue that a tuple on a heavily populated page is +>statistically likely to see a higher T when it's part of the page sample +>pool than a tuple on a near-empty page is likely to see, and therefore +>there is some bias against selection of the former tuple. But given a +>sample over a reasonably large number of pages, the contribution of any +>one page to T should be fairly small and so this effect ought to be +>small. + +It is even better: Storing a certain number of tuples on heavily +populated pages takes less pages than to store them on sparsely +populated pages (due to tuple size or to dead tuples). So heavily +populated pages are less likely to be selected in stage one, and this +exactly offsets the effect of increasing T. + +>So I think this method is effectively unbiased at the tuple level. + +Servus + Manfred + +From pgsql-performance-owner@postgresql.org Fri Apr 16 19:57:55 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8A120D1DACE + for ; + Fri, 16 Apr 2004 19:57:53 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 18431-06 + for ; + Fri, 16 Apr 2004 19:57:48 -0300 (ADT) +Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) + by svr1.postgresql.org (Postfix) with ESMTP id BBD34D1D5E4 + for ; + Fri, 16 Apr 2004 19:57:49 -0300 (ADT) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by smtp.istop.com (Postfix) with ESMTP + id 642E417C490; Fri, 16 Apr 2004 18:57:52 -0400 (EDT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1BEcHQ-0000Qj-00; Fri, 16 Apr 2004 18:57:52 -0400 +To: "Jim C. Nasby" +Cc: pgsql-performance@postgresql.org +Subject: Re: Poor performance of group by query +References: <20040416151706.GE87362@nasby.net> +In-Reply-To: <20040416151706.GE87362@nasby.net> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 16 Apr 2004 18:57:51 -0400 +Message-ID: <87pta78r9s.fsf@stark.xeocode.com> +Lines: 24 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/232 +X-Sequence-Number: 6532 + + + +> stats=# explain analyze SELECT work_units, min(raw_rank) AS rank FROM Trank_work_overall GROUP BY work_units; +> +> ... +> +> raw_rank | bigint | +> work_units | bigint | + + +If you create a copy of the same table using regular integers does that run +fast? And a copy of the table using bigints is still slow like the original? + +I know bigints are less efficient than integers because they're handled using +dynamically allocated memory. This especially bites aggregate functions. But I +don't see why it would be any slower for a hash aggregate than a regular +aggregate. It's a pretty gross amount of time for 18k records. + +There was a thought a while back about making 64-bit machines handle 64-bit +datatypes like bigints without pointers. That would help on your Opteron. + + +-- +greg + + +From pgsql-performance-owner@postgresql.org Fri Apr 16 20:45:02 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9F15ED1E2A7 + for ; + Fri, 16 Apr 2004 20:45:00 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 28618-06 + for ; + Fri, 16 Apr 2004 20:44:57 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 9E292D1D085 + for ; + Fri, 16 Apr 2004 20:44:58 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3GNj1lS003803; + Fri, 16 Apr 2004 19:45:02 -0400 (EDT) +To: Litao Wu +Cc: pgsql-performance@postgresql.org +Subject: Re: sunquery and estimated rows +In-reply-to: <20040416214529.10468.qmail@web13125.mail.yahoo.com> +References: <20040416214529.10468.qmail@web13125.mail.yahoo.com> +Comments: In-reply-to Litao Wu + message dated "Fri, 16 Apr 2004 14:45:29 -0700" +Date: Fri, 16 Apr 2004 19:45:01 -0400 +Message-ID: <3802.1082159101@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/233 +X-Sequence-Number: 6533 + +Litao Wu writes: +> When I included a subquery, the estimated rows (1240) +> is way too high as shown in the following example. + +> select * from test +> where scope=(select 10); + +The planner sees that as "where scope = " +and falls back to a default estimate. It won't simplify a sub-select +to a constant. (Some people consider that a feature ;-).) + +The estimate should still be derived from the statistics for the +scope column, but it will just depend on the number of distinct +values for the column and not on the specific comparison constant. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sat Apr 17 10:12:24 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B9782D1D05C + for ; + Sat, 17 Apr 2004 10:12:22 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 12458-10 + for ; + Sat, 17 Apr 2004 10:12:24 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id B3236D1C9C8 + for ; + Sat, 17 Apr 2004 10:12:20 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i3HDCKSx087303 + for ; Sat, 17 Apr 2004 13:12:20 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i3HCoLtF083930 + for pgsql-performance@postgresql.org; Sat, 17 Apr 2004 12:50:21 GMT +From: Christopher Browne +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Long running queries degrade performance +Date: Sat, 17 Apr 2004 07:59:23 -0400 +Organization: cbbrowne Computing Inc +Lines: 69 +Message-ID: +References: <200404161128.00851.chris.kratz@vistashare.com> + <200404161546.i3GFk3p3010490@gw.tssi.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@news.hub.org +X-message-flag: Outlook is rather hackable, isn't it? +X-Home-Page: http://www.cbbrowne.com/info/ +X-Affero: http://svcs.affero.net/rm.php?r=cbbrowne +User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Security Through + Obscurity, + linux) +Cancel-Lock: sha1:42F111rf9O1YatkhZzQ2UaW2rSY= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/234 +X-Sequence-Number: 6534 + +A long time ago, in a galaxy far, far away, nolan@gw.tssi.com (Mike Nolan) wrote: +>> We have a web app with a postgres backend. Most queries have subsecond +>> response times through the web even with high usage. Every once in awhile +>> someone will run either an ad-hoc query or some other long running db +>> process. +> +> Are you sure it is postgres where the delay is occurring? I ask this +> because I also have a web-based front end to postgres, and while most of +> the time the queries respond in about a second every now and then I see +> one that takes much longer, sometimes 10-15 seconds. +> +> I've seen this behavior on both my development system and on the +> production server. +> +> The same query a while later might respond quickly again. +> +> I'm not sure where to look for the delay, either, and it is +> intermittent enough that I'm not even sure what monitoring +> techniques to use. + +Well, a first thing to do is to see what query plans get set up for +the queries. If the plans are varying over time, that suggests +something's up with ANALYZEs. + +If the plans look a bit questionable, then you may be encountering the +situation where cache is helping you on the _second_ query but not the +first. I did some tuning yesterday involving the same sort of +"symptoms," and that turned out to be what was happening. + +I'll describe (in vague detail ;-)) what I was seeing. + +- The table being queried was a "transaction" table, containing tens of + thousands of records per day. + +- The query was pulling summary information about one or another + customer's activity on that day. + +- The best index we had was on transaction date. + +Thus, the query would walk through the "txn date" index, pulling +records into memory, and filtering them against the other selection +criteria. + +The table is big, so that data is pretty widely scattered across many +pages. + +The _first_ time the query is run, the data is all out on disk, and +there are hundreds-to-thousands of page reads to collect it all. That +took 10-15 seconds. + +The _second_ time it was run (as well as subsequent occasions), those +pages were all in cache, so the query runs in under a second. + +What I wound up doing was to add an index on transaction date and +customer ID, so that a query that specifies both criteria will look +just for the few hundred (at most) records relevant to a particular +customer. That's fast even the first time around. + +We had a really useful "hook" on this one because the developer +noticed that the first time he queried for a particular day, it was +slow. We could "repeat" the test easily by just changing to a day +that we hadn't pulled into cache yet. +-- +(format nil "~S@~S" "cbbrowne" "acm.org") +http://cbbrowne.com/info/lisp.html +Referring to undocumented private communications allows one to claim +virtually anything: "we discussed this idea in our working group last +year, and concluded that it was totally brain-damaged". +-- from the Symbolics Guidelines for Sending Mail + +From pgsql-performance-owner@postgresql.org Tue Apr 20 10:58:24 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8AC84D1DB96 + for ; + Sat, 17 Apr 2004 09:25:45 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 11282-02 + for ; + Sat, 17 Apr 2004 09:25:45 -0300 (ADT) +Received: from mailhost2.tudelft.nl (mailhost2.tudelft.nl [130.161.180.2]) + by svr1.postgresql.org (Postfix) with ESMTP id BCAD9D1DB17 + for ; + Sat, 17 Apr 2004 09:25:41 -0300 (ADT) +Received: from localhost (localhost [127.0.0.1]) + by rav.antivirus (Postfix) with ESMTP + id 8ACF7213A0; Sat, 17 Apr 2004 14:25:44 +0200 (MEST) +Received: from listserv.tudelft.nl (listserv.tudelft.nl [130.161.180.33]) + by mailhost2.tudelft.nl (Postfix) with ESMTP + id 54BA9212F9; Sat, 17 Apr 2004 14:25:44 +0200 (MEST) +Received: from oli.tudelft.nl (jochemd.tnw-s.tudelft.nl [145.94.90.156]) + by listserv.tudelft.nl (8.12.10/8.12.8) with ESMTP id i3HCPfF7009695; + Sat, 17 Apr 2004 14:25:43 +0200 (MEST) +Message-ID: <40812244.5080001@oli.tudelft.nl> +Date: Sat, 17 Apr 2004 14:25:40 +0200 +From: Jochem van Dieten +Organization: OnLine Internet +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: rstpierre@syscor.com +Cc: pgsql-performance@postgresql.org +Subject: Re: Index Problem? +References: <40800CC2.3050707@syscor.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at tudelft.nl +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/299 +X-Sequence-Number: 6599 + +Ron St-Pierre wrote: +> I am using postgres 7.4.1 and have a problem with a plpgsql function. +> When I run the function on the production server it takes approx 33 +> minutes to run. I dumped the DB and copied it to a similarly configured +> box and ran the function and it ran in about 10 minutes. Can anyone +> offer advice on tuning the function or my database? Here are the +> lengthy, gory details. +> +> F u n c t i o n +> It updates seven columns of a table 1 to 4 times daily. Current data = +> 42,000 rows, new data = 30,000 rows. +> +> CREATE TYPE employeeType AS (empID INTEGER, updateDate DATE, bDate +> INTEGER, val1 NUMERIC, val2 NUMERIC, val3 NUMERIC, val4 NUMERIC, favNum +> NUMERIC); +> +> CREATE OR REPLACE FUNCTION updateEmployeeData() RETURNS SETOF +> employeeType AS ' +> DECLARE +> rec RECORD; +> BEGIN +> FOR rec IN SELECT empID, updateDate, bDate, val1, val2, val3, val4, favNum FROM newData LOOP +> RETURN NEXT rec; +> UPDATE currentData SET val1=rec.val1, val2=rec.val2, val3=rec.val2, val4=rec.val4, favNum=rec.favNum, updateDate=rec.updateDate +> WHERE empID=rec.empID; +> END LOOP; +> RETURN; +> END; +> ' LANGUAGE 'plpgsql'; + +Can't you handle this with a simple update query? + +UPDATE + currentData +SET + val1 = newData.val1, + val2 = newData.val2, + val3 = newData.val3, + val4 = newData.val4, + favNum = newData.favNum, + updateDate = newData.updateDate +FROM + newData +WHERE + newDate.empID = currentData.empID + +Jochem + +-- +I don't get it +immigrants don't work +and steal our jobs + - Loesje + + + +From pgsql-performance-owner@postgresql.org Sat Apr 17 11:29:05 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 95C2BD1D05C + for ; + Sat, 17 Apr 2004 11:29:01 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 33130-09 + for ; + Sat, 17 Apr 2004 11:29:04 -0300 (ADT) +Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com + [24.128.241.68]) + by svr1.postgresql.org (Postfix) with SMTP id 75B56D1C9DA + for ; + Sat, 17 Apr 2004 11:28:59 -0300 (ADT) +Received: (qmail 77089 invoked from network); 17 Apr 2004 14:29:07 -0000 +Received: from unknown (HELO ?192.168.0.6?) (10.10.10.177) + by 10.10.10.10 with SMTP; 17 Apr 2004 14:29:07 -0000 +In-Reply-To: <407F9816.2080407@trade-india.com> +References: <407D7A89.60508@trade-india.com> + <407E8FF6.4050601@potentialtech.com> + <407EB605.70502@trade-india.com> + <200404151844.33672.dev@archonet.com> + <407F9816.2080407@trade-india.com> +Mime-Version: 1.0 (Apple Message framework v613) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <954A8D6A-907B-11D8-8E5D-000D9366F0C4@torgo.978.org> +Content-Transfer-Encoding: 7bit +Cc: Richard Huxton , Bill Moran , + Postgres Performance +From: Jeff +Subject: Re: [ SOLVED ] select count(*) very slow on an already +Date: Sat, 17 Apr 2004 10:29:06 -0400 +To: Rajesh Kumar Mallah +X-Mailer: Apple Mail (2.613) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/235 +X-Sequence-Number: 6535 + + +On Apr 16, 2004, at 4:23 AM, Rajesh Kumar Mallah wrote: + +> +> +> I am running an update on the same table +> +> update rfis set inquiry_status='APPROVED' where inquiry_status='a'; +> +> Its running for past 20 mins. and top output is below. +> The PID which is executing the query above is 6712. Can anyone +> tell me why it is in an uninterruptable sleep and does it relate +> to the apparent poor performance? Is it problem with the disk +> hardware. I know at nite this query will run reasonably fast. +> + +I've had this problem recently. The problem is simply that the disk +cannot keep up. Most likely you don't see it at night because traffic +is lower. There are only 2 solutions: 1. get more disks 2. write to +the db less + +The machine I was running on had a single(!) disk. It was a quad xeon +so there was plenty of cpu. I'd see 8-9 processes stuck in the "D" +state. Doing a simple ls -l somefile would take 10-15 seconds and of +course, db performance was abysmal. + +I had a lowly P2 with a few disks in it that was able to run circles +around it for the simple fact the machine was not waiting for disk. +Again, proof that disk is far more important than CPU in a db. + +good luck. + +-- +Jeff Trout +http://www.jefftrout.com/ +http://www.stuarthamm.net/ + + +From pgsql-performance-owner@postgresql.org Sat Apr 17 13:08:24 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DC171D1E8FB + for ; + Sat, 17 Apr 2004 13:08:19 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 62629-01 + for ; + Sat, 17 Apr 2004 13:08:18 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 6B936D1E8A5 + for ; + Sat, 17 Apr 2004 13:08:17 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3HG8Fik010604; + Sat, 17 Apr 2004 12:08:16 -0400 (EDT) +To: "Jim C. Nasby" +Cc: pgsql-performance@postgreSQL.org +Subject: Re: Horribly slow hash join +In-reply-to: <20040416184541.GK87362@nasby.net> +References: <20040416154502.GF87362@nasby.net> <450.1082133251@sss.pgh.pa.us> + <20040416164644.GH87362@nasby.net> <808.1082135098@sss.pgh.pa.us> + <20040416172523.GJ87362@nasby.net> <1263.1082138383@sss.pgh.pa.us> + <20040416184541.GK87362@nasby.net> +Comments: In-reply-to "Jim C. Nasby" + message dated "Fri, 16 Apr 2004 13:45:41 -0500" +Date: Sat, 17 Apr 2004 12:08:15 -0400 +Message-ID: <10603.1082218095@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/236 +X-Sequence-Number: 6536 + +[ resending because I fat-fingered the cc: to the list ] + +I see the problem: all the entries in your work_units column have the +low 32 bits equal to zero. + +regression=# select distinct work_units % (2^32)::bigint from Trank_work_overall; + ?column? +---------- + 0 +(1 row) + +The hash function for int8 only takes the low word into account, so all +of the entries end up on the same hash chain, resulting in worst-case +behavior. This applies to both your hash join and hash aggregate cases. + +We could change the hash function, perhaps, but then we'd just have +different cases where there's a problem ... hashing will always fail on +*some* set of inputs. (Also, I have been harboring some notions of +supporting cross-type hash joins for integer types, which will not work +unless small int8 values hash the same as int4 etc.) + +I guess the real issue is why are you encoding work_units like that? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sat Apr 17 17:35:30 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 20B6AD1BCB8 + for ; + Sat, 17 Apr 2004 17:35:29 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 27509-01 + for ; + Sat, 17 Apr 2004 17:35:27 -0300 (ADT) +Received: from mx2.mundo-r.com (mx2.mundo-r.com [212.51.32.186]) + by svr1.postgresql.org (Postfix) with ESMTP id F2F9ED1BB49 + for ; + Sat, 17 Apr 2004 17:35:24 -0300 (ADT) +Received: from lobeira (cm248132.red.mundo-r.com [213.60.248.132]) + by obelix.mundo-r.ggc + (iPlanet Messaging Server 5.1 HotFix 1.6 (built Oct 18 2002)) + with ESMTP id <0HWC00CG016MG1@obelix.mundo-r.ggc> for + pgsql-performance@postgreSQL.org; Sat, 17 Apr 2004 22:35:26 +0200 (MEST) +Date: Sat, 17 Apr 2004 22:35:09 +0200 +From: =?iso-8859-1?Q?Marcos_Mart=EDnez=28R=29?= +Subject: Re: Horribly slow hash join +To: Tom Lane , "Jim C. Nasby" +Cc: pgsql-performance@postgreSQL.org +Message-id: <001001c424bb$7fb83740$0564a8c0@lobeira> +MIME-version: 1.0 +X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 +X-Mailer: Microsoft Outlook Express 6.00.2800.1409 +Content-type: text/plain; charset=iso-8859-1 +Content-transfer-encoding: 7BIT +X-Priority: 3 +X-MSMail-priority: Normal +References: <20040416154502.GF87362@nasby.net> <450.1082133251@sss.pgh.pa.us> + <20040416164644.GH87362@nasby.net> <808.1082135098@sss.pgh.pa.us> + <20040416172523.GJ87362@nasby.net> <1263.1082138383@sss.pgh.pa.us> + <20040416184541.GK87362@nasby.net> <10603.1082218095@sss.pgh.pa.us> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/237 +X-Sequence-Number: 6537 + +I didn't follow the conversation from the begining, bu I imagine that you +could improve +performance using the value (work_units % (2^32) ) instead of work_units. +You could even make an index on this value. Like that, the HASH function +will work well. This is not a good solution, but ... + +For example. + +create index ind1 on table1 ( work_units % (2^32) ); + +create index ind1 on table2 ( work_units % (2^32) ); + +Select * from table1 join table2 on (table1.work_units % (2^32) ) = +(table2.work_units % (2^32) ) + + +----- Original Message ----- +From: "Tom Lane" +To: "Jim C. Nasby" +Cc: +Sent: Saturday, April 17, 2004 6:08 PM +Subject: Re: [PERFORM] Horribly slow hash join + + +> [ resending because I fat-fingered the cc: to the list ] +> +> I see the problem: all the entries in your work_units column have the +> low 32 bits equal to zero. +> +> regression=# select distinct work_units % (2^32)::bigint from +Trank_work_overall; +> ?column? +> ---------- +> 0 +> (1 row) +> +> The hash function for int8 only takes the low word into account, so all +> of the entries end up on the same hash chain, resulting in worst-case +> behavior. This applies to both your hash join and hash aggregate cases. +> +> We could change the hash function, perhaps, but then we'd just have +> different cases where there's a problem ... hashing will always fail on +> *some* set of inputs. (Also, I have been harboring some notions of +> supporting cross-type hash joins for integer types, which will not work +> unless small int8 values hash the same as int4 etc.) +> +> I guess the real issue is why are you encoding work_units like that? +> +> regards, tom lane +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 6: Have you searched our list archives? +> +> http://archives.postgresql.org + + + +From pgsql-performance-owner@postgresql.org Sat Apr 17 20:04:42 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 561CBD1C4C3 + for ; + Sat, 17 Apr 2004 20:04:41 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 59865-01 + for ; + Sat, 17 Apr 2004 20:04:40 -0300 (ADT) +Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) + by svr1.postgresql.org (Postfix) with ESMTP id BE560D1BCB8 + for ; + Sat, 17 Apr 2004 20:04:37 -0300 (ADT) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by smtp.istop.com (Postfix) with ESMTP + id 7139B17C431; Sat, 17 Apr 2004 19:04:40 -0400 (EDT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1BEyrY-0004mf-00; Sat, 17 Apr 2004 19:04:40 -0400 +To: Tom Lane +Cc: "Jim C. Nasby" , pgsql-performance@postgresql.org +Subject: Re: Horribly slow hash join +References: <20040416154502.GF87362@nasby.net> <450.1082133251@sss.pgh.pa.us> + <20040416164644.GH87362@nasby.net> <808.1082135098@sss.pgh.pa.us> + <20040416172523.GJ87362@nasby.net> <1263.1082138383@sss.pgh.pa.us> + <20040416184541.GK87362@nasby.net> <10603.1082218095@sss.pgh.pa.us> +In-Reply-To: <10603.1082218095@sss.pgh.pa.us> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 17 Apr 2004 19:04:39 -0400 +Message-ID: <878ygu8auw.fsf@stark.xeocode.com> +Lines: 20 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/238 +X-Sequence-Number: 6538 + + +Tom Lane writes: + +> We could change the hash function, perhaps, but then we'd just have +> different cases where there's a problem ... hashing will always fail on +> *some* set of inputs. + +Sure, but completely ignoring part of the input seems like an unfortunate +choice of hash function. + +> (Also, I have been harboring some notions of supporting cross-type hash +> joins for integer types, which will not work unless small int8 values hash +> the same as int4 etc.) + +The obvious way to modify the hash function is to xor the high 32 bits with +the low 32 bits. That maintains the property you need and at least ensures +that all the bits are taken into account. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Sun Apr 18 00:34:18 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B47CCD1E94D + for ; + Sun, 18 Apr 2004 00:34:16 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 10187-07 + for ; + Sun, 18 Apr 2004 00:34:15 -0300 (ADT) +Received: from linda-1.paradise.net.nz (bm-1a.paradise.net.nz [202.0.58.20]) + by svr1.postgresql.org (Postfix) with ESMTP id 61C65D1E949 + for ; + Sun, 18 Apr 2004 00:34:14 -0300 (ADT) +Received: from smtp-2.paradise.net.nz (smtp-2b.paradise.net.nz [202.0.32.211]) + by linda-1.paradise.net.nz (Paradise.net.nz) + with ESMTP id <0HWC002VOKL0AQ@linda-1.paradise.net.nz> for + pgsql-performance@postgresql.org; Sun, 18 Apr 2004 15:34:13 +1200 (NZST) +Received: from paradise.net.nz + (203-96-145-144.adsl.paradise.net.nz [203.96.145.144]) + by smtp-2.paradise.net.nz (Postfix) with ESMTP id 36AEB9E29A; Sun, + 18 Apr 2004 15:34:12 +1200 (NZST) +Date: Sun, 18 Apr 2004 15:35:58 +1200 +From: Mark Kirkwood +Subject: Re: Poor performance of group by query +In-reply-to: <20040416151706.GE87362@nasby.net> +To: "Jim C. Nasby" +Cc: pgsql-performance@postgresql.org +Message-id: <4081F79E.6070409@paradise.net.nz> +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=us-ascii +Content-transfer-encoding: 7bit +X-Accept-Language: en-us, en +User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.6) Gecko/20040404 +References: <20040416151706.GE87362@nasby.net> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/239 +X-Sequence-Number: 6539 + +It might be worth trying out a build with -O2, just to rule out any -O3 +oddness. + +regards + +Mark + +Jim C. Nasby wrote: + +> PostgreSQL 7.4.2 compiled with -O3. +> +> +> +> + +From pgsql-performance-owner@postgresql.org Sun Apr 18 00:46:05 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E9F60D1DCF5 + for ; + Sun, 18 Apr 2004 00:46:04 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 15239-01 + for ; + Sun, 18 Apr 2004 00:46:02 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 9297DD1DC7D + for ; + Sun, 18 Apr 2004 00:46:01 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3I3jxVJ015054; + Sat, 17 Apr 2004 23:45:59 -0400 (EDT) +To: Greg Stark +Cc: "Jim C. Nasby" , pgsql-performance@postgresql.org +Subject: Re: Horribly slow hash join +In-reply-to: <878ygu8auw.fsf@stark.xeocode.com> +References: <20040416154502.GF87362@nasby.net> <450.1082133251@sss.pgh.pa.us> + <20040416164644.GH87362@nasby.net> <808.1082135098@sss.pgh.pa.us> + <20040416172523.GJ87362@nasby.net> <1263.1082138383@sss.pgh.pa.us> + <20040416184541.GK87362@nasby.net> <10603.1082218095@sss.pgh.pa.us> + <878ygu8auw.fsf@stark.xeocode.com> +Comments: In-reply-to Greg Stark + message dated "17 Apr 2004 19:04:39 -0400" +Date: Sat, 17 Apr 2004 23:45:58 -0400 +Message-ID: <15053.1082259958@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/240 +X-Sequence-Number: 6540 + +Greg Stark writes: +> Tom Lane writes: +>> (Also, I have been harboring some notions of supporting cross-type hash +>> joins for integer types, which will not work unless small int8 values hash +>> the same as int4 etc.) + +> The obvious way to modify the hash function is to xor the high 32 bits with +> the low 32 bits. That maintains the property you need + +No it doesn't ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Apr 18 03:18:51 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id EF406D1E298 + for ; + Sun, 18 Apr 2004 03:18:49 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 38135-10 + for ; + Sun, 18 Apr 2004 03:18:49 -0300 (ADT) +Received: from zigo.dhs.org (as2-4-3.an.g.bonet.se [194.236.34.191]) + by svr1.postgresql.org (Postfix) with ESMTP id DCD2AD1E2A7 + for ; + Sun, 18 Apr 2004 03:18:47 -0300 (ADT) +Received: from zigo.zigo.dhs.org (zigo.zigo.dhs.org [192.168.0.1]) + by zigo.dhs.org (Postfix) with ESMTP + id A74D888E9; Sun, 18 Apr 2004 08:18:47 +0200 (CEST) +Date: Sun, 18 Apr 2004 08:18:47 +0200 (CEST) +From: Dennis Bjorklund +To: Tom Lane +Cc: "Jim C. Nasby" , + +Subject: Re: Horribly slow hash join +In-Reply-To: <10603.1082218095@sss.pgh.pa.us> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=ISO-8859-1 +Content-Transfer-Encoding: 8BIT +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/241 +X-Sequence-Number: 6541 + +On Sat, 17 Apr 2004, Tom Lane wrote: + +> *some* set of inputs. (Also, I have been harboring some notions of +> supporting cross-type hash joins for integer types, which will not work +> unless small int8 values hash the same as int4 etc.) + +The simple solution would be to always extend integers to 64 bits (or +whatever the biggest integer is) before calculating the hash. It makes the +hash function a little slower for smaller types, but it's mostly an +operation in the cpu and no memory involved, so it's probably not +noticable. + +-- +/Dennis Bj�rklund + + +From pgsql-performance-owner@postgresql.org Sun Apr 18 03:43:12 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 00F05D1DC7D + for ; + Sun, 18 Apr 2004 03:43:11 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 48056-03 + for ; + Sun, 18 Apr 2004 03:43:10 -0300 (ADT) +Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) + by svr1.postgresql.org (Postfix) with ESMTP id 436D0D1D300 + for ; + Sun, 18 Apr 2004 03:43:09 -0300 (ADT) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by smtp.istop.com (Postfix) with ESMTP + id D9A7417C144; Sun, 18 Apr 2004 02:43:09 -0400 (EDT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1BF61F-0006Mm-00; Sun, 18 Apr 2004 02:43:09 -0400 +To: Tom Lane +Cc: Greg Stark , "Jim C. Nasby" , + pgsql-performance@postgresql.org +Subject: Re: Horribly slow hash join +References: <20040416154502.GF87362@nasby.net> <450.1082133251@sss.pgh.pa.us> + <20040416164644.GH87362@nasby.net> <808.1082135098@sss.pgh.pa.us> + <20040416172523.GJ87362@nasby.net> <1263.1082138383@sss.pgh.pa.us> + <20040416184541.GK87362@nasby.net> <10603.1082218095@sss.pgh.pa.us> + <878ygu8auw.fsf@stark.xeocode.com> <15053.1082259958@sss.pgh.pa.us> +In-Reply-To: <15053.1082259958@sss.pgh.pa.us> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 18 Apr 2004 02:43:09 -0400 +Message-ID: <873c719476.fsf@stark.xeocode.com> +Lines: 23 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/242 +X-Sequence-Number: 6542 + +Tom Lane writes: + +> Greg Stark writes: +> > Tom Lane writes: +> >> (Also, I have been harboring some notions of supporting cross-type hash +> >> joins for integer types, which will not work unless small int8 values hash +> >> the same as int4 etc.) +> +> > The obvious way to modify the hash function is to xor the high 32 bits with +> > the low 32 bits. That maintains the property you need +> +> No it doesn't ... + +Eh? Oh, negative numbers? So low^high^sign. + + +I wonder if it makes sense to have check the hash distribution after +generating the table and if it's bad then throw it away and try again with a +different hash function. The "different hash function" would probably just be +a seed value changing. Probably way overkill though. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Sun Apr 18 12:39:15 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 53D18D1DCF5 + for ; + Sun, 18 Apr 2004 12:39:14 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 62249-05 + for ; + Sun, 18 Apr 2004 12:39:13 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 65CF0D1DCC0 + for ; + Sun, 18 Apr 2004 12:39:12 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3IFdApS019682; + Sun, 18 Apr 2004 11:39:10 -0400 (EDT) +To: Dennis Bjorklund +Cc: "Jim C. Nasby" , pgsql-performance@postgresql.org +Subject: Re: Horribly slow hash join +In-reply-to: +References: +Comments: In-reply-to Dennis Bjorklund + message dated "Sun, 18 Apr 2004 08:18:47 +0200" +Date: Sun, 18 Apr 2004 11:39:10 -0400 +Message-ID: <19681.1082302750@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/243 +X-Sequence-Number: 6543 + +Dennis Bjorklund writes: +> On Sat, 17 Apr 2004, Tom Lane wrote: +>> *some* set of inputs. (Also, I have been harboring some notions of +>> supporting cross-type hash joins for integer types, which will not work +>> unless small int8 values hash the same as int4 etc.) + +> The simple solution would be to always extend integers to 64 bits (or +> whatever the biggest integer is) before calculating the hash. + +That creates portability issues though. We do not depend on there being +a 64-bit-int type for anything except int8 itself, and I don't want to +start doing so. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Apr 18 12:46:41 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6E7FCD1B4B2 + for ; + Sun, 18 Apr 2004 12:46:40 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 68606-01 + for ; + Sun, 18 Apr 2004 12:46:38 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 1C2B3D1B482 + for ; + Sun, 18 Apr 2004 12:46:38 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3IFkZjr019740; + Sun, 18 Apr 2004 11:46:36 -0400 (EDT) +To: Greg Stark +Cc: "Jim C. Nasby" , pgsql-performance@postgresql.org +Subject: Re: Horribly slow hash join +In-reply-to: <873c719476.fsf@stark.xeocode.com> +References: <20040416154502.GF87362@nasby.net> <450.1082133251@sss.pgh.pa.us> + <20040416164644.GH87362@nasby.net> <808.1082135098@sss.pgh.pa.us> + <20040416172523.GJ87362@nasby.net> <1263.1082138383@sss.pgh.pa.us> + <20040416184541.GK87362@nasby.net> <10603.1082218095@sss.pgh.pa.us> + <878ygu8auw.fsf@stark.xeocode.com> <15053.1082259958@sss.pgh.pa.us> + <873c719476.fsf@stark.xeocode.com> +Comments: In-reply-to Greg Stark + message dated "18 Apr 2004 02:43:09 -0400" +Date: Sun, 18 Apr 2004 11:46:35 -0400 +Message-ID: <19739.1082303195@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/244 +X-Sequence-Number: 6544 + +Greg Stark writes: +> Eh? Oh, negative numbers? So low^high^sign. + +[ thinks about it... ] Yeah, that would work. We can't backpatch it +without breaking existing hash indexes on int8, but it'd be reasonable +to change for 7.5 (since at the rate things are going, we won't have +pg_upgrade for 7.5 anyway...) + +> I wonder if it makes sense to have check the hash distribution after +> generating the table and if it's bad then throw it away and try again with a +> different hash function. The "different hash function" would probably just be +> a seed value changing. Probably way overkill though. + +Yeah, it'd be a pain trying to get all the type-specific hash functions +doing that. I'm also unconvinced that a simple change of seed value +would necessarily make the distribution better. In the worst case, if +the real problem is that all the input values are identical, you can +reseed all day long and it won't fix it. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Apr 18 12:58:43 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 10A7AD1E928 + for ; + Sun, 18 Apr 2004 12:58:43 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 64800-08 + for ; + Sun, 18 Apr 2004 12:58:40 -0300 (ADT) +Received: from zigo.dhs.org (as2-4-3.an.g.bonet.se [194.236.34.191]) + by svr1.postgresql.org (Postfix) with ESMTP id 4C38CD1E8FB + for ; + Sun, 18 Apr 2004 12:58:39 -0300 (ADT) +Received: from zigo.zigo.dhs.org (zigo.zigo.dhs.org [192.168.0.1]) + by zigo.dhs.org (Postfix) with ESMTP + id B470380DB; Sun, 18 Apr 2004 17:58:38 +0200 (CEST) +Date: Sun, 18 Apr 2004 17:58:38 +0200 (CEST) +From: Dennis Bjorklund +To: Tom Lane +Cc: "Jim C. Nasby" , + +Subject: Re: Horribly slow hash join +In-Reply-To: <19681.1082302750@sss.pgh.pa.us> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=ISO-8859-1 +Content-Transfer-Encoding: 8BIT +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/245 +X-Sequence-Number: 6545 + +On Sun, 18 Apr 2004, Tom Lane wrote: + +> That creates portability issues though. We do not depend on there being +> a 64-bit-int type for anything except int8 itself, and I don't want to +> start doing so. + +What do you mean? int8 is supported on all platformas and if the +hasfunction would convert all numbers to int8 before making the hash it +would work. + +I don't see any portability problems. + +-- +/Dennis Bj�rklund + + +From pgsql-performance-owner@postgresql.org Sun Apr 18 13:23:49 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2FD25D1E812 + for ; + Sun, 18 Apr 2004 13:23:47 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 75020-02 + for ; + Sun, 18 Apr 2004 13:23:46 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 3ECBDD1E7EF + for ; + Sun, 18 Apr 2004 13:23:45 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3IGNd1C020085; + Sun, 18 Apr 2004 12:23:39 -0400 (EDT) +To: Dennis Bjorklund +Cc: "Jim C. Nasby" , pgsql-performance@postgresql.org +Subject: Re: Horribly slow hash join +In-reply-to: +References: +Comments: In-reply-to Dennis Bjorklund + message dated "Sun, 18 Apr 2004 17:58:38 +0200" +Date: Sun, 18 Apr 2004 12:23:39 -0400 +Message-ID: <20084.1082305419@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/246 +X-Sequence-Number: 6546 + +Dennis Bjorklund writes: +> What do you mean? int8 is supported on all platformas + +No it isn't. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Apr 18 13:27:12 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 10BABD1D064 + for ; + Sun, 18 Apr 2004 13:27:11 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 72710-05 + for ; + Sun, 18 Apr 2004 13:27:10 -0300 (ADT) +Received: from zigo.dhs.org (as2-4-3.an.g.bonet.se [194.236.34.191]) + by svr1.postgresql.org (Postfix) with ESMTP id 474E5D1D05C + for ; + Sun, 18 Apr 2004 13:27:09 -0300 (ADT) +Received: from zigo.zigo.dhs.org (zigo.zigo.dhs.org [192.168.0.1]) + by zigo.dhs.org (Postfix) with ESMTP + id 19FAF88E9; Sun, 18 Apr 2004 18:27:09 +0200 (CEST) +Date: Sun, 18 Apr 2004 18:27:09 +0200 (CEST) +From: Dennis Bjorklund +To: Tom Lane +Cc: "Jim C. Nasby" , + +Subject: Re: Horribly slow hash join +In-Reply-To: <20084.1082305419@sss.pgh.pa.us> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=ISO-8859-1 +Content-Transfer-Encoding: 8BIT +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/247 +X-Sequence-Number: 6547 + +On Sun, 18 Apr 2004, Tom Lane wrote: + +> > What do you mean? int8 is supported on all platformas +> +> No it isn't. + +So on platforms where it isn't you would use int4 as the biggest int then. +I don't really see that as a problem. As long as you calculate the hash on +the biggest int on that platform it should work. + +-- +/Dennis Bj�rklund + + +From pgsql-performance-owner@postgresql.org Sun Apr 18 15:47:48 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D71CDD1CC8D + for ; + Sun, 18 Apr 2004 15:47:45 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 09515-06 + for ; + Sun, 18 Apr 2004 15:47:45 -0300 (ADT) +Received: from net2.micro-automation.com (net2.micro-automation.com + [64.7.141.29]) + by svr1.postgresql.org (Postfix) with SMTP id 7777CD1C515 + for ; + Sun, 18 Apr 2004 15:47:42 -0300 (ADT) +Received: (qmail 625 invoked from network); 18 Apr 2004 18:47:38 -0000 +Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) + by net2.micro-automation.com with SMTP; 18 Apr 2004 18:47:38 -0000 +Subject: Re: Toooo many context switches (maybe SLES8?) +From: Dave Cramer +Reply-To: pg@fastcrypt.com +To: Josh Berkus +Cc: Tom Lane , Joe Conway , + Dirk =?ISO-8859-1?Q?Lutzeb=E4ck?= , + pgsql-performance@postgresql.org +In-Reply-To: <200404151337.00273.josh@agliodbs.com> +References: <407E7B99.3050306@aeccom.com> <407EBA89.6080007@joeconway.com> + <20498.1082057841@sss.pgh.pa.us> <200404151337.00273.josh@agliodbs.com> +Content-Type: text/plain +Organization: Cramer Consulting +Message-Id: <1082314193.1557.44.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Sun, 18 Apr 2004 14:49:53 -0400 +Content-Transfer-Encoding: 7bit +X-AntiVirus: scanned for viruses by AMaViS 0.2.1 (http://amavis.org/) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/248 +X-Sequence-Number: 6548 + +Isn't this a linux kernel issue ? + +My understanding is that the scheduler doesn't know that 2 of the CPU's +are actually the same underlying hardware and sometimes two contexts end +up fighting for the same underlying chip? + +--dc-- + +On Thu, 2004-04-15 at 16:37, Josh Berkus wrote: +> Folks, +> +> > I am currently chasing what seems to be the same issue: massive context +> > swapping on a dual Xeon system. I tried back-patching the above-mentioned +> > patch ... it helps a little but by no means solves the problem ... +> +> BTW, I'm currently pursuing the possibility that this has something to do with +> the ServerWorks chipset on those motherboards. If anyone knows a high-end +> hardware+linux kernel geek I can corner, I'd appreciate it. +> +> Maybe I should contact OSDL ... +-- +Dave Cramer +519 939 0336 +ICQ # 14675561 + + +From pgsql-performance-owner@postgresql.org Sun Apr 18 16:22:35 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4C565D1BC59 + for ; + Sun, 18 Apr 2004 16:22:34 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 14908-09 + for ; + Sun, 18 Apr 2004 16:22:34 -0300 (ADT) +Received: from web11.manitu.net (web11.manitu.net [217.11.48.111]) + by svr1.postgresql.org (Postfix) with ESMTP id 2A049D1BB49 + for ; + Sun, 18 Apr 2004 16:22:32 -0300 (ADT) +Received: from [192.168.0.1] (dsl-082-082-191-125.arcor-ip.net + [82.82.191.125]) + (authenticated) + by web11.manitu.net (8.10.2-SOL3/8.10.2) with ESMTP id i3IJMMM04900; + Sun, 18 Apr 2004 21:22:22 +0200 +Subject: Re: sunquery and estimated rows +From: Markus Bertheau +To: Tom Lane +Cc: Litao Wu , pgsql-performance@postgresql.org +In-Reply-To: <3802.1082159101@sss.pgh.pa.us> +References: <20040416214529.10468.qmail@web13125.mail.yahoo.com> + <3802.1082159101@sss.pgh.pa.us> +Content-Type: text/plain; charset=UTF-8 +Message-Id: <1082316145.2191.0.camel@yarrow.bertheau.de> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-1) +Date: Sun, 18 Apr 2004 21:22:26 +0200 +Content-Transfer-Encoding: quoted-printable +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/249 +X-Sequence-Number: 6549 + +=D0=92 =D0=A1=D0=B1=D1=82, 17.04.2004, =D0=B2 01:45, Tom Lane =D0=BF=D0=B8= +=D1=88=D0=B5=D1=82: + +> The planner sees that as "where scope =3D " +> and falls back to a default estimate. It won't simplify a sub-select +> to a constant. (Some people consider that a feature ;-).) + +Why? + +Thanks + +--=20 +Markus Bertheau + + +From pgsql-performance-owner@postgresql.org Sun Apr 18 18:47:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id BB186D1B8DF + for ; + Sun, 18 Apr 2004 18:47:48 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 38761-06 + for ; + Sun, 18 Apr 2004 18:47:48 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 61D49D1B4B2 + for ; + Sun, 18 Apr 2004 18:47:45 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3ILlfdb011438; + Sun, 18 Apr 2004 17:47:41 -0400 (EDT) +To: lutzeb@aeccom.com +Cc: Josh Berkus , + pgsql-performance@postgreSQL.org, Neil Conway +Subject: Re: Wierd context-switching issue on Xeon +In-reply-to: <407EFC95.5070805@aeccom.com> +References: <200311251419.36771.josh@agliodbs.com> + <200404151039.17763.josh@agliodbs.com> + <407EE93F.3090705@aeccom.com> + <200404151335.27762.josh@agliodbs.com> + <407EFC95.5070805@aeccom.com> +Comments: In-reply-to Dirk.Lutzebaeck@t-online.de (Dirk Lutzebaeck) + message dated "Thu, 15 Apr 2004 23:20:21 +0200" +Date: Sun, 18 Apr 2004 17:47:41 -0400 +Message-ID: <11437.1082324861@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/250 +X-Sequence-Number: 6550 + +After some further digging I think I'm starting to understand what's up +here, and the really fundamental answer is that a multi-CPU Xeon MP box +sucks for running Postgres. + +I did a bunch of oprofile measurements on a machine belonging to one of +Josh's clients, using a test case that involved heavy concurrent access +to a relatively small amount of data (little enough to fit into Postgres +shared buffers, so that no I/O or kernel calls were really needed once +the test got going). I found that by nearly any measure --- elapsed +time, bus transactions, or machine-clear events --- the spinlock +acquisitions associated with grabbing and releasing the BufMgrLock took +an unreasonable fraction of the time. I saw about 15% of elapsed time, +40% of bus transactions, and nearly 100% of pipeline-clear cycles going +into what is essentially two instructions out of the entire backend. +(Pipeline clears occur when the cache coherency logic detects a memory +write ordering problem.) + +I am not completely clear on why this machine-level bottleneck manifests +as a lot of context swaps at the OS level. I think what is happening is +that because SpinLockAcquire is so slow, a process is much more likely +than you'd normally expect to arrive at SpinLockAcquire while another +process is also acquiring the spinlock. This puts the two processes +into a "lockstep" condition where the second process is nearly certain +to observe the BufMgrLock as locked, and be forced to suspend itself, +even though the time the first process holds the BufMgrLock is not +really very long at all. + +If you google for Xeon and "cache coherency" you'll find quite a bit of +suggestive information about why this might be more true on the Xeon +setup than others. A couple of interesting hits: + +http://www.theinquirer.net/?article=10797 +says that Xeon MP uses a *slower* FSB than Xeon DP. This would +translate directly to more time needed to transfer a dirty cache line +from one processor to the other, which is the basic operation that we're +talking about here. + +http://www.aceshardware.com/Spades/read.php?article_id=30000187 +says that Opterons use a different cache coherency protocol that is +fundamentally superior to the Xeon's, because dirty cache data can be +transferred directly between two processor caches without waiting for +main memory. + +So in the short term I think we have to tell people that Xeon MP is not +the most desirable SMP platform to run Postgres on. (Josh thinks that +the specific motherboard chipset being used in these machines might +share some of the blame too. I don't have any evidence for or against +that idea, but it's certainly possible.) + +In the long run, however, CPUs continue to get faster than main memory +and the price of cache contention will continue to rise. So it seems +that we need to give up the assumption that SpinLockAcquire is a cheap +operation. In the presence of heavy contention it won't be. + +One thing we probably have got to do soon is break up the BufMgrLock +into multiple finer-grain locks so that there will be less contention. +However I am wary of doing this incautiously, because if we do it in a +way that makes for a significant rise in the number of locks that have +to be acquired to access a buffer, we might end up with a net loss. + +I think Neil Conway was looking into how the bufmgr might be +restructured to reduce lock contention, but if he had come up with +anything he didn't mention exactly what. Neil? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Apr 18 20:09:28 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id ED1CED1E928 + for ; + Sun, 18 Apr 2004 20:09:27 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 61183-06 + for ; + Sun, 18 Apr 2004 20:09:29 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id F0651D1E949 + for ; + Sun, 18 Apr 2004 20:09:25 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3IN9RlN012051; + Sun, 18 Apr 2004 19:09:27 -0400 (EDT) +To: Markus Bertheau +Cc: Litao Wu , pgsql-performance@postgresql.org +Subject: Re: sunquery and estimated rows +In-reply-to: <1082316145.2191.0.camel@yarrow.bertheau.de> +References: <20040416214529.10468.qmail@web13125.mail.yahoo.com> + <3802.1082159101@sss.pgh.pa.us> + <1082316145.2191.0.camel@yarrow.bertheau.de> +Comments: In-reply-to Markus Bertheau + message dated "Sun, 18 Apr 2004 21:22:26 +0200" +Date: Sun, 18 Apr 2004 19:09:26 -0400 +Message-ID: <12050.1082329766@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/251 +X-Sequence-Number: 6551 + +Markus Bertheau writes: +> В Сбт, 17.04.2004, в 01:45, Tom Lane пишет: +>> The planner sees that as "where scope = " +>> and falls back to a default estimate. It won't simplify a sub-select +>> to a constant. (Some people consider that a feature ;-).) + +> Why? + +It's the only way to prevent it from simplifying when you don't want it +to. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Apr 18 20:32:30 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 66519D1D064 + for ; + Sun, 18 Apr 2004 20:32:29 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 58765-09 + for ; + Sun, 18 Apr 2004 20:32:29 -0300 (ADT) +Received: from net2.micro-automation.com (net2.micro-automation.com + [64.7.141.29]) + by svr1.postgresql.org (Postfix) with SMTP id 916B0D1CACC + for ; + Sun, 18 Apr 2004 20:32:25 -0300 (ADT) +Received: (qmail 10377 invoked from network); 18 Apr 2004 23:32:23 -0000 +Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) + by net2.micro-automation.com with SMTP; 18 Apr 2004 23:32:24 -0000 +Subject: Re: Wierd context-switching issue on Xeon +From: Dave Cramer +Reply-To: pg@fastcrypt.com +To: Tom Lane +Cc: lutzeb@aeccom.com, Josh Berkus , + pgsql-performance@postgreSQL.org, Neil Conway +In-Reply-To: <11437.1082324861@sss.pgh.pa.us> +References: <200311251419.36771.josh@agliodbs.com> + <200404151039.17763.josh@agliodbs.com> <407EE93F.3090705@aeccom.com> + <200404151335.27762.josh@agliodbs.com> <407EFC95.5070805@aeccom.com> + <11437.1082324861@sss.pgh.pa.us> +Content-Type: text/plain +Organization: Cramer Consulting +Message-Id: <1082331281.1557.47.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Sun, 18 Apr 2004 19:34:41 -0400 +Content-Transfer-Encoding: 7bit +X-AntiVirus: scanned for viruses by AMaViS 0.2.1 (http://amavis.org/) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/252 +X-Sequence-Number: 6552 + +So the the kernel/OS is irrelevant here ? this happens on any dual xeon? + +What about hypterthreading does it still happen if HTT is turned off ? + +Dave +On Sun, 2004-04-18 at 17:47, Tom Lane wrote: +> After some further digging I think I'm starting to understand what's up +> here, and the really fundamental answer is that a multi-CPU Xeon MP box +> sucks for running Postgres. +> +> I did a bunch of oprofile measurements on a machine belonging to one of +> Josh's clients, using a test case that involved heavy concurrent access +> to a relatively small amount of data (little enough to fit into Postgres +> shared buffers, so that no I/O or kernel calls were really needed once +> the test got going). I found that by nearly any measure --- elapsed +> time, bus transactions, or machine-clear events --- the spinlock +> acquisitions associated with grabbing and releasing the BufMgrLock took +> an unreasonable fraction of the time. I saw about 15% of elapsed time, +> 40% of bus transactions, and nearly 100% of pipeline-clear cycles going +> into what is essentially two instructions out of the entire backend. +> (Pipeline clears occur when the cache coherency logic detects a memory +> write ordering problem.) +> +> I am not completely clear on why this machine-level bottleneck manifests +> as a lot of context swaps at the OS level. I think what is happening is +> that because SpinLockAcquire is so slow, a process is much more likely +> than you'd normally expect to arrive at SpinLockAcquire while another +> process is also acquiring the spinlock. This puts the two processes +> into a "lockstep" condition where the second process is nearly certain +> to observe the BufMgrLock as locked, and be forced to suspend itself, +> even though the time the first process holds the BufMgrLock is not +> really very long at all. +> +> If you google for Xeon and "cache coherency" you'll find quite a bit of +> suggestive information about why this might be more true on the Xeon +> setup than others. A couple of interesting hits: +> +> http://www.theinquirer.net/?article=10797 +> says that Xeon MP uses a *slower* FSB than Xeon DP. This would +> translate directly to more time needed to transfer a dirty cache line +> from one processor to the other, which is the basic operation that we're +> talking about here. +> +> http://www.aceshardware.com/Spades/read.php?article_id=30000187 +> says that Opterons use a different cache coherency protocol that is +> fundamentally superior to the Xeon's, because dirty cache data can be +> transferred directly between two processor caches without waiting for +> main memory. +> +> So in the short term I think we have to tell people that Xeon MP is not +> the most desirable SMP platform to run Postgres on. (Josh thinks that +> the specific motherboard chipset being used in these machines might +> share some of the blame too. I don't have any evidence for or against +> that idea, but it's certainly possible.) +> +> In the long run, however, CPUs continue to get faster than main memory +> and the price of cache contention will continue to rise. So it seems +> that we need to give up the assumption that SpinLockAcquire is a cheap +> operation. In the presence of heavy contention it won't be. +> +> One thing we probably have got to do soon is break up the BufMgrLock +> into multiple finer-grain locks so that there will be less contention. +> However I am wary of doing this incautiously, because if we do it in a +> way that makes for a significant rise in the number of locks that have +> to be acquired to access a buffer, we might end up with a net loss. +> +> I think Neil Conway was looking into how the bufmgr might be +> restructured to reduce lock contention, but if he had come up with +> anything he didn't mention exactly what. Neil? +> +> regards, tom lane +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: you can get off all lists at once with the unregister command +> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) +> +> +> +> !DSPAM:4082feb7326901956819835! +> +> +-- +Dave Cramer +519 939 0336 +ICQ # 14675561 + + +From pgsql-performance-owner@postgresql.org Tue Apr 20 10:58:29 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 86EE5D1D09C + for ; + Sun, 18 Apr 2004 20:43:52 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 73713-01 + for ; + Sun, 18 Apr 2004 20:43:53 -0300 (ADT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3B0C7D1D064 + for ; + Sun, 18 Apr 2004 20:43:50 -0300 (ADT) +Received: from [134.22.69.199] (dyn-69-199.tor.dsl.tht.net [134.22.69.199]) + by tht.net (Postfix) with ESMTP + id D132876A2A; Sun, 18 Apr 2004 19:43:57 -0400 (EDT) +Subject: Re: sunquery and estimated rows +From: Rod Taylor +To: Tom Lane +Cc: Markus Bertheau , Litao Wu , + Postgresql Performance +In-Reply-To: <12050.1082329766@sss.pgh.pa.us> +References: <20040416214529.10468.qmail@web13125.mail.yahoo.com> + <3802.1082159101@sss.pgh.pa.us> + <1082316145.2191.0.camel@yarrow.bertheau.de> + <12050.1082329766@sss.pgh.pa.us> +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="=-lUbIYknmc3AnUBbPQ3d/" +Message-Id: <1082331774.47576.136.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Sun, 18 Apr 2004 19:42:55 -0400 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/300 +X-Sequence-Number: 6600 + +--=-lUbIYknmc3AnUBbPQ3d/ +Content-Type: text/plain +Content-Transfer-Encoding: quoted-printable + +On Sun, 2004-04-18 at 19:09, Tom Lane wrote: +> Markus Bertheau writes: +> > , 17.04.2004, 01:45, Tom Lane : +> >> The planner sees that as "where scope =3D " +> >> and falls back to a default estimate. It won't simplify a sub-select +> >> to a constant. (Some people consider that a feature ;-).) +>=20 +> > Why? +>=20 +> It's the only way to prevent it from simplifying when you don't want it +> to. + +I'm having a difficult time coming up with a circumstance where that is +beneficial except when stats are out of whack. + +Doesn't a prepared statement also falls back to the default estimate for +variables. + +--=20 +Rod Taylor + +Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL +PGP Key: http://www.rbt.ca/signature.asc + +--=-lUbIYknmc3AnUBbPQ3d/ +Content-Type: application/pgp-signature; name=signature.asc +Content-Description: This is a digitally signed message part + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.4 (FreeBSD) + +iD8DBQBAgxJ96DETLow6vwwRAsIkAJ91VWf31bzt826YLFp5TaIU2847SwCeP5bd +EL/fSZkC394t55ypX0sD2GQ= +=xhey +-----END PGP SIGNATURE----- + +--=-lUbIYknmc3AnUBbPQ3d/-- + + +From pgsql-performance-owner@postgresql.org Sun Apr 18 21:40:35 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2BD19D1E1F3 + for ; + Sun, 18 Apr 2004 21:40:34 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 86378-01 + for ; + Sun, 18 Apr 2004 21:40:35 -0300 (ADT) +Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) + by svr1.postgresql.org (Postfix) with ESMTP id 3875ED1E0D8 + for ; + Sun, 18 Apr 2004 21:40:32 -0300 (ADT) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by smtp.istop.com (Postfix) with ESMTP + id A582617C46F; Sun, 18 Apr 2004 20:40:35 -0400 (EDT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1BFMpv-00016W-00; Sun, 18 Apr 2004 20:40:35 -0400 +To: Tom Lane +Cc: lutzeb@aeccom.com, Josh Berkus , + pgsql-performance@postgresql.org, Neil Conway +Subject: Re: Wierd context-switching issue on Xeon +References: <200311251419.36771.josh@agliodbs.com> + <200404151039.17763.josh@agliodbs.com> <407EE93F.3090705@aeccom.com> + <200404151335.27762.josh@agliodbs.com> <407EFC95.5070805@aeccom.com> + <11437.1082324861@sss.pgh.pa.us> +In-Reply-To: <11437.1082324861@sss.pgh.pa.us> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 18 Apr 2004 20:40:35 -0400 +Message-ID: <87d6647qbg.fsf@stark.xeocode.com> +Lines: 23 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/253 +X-Sequence-Number: 6553 + + +Tom Lane writes: + +> So in the short term I think we have to tell people that Xeon MP is not +> the most desirable SMP platform to run Postgres on. (Josh thinks that +> the specific motherboard chipset being used in these machines might +> share some of the blame too. I don't have any evidence for or against +> that idea, but it's certainly possible.) +> +> In the long run, however, CPUs continue to get faster than main memory +> and the price of cache contention will continue to rise. So it seems +> that we need to give up the assumption that SpinLockAcquire is a cheap +> operation. In the presence of heavy contention it won't be. + +There's nothing about the way Postgres spinlocks are coded that affects this? + +Is it something the kernel could help with? I've been wondering whether +there's any benefits postgres is missing out on by using its own hand-rolled +locking instead of using the pthreads infrastructure that the kernel is often +involved in. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Sun Apr 18 23:16:52 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6DB6BD1B4BE + for ; + Sun, 18 Apr 2004 23:16:51 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 06866-01 + for ; + Sun, 18 Apr 2004 23:16:53 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id A3D42D1B482 + for ; + Sun, 18 Apr 2004 23:16:49 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3J2GrME013911; + Sun, 18 Apr 2004 22:16:53 -0400 (EDT) +To: Rod Taylor +Cc: Markus Bertheau , Litao Wu , + Postgresql Performance +Subject: Re: sunquery and estimated rows +In-reply-to: <1082331774.47576.136.camel@jester> +References: <20040416214529.10468.qmail@web13125.mail.yahoo.com> + <3802.1082159101@sss.pgh.pa.us> + <1082316145.2191.0.camel@yarrow.bertheau.de> + <12050.1082329766@sss.pgh.pa.us> + <1082331774.47576.136.camel@jester> +Comments: In-reply-to Rod Taylor + message dated "Sun, 18 Apr 2004 19:42:55 -0400" +Date: Sun, 18 Apr 2004 22:16:53 -0400 +Message-ID: <13910.1082341013@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/254 +X-Sequence-Number: 6554 + +Rod Taylor writes: +>> It's the only way to prevent it from simplifying when you don't want it +>> to. + +> I'm having a difficult time coming up with a circumstance where that is +> beneficial except when stats are out of whack. + +Try trawling the archives --- I recall several cases in which people +were using sub-selects for this purpose. + +In any case, I don't see the value of having the planner check to see if +a sub-select is just a trivial arithmetic expression. The cases where +people write that and expect it to be simplified are so few and far +between that I can't believe it'd be a good use of planner cycles. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Apr 18 23:20:25 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1DCF7D1E98C + for ; + Sun, 18 Apr 2004 23:20:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 03558-06 + for ; + Sun, 18 Apr 2004 23:20:27 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 6EE19D1E997 + for ; + Sun, 18 Apr 2004 23:20:23 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3J2KMMc013961; + Sun, 18 Apr 2004 22:20:22 -0400 (EDT) +To: pg@fastcrypt.com +Cc: lutzeb@aeccom.com, Josh Berkus , + pgsql-performance@postgreSQL.org, Neil Conway +Subject: Re: Wierd context-switching issue on Xeon +In-reply-to: <1082331281.1557.47.camel@localhost.localdomain> +References: <200311251419.36771.josh@agliodbs.com> + <200404151039.17763.josh@agliodbs.com> + <407EE93F.3090705@aeccom.com> + <200404151335.27762.josh@agliodbs.com> + <407EFC95.5070805@aeccom.com> <11437.1082324861@sss.pgh.pa.us> + <1082331281.1557.47.camel@localhost.localdomain> +Comments: In-reply-to Dave Cramer + message dated "Sun, 18 Apr 2004 19:34:41 -0400" +Date: Sun, 18 Apr 2004 22:20:22 -0400 +Message-ID: <13960.1082341222@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/255 +X-Sequence-Number: 6555 + +Dave Cramer writes: +> So the the kernel/OS is irrelevant here ? this happens on any dual xeon? + +I believe so. The context-switch behavior might possibly be a little +more pleasant on other kernels, but the underlying spinlock problem is +not dependent on the kernel. + +> What about hypterthreading does it still happen if HTT is turned off ? + +The problem comes from keeping the caches synchronized between multiple +physical CPUs. AFAICS enabling HTT wouldn't make it worse, because a +hyperthreaded processor still only has one cache. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Apr 18 23:30:15 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 719CFD1B579 + for ; + Sun, 18 Apr 2004 23:30:12 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 10407-02 + for ; + Sun, 18 Apr 2004 23:30:15 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 5D9BDD1B515 + for ; + Sun, 18 Apr 2004 23:30:09 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3J2U9eT014057; + Sun, 18 Apr 2004 22:30:09 -0400 (EDT) +To: Greg Stark +Cc: lutzeb@aeccom.com, Josh Berkus , + pgsql-performance@postgresql.org, Neil Conway +Subject: Re: Wierd context-switching issue on Xeon +In-reply-to: <87d6647qbg.fsf@stark.xeocode.com> +References: <200311251419.36771.josh@agliodbs.com> + <200404151039.17763.josh@agliodbs.com> + <407EE93F.3090705@aeccom.com> + <200404151335.27762.josh@agliodbs.com> + <407EFC95.5070805@aeccom.com> <11437.1082324861@sss.pgh.pa.us> + <87d6647qbg.fsf@stark.xeocode.com> +Comments: In-reply-to Greg Stark + message dated "18 Apr 2004 20:40:35 -0400" +Date: Sun, 18 Apr 2004 22:30:08 -0400 +Message-ID: <14056.1082341808@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/256 +X-Sequence-Number: 6556 + +Greg Stark writes: +> There's nothing about the way Postgres spinlocks are coded that affects this? + +No. AFAICS our spinlock sequences are pretty much equivalent to the way +the Linux kernel codes its spinlocks, so there's no deep dark knowledge +to be mined there. + +We could possibly use some more-efficient blocking mechanism than semop() +once we've decided we have to block (it's a shame Linux still doesn't +have cross-process POSIX semaphores). But the striking thing I learned +from looking at the oprofile results is that most of the inefficiency +comes at the very first TAS() operation, before we've even "spun" let +alone decided we have to block. The s_lock() subroutine does not +account for more than a few percent of the runtime in these tests, +compared to 15% at the inline TAS() operations in LWLockAcquire and +LWLockRelease. I interpret this to mean that once it's acquired +ownership of the cache line, a Xeon can get through the "spinning" +loop in s_lock() mighty quickly. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Apr 19 00:12:20 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4A659D1EC90 + for ; + Mon, 19 Apr 2004 00:12:18 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 17503-05 + for ; + Mon, 19 Apr 2004 00:12:12 -0300 (ADT) +Received: from wolff.to (wolff.to [66.93.249.74]) + by svr1.postgresql.org (Postfix) with SMTP id 414DDD1B49B + for ; + Mon, 19 Apr 2004 00:12:06 -0300 (ADT) +Received: (qmail 1925 invoked by uid 500); 19 Apr 2004 03:15:54 -0000 +Date: Sun, 18 Apr 2004 22:15:54 -0500 +From: Bruno Wolff III +To: Dennis Bjorklund +Cc: Tom Lane , "Jim C. Nasby" , + pgsql-performance@postgresql.org +Subject: Re: Horribly slow hash join +Message-ID: <20040419031554.GA1881@wolff.to> +Mail-Followup-To: Dennis Bjorklund , + Tom Lane , "Jim C. Nasby" , + pgsql-performance@postgresql.org +References: <20084.1082305419@sss.pgh.pa.us> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/257 +X-Sequence-Number: 6557 + +On Sun, Apr 18, 2004 at 18:27:09 +0200, + Dennis Bjorklund wrote: +> On Sun, 18 Apr 2004, Tom Lane wrote: +> +> > > What do you mean? int8 is supported on all platformas +> > +> > No it isn't. +> +> So on platforms where it isn't you would use int4 as the biggest int then. +> I don't really see that as a problem. As long as you calculate the hash on +> the biggest int on that platform it should work. + +Another option would be to put the numbers into two int4s. For int4 or +smaller types one of these would be zero. int8s would be split between +the two. The hash function would then be defined on the two int4s. + +From pgsql-performance-owner@postgresql.org Mon Apr 19 00:20:07 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id BD7D4D1E98D + for ; + Mon, 19 Apr 2004 00:20:05 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 19777-05 + for ; + Mon, 19 Apr 2004 00:20:03 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id DAD8DD1B49B + for ; + Mon, 19 Apr 2004 00:20:01 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3J3JuHv014395; + Sun, 18 Apr 2004 23:19:56 -0400 (EDT) +To: pg@fastcrypt.com +Cc: lutzeb@aeccom.com, Josh Berkus , + pgsql-performance@postgresql.org, Neil Conway +Subject: Re: Wierd context-switching issue on Xeon +In-reply-to: <13960.1082341222@sss.pgh.pa.us> +References: <200311251419.36771.josh@agliodbs.com> + <200404151039.17763.josh@agliodbs.com> + <407EE93F.3090705@aeccom.com> + <200404151335.27762.josh@agliodbs.com> + <407EFC95.5070805@aeccom.com> <11437.1082324861@sss.pgh.pa.us> + <1082331281.1557.47.camel@localhost.localdomain> + <13960.1082341222@sss.pgh.pa.us> +Comments: In-reply-to Tom Lane + message dated "Sun, 18 Apr 2004 22:20:22 -0400" +Date: Sun, 18 Apr 2004 23:19:56 -0400 +Message-ID: <14394.1082344796@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/258 +X-Sequence-Number: 6558 + +>> What about hypterthreading does it still happen if HTT is turned off ? + +> The problem comes from keeping the caches synchronized between multiple +> physical CPUs. AFAICS enabling HTT wouldn't make it worse, because a +> hyperthreaded processor still only has one cache. + +Also, I forgot to say that the numbers I'm quoting *are* with HTT off. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Apr 19 01:43:21 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E9B33D1DACE + for ; + Mon, 19 Apr 2004 01:43:19 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 47657-02 + for ; + Mon, 19 Apr 2004 01:43:19 -0300 (ADT) +Received: from zigo.dhs.org (as2-4-3.an.g.bonet.se [194.236.34.191]) + by svr1.postgresql.org (Postfix) with ESMTP id 9DD36D1D167 + for ; + Mon, 19 Apr 2004 01:43:17 -0300 (ADT) +Received: from zigo.zigo.dhs.org (zigo.zigo.dhs.org [192.168.0.1]) + by zigo.dhs.org (Postfix) with ESMTP + id 899E480DB; Mon, 19 Apr 2004 06:43:16 +0200 (CEST) +Date: Mon, 19 Apr 2004 06:43:16 +0200 (CEST) +From: Dennis Bjorklund +To: Bruno Wolff III +Cc: Tom Lane , "Jim C. Nasby" , + +Subject: Re: Horribly slow hash join +In-Reply-To: <20040419031554.GA1881@wolff.to> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=ISO-8859-1 +Content-Transfer-Encoding: 8BIT +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/259 +X-Sequence-Number: 6559 + +On Sun, 18 Apr 2004, Bruno Wolff III wrote: + +> Another option would be to put the numbers into two int4s. For int4 or +> smaller types one of these would be zero. int8s would be split between +> the two. The hash function would then be defined on the two int4s. + +Sure, this is an internal calculation in the hash function. The only +important thing is that the number 7 (for example) gives the same hash +value no matter if it is an int2 or an int8 and that the hash function +works well also for int8 numbers (which is does not today). + +At least that was the properties I understood that we wanted. + +We got side tracked into talking about what datatype exists in all +platforms, that's not an issue at all. + +-- +/Dennis Bj�rklund + + +From pgsql-performance-owner@postgresql.org Mon Apr 19 02:29:24 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E5F68D1B8DF + for ; + Mon, 19 Apr 2004 02:29:22 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 53884-10 + for ; + Mon, 19 Apr 2004 02:29:21 -0300 (ADT) +Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) + by svr1.postgresql.org (Postfix) with ESMTP id 7E17ED1B4BE + for ; + Mon, 19 Apr 2004 02:29:20 -0300 (ADT) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by smtp.istop.com (Postfix) with ESMTP + id 5D7DD17C428; Mon, 19 Apr 2004 01:29:20 -0400 (EDT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1BFRLM-0001s9-00; Mon, 19 Apr 2004 01:29:20 -0400 +To: Dennis Bjorklund +Cc: Bruno Wolff III , Tom Lane , + "Jim C. Nasby" , +Subject: Re: Horribly slow hash join +References: +In-Reply-To: +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 19 Apr 2004 01:29:19 -0400 +Message-ID: <874qrg7cy8.fsf@stark.xeocode.com> +Lines: 50 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/260 +X-Sequence-Number: 6560 + + +Dennis Bjorklund writes: + +> On Sun, 18 Apr 2004, Bruno Wolff III wrote: +> +> > Another option would be to put the numbers into two int4s. For int4 or +> > smaller types one of these would be zero. int8s would be split between +> > the two. The hash function would then be defined on the two int4s. +> +> Sure, this is an internal calculation in the hash function. The only +> important thing is that the number 7 (for example) gives the same hash +> value no matter if it is an int2 or an int8 and that the hash function +> works well also for int8 numbers (which is does not today). + +What's missing here is that the actual API for hash functions is that the data +type provides a function that hashes to 32 bit integers. Then the hash code +uses the 32 bit integer to crunch down to the actual number of buckets (using +mod). + +The choice of 32 bit integers is purely arbitrary. As long as it's larger than +than the number of buckets in any sane hash table it's fine. 32 bits is +plenty. + +I question the use of mod to crunch the hash value down though. In the case of +int4 the mapping to 32 bits is simply the identity. So the entire hash +function ends up being simply "input mod #buckets". It seems way too easy to +find real world data sets where many numbers will all be multiples of some +number. If that common divisor shares any factors with the number of buckets, +then the distribution will be very far from even with many empty buckets. + +If the hash tables were made a power of two then it would be possible to mix +the bits of the 32 bit value and just mask off the unneeded bits. I've found +one page via google that mentions mixing bits in a hash function, but I would +look for a more serious treatment somewhere. + + http://burtleburtle.net/bob/hash/doobs.html + +Incidentally, this text claims mod is extremely slow compared to bit +manipulations. I don't know that that kind of cycle counting is really is a +factor for postgres though. + + +Also, incidentally, this text is interesting: + + http://www.isthe.com/chongo/tech/comp/fnv/ + + + +-- +greg + + +From pgsql-performance-owner@postgresql.org Mon Apr 19 03:09:36 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 55E0ED1D2C1 + for ; + Mon, 19 Apr 2004 03:09:34 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 73070-01 + for ; + Mon, 19 Apr 2004 03:09:33 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 6D3FCD1D29D + for ; + Mon, 19 Apr 2004 03:09:32 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3J69Ugw016042; + Mon, 19 Apr 2004 02:09:31 -0400 (EDT) +To: Greg Stark +Cc: Dennis Bjorklund , + Bruno Wolff III , "Jim C. Nasby" , + pgsql-performance@postgresql.org +Subject: Re: Horribly slow hash join +In-reply-to: <874qrg7cy8.fsf@stark.xeocode.com> +References: + <874qrg7cy8.fsf@stark.xeocode.com> +Comments: In-reply-to Greg Stark + message dated "19 Apr 2004 01:29:19 -0400" +Date: Mon, 19 Apr 2004 02:09:30 -0400 +Message-ID: <16041.1082354970@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/261 +X-Sequence-Number: 6561 + +Greg Stark writes: +> If the hash tables were made a power of two then it would be possible to mix +> the bits of the 32 bit value and just mask off the unneeded bits. I've found +> one page via google that mentions mixing bits in a hash function, but I would +> look for a more serious treatment somewhere. +> http://burtleburtle.net/bob/hash/doobs.html +> Incidentally, this text claims mod is extremely slow compared to bit +> manipulations. + +Modding by a *non* power of 2 (esp. a prime) mixes the bits quite well, +and is likely faster than any multiple-instruction way to do the same. + +The quoted article seems to be by someone who has spent a lot of time +counting assembly cycles and none at all reading the last thirty years +worth of CS literature. Knuth's treatment of hashing has some actual +math to it... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Apr 19 04:28:00 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 43A33D1D086 + for ; + Mon, 19 Apr 2004 04:27:59 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 90727-08 + for ; + Mon, 19 Apr 2004 04:27:59 -0300 (ADT) +Received: from mail2.aeccom.com (port-212-202-101-158.reverse.qsc.de + [212.202.101.158]) + by svr1.postgresql.org (Postfix) with ESMTP id F21BCD1D096 + for ; + Mon, 19 Apr 2004 04:27:56 -0300 (ADT) +Received: from aeccom.com (cayambe.core.aeccom.com [192.168.2.12]) + by mail2.aeccom.com (Postfix) with ESMTP + id 1E91F34; Mon, 19 Apr 2004 09:27:57 +0200 (CEST) +Message-ID: <40837F7D.9050102@aeccom.com> +Date: Mon, 19 Apr 2004 09:27:57 +0200 +From: =?ISO-8859-1?Q?Dirk_Lutzeb=E4ck?= +Organization: AEC/communications GmbH, Berlin +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031016 +X-Accept-Language: de, en +MIME-Version: 1.0 +To: josh@agliodbs.com +Cc: Tom Lane , pgsql-performance@postgresql.org +Subject: Re: RESOLVED: Re: Wierd context-switching issue on Xeon +References: <200311251419.36771.josh@agliodbs.com> + <407FAF0F.2070304@aeccom.com> <407FD9A0.6040608@aeccom.com> + <200404160958.14902.josh@agliodbs.com> +In-Reply-To: <200404160958.14902.josh@agliodbs.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/262 +X-Sequence-Number: 6562 + +Josh, I cannot reproduce the excessive semop() on a Dual XEON DP on a +non-bigmem kernel, HT on. Interesting to know if the problem is related +to XEON MP (as Tom wrote) or bigmem. + +Josh Berkus wrote: + +>Dirk, +> +> +> +>>I'm not sure if this semop() problem is still an issue but the database +>>behaves a bit out of bounds in this situation, i.e. consuming system +>>resources with semop() calls 95% while tables are locked very often and +>>longer. +>> +>> +> +>It would be helpful to us if you could test this with the indexes disabled on +>the non-Bigmem system. I'd like to eliminate Bigmem as a factor, if +>possible. +> +> +> + + + +From pgsql-performance-owner@postgresql.org Mon Apr 19 08:02:55 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DB60BD1D064 + for ; + Mon, 19 Apr 2004 08:02:52 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 64527-01 + for ; + Mon, 19 Apr 2004 08:02:53 -0300 (ADT) +Received: from kinetic.co.uk (mailhost.lei.co.uk [217.207.0.112]) + by svr1.postgresql.org (Postfix) with ESMTP id 17557D1BAAE + for ; + Mon, 19 Apr 2004 08:02:50 -0300 (ADT) +Received: from WorldClient ([217.207.0.112]) + (authenticated user gerard.isdell@kinetic.co.uk) + by kinetic.co.uk (kinetic.co.uk [217.207.0.112]) + (MDaemon.PRO.v7.0.1.R) with ESMTP id md50000026316.msg + for ; Mon, 19 Apr 2004 11:59:48 +0100 +Received: from [217.207.0.3] via WorldClient with HTTP; + Mon, 19 Apr 2004 11:59:48 +0100 +Date: Mon, 19 Apr 2004 11:59:48 +0100 +From: "Gerard Isdell" +To: pgsql-performance@postgresql.org +Subject: very slow simple query - outer join makes it quicker +MIME-Version: 1.0 +Content-Type: text/plain +Message-ID: +X-Mailer: WorldClient 7.0.1 +X-Authenticated-Sender: gerard.isdell@kinetic.co.uk +X-MDRemoteIP: 217.207.0.112 +X-Return-Path: gerard.isdell@kinetic.co.uk +X-MDaemon-Deliver-To: pgsql-performance@postgresql.org +Reply-To: gerard.isdell@kinetic.co.uk +X-Spam-Processed: kinetic.co.uk, Mon, 19 Apr 2004 11:59:49 +0100 +X-MDAV-Processed: kinetic.co.uk, Mon, 19 Apr 2004 11:59:49 +0100 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/263 +X-Sequence-Number: 6563 + +Hi Everyone + +I am new to this group and relatively new to Postgres, having used MSSQL 7 +up until now. + +One table in my database in returning even the simplest of queries extremely +slowly. The table is user table, and even the select userid from users takes +over 20 seconds to run. There are about 2000 records in the table. + + +The EXPLAIN ANALYZE on this table produces this output: +Seq Scan on users (cost=0.00..89482.63 rows=1463 width=4) (actual +time=68.836..40233.463 rows=1465 loops=1) +Total runtime: 40234.965 ms + + +SELECT USERID FROM USERS produces this: +1465 rows fetched (25.28 sec) + +The userid field is the primary key and has an index on it with this ddl: +ALTER TABLE "public"."users" ADD CONSTRAINT "users_pkey" PRIMARY KEY +("userid"); + +There are other tables, such as the messages table, that have 10s of +thousands of rows and they return records much more quickly. + + +There must be something seriously wrong for simple queries like this to take +so long. + +I should say that we are using the OpenFTS text search on the users table. + +In many cases to make the queries run at reasonable speeds I do an outer +join on another table, and surprisingly these results come back very quickly + +Can anybody help me in diagnosing this problem. + + +Gerard Isdell + + +************************************************************************* +This e-mail and any attachments may contain confidential or privileged +information. If you are not the intended recipient, please contact the +sender immediately and do not use, store or disclose their contents. +Any views expressed are those of the individual sender and not of Kinetic +Information System Services Limited unless otherwise stated. + + www.kinetic.co.uk + + +From pgsql-performance-owner@postgresql.org Mon Apr 19 23:29:23 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A8089D1D98A + for ; + Mon, 19 Apr 2004 23:29:19 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 12981-02 + for ; + Mon, 19 Apr 2004 23:29:21 -0300 (ADT) +Received: from ganymede.hub.org (u46n208.hfx.eastlink.ca [24.222.46.208]) + by svr1.postgresql.org (Postfix) with ESMTP id AF898D1B564 + for ; + Mon, 19 Apr 2004 23:29:14 -0300 (ADT) +Received: by ganymede.hub.org (Postfix, from userid 1000) + id A5EAB34288; Mon, 19 Apr 2004 23:29:18 -0300 (ADT) +Received: from localhost (localhost [127.0.0.1]) + by ganymede.hub.org (Postfix) with ESMTP id A32F9341DD + for ; + Mon, 19 Apr 2004 23:29:18 -0300 (ADT) +X-Received: from localhost ([unix socket]) + by ganymede.hub.org (Cyrus v2.2.3) with LMTP; + Mon, 19 Apr 2004 08:30:38 -0300 +X-Sieve: CMU Sieve 2.2 +X-Received: from localhost (localhost [127.0.0.1]) + by ganymede.hub.org (Postfix) with ESMTP id CF48F35BBD + for ; Mon, 19 Apr 2004 08:30:27 -0300 (ADT) +X-Received: from mail.postgresql.org [200.46.204.71] + by localhost with IMAP (fetchmail-6.2.5) + for scrappy@localhost (single-drop); + Mon, 19 Apr 2004 08:30:27 -0300 (ADT) +X-Received: from svr1.postgresql.org ([unix socket]) + by svr1.postgresql.org (Cyrus v2.2.3) with LMTP; + Mon, 19 Apr 2004 08:30:15 -0300 +X-Sieve: CMU Sieve 2.2 +X-Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9C69AD1D08C + for ; Mon, 19 Apr 2004 08:30:14 -0300 (ADT) +X-Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 69136-07 for ; + Mon, 19 Apr 2004 08:30:16 -0300 (ADT) +X-Received: from minnie.omroep.nl (minnie.omroep.nl [145.58.30.4]) + by svr1.postgresql.org (Postfix) with ESMTP id BA04FD1BCB8 + for ; Mon, 19 Apr 2004 08:30:10 -0300 (ADT) +X-Received: from tron.omroep.nl (tron.omroep.nl [145.58.31.20]) + by minnie.omroep.nl (Postfix) with ESMTP id AB8271CF3E15 + for ; Mon, 19 Apr 2004 13:30:13 +0200 (CDT) +X-Received: from michiel.omroep.nl (michiel.omroep.nl [145.58.67.10]) + by tron.omroep.nl (Postfix) with ESMTP id 9E8CE10056BD + for ; Mon, 19 Apr 2004 13:30:13 +0200 (CEST) +X-Received: from michiel by michiel.omroep.nl with local (Exim 3.35 #1 + (Debian)) id 1BFWyb-0008UY-00 + for ; Mon, 19 Apr 2004 13:30:13 +0200 +Date: Mon, 19 Apr 2004 13:30:13 +0200 +From: Michiel Meeuwissen +To: performance@postgresql.org +Subject: order by index, and inheritance +Message-ID: <20040419113013.GA32186@michiel.omroep.nl> +Reply-To: Michiel Meeuwissen +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +Organization: Publieke Omroep []() +User-Agent: Mutt/1.5.5.1+cvs20040105i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-DCC: EATSERVER: ganymede.hub.org 1166; IP=ok Body=1 Fuz1=1 Fuz2=1 +X-Spam-Pyzor: Reported 0 times. +ReSent-Date: Mon, 19 Apr 2004 23:29:13 -0300 (ADT) +Resent-From: "Marc G. Fournier" +Resent-To: pgsql-performance@postgresql.org +ReSent-Subject: order by index, and inheritance +ReSent-Message-ID: <20040419232913.V780@ganymede.hub.org> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/283 +X-Sequence-Number: 6583 + + +I have a query which performs not so well: + +SELECT * FROM mm_mediasources ORDER BY number DESC LIMIT 20; + +costs nearly a minute. The table contains over 300 000 records. + +The table has two extensions, which are (a the moment) nearly empty, but +have something to do with this, because: + +SELECT * FROM only mm_mediasources ORDER BY number DESC LIMIT 20; + +performs ok (8ms). The query plan is then as I would expect: + +media=# explain SELECT * FROM only mm_mediasources ORDER BY number DESC +LIMIT 20; + QUERY PLAN +--------------------------------------------------------------------------------------------------------------------- + Limit (cost=0.00..8.36 rows=20 width=105) + -> Index Scan Backward using mediasource_object on mm_mediasources +(cost=0.00..114641.05 rows=274318 width=105) + + + +The query plan of the original query, without 'only' does table scans: + +media=# explain SELECT * FROM mm_mediasources ORDER BY number DESC LIMIT 20; + QUERY PLAN +-------------------------------------------------------------------------------------------------------- + Limit (cost=47248.70..47248.75 rows=20 width=105) + -> Sort (cost=47248.70..47934.52 rows=274328 width=105) + Sort Key: public.mm_mediasources.number + -> Result (cost=0.00..8364.28 rows=274328 width=105) + -> Append (cost=0.00..8364.28 rows=274328 width=105) + -> Seq Scan on mm_mediasources (cost=0.00..8362.18 rows=274318 width=105) + -> Seq Scan on mm_audiosources mm_mediasources (cost=0.00..1.01 rows=1 width=84) + -> Seq Scan on mm_videosources mm_mediasources (cost=0.00..1.09 rows=9 width=89) + +and presumably because if that performs so lousy. + +Simply selecting on a number does work fast: +media=# explain SELECT * FROM mm_mediasources where number = 606973 ; + QUERY PLAN +-------------------------------------------------------------------------------------------------------- + Result (cost=0.00..6.13 rows=4 width=105) + -> Append (cost=0.00..6.13 rows=4 width=105) + -> Index Scan using mediasource_object on mm_mediasources (cost=0.00..4.00 rows=2 width=105) + Index Cond: (number = 606973) + -> Seq Scan on mm_audiosources mm_mediasources (cost=0.00..1.01 rows=1 width=84) + Filter: (number = 606973) + -> Seq Scan on mm_videosources mm_mediasources (cost=0.00..1.11 rows=1 width=89) + Filter: (number = 606973) + +(3ms) + +I suppose seq scans are used on the extensions because they contain so few +records. + + +All tables have index on number. How do I force it to use them also when I +use order by? + +I use psql 7.3.2 + +Michiel + +-- +Michiel Meeuwissen | +Mediapark C101 Hilversum | ++31 (0)35 6772979 | I hate computers +nl_NL eo_XX en_US | +mihxil' | + [] () | + +From pgsql-performance-owner@postgresql.org Mon Apr 19 09:02:21 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 997FDD1C952 + for ; + Mon, 19 Apr 2004 09:02:20 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 79041-05 + for ; + Mon, 19 Apr 2004 09:02:22 -0300 (ADT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8D489D1BB93 + for ; + Mon, 19 Apr 2004 09:02:18 -0300 (ADT) +Received: from [134.22.69.199] (dyn-69-199.tor.dsl.tht.net [134.22.69.199]) + by tht.net (Postfix) with ESMTP + id E818C76A6D; Mon, 19 Apr 2004 08:02:18 -0400 (EDT) +Subject: Re: very slow simple query - outer join makes it quicker +From: Rod Taylor +To: gerard.isdell@kinetic.co.uk +Cc: Postgresql Performance +In-Reply-To: +References: +Content-Type: text/plain +Message-Id: <1082376074.24414.3.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Mon, 19 Apr 2004 08:01:15 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/264 +X-Sequence-Number: 6564 + +> There are other tables, such as the messages table, that have 10s of +> thousands of rows and they return records much more quickly. + +> There must be something seriously wrong for simple queries like this to take +> so long. + +Have you run VACUUM recently? + +If not, run VACUUM FULL against the users table and see if that makes a +difference. + + +From pgsql-performance-owner@postgresql.org Mon Apr 19 09:05:27 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6CCDED1D08B + for ; + Mon, 19 Apr 2004 09:05:26 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 75036-09 + for ; + Mon, 19 Apr 2004 09:05:27 -0300 (ADT) +Received: from net2.micro-automation.com (net2.micro-automation.com + [64.7.141.29]) + by svr1.postgresql.org (Postfix) with SMTP id 43A74D1D08C + for ; + Mon, 19 Apr 2004 09:05:23 -0300 (ADT) +Received: (qmail 8053 invoked from network); 19 Apr 2004 12:05:19 -0000 +Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) + by net2.micro-automation.com with SMTP; 19 Apr 2004 12:05:19 -0000 +Subject: Re: Horribly slow hash join +From: Dave Cramer +Reply-To: pg@fastcrypt.com +To: Tom Lane +Cc: Greg Stark , Dennis Bjorklund , + Bruno Wolff III , "Jim C. Nasby" , + pgsql-performance@postgresql.org +In-Reply-To: <16041.1082354970@sss.pgh.pa.us> +References: + <874qrg7cy8.fsf@stark.xeocode.com> <16041.1082354970@sss.pgh.pa.us> +Content-Type: text/plain +Organization: Cramer Consulting +Message-Id: <1082376464.1558.69.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Mon, 19 Apr 2004 08:07:44 -0400 +Content-Transfer-Encoding: 7bit +X-AntiVirus: scanned for viruses by AMaViS 0.2.1 (http://amavis.org/) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/265 +X-Sequence-Number: 6565 + +Here's an interesting link that suggests that hyperthreading would be +much worse. + +http://groups.google.com/groups?q=hyperthreading+dual+xeon+idle&start=10&hl=en&lr=&ie=UTF-8&c2coff=1&selm=aukkonen-FE5275.21093624062003%40shawnews.gv.shawcable.net&rnum=16 + +FWIW, I have anecdotal evidence that suggests that this is the case, on +of my clients was seeing very large context switches with HTT turned on, +and without it was much better. + +Dave +On Mon, 2004-04-19 at 02:09, Tom Lane wrote: +> Greg Stark writes: +> > If the hash tables were made a power of two then it would be possible to mix +> > the bits of the 32 bit value and just mask off the unneeded bits. I've found +> > one page via google that mentions mixing bits in a hash function, but I would +> > look for a more serious treatment somewhere. +> > http://burtleburtle.net/bob/hash/doobs.html +> > Incidentally, this text claims mod is extremely slow compared to bit +> > manipulations. +> +> Modding by a *non* power of 2 (esp. a prime) mixes the bits quite well, +> and is likely faster than any multiple-instruction way to do the same. +> +> The quoted article seems to be by someone who has spent a lot of time +> counting assembly cycles and none at all reading the last thirty years +> worth of CS literature. Knuth's treatment of hashing has some actual +> math to it... +> +> regards, tom lane +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 3: if posting/reading through Usenet, please send an appropriate +> subscribe-nomail command to majordomo@postgresql.org so that your +> message can get through to the mailing list cleanly +> +> +> +> !DSPAM:40837183123741526418863! +> +> +-- +Dave Cramer +519 939 0336 +ICQ # 14675561 + + +From pgsql-performance-owner@postgresql.org Mon Apr 19 09:12:55 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 461CAD1D08C + for ; + Mon, 19 Apr 2004 09:12:54 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 82621-08 + for ; + Mon, 19 Apr 2004 09:12:55 -0300 (ADT) +Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) + by svr1.postgresql.org (Postfix) with ESMTP id B0E71D1C9E1 + for ; + Mon, 19 Apr 2004 09:12:51 -0300 (ADT) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by smtp.istop.com (Postfix) with ESMTP + id 081CB17C4D1; Mon, 19 Apr 2004 08:12:55 -0400 (EDT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1BFXdu-00034x-00; Mon, 19 Apr 2004 08:12:54 -0400 +To: Tom Lane +Cc: Greg Stark , Dennis Bjorklund , + Bruno Wolff III , "Jim C. Nasby" , + pgsql-performance@postgresql.org +Subject: Re: Horribly slow hash join +References: + <874qrg7cy8.fsf@stark.xeocode.com> <16041.1082354970@sss.pgh.pa.us> +In-Reply-To: <16041.1082354970@sss.pgh.pa.us> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 19 Apr 2004 08:12:54 -0400 +Message-ID: <87vfjw5fp5.fsf@stark.xeocode.com> +Lines: 27 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/266 +X-Sequence-Number: 6566 + +Tom Lane writes: + +> Greg Stark writes: +> > If the hash tables were made a power of two then it would be possible to mix +> > the bits of the 32 bit value and just mask off the unneeded bits. I've found +> > one page via google that mentions mixing bits in a hash function, but I would +> > look for a more serious treatment somewhere. + + +> Modding by a *non* power of 2 (esp. a prime) mixes the bits quite well, +> and is likely faster than any multiple-instruction way to do the same. + +Well a) any number that has any factors of two fails to mix in some bits. +That's a lot more common than non powers of two. b) The postgres code makes no +attempt to make the number of buckets a prime and c) Even if the number of +buckets were prime then it seems it would still be too easy to find real-world +data where all the data have that prime as a factor. As it is they only need +to have common factors to lose. + +> The quoted article seems to be by someone who has spent a lot of time +> counting assembly cycles and none at all reading the last thirty years +> worth of CS literature. + +Yes, well I did note that. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Mon Apr 19 09:16:37 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6B948D1E991 + for ; + Mon, 19 Apr 2004 09:16:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 88057-03 + for ; + Mon, 19 Apr 2004 09:16:36 -0300 (ADT) +Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) + by svr1.postgresql.org (Postfix) with ESMTP id 62E96D1E98A + for ; + Mon, 19 Apr 2004 09:16:33 -0300 (ADT) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by smtp.istop.com (Postfix) with ESMTP + id 05BEF17C4CE; Mon, 19 Apr 2004 08:16:37 -0400 (EDT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1BFXhU-00036V-00; Mon, 19 Apr 2004 08:16:36 -0400 +To: pg@fastcrypt.com +Cc: Tom Lane , Greg Stark , + Dennis Bjorklund , Bruno Wolff III , + "Jim C. Nasby" , pgsql-performance@postgresql.org +Subject: Re: Horribly slow hash join +References: + <874qrg7cy8.fsf@stark.xeocode.com> <16041.1082354970@sss.pgh.pa.us> + <1082376464.1558.69.camel@localhost.localdomain> +In-Reply-To: <1082376464.1558.69.camel@localhost.localdomain> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 19 Apr 2004 08:16:36 -0400 +Message-ID: <87pta45fiz.fsf@stark.xeocode.com> +Lines: 10 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/267 +X-Sequence-Number: 6567 + + +Dave Cramer writes: + +> Here's an interesting link that suggests that hyperthreading would be +> much worse. + +Uh, this is the wrong thread. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Tue Apr 20 10:58:34 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D06F8D1D08E + for ; + Mon, 19 Apr 2004 09:27:45 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 89415-05 + for ; + Mon, 19 Apr 2004 09:27:47 -0300 (ADT) +Received: from mail2.aeccom.com (port-212-202-101-158.reverse.qsc.de + [212.202.101.158]) + by svr1.postgresql.org (Postfix) with ESMTP id 8B102D1D099 + for ; + Mon, 19 Apr 2004 09:27:42 -0300 (ADT) +Received: from andesW2K (dhcp00.core.aeccom.com [192.168.2.100]) + by mail2.aeccom.com (Postfix) with SMTP + id D27CC34; Mon, 19 Apr 2004 14:27:44 +0200 (CEST) +Message-ID: <004201c42609$b7321390$6402a8c0@andesW2K> +From: "Sven Geisler" +To: , "Tom Lane" +Cc: "Josh Berkus" , + , "Neil Conway" +References: <200311251419.36771.josh@agliodbs.com> + <200404151039.17763.josh@agliodbs.com> + <407EE93F.3090705@aeccom.com> + <200404151335.27762.josh@agliodbs.com> + <407EFC95.5070805@aeccom.com> <11437.1082324861@sss.pgh.pa.us> +Subject: Re: Wierd context-switching issue on Xeon +Date: Mon, 19 Apr 2004 14:27:44 +0200 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1409 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/301 +X-Sequence-Number: 6601 + +Hi Tom, + +Just to explain our hardware situation releated to the FSB of the XEON's. +We have older XEON DP in operation with FSB 400 and 2.4 GHz. +The XEON MP box runs with 2.5 GHz. +The XEON MP box is a Fujitsu Siemens Primergy RX600 with ServerWorks GC LE +as chipset. + +The box, which Dirk were use to compare the behavior, is our newest XEON DP +system. +This XEON DP box runs with 2.8 GHz and FSB 533 using the Intel 7501 chipset +(Supermicro). + +I would agree to Jush. When PostgreSQL has an issue with the INTEL XEON MP +hardware, this is more releated to the chipset. + +Back to the SQL-Level. We use SELECT FOR UPDATE as "semaphore". +Should we try another implementation for this semahore on the client side to +prevent this issue? + +Regards +Sven. + +----- Original Message ----- +From: "Tom Lane" +To: +Cc: "Josh Berkus" ; ; +"Neil Conway" +Sent: Sunday, April 18, 2004 11:47 PM +Subject: Re: [PERFORM] Wierd context-switching issue on Xeon + + +> After some further digging I think I'm starting to understand what's up +> here, and the really fundamental answer is that a multi-CPU Xeon MP box +> sucks for running Postgres. +> +> I did a bunch of oprofile measurements on a machine belonging to one of +> Josh's clients, using a test case that involved heavy concurrent access +> to a relatively small amount of data (little enough to fit into Postgres +> shared buffers, so that no I/O or kernel calls were really needed once +> the test got going). I found that by nearly any measure --- elapsed +> time, bus transactions, or machine-clear events --- the spinlock +> acquisitions associated with grabbing and releasing the BufMgrLock took +> an unreasonable fraction of the time. I saw about 15% of elapsed time, +> 40% of bus transactions, and nearly 100% of pipeline-clear cycles going +> into what is essentially two instructions out of the entire backend. +> (Pipeline clears occur when the cache coherency logic detects a memory +> write ordering problem.) +> +> I am not completely clear on why this machine-level bottleneck manifests +> as a lot of context swaps at the OS level. I think what is happening is +> that because SpinLockAcquire is so slow, a process is much more likely +> than you'd normally expect to arrive at SpinLockAcquire while another +> process is also acquiring the spinlock. This puts the two processes +> into a "lockstep" condition where the second process is nearly certain +> to observe the BufMgrLock as locked, and be forced to suspend itself, +> even though the time the first process holds the BufMgrLock is not +> really very long at all. +> +> If you google for Xeon and "cache coherency" you'll find quite a bit of +> suggestive information about why this might be more true on the Xeon +> setup than others. A couple of interesting hits: +> +> http://www.theinquirer.net/?article=10797 +> says that Xeon MP uses a *slower* FSB than Xeon DP. This would +> translate directly to more time needed to transfer a dirty cache line +> from one processor to the other, which is the basic operation that we're +> talking about here. +> +> http://www.aceshardware.com/Spades/read.php?article_id=30000187 +> says that Opterons use a different cache coherency protocol that is +> fundamentally superior to the Xeon's, because dirty cache data can be +> transferred directly between two processor caches without waiting for +> main memory. +> +> So in the short term I think we have to tell people that Xeon MP is not +> the most desirable SMP platform to run Postgres on. (Josh thinks that +> the specific motherboard chipset being used in these machines might +> share some of the blame too. I don't have any evidence for or against +> that idea, but it's certainly possible.) +> +> In the long run, however, CPUs continue to get faster than main memory +> and the price of cache contention will continue to rise. So it seems +> that we need to give up the assumption that SpinLockAcquire is a cheap +> operation. In the presence of heavy contention it won't be. +> +> One thing we probably have got to do soon is break up the BufMgrLock +> into multiple finer-grain locks so that there will be less contention. +> However I am wary of doing this incautiously, because if we do it in a +> way that makes for a significant rise in the number of locks that have +> to be acquired to access a buffer, we might end up with a net loss. +> +> I think Neil Conway was looking into how the bufmgr might be +> restructured to reduce lock contention, but if he had come up with +> anything he didn't mention exactly what. Neil? +> +> regards, tom lane +> +> + + +From pgsql-performance-owner@postgresql.org Mon Apr 19 09:30:17 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id BAFCFD1CC8D + for ; + Mon, 19 Apr 2004 09:30:16 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 85835-08 + for ; + Mon, 19 Apr 2004 09:30:13 -0300 (ADT) +Received: from net2.micro-automation.com (net2.micro-automation.com + [64.7.141.29]) + by svr1.postgresql.org (Postfix) with SMTP id 681C3D1B515 + for ; + Mon, 19 Apr 2004 09:30:09 -0300 (ADT) +Received: (qmail 12810 invoked from network); 19 Apr 2004 12:30:08 -0000 +Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) + by net2.micro-automation.com with SMTP; 19 Apr 2004 12:30:08 -0000 +Subject: Re: Wierd context-switching issue on Xeon +From: Dave Cramer +Reply-To: pg@fastcrypt.com +To: Tom Lane +Cc: lutzeb@aeccom.com, Josh Berkus , + pgsql-performance@postgresql.org, Neil Conway +In-Reply-To: <14394.1082344796@sss.pgh.pa.us> +References: <200311251419.36771.josh@agliodbs.com> + <200404151039.17763.josh@agliodbs.com> <407EE93F.3090705@aeccom.com> + <200404151335.27762.josh@agliodbs.com> <407EFC95.5070805@aeccom.com> + <11437.1082324861@sss.pgh.pa.us> + <1082331281.1557.47.camel@localhost.localdomain> + <13960.1082341222@sss.pgh.pa.us> <14394.1082344796@sss.pgh.pa.us> +Content-Type: text/plain +Organization: Cramer Consulting +Message-Id: <1082377953.1554.77.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Mon, 19 Apr 2004 08:32:33 -0400 +Content-Transfer-Encoding: 7bit +X-AntiVirus: scanned for viruses by AMaViS 0.2.1 (http://amavis.org/) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/268 +X-Sequence-Number: 6568 + +Here's an interesting link that suggests that hyperthreading would be +much worse. + +http://groups.google.com/groups?q=hyperthreading+dual+xeon+idle&start=10&hl=en&lr=&ie=UTF-8&c2coff=1&selm=aukkonen-FE5275.21093624062003%40shawnews.gv.shawcable.net&rnum=16 + +another which has some hints as to how it should be handled + +http://groups.google.com/groups?q=hyperthreading+dual+xeon+idle&start=10&hl=en&lr=&ie=UTF-8&c2coff=1&selm=u5tl1XD3BHA.2760%40tkmsftngp04&rnum=19 +FWIW, I have anecdotal evidence that suggests that this is the case, on +of my clients was seeing very large context switches with HTT turned on, +and without it was much better. + +Dave +On Sun, 2004-04-18 at 23:19, Tom Lane wrote: +> >> What about hypterthreading does it still happen if HTT is turned off ? +> +> > The problem comes from keeping the caches synchronized between multiple +> > physical CPUs. AFAICS enabling HTT wouldn't make it worse, because a +> > hyperthreaded processor still only has one cache. +> +> Also, I forgot to say that the numbers I'm quoting *are* with HTT off. +> +> regards, tom lane +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 8: explain analyze is your friend +> +> +> +> !DSPAM:40834781158911062514350! +> +> +-- +Dave Cramer +519 939 0336 +ICQ # 14675561 + + +From pgsql-performance-owner@postgresql.org Mon Apr 19 09:37:38 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7D314D1B9A6 + for ; + Mon, 19 Apr 2004 09:37:37 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 88910-08 + for ; + Mon, 19 Apr 2004 09:37:37 -0300 (ADT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C6ECED1B4BE + for ; + Mon, 19 Apr 2004 09:37:33 -0300 (ADT) +Received: from [134.22.69.199] (dyn-69-199.tor.dsl.tht.net [134.22.69.199]) + by tht.net (Postfix) with ESMTP + id BCE1F76A76; Mon, 19 Apr 2004 08:37:38 -0400 (EDT) +Subject: Re: very slow simple query - outer join makes it quicker +From: Rod Taylor +To: gerard.isdell@kinetic.co.uk +Cc: Postgresql Performance +In-Reply-To: +References: + <1082376074.24414.3.camel@jester> + +Content-Type: text/plain +Message-Id: <1082378194.24414.5.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Mon, 19 Apr 2004 08:36:34 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/269 +X-Sequence-Number: 6569 + +On Mon, 2004-04-19 at 08:26, Gerard Isdell wrote: +> Thank, that has worked. +> +> I've been running VACUUM regularly and thought that would have done it. +> +> Obviously the FULL makes a big difference + +It shouldn't. That FULL makes a significant difference says that you're +not running regular VACUUM frequently enough and/or your fsm_* settings +are too low. + +> -----Original Message----- +> From: Rod Taylor +> To: gerard.isdell@kinetic.co.uk +> Cc: Postgresql Performance +> Date: Mon, 19 Apr 2004 08:01:15 -0400 +> Subject: Re: [PERFORM] very slow simple query - outer join makes it quicker +> +> > > There are other tables, such as the messages table, that have 10s of +> > > thousands of rows and they return records much more quickly. +> > +> > > There must be something seriously wrong for simple queries like this +> > to take +> > > so long. +> > +> > Have you run VACUUM recently? +> > +> > If not, run VACUUM FULL against the users table and see if that makes a +> > difference. +> > +> +> +> ************************************************************************* +> This e-mail and any attachments may contain confidential or privileged +> information. If you are not the intended recipient, please contact the +> sender immediately and do not use, store or disclose their contents. +> Any views expressed are those of the individual sender and not of Kinetic +> Information System Services Limited unless otherwise stated. +> +> www.kinetic.co.uk + + +From pgsql-performance-owner@postgresql.org Mon Apr 19 10:52:42 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id CAD1DD1C952 + for ; + Mon, 19 Apr 2004 10:52:40 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 22945-05 + for ; + Mon, 19 Apr 2004 10:52:41 -0300 (ADT) +Received: from vt-pe2550-001.VANTAGE.vantage.com (unknown [64.80.203.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 5CC2AD1B9A6 + for ; + Mon, 19 Apr 2004 10:52:36 -0300 (ADT) +Content-class: urn:content-classes:message +Subject: Re: Wierd context-switching issue on Xeon +MIME-Version: 1.0 +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: base64 +X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 +Date: Mon, 19 Apr 2004 09:52:39 -0400 +Message-ID: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78509813F@vt-pe2550-001.vantage.vantage.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Wierd context-switching issue on Xeon +Thread-Index: AcQlv1CsaIQyxA6cQsGxKSjJqw9QsQAVW1zS +From: "Anjan Dave" +To: "Greg Stark" , "Tom Lane" +Cc: , "Josh Berkus" , + , "Neil Conway" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/270 +X-Sequence-Number: 6570 + +V2hhdCBhYm91dCBxdWFkLVhFT04gc2V0dXBzPyBDb3VsZCB0aGF0IGJlIHdv +cnNlPyAoaGF2ZSBkdWFsLCBhbmQgcXVhZCBzZXR1cHMgYm90aCkgU2hhbGwg +d2UgcmUtY29uc2lkZXIgWEVPTi1NUCBDUFUgbWFjaGluZXMgd2l0aCBoaWdo +IGNhY2hlICg0TUIrKT8NCiANClZlcnkgZ2VuZXJhbGx5LCB3aGF0IG51bWJl +ciB3b3VsZCBiZSBjb25zaWRlcmVkIGhpZ2gsIGVzcGVjaWFsbHksIGlmIGl0 +IGNvaW5jaWRlcyB3aXRoIGV4cGVjdGVkIGhlYXZ5IGxvYWQ/DQogDQpOb3Qg +c3VyZSBhIHNwZWNpZmljIGNoaXBzZXQgd2FzIG1lbnRpb25lZC4uLg0KIA0K +VGhhbmtzLA0KQW5qYW4NCg0KCS0tLS0tT3JpZ2luYWwgTWVzc2FnZS0tLS0t +IA0KCUZyb206IEdyZWcgU3RhcmsgW21haWx0bzpnc3N0YXJrQG1pdC5lZHVd +IA0KCVNlbnQ6IFN1biA0LzE4LzIwMDQgODo0MCBQTSANCglUbzogVG9tIExh +bmUgDQoJQ2M6IGx1dHplYkBhZWNjb20uY29tOyBKb3NoIEJlcmt1czsgcGdz +cWwtcGVyZm9ybWFuY2VAcG9zdGdyZXNxbC5vcmc7IE5laWwgQ29ud2F5IA0K +CVN1YmplY3Q6IFJlOiBbUEVSRk9STV0gV2llcmQgY29udGV4dC1zd2l0Y2hp +bmcgaXNzdWUgb24gWGVvbg0KCQ0KCQ0KDQoNCglUb20gTGFuZSA8dGdsQHNz +cy5wZ2gucGEudXM+IHdyaXRlczoNCgkNCgk+IFNvIGluIHRoZSBzaG9ydCB0 +ZXJtIEkgdGhpbmsgd2UgaGF2ZSB0byB0ZWxsIHBlb3BsZSB0aGF0IFhlb24g +TVAgaXMgbm90DQoJPiB0aGUgbW9zdCBkZXNpcmFibGUgU01QIHBsYXRmb3Jt +IHRvIHJ1biBQb3N0Z3JlcyBvbi4gIChKb3NoIHRoaW5rcyB0aGF0DQoJPiB0 +aGUgc3BlY2lmaWMgbW90aGVyYm9hcmQgY2hpcHNldCBiZWluZyB1c2VkIGlu +IHRoZXNlIG1hY2hpbmVzIG1pZ2h0DQoJPiBzaGFyZSBzb21lIG9mIHRoZSBi +bGFtZSB0b28uICBJIGRvbid0IGhhdmUgYW55IGV2aWRlbmNlIGZvciBvciBh +Z2FpbnN0DQoJPiB0aGF0IGlkZWEsIGJ1dCBpdCdzIGNlcnRhaW5seSBwb3Nz +aWJsZS4pDQoJPg0KCT4gSW4gdGhlIGxvbmcgcnVuLCBob3dldmVyLCBDUFVz +IGNvbnRpbnVlIHRvIGdldCBmYXN0ZXIgdGhhbiBtYWluIG1lbW9yeQ0KCT4g +YW5kIHRoZSBwcmljZSBvZiBjYWNoZSBjb250ZW50aW9uIHdpbGwgY29udGlu +dWUgdG8gcmlzZS4gIFNvIGl0IHNlZW1zDQoJPiB0aGF0IHdlIG5lZWQgdG8g +Z2l2ZSB1cCB0aGUgYXNzdW1wdGlvbiB0aGF0IFNwaW5Mb2NrQWNxdWlyZSBp +cyBhIGNoZWFwDQoJPiBvcGVyYXRpb24uICBJbiB0aGUgcHJlc2VuY2Ugb2Yg +aGVhdnkgY29udGVudGlvbiBpdCB3b24ndCBiZS4NCgkNCglUaGVyZSdzIG5v +dGhpbmcgYWJvdXQgdGhlIHdheSBQb3N0Z3JlcyBzcGlubG9ja3MgYXJlIGNv +ZGVkIHRoYXQgYWZmZWN0cyB0aGlzPw0KCQ0KCUlzIGl0IHNvbWV0aGluZyB0 +aGUga2VybmVsIGNvdWxkIGhlbHAgd2l0aD8gSSd2ZSBiZWVuIHdvbmRlcmlu +ZyB3aGV0aGVyDQoJdGhlcmUncyBhbnkgYmVuZWZpdHMgcG9zdGdyZXMgaXMg +bWlzc2luZyBvdXQgb24gYnkgdXNpbmcgaXRzIG93biBoYW5kLXJvbGxlZA0K +CWxvY2tpbmcgaW5zdGVhZCBvZiB1c2luZyB0aGUgcHRocmVhZHMgaW5mcmFz +dHJ1Y3R1cmUgdGhhdCB0aGUga2VybmVsIGlzIG9mdGVuDQoJaW52b2x2ZWQg +aW4uDQoJDQoJLS0NCglncmVnDQoJDQoJDQoJLS0tLS0tLS0tLS0tLS0tLS0t +LS0tLS0tLS0tKGVuZCBvZiBicm9hZGNhc3QpLS0tLS0tLS0tLS0tLS0tLS0t +LS0tLS0tLS0tDQoJVElQIDI6IHlvdSBjYW4gZ2V0IG9mZiBhbGwgbGlzdHMg +YXQgb25jZSB3aXRoIHRoZSB1bnJlZ2lzdGVyIGNvbW1hbmQNCgkgICAgKHNl +bmQgInVucmVnaXN0ZXIgWW91ckVtYWlsQWRkcmVzc0hlcmUiIHRvIG1ham9y +ZG9tb0Bwb3N0Z3Jlc3FsLm9yZykNCgkNCg0K + +From pgsql-performance-owner@postgresql.org Mon Apr 19 13:00:25 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2B12ED1E956 + for ; + Mon, 19 Apr 2004 13:00:21 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 77386-10 + for ; + Mon, 19 Apr 2004 13:00:19 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id D49F9D1E413 + for ; + Mon, 19 Apr 2004 13:00:16 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3JG0AQT025763; + Mon, 19 Apr 2004 12:00:11 -0400 (EDT) +To: Manfred Koizar +Cc: Robert Treat , + pgsql-performance@postgresql.org +Subject: Re: query slows down with more accurate stats +In-reply-to: +References: <1081879359.25537.526.camel@camel> + <25556.1081883922@sss.pgh.pa.us> + + <22642.1082074729@sss.pgh.pa.us> + + <29060.1082126089@sss.pgh.pa.us> + +Comments: In-reply-to Manfred Koizar + message dated "Sat, 17 Apr 2004 00:26:22 +0200" +Date: Mon, 19 Apr 2004 12:00:10 -0400 +Message-ID: <25762.1082390410@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/271 +X-Sequence-Number: 6571 + +Manfred Koizar writes: +> Random sampling is more like "every possible sample is equally likely to +> be collected", and two-stage sampling doesn't satisfy this condition. + +Okay, I finally see the point here: in the limit as the number of pages +B goes to infinity, you'd expect the probability that each tuple in your +sample came from a different page to go to 1. But this doesn't happen +in the two-stage sampling method: the probability doesn't increase +beyond the value it would have for B=n. On the average each sample page +would supply one tuple, but the odds that this holds *exactly* would be +pretty low. + +However the existing sampling method has glaring flaws of its own, +in particular having to do with the fact that a tuple whose slot is +preceded by N empty slots is N times more likely to be picked than one +that has no empty-slot predecessors. The fact that the two-stage +method artificially constrains the sample to come from only n pages +seems like a minor problem by comparison; I'd happily accept it to get +rid of the empty-slot bias. + +A possible compromise is to limit the number of pages sampled to +something a bit larger than n, perhaps 2n or 3n. I don't have a feeling +for the shape of the different-pages probability function; would this +make a significant difference, or would it just waste cycles? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Apr 20 00:11:13 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B29A9D1CC8D + for ; + Tue, 20 Apr 2004 00:11:12 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 25282-03 + for ; + Tue, 20 Apr 2004 00:11:05 -0300 (ADT) +Received: from web13121.mail.yahoo.com (web13121.mail.yahoo.com + [216.136.174.83]) + by svr1.postgresql.org (Postfix) with SMTP id E38C9D1DD91 + for ; + Tue, 20 Apr 2004 00:11:04 -0300 (ADT) +Message-ID: <20040419162603.31251.qmail@web13121.mail.yahoo.com> +Received: from [63.78.248.48] by web13121.mail.yahoo.com via HTTP; + Mon, 19 Apr 2004 09:26:03 PDT +Date: Mon, 19 Apr 2004 09:26:03 -0700 (PDT) +From: Litao Wu +Subject: Re: sunquery and estimated rows +To: Tom Lane +Cc: pgsql-performance@postgresql.org +In-Reply-To: <1082316145.2191.0.camel@yarrow.bertheau.de> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/285 +X-Sequence-Number: 6585 + +Well, the example shown is simplified version. +Now, let's see a little 'real' example (still +simplified version): + +Table test is same as before: +\d test + Table "public.test" + Column | Type | Modifiers +---------+--------------------------+----------- + id | integer | + ... + scope | integer | + ... +Indexes: test_scope_idx btree (scope) + +select count(*) from test; + count +------- + 4959 +(1 row) +select count(*) from test where scope=10; + count +------- + 10 +(1 row) + +create table scope_def (scope int primary key, name +varchar(30) unique); +insert into scope_def values (10, 'TEST_SCOPE'); + +-- This is not a trivial arithmetic expression +explain analyze +select * from test +where scope=(select scope from scope_def where name = +'TEST_SCOPE'); + +-- estimated row is 1653, returned rows is 10 + + + QUERY PLAN + +------------------------------------------------------------------------------------------------------------------------------------ + Index Scan using test_scope_idx on test +(cost=0.00..49.91 rows=1653 width=59) (actual +time=0.08..0.15 rows=10 loops=1) + Index Cond: (scope = $0) + InitPlan + -> Index Scan using scope_def_name_key on +scope_def (cost=0.00..4.82 rows=1 width=4) (actual +time=0.04..0.04 rows=1 loops=1) + Index Cond: (name = 'TEST_SCOPE'::character +varying) + Total runtime: 0.22 msec +(6 rows) + + +-- trivial arithmetic expression +-- estimated row is 1653, returned rows is 10 +explain analyze +select * from test +where scope=(select 10); + +QUERY PLAN +------------------------------------------------------------------------------------------------------------------------- + Index Scan using test_scope_idx on test +(cost=0.00..49.91 rows=1653 width=59) (actual +time=0.06..0.14 rows=10 loops=1) + Index Cond: (scope = $0) + InitPlan + -> Result (cost=0.00..0.01 rows=1 width=0) +(actual time=0.01..0.01 rows=1 loops=1) + Total runtime: 0.20 msec +(5 rows) + +-- This is the plan I expect to see: estimated rows is +-- close the actual returned rows. +-- Do I have to devide the sub-select into two +-- queries? + +explain analyze +select * from test +where scope=10; + +QUERY PLAN +---------------------------------------------------------------------------------------------------------------------- + Index Scan using test_scope_idx on test +(cost=0.00..3.77 rows=10 width=59) (actual +time=0.05..0.12 rows=10 loops=1) + Index Cond: (scope = 10) + Total runtime: 0.18 msec +(3 rows) + +-- Rewritten query using join in this case +explain analyze +select test.* from test JOIN scope_def using (scope) +where scope_def.name = 'TEST_SCOPE'; + + QUERY PLAN + +---------------------------------------------------------------------------------------------------------------------------------- + Nested Loop (cost=0.00..75.39 rows=5 width=63) +(actual time=0.07..0.19 rows=10 loops=1) + -> Index Scan using scope_def_name_key on +scope_def (cost=0.00..4.82 rows=1 width=4) (actual +time=0.04..0.04 rows=1 loops=1) + Index Cond: (name = 'TEST_SCOPE'::character +varying) + -> Index Scan using test_scope_idx on test +(cost=0.00..49.91 rows=1653 width=59) (actual +time=0.02..0.09 rows=10 loops=1) + Index Cond: (test.scope = "outer".scope) + Total runtime: 0.28 msec +(6 rows) + + + + + +__________________________________ +Do you Yahoo!? +Yahoo! Tax Center - File online by April 15th +http://taxes.yahoo.com/filing.html + +From pgsql-performance-owner@postgresql.org Mon Apr 19 15:10:23 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B68ADD1E949 + for ; + Mon, 19 Apr 2004 14:39:03 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 26384-04 + for ; + Mon, 19 Apr 2004 14:39:02 -0300 (ADT) +Received: from lorax.kcilink.com (lorax.kciLink.com [206.112.95.1]) + by svr1.postgresql.org (Postfix) with ESMTP id CD11CD1E812 + for ; + Mon, 19 Apr 2004 14:39:01 -0300 (ADT) +Received: from localhost (localhost [127.0.0.1]) + by lorax.kcilink.com (Postfix) with ESMTP id CEDED3F44 + for ; + Mon, 19 Apr 2004 13:39:01 -0400 (EDT) +Received: from lorax.kcilink.com ([127.0.0.1]) + by localhost (lorax.kcilink.com [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 25357-03-2 for ; + Mon, 19 Apr 2004 13:39:01 -0400 (EDT) +Received: by lorax.kcilink.com (Postfix, from userid 8) + id 533453F1D; Mon, 19 Apr 2004 13:39:01 -0400 (EDT) +To: pgsql-performance@postgresql.org +Path: not-for-mail +From: Vivek Khera +Newsgroups: ml.postgres.performance +Subject: Re: possible improvement between G4 and G5 +Date: Mon, 19 Apr 2004 13:39:00 -0400 +Organization: Khera Communications, Inc., Rockville, MD +Lines: 26 +Message-ID: +References: <009901c41b48$8357c860$2500fa0a@CardServices.TCI.com> + <200404061152.17997.josh@agliodbs.com> + + <200404061441.53598.josh@agliodbs.com> +NNTP-Posting-Host: yertle.kcilink.com +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Trace: lorax.kcilink.com 1082396341 55887 65.205.34.180 (19 Apr 2004 + 17:39:01 GMT) +X-Complaints-To: daemon@kciLink.com +NNTP-Posting-Date: Mon, 19 Apr 2004 17:39:01 +0000 (UTC) +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + berkeley-unix) +Cancel-Lock: sha1:z/lJLpuNc9JdR8uVFivUP1NvE5Q= +X-Virus-Scanned: by amavisd-new at kcilink.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/275 +X-Sequence-Number: 6575 + +>>>>> "JB" == Josh Berkus writes: + +JB> Aaron, +>> I do consulting, so they're all over the place and tend to be complex. Very +>> few fit in RAM, but still are very buffered. These are almost all backed +>> with very high end I/O subsystems, with dozens of spindles with battery +>> backed up writethrough cache and gigs of buffers, which may be why I worry +>> so much about CPU. I have had this issue with multiple servers. + +JB> Aha, I think this is the difference. I never seem to be able to +JB> get my clients to fork out for adequate disk support. They are +JB> always running off single or double SCSI RAID in the host server; +JB> not the sort of setup you have. + +Even when I upgraded my system to a 14-spindle RAID5 with 128M cache +and 4GB RAM on a dual Xeon system, I still wind up being I/O bound +quite often. + +I think it depends on what your "working set" turns out to be. My +workload really spans a lot more of the DB than I can end up caching. + +-- +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +Vivek Khera, Ph.D. Khera Communications, Inc. +Internet: khera@kciLink.com Rockville, MD +1-301-869-4449 x806 +AIM: vivekkhera Y!: vivek_khera http://www.khera.org/~vivek/ + +From pgsql-performance-owner@postgresql.org Mon Apr 19 14:52:52 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7F964D1E98D + for ; + Mon, 19 Apr 2004 14:50:27 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 31056-02 + for ; + Mon, 19 Apr 2004 14:50:25 -0300 (ADT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id DD481D1E95F + for ; + Mon, 19 Apr 2004 14:50:23 -0300 (ADT) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4900262; Mon, 19 Apr 2004 10:51:46 -0700 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: Tom Lane , lutzeb@aeccom.com +Subject: Re: Wierd context-switching issue on Xeon +Date: Mon, 19 Apr 2004 10:50:12 -0700 +User-Agent: KMail/1.4.3 +Cc: pgsql-performance@postgreSQL.org, Neil Conway +References: <200311251419.36771.josh@agliodbs.com> + <407EFC95.5070805@aeccom.com> <11437.1082324861@sss.pgh.pa.us> +In-Reply-To: <11437.1082324861@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200404191050.12833.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/272 +X-Sequence-Number: 6572 + +Tom, + +> So in the short term I think we have to tell people that Xeon MP is not +> the most desirable SMP platform to run Postgres on. (Josh thinks that +> the specific motherboard chipset being used in these machines might +> share some of the blame too. I don't have any evidence for or against +> that idea, but it's certainly possible.) + +I have 3 reasons for thinking this: +1) the ServerWorks chipset is present in the fully documented cases that we +have of this problem so far. This is notable becuase the SW is notorious +for poor manufacturing quality, so much so that the company that made them is +currently in receivership. These chips were so bad that Dell was forced to +recall several hundred of it's 2650's, where the motherboards caught fire! +2) the main defect of the SW is the NorthBridge, which could conceivably +adversely affect traffic between RAM and the processor cache. +3) XeonMP is a very popular platform thanks to Dell, and we are not seeing +more problem reports than we are. + +The other thing I'd like your comment on, Tom, is that Dirk appears to have +reported that when he installed a non-bigmem kernel, the issue went away. +Dirk, is this correct? + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Mon Apr 19 15:02:34 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D75BDD1D52E + for ; + Mon, 19 Apr 2004 14:55:59 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 29582-05 + for ; + Mon, 19 Apr 2004 14:55:51 -0300 (ADT) +Received: from mx1.neopolitan.us (mx1.neopolitan.us [65.87.16.224]) + by svr1.postgresql.org (Postfix) with ESMTP id 3E6DDD1C9E1 + for ; + Mon, 19 Apr 2004 14:55:50 -0300 (ADT) +Received: from [65.87.16.98] (HELO [10.0.0.210]) + by mx1.neopolitan.us (CommuniGate Pro SMTP 4.1.8) + with ESMTP-TLS id 3984841 for pgsql-performance@postgresql.org; + Mon, 19 Apr 2004 10:55:50 -0700 +Subject: Re: Wierd context-switching issue on Xeon +From: "J. Andrew Rogers" +To: pgsql-performance@postgresql.org +In-Reply-To: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78509813F@vt-pe2550-001.vantage.vantage.com> +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78509813F@vt-pe2550-001.vantage.vantage.com> +Content-Type: text/plain +Organization: +Message-Id: <1082397350.30934.34.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.2.2 (1.2.2-5) +Date: 19 Apr 2004 10:55:50 -0700 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/274 +X-Sequence-Number: 6574 + + +I decided to check the context-switching behavior here for baseline +since we have a rather diverse set of postgres server hardware, though +nothing using Xeon MP that is also running a postgres instance, and +everything looks normal under load. Some platforms are better than +others, but nothing is outside of what I would consider normal bounds. + +Our biggest database servers are Opteron SMP systems, and these servers +are particularly well-behaved under load with Postgres 7.4.2. If there +is a problem with the locking code and context-switching, it sure isn't +manifesting on our Opteron SMP systems. Under rare confluences of +process interaction, we occasionally see short spikes in the 2-3,000 +cs/sec range. It typically peaks at a couple hundred cs/sec under load. +Obviously this is going to be a function of our load profile a certain +extent. + +The Opterons have proven to be very good database hardware in general +for us. + + +j. andrew rogers + + + + + + + + +From pgsql-performance-owner@postgresql.org Mon Apr 19 15:02:20 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B5154D1DCA0 + for ; + Mon, 19 Apr 2004 15:00:12 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 28608-10 + for ; + Mon, 19 Apr 2004 15:00:07 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id EFA2FD1E98A + for ; + Mon, 19 Apr 2004 15:00:05 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3JI01Mi026942; + Mon, 19 Apr 2004 14:00:01 -0400 (EDT) +To: Josh Berkus +Cc: lutzeb@aeccom.com, pgsql-performance@postgreSQL.org, + Neil Conway +Subject: Re: Wierd context-switching issue on Xeon +In-reply-to: <200404191050.12833.josh@agliodbs.com> +References: <200311251419.36771.josh@agliodbs.com> + <407EFC95.5070805@aeccom.com> <11437.1082324861@sss.pgh.pa.us> + <200404191050.12833.josh@agliodbs.com> +Comments: In-reply-to Josh Berkus + message dated "Mon, 19 Apr 2004 10:50:12 -0700" +Date: Mon, 19 Apr 2004 14:00:01 -0400 +Message-ID: <26941.1082397601@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/273 +X-Sequence-Number: 6573 + +Josh Berkus writes: +> The other thing I'd like your comment on, Tom, is that Dirk appears to have +> reported that when he installed a non-bigmem kernel, the issue went away. +> Dirk, is this correct? + +I'd be really surprised if that had anything to do with it. AFAIR +Dirk's test changed more than one variable and so didn't prove a +connection. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Apr 19 15:33:25 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7FADED1B8DF + for ; + Mon, 19 Apr 2004 15:33:24 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 45171-08 + for ; + Mon, 19 Apr 2004 15:33:23 -0300 (ADT) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id 14ECED1B49B + for ; + Mon, 19 Apr 2004 15:33:21 -0300 (ADT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i3JIWxx10909; + Mon, 19 Apr 2004 14:32:59 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200404191832.i3JIWxx10909@candle.pha.pa.us> +Subject: Re: Wierd context-switching issue on Xeon +In-Reply-To: <200404191050.12833.josh@agliodbs.com> +To: Josh Berkus +Date: Mon, 19 Apr 2004 14:32:59 -0400 (EDT) +Cc: Tom Lane , lutzeb@aeccom.com, + pgsql-performance@postgresql.org, Neil Conway +X-Mailer: ELM [version 2.4ME+ PL108 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/276 +X-Sequence-Number: 6576 + +Josh Berkus wrote: +> Tom, +> +> > So in the short term I think we have to tell people that Xeon MP is not +> > the most desirable SMP platform to run Postgres on. (Josh thinks that +> > the specific motherboard chipset being used in these machines might +> > share some of the blame too. I don't have any evidence for or against +> > that idea, but it's certainly possible.) +> +> I have 3 reasons for thinking this: +> 1) the ServerWorks chipset is present in the fully documented cases that we +> have of this problem so far. This is notable becuase the SW is notorious +> for poor manufacturing quality, so much so that the company that made them is +> currently in receivership. These chips were so bad that Dell was forced to +> recall several hundred of it's 2650's, where the motherboards caught fire! +> 2) the main defect of the SW is the NorthBridge, which could conceivably +> adversely affect traffic between RAM and the processor cache. +> 3) XeonMP is a very popular platform thanks to Dell, and we are not seeing +> more problem reports than we are. +> +> The other thing I'd like your comment on, Tom, is that Dirk appears to have +> reported that when he installed a non-bigmem kernel, the issue went away. + +I have BSD on a SuperMicro dual Xeon, so if folks want another +hardware/OS combination to test, I can give out logins to my machine. + + http://candle.pha.pa.us/main/hardware.html + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-performance-owner@postgresql.org Mon Apr 19 17:16:05 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9DD12D1B895 + for ; + Mon, 19 Apr 2004 17:16:02 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 89674-08 + for ; + Mon, 19 Apr 2004 17:16:02 -0300 (ADT) +Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) + by svr1.postgresql.org (Postfix) with ESMTP id 5A59FD1B49B + for ; + Mon, 19 Apr 2004 17:16:00 -0300 (ADT) +Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) + by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i3JKETu9019523; + Mon, 19 Apr 2004 14:14:29 -0600 (MDT) +Date: Mon, 19 Apr 2004 14:12:32 -0600 (MDT) +From: "scott.marlowe" +To: Bruce Momjian +Cc: Josh Berkus , Tom Lane , + , , + Neil Conway +Subject: Re: Wierd context-switching issue on Xeon +In-Reply-To: <200404191832.i3JIWxx10909@candle.pha.pa.us> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-IHS-MailScanner: Found to be clean +X-IHS-MailScanner-SpamCheck: +X-IHS-MailScanner-Envelope-Sender: scott.marlowe@ihs.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/277 +X-Sequence-Number: 6577 + +On Mon, 19 Apr 2004, Bruce Momjian wrote: + +> Josh Berkus wrote: +> > Tom, +> > +> > > So in the short term I think we have to tell people that Xeon MP is not +> > > the most desirable SMP platform to run Postgres on. (Josh thinks that +> > > the specific motherboard chipset being used in these machines might +> > > share some of the blame too. I don't have any evidence for or against +> > > that idea, but it's certainly possible.) +> > +> > I have 3 reasons for thinking this: +> > 1) the ServerWorks chipset is present in the fully documented cases that we +> > have of this problem so far. This is notable becuase the SW is notorious +> > for poor manufacturing quality, so much so that the company that made them is +> > currently in receivership. These chips were so bad that Dell was forced to +> > recall several hundred of it's 2650's, where the motherboards caught fire! +> > 2) the main defect of the SW is the NorthBridge, which could conceivably +> > adversely affect traffic between RAM and the processor cache. +> > 3) XeonMP is a very popular platform thanks to Dell, and we are not seeing +> > more problem reports than we are. +> > +> > The other thing I'd like your comment on, Tom, is that Dirk appears to have +> > reported that when he installed a non-bigmem kernel, the issue went away. +> +> I have BSD on a SuperMicro dual Xeon, so if folks want another +> hardware/OS combination to test, I can give out logins to my machine. + +I can probably do some nighttime testing on a dual 2800MHz non-MP Xeon +machine as well. It's a Dell 2600 series machine and very fast. It has +the moderately fast 533MHz FSB so may not have as many problems as the MP +type CPUs seem to be having. + + +From pgsql-performance-owner@postgresql.org Tue Apr 20 10:58:39 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5F590D1B49B + for ; + Mon, 19 Apr 2004 17:41:09 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 94623-09 + for ; + Mon, 19 Apr 2004 17:41:08 -0300 (ADT) +Received: from hotmail.com (bay9-dav33.bay9.hotmail.com [64.4.46.90]) + by svr1.postgresql.org (Postfix) with ESMTP id 72086D1DB5B + for ; + Mon, 19 Apr 2004 17:41:05 -0300 (ADT) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Mon, 19 Apr 2004 13:41:07 -0700 +Received: from 67.81.102.201 by bay9-dav33.bay9.hotmail.com with DAV; + Mon, 19 Apr 2004 20:41:06 +0000 +X-Originating-IP: [67.81.102.201] +X-Originating-Email: [awerman@hotmail.com] +X-Sender: awerman@hotmail.com +From: "Aaron Werman" +To: +References: <200311251419.36771.josh@agliodbs.com> + <407EFC95.5070805@aeccom.com> <11437.1082324861@sss.pgh.pa.us> + <200404191050.12833.josh@agliodbs.com> +Subject: Re: possible improvement between G4 and G5 +Date: Mon, 19 Apr 2004 16:41:22 -0400 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1409 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 +Message-ID: +X-OriginalArrivalTime: 19 Apr 2004 20:41:07.0060 (UTC) + FILETIME=[A3CC5B40:01C4264E] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/302 +X-Sequence-Number: 6602 + +There are a few things that you can do to help force yourself to be I/O +bound. These include: + +- RAID 5 for write intensive applications, since multiple writes per synch +write is good. (There is a special case for logging or other streaming +sequential writes on RAID 5) + +- Data journaling file systems are helpful in stress testing your +checkpoints + +- Using midsized battery backed up write through buffering controllers. In +general, if you have a small cache, you see the problem directly, and a huge +cache will balance out load and defer writes to quieter times. That is why a +midsized cache is so useful in showing stress in your system only when it is +being stressed. + +Only partly in jest, +/Aaron + +BTW - I am truly curious about what happens to your system if you use +separate RAID 0+1 for your logs, disk sorts, and at least the most active +tables. This should reduce I/O load by an order of magnitude. + +"Vivek Khera" wrote in message +news:x7smez7tqj.fsf@yertle.int.kciLink.com... +> >>>>> "JB" == Josh Berkus writes: +> +> JB> Aaron, +> >> I do consulting, so they're all over the place and tend to be complex. +Very +> >> few fit in RAM, but still are very buffered. These are almost all +backed +> >> with very high end I/O subsystems, with dozens of spindles with battery +> >> backed up writethrough cache and gigs of buffers, which may be why I +worry +> >> so much about CPU. I have had this issue with multiple servers. +> +> JB> Aha, I think this is the difference. I never seem to be able to +> JB> get my clients to fork out for adequate disk support. They are +> JB> always running off single or double SCSI RAID in the host server; +> JB> not the sort of setup you have. +> +> Even when I upgraded my system to a 14-spindle RAID5 with 128M cache +> and 4GB RAM on a dual Xeon system, I still wind up being I/O bound +> quite often. +> +> I think it depends on what your "working set" turns out to be. My +> workload really spans a lot more of the DB than I can end up caching. +> +> -- +> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +> Vivek Khera, Ph.D. Khera Communications, Inc. +> Internet: khera@kciLink.com Rockville, MD +1-301-869-4449 x806 +> AIM: vivekkhera Y!: vivek_khera http://www.khera.org/~vivek/ +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 8: explain analyze is your friend +> + +From pgsql-performance-owner@postgresql.org Tue Apr 20 10:59:48 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1BEC3D1E944 + for ; + Mon, 19 Apr 2004 17:50:55 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 05121-05 + for ; + Mon, 19 Apr 2004 17:50:55 -0300 (ADT) +Received: from main.gmane.org (main.gmane.org [80.91.224.249]) + by svr1.postgresql.org (Postfix) with ESMTP id 6CD83D1E8A5 + for ; + Mon, 19 Apr 2004 17:50:52 -0300 (ADT) +Received: from root by main.gmane.org with local (Exim 3.35 #1 (Debian)) + id 1BFfjA-0007Rp-00 + for ; Mon, 19 Apr 2004 22:50:52 +0200 +Received: from tanagra.summersault.com ([12.161.105.149]) + by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) + id 1AlnuQ-0007hv-00 + for ; Mon, 19 Apr 2004 22:50:52 +0200 +Received: from mark by tanagra.summersault.com with local (Gmexim 0.1 + (Debian)) + id 1AlnuQ-0007hv-00 + for ; Mon, 19 Apr 2004 22:50:52 +0200 +X-Injected-Via-Gmane: http://gmane.org/ +To: pgsql-performance@postgresql.org +From: Mark Stosberg +Subject: seeking consultant for high performance, + complex searching with Postgres web app +Date: Mon, 19 Apr 2004 20:42:06 +0000 (UTC) +Lines: 40 +Message-ID: +X-Complaints-To: usenet@sea.gmane.org +X-Gmane-NNTP-Posting-Host: tanagra.summersault.com +X-Archive: encrypt +User-Agent: slrn/0.9.8.0 (FreeBSD) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/303 +X-Sequence-Number: 6603 + +Hello, + +I work for Summersault, LLC. We've been using Postgres since the days of +Postgres 6.5. We're focused on building database-driven websites using Perl and +Postgres. We are currently seeking help developing a search system that needs +to perform complex queries with high performance. Although we have strong +skills in Perl and Postgres, we are new to the arena of complex, +high-performance search systems. + +We are seeking to hire a consultant to help this as part of the re-vamp +of the 1-800-Save-A-Pet.com website. + +1-800-Save-A-Pet.com is a not-for-profit organization whose website +finds homes for homeless pets, promoting pet adoption and saving +thousands of animal lives. Summersault, LLC is a website development +firm focused on creating highly customized database driven websites. + +The ideal consultant has expert experience with the PostgreSQL RDBMS and +the Perl programming language, and is intimately familiar with the +architecture and implementation of complex database queries for +high-traffic web applications. The consultant should also have a strong +background in creating solutions complementary to this work, e.g. +assessing hardware requirements, designing a hosting and network +infrastructure, and optimizing the algorithm based on real-world +feedback. The consultant will work with Summersault developers as a +part of a larger application development process. + +Interested persons or organizations should contact Chris Hardie of +Summersault, LLC at chris@summersault.com for more information. + +Thanks! + + Mark + +-- + . . . . . . . . . . . . . . . . . . . . . . . . . . . + Mark Stosberg Principal Developer + mark@summersault.com Summersault, LLC + 765-939-9301 ext 202 database driven websites + . . . . . http://www.summersault.com/ . . . . . . . . + + +From pgsql-performance-owner@postgresql.org Mon Apr 19 18:02:56 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0EDF4D1D189 + for ; + Mon, 19 Apr 2004 18:02:55 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 09275-05 + for ; + Mon, 19 Apr 2004 18:02:53 -0300 (ADT) +Received: from joeconway.com (66-146-172-82.skyriver.net [66.146.172.82]) + by svr1.postgresql.org (Postfix) with ESMTP id 5D213D1D08B + for ; + Mon, 19 Apr 2004 18:02:50 -0300 (ADT) +Received: from [206.19.64.3] (account jconway HELO joeconway.com) + by joeconway.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP-TLS id 1439829; Mon, 19 Apr 2004 13:56:56 -0700 +Message-ID: <40843E63.7050101@joeconway.com> +Date: Mon, 19 Apr 2004 14:02:27 -0700 +From: Joe Conway +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.6) Gecko/20040113 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "scott.marlowe" +Cc: Bruce Momjian , + Josh Berkus , Tom Lane , + lutzeb@aeccom.com, pgsql-performance@postgresql.org, + Neil Conway +Subject: Re: Wierd context-switching issue on Xeon +References: +In-Reply-To: +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/278 +X-Sequence-Number: 6578 + +scott.marlowe wrote: +> On Mon, 19 Apr 2004, Bruce Momjian wrote: +>>I have BSD on a SuperMicro dual Xeon, so if folks want another +>>hardware/OS combination to test, I can give out logins to my machine. +> +> I can probably do some nighttime testing on a dual 2800MHz non-MP Xeon +> machine as well. It's a Dell 2600 series machine and very fast. It has +> the moderately fast 533MHz FSB so may not have as many problems as the MP +> type CPUs seem to be having. + +I've got a quad 2.8Ghz MP Xeon (IBM x445) that I could test on. Does +anyone have a test set that can reliably reproduce the problem? + +Joe + +From pgsql-performance-owner@postgresql.org Tue Apr 20 11:01:38 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 12C99D1CC8D + for ; + Mon, 19 Apr 2004 18:58:54 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 28070-08 + for ; + Mon, 19 Apr 2004 18:58:55 -0300 (ADT) +Received: from mailout05.sul.t-online.com (mailout05.sul.t-online.com + [194.25.134.82]) + by svr1.postgresql.org (Postfix) with ESMTP id 60CC0D1CACF + for ; + Mon, 19 Apr 2004 18:58:52 -0300 (ADT) +Received: from fwd04.aul.t-online.de by mailout05.sul.t-online.com with smtp + id 1BFgAB-0006lt-01; Mon, 19 Apr 2004 23:18:47 +0200 +Received: from aeccom.com + (Ek4eAcZGQeKPbfWeYc-9iHLKRPA1WT-9F+6OpXlIg+UbP1he0hDTYg@[217.231.172.140]) + by fwd04.sul.t-online.com + with esmtp id 1BFg9s-13rlK40; Mon, 19 Apr 2004 23:18:28 +0200 +Message-ID: <40844223.9070200@aeccom.com> +Date: Mon, 19 Apr 2004 23:18:27 +0200 +From: Dirk.Lutzebaeck@t-online.de (Dirk Lutzebaeck) +Reply-To: lutzeb@aeccom.com +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.1) Gecko/20031030 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: Josh Berkus , + pgsql-performance@postgreSQL.org, Neil Conway +Subject: Re: Wierd context-switching issue on Xeon +References: <200311251419.36771.josh@agliodbs.com> + <407EFC95.5070805@aeccom.com> <11437.1082324861@sss.pgh.pa.us> + <200404191050.12833.josh@agliodbs.com> + <26941.1082397601@sss.pgh.pa.us> +In-Reply-To: <26941.1082397601@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Seen: false +X-ID: Ek4eAcZGQeKPbfWeYc-9iHLKRPA1WT-9F+6OpXlIg+UbP1he0hDTYg +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/304 +X-Sequence-Number: 6604 + +I would agree to Tom, that too much parameters are involved to blame +bigmem. I have access to the following machines where the same +application operates: + +a) Dual (4way) XEON MP, bigmem, HT off, ServerWorks chipset (a +Fujitsu-Siemens Primergy) + +performs ok now because missing indexes were added but this is no proof +that this behaviour occurs again under high load, context switches are +moderate but have peaks to 40.000 + +b) Dual XEON DP, non-bigmem, HT on, ServerWorks chipset (a Dell machine +I think) + +performs moderate because I see too much context switches here although +the mentioned indexes are created, context switches go up to 30.000 +often, I can see 50% semop calls + +c) Dual XEON DP, non-bigmem, HT on, E7500 Intel chipset (Supermicro) + +performs well and I could not observe context switch peaks here (one +user active), almost no extra semop calls + +d) Dual XEON DP, bigmem, HT off, ServerWorks chipset (a Fujitsu-Siemens +Primergy) + +performance unknown at the moment (is offline) but looks like a) in the past + +I can offer to do tests on those machines if somebody would provide me +some test instructions to nail this problem down. + +Dirk + + + +Tom Lane wrote: + +>Josh Berkus writes: +> +> +>>The other thing I'd like your comment on, Tom, is that Dirk appears to have +>>reported that when he installed a non-bigmem kernel, the issue went away. +>>Dirk, is this correct? +>> +>> +> +>I'd be really surprised if that had anything to do with it. AFAIR +>Dirk's test changed more than one variable and so didn't prove a +>connection. +> +> regards, tom lane +> +> +> + + + +From pgsql-performance-owner@postgresql.org Mon Apr 19 18:54:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A6E96D1BAAE + for ; + Mon, 19 Apr 2004 18:54:49 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 27459-07 + for ; + Mon, 19 Apr 2004 18:54:49 -0300 (ADT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 1AE67D1B581 + for ; + Mon, 19 Apr 2004 18:54:47 -0300 (ADT) +Received: from [64.81.245.111] (HELO 192.168.1.102) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4902060; Mon, 19 Apr 2004 14:56:14 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Joe Conway , + "scott.marlowe" +Subject: Re: Wierd context-switching issue on Xeon +Date: Mon, 19 Apr 2004 14:55:04 -0700 +User-Agent: KMail/1.5.4 +Cc: Bruce Momjian , + Tom Lane , lutzeb@aeccom.com, + pgsql-performance@postgresql.org, Neil Conway +References: + <40843E63.7050101@joeconway.com> +In-Reply-To: <40843E63.7050101@joeconway.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200404191455.04068.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/279 +X-Sequence-Number: 6579 + +Joe, + +> I've got a quad 2.8Ghz MP Xeon (IBM x445) that I could test on. Does +> anyone have a test set that can reliably reproduce the problem? + +Unfortunately we can't seem to come up with one. So far we have 2 machines +that exhibit the issue, and their databases are highly confidential (State of +WA education data). + +It does seem to require a database which is in the many GB (> 10GB), and a +situation where a small subset of the data is getting hit repeatedly by +multiple processes. So you could try your own data warehouse, making sure +that you have at least 4 connections hitting one query after another. + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Mon Apr 19 19:56:40 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 875FCD1B7F0 + for ; + Mon, 19 Apr 2004 19:56:39 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 50509-01 + for ; + Mon, 19 Apr 2004 19:56:39 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 8698CD1B4BE + for ; + Mon, 19 Apr 2004 19:56:36 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3JMtYNE029785; + Mon, 19 Apr 2004 18:55:35 -0400 (EDT) +To: josh@agliodbs.com +Cc: Joe Conway , "scott.marlowe" , + Bruce Momjian , lutzeb@aeccom.com, + pgsql-performance@postgresql.org, Neil Conway +Subject: Re: Wierd context-switching issue on Xeon +In-reply-to: <200404191455.04068.josh@agliodbs.com> +References: + <40843E63.7050101@joeconway.com> + <200404191455.04068.josh@agliodbs.com> +Comments: In-reply-to Josh Berkus + message dated "Mon, 19 Apr 2004 14:55:04 -0700" +Date: Mon, 19 Apr 2004 18:55:34 -0400 +Message-ID: <29784.1082415334@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/280 +X-Sequence-Number: 6580 + +Josh Berkus writes: +>> I've got a quad 2.8Ghz MP Xeon (IBM x445) that I could test on. Does +>> anyone have a test set that can reliably reproduce the problem? + +> Unfortunately we can't seem to come up with one. + +> It does seem to require a database which is in the many GB (> 10GB), and a +> situation where a small subset of the data is getting hit repeatedly by +> multiple processes. + +I do not think a large database is actually necessary; the test case +Josh's client has is only hitting a relatively small amount of data. +The trick seems to be to cause lots and lots of ReadBuffer/ReleaseBuffer +activity without much else happening, and to do this from multiple +backends concurrently. + +I believe the best way to make this happen is a lot of relatively simple +(but not short) indexscan queries that in aggregate touch just a bit +less than shared_buffers worth of data. I have not tried to make a +self-contained test case, but based on what I know now I think it should +be possible. + +I'll give this a shot later tonight --- it does seem that trying to +reproduce the problem on different kinds of hardware is the next useful +step we can take. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Apr 19 21:02:52 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5389AD1BAF5 + for ; + Mon, 19 Apr 2004 21:02:50 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 64666-06 + for ; + Mon, 19 Apr 2004 21:02:51 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id D9C26D1D189 + for ; + Mon, 19 Apr 2004 21:02:47 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3K01udf001408; + Mon, 19 Apr 2004 20:01:57 -0400 (EDT) +To: josh@agliodbs.com +Cc: Joe Conway , "scott.marlowe" , + Bruce Momjian , lutzeb@aeccom.com, + pgsql-performance@postgresql.org, Neil Conway +Subject: Re: Wierd context-switching issue on Xeon +In-reply-to: <200404191455.04068.josh@agliodbs.com> +References: + <40843E63.7050101@joeconway.com> + <200404191455.04068.josh@agliodbs.com> +Comments: In-reply-to Josh Berkus + message dated "Mon, 19 Apr 2004 14:55:04 -0700" +MIME-Version: 1.0 +Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" +Content-ID: <1376.1082419088.0@sss.pgh.pa.us> +Date: Mon, 19 Apr 2004 20:01:56 -0400 +Message-ID: <1407.1082419316@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/281 +X-Sequence-Number: 6581 + +------- =_aaaaaaaaaa0 +Content-Type: text/plain; charset="us-ascii" +Content-ID: <1376.1082419088.1@sss.pgh.pa.us> + +Here is a test case. To set up, run the "test_setup.sql" script once; +then launch two copies of the "test_run.sql" script. (For those of +you with more than two CPUs, see whether you need one per CPU to make +trouble, or whether two test_runs are enough.) Check that you get a +nestloops-with-index-scans plan shown by the EXPLAIN in test_run. + +In isolation, test_run.sql should do essentially no syscalls at all once +it's past the initial ramp-up. On a machine that's functioning per +expectations, multiple copies of test_run show a relatively low rate of +semop() calls --- a few per second, at most --- and maybe a delaying +select() here and there. + +What I actually see on Josh's client's machine is a context swap storm: +"vmstat 1" shows CS rates around 170K/sec. strace'ing the backends +shows a corresponding rate of semop() syscalls, with a few delaying +select()s sprinkled in. top(1) shows system CPU percent of 25-30 +and idle CPU percent of 16-20. + +I haven't bothered to check how long the test_run query takes, but if it +ends while you're still examining the behavior, just start it again. + +Note the test case assumes you've got shared_buffers set to at least +1000; with smaller values, you may get some I/O syscalls, which will +probably skew the results. + + regards, tom lane + + +------- =_aaaaaaaaaa0 +Content-Type: text/plain; charset="us-ascii" +Content-ID: <1376.1082419088.2@sss.pgh.pa.us> +Content-Description: test_setup.sql + +drop table test_data; + +create table test_data(f1 int); + +insert into test_data values (random() * 100); +insert into test_data select random() * 100 from test_data; +insert into test_data select random() * 100 from test_data; +insert into test_data select random() * 100 from test_data; +insert into test_data select random() * 100 from test_data; +insert into test_data select random() * 100 from test_data; +insert into test_data select random() * 100 from test_data; +insert into test_data select random() * 100 from test_data; +insert into test_data select random() * 100 from test_data; +insert into test_data select random() * 100 from test_data; +insert into test_data select random() * 100 from test_data; +insert into test_data select random() * 100 from test_data; +insert into test_data select random() * 100 from test_data; +insert into test_data select random() * 100 from test_data; +insert into test_data select random() * 100 from test_data; +insert into test_data select random() * 100 from test_data; +insert into test_data select random() * 100 from test_data; + +create index test_index on test_data(f1); + +vacuum verbose analyze test_data; +checkpoint; + +------- =_aaaaaaaaaa0 +Content-Type: text/plain; charset="us-ascii" +Content-ID: <1376.1082419088.3@sss.pgh.pa.us> +Content-Description: test_run.sql + +-- force nestloop indexscan plan +set enable_seqscan to 0; +set enable_mergejoin to 0; +set enable_hashjoin to 0; + +explain +select count(*) from test_data a, test_data b, test_data c +where a.f1 = b.f1 and b.f1 = c.f1; + +select count(*) from test_data a, test_data b, test_data c +where a.f1 = b.f1 and b.f1 = c.f1; + +------- =_aaaaaaaaaa0-- + +From pgsql-performance-owner@postgresql.org Mon Apr 19 21:53:58 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 76BA3D1DD51 + for ; + Mon, 19 Apr 2004 21:53:57 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 80625-04 + for ; + Mon, 19 Apr 2004 21:53:59 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 74A3AD1DC7D + for ; + Mon, 19 Apr 2004 21:53:55 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3K0r9aj001932; + Mon, 19 Apr 2004 20:53:09 -0400 (EDT) +To: josh@agliodbs.com +Cc: Joe Conway , "scott.marlowe" , + Bruce Momjian , lutzeb@aeccom.com, + pgsql-performance@postgresql.org, Neil Conway +Subject: Re: Wierd context-switching issue on Xeon +In-reply-to: <1407.1082419316@sss.pgh.pa.us> +References: + <40843E63.7050101@joeconway.com> + <200404191455.04068.josh@agliodbs.com> + <1407.1082419316@sss.pgh.pa.us> +Comments: In-reply-to Tom Lane + message dated "Mon, 19 Apr 2004 20:01:56 -0400" +Date: Mon, 19 Apr 2004 20:53:09 -0400 +Message-ID: <1931.1082422389@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/282 +X-Sequence-Number: 6582 + +I wrote: +> Here is a test case. + +Hmmm ... I've been able to reproduce the CS storm on a dual Athlon, +which seems to pretty much let the Xeon per se off the hook. Anybody +got a multiple Opteron to try? Totally non-Intel CPUs? + +It would be interesting to see results with non-Linux kernels, too. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Apr 20 00:00:32 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 665C5D1BAAE + for ; + Tue, 20 Apr 2004 00:00:30 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 16732-06 + for ; + Tue, 20 Apr 2004 00:00:26 -0300 (ADT) +Received: from joeconway.com (66-146-172-82.skyriver.net [66.146.172.82]) + by svr1.postgresql.org (Postfix) with ESMTP id A2E14D1B973 + for ; + Tue, 20 Apr 2004 00:00:25 -0300 (ADT) +Received: from [206.19.64.3] (account jconway HELO joeconway.com) + by joeconway.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP-TLS id 1446269; Mon, 19 Apr 2004 19:54:27 -0700 +Message-ID: <40849235.2070808@joeconway.com> +Date: Mon, 19 Apr 2004 20:00:05 -0700 +From: Joe Conway +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.6) Gecko/20040113 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: josh@agliodbs.com, "scott.marlowe" , + Bruce Momjian , lutzeb@aeccom.com, + pgsql-performance@postgresql.org, Neil Conway +Subject: Re: Wierd context-switching issue on Xeon +References: + <40843E63.7050101@joeconway.com> + <200404191455.04068.josh@agliodbs.com> + <1407.1082419316@sss.pgh.pa.us> +In-Reply-To: <1407.1082419316@sss.pgh.pa.us> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/284 +X-Sequence-Number: 6584 + +Tom Lane wrote: +> Here is a test case. To set up, run the "test_setup.sql" script once; +> then launch two copies of the "test_run.sql" script. (For those of +> you with more than two CPUs, see whether you need one per CPU to make +> trouble, or whether two test_runs are enough.) Check that you get a +> nestloops-with-index-scans plan shown by the EXPLAIN in test_run. + +Check. + +> In isolation, test_run.sql should do essentially no syscalls at all once +> it's past the initial ramp-up. On a machine that's functioning per +> expectations, multiple copies of test_run show a relatively low rate of +> semop() calls --- a few per second, at most --- and maybe a delaying +> select() here and there. +> +> What I actually see on Josh's client's machine is a context swap storm: +> "vmstat 1" shows CS rates around 170K/sec. strace'ing the backends +> shows a corresponding rate of semop() syscalls, with a few delaying +> select()s sprinkled in. top(1) shows system CPU percent of 25-30 +> and idle CPU percent of 16-20. + +Your test case works perfectly. I ran 4 concurrent psql sessions, on a +quad Xeon (IBM x445, 2.8GHz, 4GB RAM), hyperthreaded. Heres what 'top' +looks like: + +177 processes: 173 sleeping, 3 running, 1 zombie, 0 stopped +CPU states: cpu user nice system irq softirq iowait idle + total 35.9% 0.0% 7.2% 0.0% 0.0% 0.0% 56.8% + cpu00 19.6% 0.0% 4.9% 0.0% 0.0% 0.0% 75.4% + cpu01 44.1% 0.0% 7.8% 0.0% 0.0% 0.0% 48.0% + cpu02 0.0% 0.0% 0.0% 0.0% 0.0% 0.0% 100.0% + cpu03 32.3% 0.0% 13.7% 0.0% 0.0% 0.0% 53.9% + cpu04 21.5% 0.0% 10.7% 0.0% 0.0% 0.0% 67.6% + cpu05 42.1% 0.0% 9.8% 0.0% 0.0% 0.0% 48.0% + cpu06 100.0% 0.0% 0.0% 0.0% 0.0% 0.0% 0.0% + cpu07 27.4% 0.0% 10.7% 0.0% 0.0% 0.0% 61.7% +Mem: 4123700k av, 3933896k used, 189804k free, 0k shrd, 221948k buff + 2492124k actv, 760612k in_d, 41416k in_c +Swap: 2040244k av, 5632k used, 2034612k free 3113272k cached + +Note that cpu06 is not a postgres process. The output of vmstat looks +like this: + +# vmstat 1 +procs memory swap io system + cpu +r b swpd free buff cache si so bi bo in cs us sy id wa +4 0 5632 184264 221948 3113308 0 0 0 0 0 0 0 0 0 0 +3 0 5632 184264 221948 3113308 0 0 0 0 112 211894 36 9 55 0 +5 0 5632 184264 221948 3113308 0 0 0 0 125 222071 39 8 53 0 +4 0 5632 184264 221948 3113308 0 0 0 0 110 215097 39 10 52 0 +1 0 5632 184588 221948 3113308 0 0 0 96 139 187561 35 10 55 0 +3 0 5632 184588 221948 3113308 0 0 0 0 114 241731 38 10 52 0 +3 0 5632 184920 221948 3113308 0 0 0 0 132 257168 40 9 51 0 +1 0 5632 184912 221948 3113308 0 0 0 0 114 251802 38 9 54 0 + +> Note the test case assumes you've got shared_buffers set to at least +> 1000; with smaller values, you may get some I/O syscalls, which will +> probably skew the results. + + shared_buffers +---------------- + 16384 +(1 row) + +I found that killing three of the four concurrent queries dropped +context switches to about 70,000 to 100,000. Two or more sessions brings +it up to 200K+. + +Joe + +From pgsql-performance-owner@postgresql.org Tue Apr 20 00:37:58 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E656ED1D137 + for ; + Tue, 20 Apr 2004 00:37:57 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 33925-03 + for ; + Tue, 20 Apr 2004 00:37:54 -0300 (ADT) +Received: from ECCMCBH.cmc.int.ec.gc.ca (ecdor130.cmc.ec.gc.ca + [199.212.17.130]) + by svr1.postgresql.org (Postfix) with ESMTP id CBD34D1D06C + for ; + Tue, 20 Apr 2004 00:37:53 -0300 (ADT) +Received: by eccmcbh.cmc.ec.gc.ca with Internet Mail Service (5.5.2653.19) + id ; Mon, 19 Apr 2004 23:37:48 -0400 +Message-ID: +From: "Shea,Dan [CIS]" +To: pgsql-performance@postgresql.org +Subject: Why will vacuum not end? +Date: Mon, 19 Apr 2004 23:37:47 -0400 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2653.19) +Content-Type: text/plain; + charset="iso-8859-1" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/286 +X-Sequence-Number: 6586 + +This vacuum is running a marathon. Why will it not end and show me free +space map INFO? We have deleted a lot of data and I would like to be +confident that these deletions will be used as free space, rather than +creating more table files. + + + +PWFPM_DEV=# select now();vacuum verbose forecastelement;select now(); + now +------------------------------- + 2004-04-14 18:36:13.725285+00 +(1 row) + +INFO: vacuuming "public.forecastelement" +INFO: index "forecastelement_rwv_idx" now contains 473380072 row versions +in 4986653 pages +DETAIL: 5592106 index row versions were removed. +44688 index pages have been deleted, 1 are currently reusable. +CPU 4942.30s/336.27u sec elapsed 74710.07 sec. +INFO: "forecastelement": removed 5592106 row versions in 126370 pages +DETAIL: CPU 58.43s/16.99u sec elapsed 366.24 sec. +INFO: index "forecastelement_rwv_idx" now contains 472296119 row versions +in 5027529 pages +DETAIL: 5592097 index row versions were removed. +89120 index pages have been deleted, 0 are currently reusable. +CPU 4260.08s/327.29u sec elapsed 59592.38 sec. +INFO: "forecastelement": removed 5592097 row versions in 124726 pages +DETAIL: CPU 33.38s/14.21u sec elapsed 210.36 sec. +INFO: index "forecastelement_rwv_idx" now contains 467784889 row versions +in 5037914 pages +DETAIL: 5592089 index row versions were removed. +134286 index pages have been deleted, 0 are currently reusable. +CPU 4185.86s/318.19u sec elapsed 57048.65 sec. +INFO: "forecastelement": removed 5592089 row versions in 121657 pages +DETAIL: CPU 51.19s/14.19u sec elapsed 238.31 sec. +INFO: index "forecastelement_rwv_idx" now contains 462960132 row versions +in 5039886 pages +DETAIL: 5592067 index row versions were removed. +179295 index pages have been deleted, 0 are currently reusable. +CPU 4002.76s/313.63u sec elapsed 54806.09 sec. +INFO: "forecastelement": removed 5592067 row versions in 122510 pages +DETAIL: CPU 25.32s/14.47u sec elapsed 187.73 sec. +INFO: index "forecastelement_rwv_idx" now contains 457555142 row versions +in 5041631 pages +DETAIL: 5592085 index row versions were removed. +224480 index pages have been deleted, 0 are currently reusable. +CPU 4149.42s/310.94u sec elapsed 55880.65 sec. +INFO: "forecastelement": removed 5592085 row versions in 122500 pages +DETAIL: CPU 16.70s/14.47u sec elapsed 180.27 sec. +INFO: index "forecastelement_rwv_idx" now contains 452191660 row versions +in 5044414 pages +DETAIL: 5592089 index row versions were removed. +269665 index pages have been deleted, 0 are currently reusable. +CPU 4213.10s/304.61u sec elapsed 55159.36 sec. +INFO: "forecastelement": removed 5592089 row versions in 122663 pages +DETAIL: CPU 37.28s/14.63u sec elapsed 206.96 sec. +INFO: index "forecastelement_rwv_idx" now contains 446807778 row versions +in 5046541 pages +DETAIL: 5592077 index row versions were removed. +314747 index pages have been deleted, 0 are currently reusable. +CPU 4039.49s/297.15u sec elapsed 55086.56 sec. +INFO: "forecastelement": removed 5592077 row versions in 122558 pages +DETAIL: CPU 20.21s/14.74u sec elapsed 227.53 sec. + + + + + + + + + + + + + + + + +From pgsql-performance-owner@postgresql.org Tue Apr 20 00:47:55 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4B8B8D1C4C2 + for ; + Tue, 20 Apr 2004 00:47:53 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 37226-02 + for ; + Tue, 20 Apr 2004 00:47:50 -0300 (ADT) +Received: from srvr3.iniquinet.com (srvr2.iniquinet.com [64.240.87.12]) + by svr1.postgresql.org (Postfix) with SMTP id 6AEDDD1B482 + for ; + Tue, 20 Apr 2004 00:47:49 -0300 (ADT) +Received: (qmail 14697 invoked by uid 104); 20 Apr 2004 03:47:47 -0000 +Received: from Robert_Creager@LogicalChaos.org by srvr3.iniquinet.com by uid + 101 with qmail-scanner-1.15 + (clamscan: 0.65. spamassassin: 2.55. Clear:SA:0(-7.4/6.0):. + Processed in 32.951673 secs); 20 Apr 2004 03:47:47 -0000 +Received: from unknown (HELO thunder.mshome.net) (216.58.165.126) + by srvr3.iniquinet.com with SMTP; 20 Apr 2004 03:47:14 -0000 +Received: from localhost.localdomain (thunder.mshome.net [192.168.0.250]) + by thunder.mshome.net (Postfix) with ESMTP id 998C994857; + Mon, 19 Apr 2004 21:47:13 -0600 (MDT) +Received: from logicalchaos.org (thunder.mshome.net [192.168.0.250]) + by thunder.mshome.net (Postfix) with SMTP id 263B694857; + Mon, 19 Apr 2004 21:47:10 -0600 (MDT) +Date: Mon, 19 Apr 2004 21:47:02 -0600 +From: Robert Creager +To: Tom Lane +Cc: josh@agliodbs.com, Joe Conway , + "scott.marlowe" , + Bruce Momjian , lutzeb@aeccom.com, + pgsql-performance@postgresql.org, Neil Conway +Subject: Re: Wierd context-switching issue on Xeon +Message-Id: <20040419214702.70e5c9b6@thunder.mshome.net> +In-Reply-To: <1931.1082422389@sss.pgh.pa.us> +References: + <40843E63.7050101@joeconway.com> + <200404191455.04068.josh@agliodbs.com> + <1407.1082419316@sss.pgh.pa.us> <1931.1082422389@sss.pgh.pa.us> +Organization: Starlight Vision, LLC. +X-Mailer: Sylpheed version 0.9.9claws (GTK+ 1.2.10; i586-mandrake-linux-gnu) +Mime-Version: 1.0 +Content-Type: multipart/signed; protocol="application/pgp-signature"; + micalg="pgp-sha1"; + boundary="Signature=_Mon__19_Apr_2004_21_47_02_-0600_TKk0qNlhGAUFCcfZ" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/287 +X-Sequence-Number: 6587 + +--Signature=_Mon__19_Apr_2004_21_47_02_-0600_TKk0qNlhGAUFCcfZ +Content-Type: text/plain; charset=US-ASCII +Content-Disposition: inline +Content-Transfer-Encoding: 7bit + +When grilled further on (Mon, 19 Apr 2004 20:53:09 -0400), +Tom Lane confessed: + +> I wrote: +> > Here is a test case. +> +> Hmmm ... I've been able to reproduce the CS storm on a dual Athlon, +> which seems to pretty much let the Xeon per se off the hook. Anybody +> got a multiple Opteron to try? Totally non-Intel CPUs? +> +> It would be interesting to see results with non-Linux kernels, too. +> + +Same problem on my dual AMD MP with 2.6.5 kernel using two sessions of your +test, but maybe not quite as severe. The highest CS values I saw was 102k, with +some non-db number crunching going on in parallel with the test. 'Average' +about 80k with two instances. Using the anticipatory scheduler. + +A single instance pulls in around 200-300 CS, and no tests running around +200-300 CS (i.e. no CS difference). + +A snipet: + +procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu---- + 3 0 284 90624 93452 1453740 0 0 0 0 1075 76548 83 17 0 0 + 6 0 284 125312 93452 1470196 0 0 0 0 1073 87702 78 22 0 0 + 3 0 284 178392 93460 1420208 0 0 76 298 1083 67721 77 24 0 0 + 4 0 284 177120 93460 1421500 0 0 1104 0 1054 89593 80 21 0 0 + 5 0 284 173504 93460 1425172 0 0 3584 0 1110 65536 81 19 0 0 + 4 0 284 169984 93460 1428708 0 0 3456 0 1098 66937 81 20 0 0 + 6 0 284 170944 93460 1428708 0 0 8 0 1045 66065 81 19 0 0 + 6 0 284 167288 93460 1428776 0 0 0 8 1097 75560 81 19 0 0 + 6 0 284 136296 93460 1458356 0 0 0 0 1036 80808 75 26 0 0 + 5 0 284 132864 93460 1461688 0 0 0 0 1007 76071 84 17 0 0 + 4 0 284 132880 93460 1461688 0 0 0 0 1079 86903 82 18 0 0 + 5 0 284 132880 93460 1461688 0 0 0 0 1078 79885 83 17 0 0 + 6 0 284 132648 93460 1461688 0 0 0 760 1228 66564 86 14 0 0 + 6 0 284 132648 93460 1461688 0 0 0 0 1047 69741 86 15 0 0 + 6 0 284 132672 93460 1461688 0 0 0 0 1057 79052 84 16 0 0 + 5 0 284 132672 93460 1461688 0 0 0 0 1054 81109 82 18 0 0 + 5 0 284 132736 93460 1461688 0 0 0 0 1043 91725 80 20 0 0 + + +Cheers, +Rob + +-- + 21:33:03 up 3 days, 1:10, 3 users, load average: 5.05, 4.67, 4.22 +Linux 2.6.5-01 #5 SMP Tue Apr 6 21:32:39 MDT 2004 + +--Signature=_Mon__19_Apr_2004_21_47_02_-0600_TKk0qNlhGAUFCcfZ +Content-Type: application/pgp-signature + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.4 (GNU/Linux) + +iEYEARECAAYFAkCEnT4ACgkQLQ/DKuwDYzlP+gCfUEjce4uOlds2UYi74gQF4x74 +RZoAn1NxiPBUks7VXrPJesieH371NWYp +=cWZK +-----END PGP SIGNATURE----- + +--Signature=_Mon__19_Apr_2004_21_47_02_-0600_TKk0qNlhGAUFCcfZ-- + + +From pgsql-performance-owner@postgresql.org Tue Apr 20 00:57:35 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1EB7BD1DC8D + for ; + Tue, 20 Apr 2004 00:57:34 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 35593-07 + for ; + Tue, 20 Apr 2004 00:57:32 -0300 (ADT) +Received: from houston.familyhealth.com.au (fhnet.arach.net.au + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 22AA7D1DCA0 + for ; + Tue, 20 Apr 2004 00:57:31 -0300 (ADT) +Received: from familyhealth.com.au (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id + i3K3vEWL018842; Tue, 20 Apr 2004 11:57:14 +0800 (WST) + (envelope-from chriskl@familyhealth.com.au) +Message-ID: <4084A0D0.5060305@familyhealth.com.au> +Date: Tue, 20 Apr 2004 12:02:24 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "Shea,Dan [CIS]" +Cc: pgsql-performance@postgresql.org +Subject: Re: Why will vacuum not end? +References: +In-Reply-To: +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/288 +X-Sequence-Number: 6588 + +> This vacuum is running a marathon. Why will it not end and show me free +> space map INFO? We have deleted a lot of data and I would like to be +> confident that these deletions will be used as free space, rather than +> creating more table files. + +Does another postgres query running have a lock on that table? + +Chris + + +From pgsql-performance-owner@postgresql.org Tue Apr 20 02:20:12 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5F2BBD1CCCF + for ; + Tue, 20 Apr 2004 02:20:09 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 60265-05 + for ; + Tue, 20 Apr 2004 02:20:08 -0300 (ADT) +Received: from mtaw4.prodigy.net (mtaw4.prodigy.net [64.164.98.52]) + by svr1.postgresql.org (Postfix) with ESMTP id BDC07D1C9E6 + for ; + Tue, 20 Apr 2004 02:20:06 -0300 (ADT) +Received: from local2 (adsl-216-100-44-178.dsl.snfc21.pacbell.net + [216.100.44.178]) + by mtaw4.prodigy.net (8.12.10/8.12.10) with ESMTP id i3K5K55l012466 + for ; + Mon, 19 Apr 2004 22:20:05 -0700 (PDT) +Date: Mon, 19 Apr 2004 22:18:21 -0700 (PDT) +From: jelle +X-X-Sender: jelle@localhost.localdomain +Reply-To: jellej@pacbell.net +To: pgsql-performance@postgresql.org +Subject: Re: Wierd context-switching issue on Xeon +In-Reply-To: <1931.1082422389@sss.pgh.pa.us> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/289 +X-Sequence-Number: 6589 + + +Same problem with dual 1Ghz P3's running Postgres 7.4.2, linux 2.4.x, and +2GB ram, under load, with long transactions (i.e. 1 "cannot serialize" +rollback per minute). 200K was the worst observed with vmstat. + +Finally moved DB to a single xeon box. + + +From pgsql-performance-owner@postgresql.org Tue Apr 20 07:35:54 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id ED88FD1B7F0 + for ; + Tue, 20 Apr 2004 07:35:53 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 58446-06 + for ; + Tue, 20 Apr 2004 07:35:55 -0300 (ADT) +Received: from server.pyrenet.fr (server.pyrenet.fr [194.250.190.1]) + by svr1.postgresql.org (Postfix) with ESMTP id 8F332D1B49B + for ; + Tue, 20 Apr 2004 07:35:51 -0300 (ADT) +Received: from localhost (localhost [127.0.0.1]) + by localhost.pyrenet.fr (Postfix) with ESMTP + id 906D2295D1; Tue, 20 Apr 2004 12:35:53 +0200 (MET DST) +Received: from server.pyrenet.fr ([127.0.0.1]) + by localhost (server [127.0.0.1]) (amavisd-new, port 10024) with ESMTP + id 03467-03; Tue, 20 Apr 2004 12:35:50 +0200 (MET DST) +Received: from server.pyrenet.fr (server.pyrenet.fr [194.250.190.1]) + by server.pyrenet.fr (Postfix) with ESMTP + id 4AD71295D0; Tue, 20 Apr 2004 12:35:50 +0200 (MET DST) +Date: Tue, 20 Apr 2004 12:35:50 +0200 (MET DST) +From: ohp@pyrenet.fr +Reply-To: ohp@pyrenet.fr +To: Tom Lane +Cc: josh@agliodbs.com, Joe Conway , + "scott.marlowe" , + Bruce Momjian , lutzeb@aeccom.com, + pgsql-performance@postgresql.org, Neil Conway +Subject: Re: Wierd context-switching issue on Xeon +In-Reply-To: <1931.1082422389@sss.pgh.pa.us> +Message-ID: +References: + <40843E63.7050101@joeconway.com> <200404191455.04068.josh@agliodbs.com> + <1407.1082419316@sss.pgh.pa.us> <1931.1082422389@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at pyrenet.fr +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME +X-Spam-Level: +X-Archive-Number: 200404/290 +X-Sequence-Number: 6590 + +Hi Tom, + +You still have an account on my Unixware Bi-Xeon hyperthreded machine. +Feel free to use it for your tests. +On Mon, 19 Apr 2004, Tom Lane wrote: + +> Date: Mon, 19 Apr 2004 20:53:09 -0400 +> From: Tom Lane +> To: josh@agliodbs.com +> Cc: Joe Conway , scott.marlowe , +> Bruce Momjian , lutzeb@aeccom.com, +> pgsql-performance@postgresql.org, Neil Conway +> Subject: Re: [PERFORM] Wierd context-switching issue on Xeon +> +> I wrote: +> > Here is a test case. +> +> Hmmm ... I've been able to reproduce the CS storm on a dual Athlon, +> which seems to pretty much let the Xeon per se off the hook. Anybody +> got a multiple Opteron to try? Totally non-Intel CPUs? +> +> It would be interesting to see results with non-Linux kernels, too. +> +> regards, tom lane +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 4: Don't 'kill -9' the postmaster +> + +-- +Olivier PRENANT Tel: +33-5-61-50-97-00 (Work) +6, Chemin d'Harraud Turrou +33-5-61-50-97-01 (Fax) +31190 AUTERIVE +33-6-07-63-80-64 (GSM) +FRANCE Email: ohp@pyrenet.fr +------------------------------------------------------------------------------ +Make your life a dream, make your dream a reality. (St Exupery) + +From pgsql-performance-owner@postgresql.org Tue Apr 20 08:16:01 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id F3B9ED1D08B + for ; + Tue, 20 Apr 2004 08:15:58 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 80842-02 + for ; + Tue, 20 Apr 2004 08:16:00 -0300 (ADT) +Received: from biglumber.com (biglumber.com [207.228.252.42]) + by svr1.postgresql.org (Postfix) with SMTP id 520C4D1B482 + for ; + Tue, 20 Apr 2004 08:15:56 -0300 (ADT) +Received: (qmail 24833 invoked from network); 20 Apr 2004 11:15:58 -0000 +Received: from unknown (HELO localhost) (207.228.252.42) + by 0 with SMTP; 20 Apr 2004 11:15:58 -0000 +From: "Greg Sabino Mullane" +To: pgsql-performance@postgresql.org +Subject: Re: Deleting certain duplicates +X-PGP-Key: 2529 DF6A B8F7 9407 E944 45B4 BC9B 9067 1496 4AC8 +X-Request-PGP: + http://www.biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8 +In-Reply-To: +Date: Tue, 20 Apr 2004 11:15:58 -0000 +X-Mailer: JoyMail 1.47 +Message-ID: <82428c807d3c47fbcd0c013dbcab12b5@biglumber.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/291 +X-Sequence-Number: 6591 + + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + + +> So I was thinking maybe of doing the deletion in chunks, perhaps based on +> reception time. +> Are there any suggestions for a better way to do this, or using multiple +> queries to delete selectively a week at a time based on the reception_time. +> I would say there are a lot of duplicate entries between mid march to the +> first week of April. + +You are on the right track, in that dividing up the table will help. However, +you cannot divide on the reception_time as that is the unique column. Analyze +your data and divide on a row with a fairly uniform distribution over the +time period in question. Then copy a segment out, clean it up, and put it +back in. Make sure there is an index on the column in question, of course. + +For example, if 1/10 of the table has a "units" of 12, you could do something +like this: + +CREATE INDEX units_dev ON forecastelement (units); + +CREATE TEMPORARY TABLE units_temp AS SELECT * FROM forecastelement WHERE units='12'; + +CREATE INDEX units_oid_index ON units_temp(oid); + +(Delete out duplicate rows from units_temp using your previous query or something else) + +DELETE FROM forecastelement WHERE units='12'; + +INSERT INTO forecastelement SELECT * FROM units_temp; + +DELETE FROM units_temp; + +Repeat as needed until all rows are done. Subsequent runs can be done by doing a + +INSERT INTO units_temp SELECT * FROM forecastelement WHERE units='...' + +and skipping the CREATE INDEX steps. + +On the other hand, your original deletion query may work as is, with the addition +of an oid index. Perhaps try an EXPLAIN on it. + +- -- +Greg Sabino Mullane greg@turnstep.com +PGP Key: 0x14964AC8 200404200706 + +-----BEGIN PGP SIGNATURE----- + +iD8DBQFAhQVWvJuQZxSWSsgRAvLEAKDCVcX3Llm8JgszI/BBC1SobtjVawCfVGKu +ERcV5J2JolwgZRhMbXnNM90= +=JqET +-----END PGP SIGNATURE----- + + + +From pgsql-performance-owner@postgresql.org Tue Apr 20 09:46:13 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B7A56D1DD56 + for ; + Tue, 20 Apr 2004 09:46:11 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 01149-10 + for ; + Tue, 20 Apr 2004 09:46:12 -0300 (ADT) +Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com + [24.128.241.68]) + by svr1.postgresql.org (Postfix) with SMTP id A7497D1DD51 + for ; + Tue, 20 Apr 2004 09:46:08 -0300 (ADT) +Received: (qmail 34366 invoked from network); 20 Apr 2004 12:46:15 -0000 +Received: from localhost (HELO ?10.124.7.139?) (threshar@127.0.0.1) + by localhost with SMTP; 20 Apr 2004 12:46:15 -0000 +In-Reply-To: <1407.1082419316@sss.pgh.pa.us> +References: + <40843E63.7050101@joeconway.com> + <200404191455.04068.josh@agliodbs.com> + <1407.1082419316@sss.pgh.pa.us> +Mime-Version: 1.0 (Apple Message framework v613) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: +Content-Transfer-Encoding: 7bit +Cc: Bruce Momjian , + Joe Conway , Neil Conway , + josh@agliodbs.com, lutzeb@aeccom.com, pgsql-performance@postgresql.org, + "scott.marlowe" +From: Jeff +Subject: Re: Wierd context-switching issue on Xeon +Date: Tue, 20 Apr 2004 08:46:12 -0400 +To: Tom Lane +X-Mailer: Apple Mail (2.613) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=2.7 tagged_above=0.0 required=5.0 + tests=RCVD_IN_DYNABLOCK, RCVD_IN_SORBS +X-Spam-Level: ** +X-Archive-Number: 200404/292 +X-Sequence-Number: 6592 + + +On Apr 19, 2004, at 8:01 PM, Tom Lane wrote: +[test case] + +Quad P3-700Mhz, ServerWorks, pg 7.4.2 - 1 process: 10-30 cs / second + 2 process: 100k cs / sec + 3 process: 140k cs / sec + 8 process: 115k cs / sec + +Dual P2-450Mhz, non-serverworks (piix) - 1 process 15-20 / sec + 2 process 30k / sec + 3 (up to 7) process: 15k /sec + +(Yes, I verified with more processes the cs's drop) + +And finally, + +6 cpu sun e4500, solaris 2.6, pg 7.4.2: 1 - 10 processes: hovered +between 2-3k cs/second (there was other stuff running on the machine as +well) + + +Verrry interesting. +I've got a dual G4 at home, but for convenience Apple doesn't ship a +vmstat that tells context switches + +-- +Jeff Trout +http://www.jefftrout.com/ +http://www.stuarthamm.net/ + + +From pgsql-performance-owner@postgresql.org Tue Apr 20 09:58:20 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3C3BED1BB93 + for ; + Tue, 20 Apr 2004 09:58:19 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 08156-09 + for ; + Tue, 20 Apr 2004 09:58:21 -0300 (ADT) +Received: from ECCMCBH.cmc.int.ec.gc.ca (ecdor130.cmc.ec.gc.ca + [199.212.17.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 962FBD1D2B7 + for ; + Tue, 20 Apr 2004 09:58:08 -0300 (ADT) +Received: by eccmcbh.cmc.ec.gc.ca with Internet Mail Service (5.5.2653.19) + id ; Tue, 20 Apr 2004 08:58:09 -0400 +Message-ID: +From: "Shea,Dan [CIS]" +To: 'Christopher Kings-Lynne' +Cc: pgsql-performance@postgresql.org +Subject: Re: Why will vacuum not end? +Date: Tue, 20 Apr 2004 08:58:09 -0400 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2653.19) +Content-Type: text/plain +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/293 +X-Sequence-Number: 6593 + +No, but data is constantly being inserted by userid scores. It is postgres +runnimg the vacuum. +Dan. + +-----Original Message----- +From: Christopher Kings-Lynne [mailto:chriskl@familyhealth.com.au] +Sent: Tuesday, April 20, 2004 12:02 AM +To: Shea,Dan [CIS] +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Why will vacuum not end? + + +> This vacuum is running a marathon. Why will it not end and show me free +> space map INFO? We have deleted a lot of data and I would like to be +> confident that these deletions will be used as free space, rather than +> creating more table files. + +Does another postgres query running have a lock on that table? + +Chris + +From pgsql-performance-owner@postgresql.org Tue Apr 20 10:04:31 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id F20B8D1DD59 + for ; + Tue, 20 Apr 2004 10:04:27 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 08341-08 + for ; + Tue, 20 Apr 2004 10:04:28 -0300 (ADT) +Received: from net2.micro-automation.com (net2.micro-automation.com + [64.7.141.29]) + by svr1.postgresql.org (Postfix) with SMTP id AE033D1DD42 + for ; + Tue, 20 Apr 2004 10:04:24 -0300 (ADT) +Received: (qmail 21581 invoked from network); 20 Apr 2004 13:04:20 -0000 +Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) + by net2.micro-automation.com with SMTP; 20 Apr 2004 13:04:20 -0000 +Subject: Re: Wierd context-switching issue on Xeon +From: Dave Cramer +Reply-To: pg@fastcrypt.com +To: Jeff +Cc: Tom Lane , Bruce Momjian , + Joe Conway , Neil Conway , + Josh Berkus , lutzeb@aeccom.com, + pgsql-performance@postgresql.org, "scott.marlowe" +In-Reply-To: +References: + <40843E63.7050101@joeconway.com> <200404191455.04068.josh@agliodbs.com> + <1407.1082419316@sss.pgh.pa.us> + +Content-Type: text/plain +Organization: Cramer Consulting +Message-Id: <1082466419.3069.132.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Tue, 20 Apr 2004 09:06:59 -0400 +Content-Transfer-Encoding: 7bit +X-AntiVirus: scanned for viruses by AMaViS 0.2.1 (http://amavis.org/) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/294 +X-Sequence-Number: 6594 + +Dual Athlon + +With one process running 30 cs/second +with two process running 15000 cs/second + +Dave +On Tue, 2004-04-20 at 08:46, Jeff wrote: +> On Apr 19, 2004, at 8:01 PM, Tom Lane wrote: +> [test case] +> +> Quad P3-700Mhz, ServerWorks, pg 7.4.2 - 1 process: 10-30 cs / second +> 2 process: 100k cs / sec +> 3 process: 140k cs / sec +> 8 process: 115k cs / sec +> +> Dual P2-450Mhz, non-serverworks (piix) - 1 process 15-20 / sec +> 2 process 30k / sec +> 3 (up to 7) process: 15k /sec +> +> (Yes, I verified with more processes the cs's drop) +> +> And finally, +> +> 6 cpu sun e4500, solaris 2.6, pg 7.4.2: 1 - 10 processes: hovered +> between 2-3k cs/second (there was other stuff running on the machine as +> well) +> +> +> Verrry interesting. +> I've got a dual G4 at home, but for convenience Apple doesn't ship a +> vmstat that tells context switches +> +> -- +> Jeff Trout +> http://www.jefftrout.com/ +> http://www.stuarthamm.net/ +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 5: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faqs/FAQ.html +> +> +> +> !DSPAM:40851da1199651145780980! +> +> +-- +Dave Cramer +519 939 0336 +ICQ # 14675561 + + +From pgsql-performance-owner@postgresql.org Tue Apr 20 10:14:04 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id EA6CAD1D2B5 + for ; + Tue, 20 Apr 2004 10:14:02 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 14734-09 + for ; + Tue, 20 Apr 2004 10:14:05 -0300 (ADT) +Received: from internet.potentialtech.com (h-66-167-251-6.phlapafg.covad.net + [66.167.251.6]) + by svr1.postgresql.org (Postfix) with ESMTP id 377CED1D238 + for ; + Tue, 20 Apr 2004 10:14:01 -0300 (ADT) +Received: from potentialtech.com (pa-plum1c-102.pit.adelphia.net + [24.53.179.102]) by internet.potentialtech.com (Postfix) with ESMTP + id A556669A71; Tue, 20 Apr 2004 09:14:04 -0400 (EDT) +Message-ID: <40852218.2050204@potentialtech.com> +Date: Tue, 20 Apr 2004 09:14:00 -0400 +From: Bill Moran +User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.4) Gecko/20031005 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "Shea,Dan [CIS]" +Cc: 'Christopher Kings-Lynne' , + pgsql-performance@postgresql.org +Subject: Re: Why will vacuum not end? +References: +In-Reply-To: +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=RCVD_IN_RFCI, + RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200404/295 +X-Sequence-Number: 6595 + +Shea,Dan [CIS] wrote: +> No, but data is constantly being inserted by userid scores. It is postgres +> runnimg the vacuum. +> Dan. +> +> -----Original Message----- +> From: Christopher Kings-Lynne [mailto:chriskl@familyhealth.com.au] +> Sent: Tuesday, April 20, 2004 12:02 AM +> To: Shea,Dan [CIS] +> Cc: pgsql-performance@postgresql.org +> Subject: Re: [PERFORM] Why will vacuum not end? +> +>>This vacuum is running a marathon. Why will it not end and show me free +>>space map INFO? We have deleted a lot of data and I would like to be +>>confident that these deletions will be used as free space, rather than +>>creating more table files. +> +> Does another postgres query running have a lock on that table? + +This may be a dumb question (but only because I don't know the answer) + +Doesn't/shouldn't vacuum have some kind of timeout so if a table is locked +it will give up eventually (loudly complaining when it does so)? + +-- +Bill Moran +Potential Technologies +http://www.potentialtech.com + + +From pgsql-performance-owner@postgresql.org Tue Apr 20 10:44:42 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 53643D1DB0C + for ; + Tue, 20 Apr 2004 10:44:41 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 39727-02 + for ; + Tue, 20 Apr 2004 10:44:42 -0300 (ADT) +Received: from bayswater1.ymogen.net (host-154-240-27-217.pobox.net.uk + [217.27.240.154]) + by svr1.postgresql.org (Postfix) with ESMTP id CB157D1D2CC + for ; + Tue, 20 Apr 2004 10:44:37 -0300 (ADT) +Received: from solent (82-68-95-1.dsl.in-addr.zen.co.uk [82.68.95.1]) + by bayswater1.ymogen.net (Postfix) with ESMTP + id E9FA29B774; Tue, 20 Apr 2004 14:44:40 +0100 (BST) +From: "Matt Clark" +To: "Tom Lane" , +Cc: "Joe Conway" , + "scott.marlowe" , + "Bruce Momjian" , , + , "Neil Conway" +Subject: Re: Wierd context-switching issue on Xeon +Date: Tue, 20 Apr 2004 14:44:40 +0100 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 +In-Reply-To: <1407.1082419316@sss.pgh.pa.us> +Importance: Normal +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/296 +X-Sequence-Number: 6596 + +As a cross-ref to all the 7.4.x tests people have sent in, here's 7.2.3 (Redhat 7.3), Quad Xeon 700MHz/1MB L2 cache, 3GB RAM. + +Idle-ish (it's a production server) cs/sec ~5000 + +3 test queries running: + procs memory swap io system cpu + r b w swpd free buff cache si so bi bo in cs us sy id + 3 0 0 23380 577680 105912 2145140 0 0 0 0 107 116890 50 14 35 + 2 0 0 23380 577680 105912 2145140 0 0 0 0 114 118583 50 15 34 + 2 0 0 23380 577680 105912 2145140 0 0 0 0 107 115842 54 14 32 + 2 1 0 23380 577680 105920 2145140 0 0 0 32 156 117549 50 16 35 + +HTH + +Matt + +> -----Original Message----- +> From: pgsql-performance-owner@postgresql.org +> [mailto:pgsql-performance-owner@postgresql.org]On Behalf Of Tom Lane +> Sent: 20 April 2004 01:02 +> To: josh@agliodbs.com +> Cc: Joe Conway; scott.marlowe; Bruce Momjian; lutzeb@aeccom.com; +> pgsql-performance@postgresql.org; Neil Conway +> Subject: Re: [PERFORM] Wierd context-switching issue on Xeon +> +> +> Here is a test case. To set up, run the "test_setup.sql" script once; +> then launch two copies of the "test_run.sql" script. (For those of +> you with more than two CPUs, see whether you need one per CPU to make +> trouble, or whether two test_runs are enough.) Check that you get a +> nestloops-with-index-scans plan shown by the EXPLAIN in test_run. +> +> In isolation, test_run.sql should do essentially no syscalls at all once +> it's past the initial ramp-up. On a machine that's functioning per +> expectations, multiple copies of test_run show a relatively low rate of +> semop() calls --- a few per second, at most --- and maybe a delaying +> select() here and there. +> +> What I actually see on Josh's client's machine is a context swap storm: +> "vmstat 1" shows CS rates around 170K/sec. strace'ing the backends +> shows a corresponding rate of semop() syscalls, with a few delaying +> select()s sprinkled in. top(1) shows system CPU percent of 25-30 +> and idle CPU percent of 16-20. +> +> I haven't bothered to check how long the test_run query takes, but if it +> ends while you're still examining the behavior, just start it again. +> +> Note the test case assumes you've got shared_buffers set to at least +> 1000; with smaller values, you may get some I/O syscalls, which will +> probably skew the results. +> +> regards, tom lane +> +> + + +From pgsql-performance-owner@postgresql.org Tue Apr 20 12:39:18 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D8E05D1D08B + for ; + Tue, 20 Apr 2004 11:19:47 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 48887-09 + for ; + Tue, 20 Apr 2004 11:19:50 -0300 (ADT) +Received: from mail.astudios.com (unknown [66.49.77.3]) + by svr1.postgresql.org (Postfix) with ESMTP id 5111FD1C9E1 + for ; + Tue, 20 Apr 2004 11:19:45 -0300 (ADT) +thread-index: AcQm4v/045T4I1TUSGSZhIXZa9046w== +Received: from [10.4.2.163] ([66.194.26.150]) by mail.astudios.com with + Microsoft SMTPSVC(6.0.3790.0); Tue, 20 Apr 2004 10:23:06 -0400 +Content-Class: urn:content-classes:message +Importance: normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.132 +From: "Chris Hoover" +To: +Subject: Use of subquery causes seq scan??? +Date: Tue, 20 Apr 2004 10:20:05 -0400 +User-Agent: KMail/1.6.1 +References: <200404151248.16067.jeremy.guthrie@berbee.com> +In-Reply-To: <200404151248.16067.jeremy.guthrie@berbee.com> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Message-ID: <200404201020.05699.revoohc@sermonaudio.com> +X-OriginalArrivalTime: 20 Apr 2004 14:23:07.0093 (UTC) + FILETIME=[FFE5C850:01C426E2] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/307 +X-Sequence-Number: 6607 + +I need some help. I have a query that refuses to use the provided index an= +d=20 +is always sequentially scanning causing me large performance headaches. He= +re=20 +is the basic situation: + +Table A: +inv_num int +type char +=2E +=2E +=2E +pkey (inv_num, type) +indx(inv_num) + +Table B (has the same primary key) + +Select * +from table a +where inv_num in (select inv_num from table b where ....) + +Doing this causes sequential scans of both tables. If I do a set=20 +enable_seqscan to false before the query, I get an index scan of table b bu= +t=20 +still seq scan table a.=20 + +Is there anyway to force table a to use this index (or another) and not=20 +sequentially scan the table? + +I'm running 7.3.4 on RedHat EL 2.1. + +Thanks, + +Chris + + +From pgsql-performance-owner@postgresql.org Tue Apr 20 12:28:59 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 242CAD1C952 + for ; + Tue, 20 Apr 2004 11:29:05 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 56581-09 + for ; + Tue, 20 Apr 2004 11:29:02 -0300 (ADT) +Received: from mail2.aeccom.com (port-212-202-101-158.reverse.qsc.de + [212.202.101.158]) + by svr1.postgresql.org (Postfix) with ESMTP id A927CD1BB89 + for ; + Tue, 20 Apr 2004 11:28:58 -0300 (ADT) +Received: from aeccom.com (cayambe.core.aeccom.com [192.168.2.12]) + by mail2.aeccom.com (Postfix) with ESMTP + id DCF8E34; Tue, 20 Apr 2004 16:29:01 +0200 (CEST) +Message-ID: <408533AD.40904@aeccom.com> +Date: Tue, 20 Apr 2004 16:29:01 +0200 +From: =?ISO-8859-1?Q?Dirk_Lutzeb=E4ck?= +Organization: AEC/communications GmbH, Berlin +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031016 +X-Accept-Language: de, en +MIME-Version: 1.0 +To: Tom Lane , Josh Berkus +Cc: pgsql-performance@postgreSQL.org, Neil Conway +Subject: Re: Wierd context-switching issue on Xeon +References: <200311251419.36771.josh@agliodbs.com> + <407EFC95.5070805@aeccom.com> <11437.1082324861@sss.pgh.pa.us> + <200404191050.12833.josh@agliodbs.com> + <26941.1082397601@sss.pgh.pa.us> <40844223.9070200@aeccom.com> +In-Reply-To: <40844223.9070200@aeccom.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/306 +X-Sequence-Number: 6606 + +Dirk Lutzebaeck wrote: + +> c) Dual XEON DP, non-bigmem, HT on, E7500 Intel chipset (Supermicro) +> +> performs well and I could not observe context switch peaks here (one +> user active), almost no extra semop calls + +Did Tom's test here: with 2 processes I'll reach 200k+ CS with peaks to +300k CS. Bummer.. Josh, I don't think you can bash the ServerWorks +chipset here nor bigmem. + +Dirk + + + +From pgsql-performance-owner@postgresql.org Tue Apr 20 11:48:38 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B448ED1CB0F + for ; + Tue, 20 Apr 2004 11:48:19 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 69090-02 + for ; + Tue, 20 Apr 2004 11:48:17 -0300 (ADT) +Received: from net2.micro-automation.com (net2.micro-automation.com + [64.7.141.29]) + by svr1.postgresql.org (Postfix) with SMTP id 0BE17D1B967 + for ; + Tue, 20 Apr 2004 11:48:13 -0300 (ADT) +Received: (qmail 10804 invoked from network); 20 Apr 2004 14:48:14 -0000 +Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) + by net2.micro-automation.com with SMTP; 20 Apr 2004 14:48:14 -0000 +Subject: Re: Toooo many context switches (maybe SLES8?) +From: Dave Cramer +Reply-To: pg@fastcrypt.com +To: lutzeb@aeccom.com +Cc: Tom Lane , Joe Conway , + pgsql-performance@postgresql.org +In-Reply-To: <407EEA9B.7010807@aeccom.com> +References: <407E7B99.3050306@aeccom.com> <407EB1E5.4030600@joeconway.com> + <407EB86B.6080801@aeccom.com> <407EBA89.6080007@joeconway.com> + <20498.1082057841@sss.pgh.pa.us> <407EEA9B.7010807@aeccom.com> +Content-Type: text/plain +Organization: Cramer Consulting +Message-Id: <1082472652.1554.155.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Tue, 20 Apr 2004 10:50:52 -0400 +Content-Transfer-Encoding: 7bit +X-AntiVirus: scanned for viruses by AMaViS 0.2.1 (http://amavis.org/) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/305 +X-Sequence-Number: 6605 + +Don't think so, mine is a vanilla kernel from kernel.org + +Dave +On Thu, 2004-04-15 at 16:03, Dirk Lutzebaeck wrote: +> Could this be related to the O(1) scheduler backpatches from 2.6 to 2.4 +> kernel on newer 2.4er distros (RedHat, SuSE)? +> +> +> Tom Lane wrote: +> +> >Joe Conway writes: +> > +> > +> >>>Improve spinlock code for recent x86 processors: insert a PAUSE +> >>>instruction in the s_lock() wait loop, and use test before test-and-set +> >>>in TAS() macro to avoid unnecessary bus traffic. Patch from Manfred +> >>>Spraul, reworked a bit by Tom. +> >>> +> >>> +> > +> > +> > +> >>I thought this had been committed to the 7.4 stable branch as well, but +> >>it appears not. +> >> +> >> +> > +> >I am currently chasing what seems to be the same issue: massive context +> >swapping on a dual Xeon system. I tried back-patching the above-mentioned +> >patch ... it helps a little but by no means solves the problem ... +> > +> > regards, tom lane +> > +> > +> > +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 3: if posting/reading through Usenet, please send an appropriate +> subscribe-nomail command to majordomo@postgresql.org so that your +> message can get through to the mailing list cleanly +> +> +> +> !DSPAM:408535ce93801252113544! +> +> +-- +Dave Cramer +519 939 0336 +ICQ # 14675561 + + +From pgsql-performance-owner@postgresql.org Tue Apr 20 22:50:45 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 90446D1E98F; Tue, 20 Apr 2004 22:50:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 17447-03; Tue, 20 Apr 2004 22:50:21 -0300 (ADT) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP + id 9C7A1D1EC56; Tue, 20 Apr 2004 12:48:09 -0300 (ADT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i3KFmA814010; + Tue, 20 Apr 2004 11:48:10 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200404201548.i3KFmA814010@candle.pha.pa.us> +Subject: pgbench written in Pro*C +To: PostgreSQL-development +Date: Tue, 20 Apr 2004 11:48:09 -0400 (EDT) +Cc: pgsql-performance@postgreSQL.org +X-Mailer: ELM [version 2.4ME+ PL108 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/323 +X-Sequence-Number: 6623 + +I received a copy of pgbench rewritten in Pro*C, which is similar to +embedded C. I think it was done so the same program could be tested on +Oracle and PostgreSQL. + +Are folks interested in this code? Should it be put on gborg or in our +/contrib/pgbench? + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-performance-owner@postgresql.org Tue Apr 20 22:51:26 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8FC6AD1EAA2 + for ; + Tue, 20 Apr 2004 22:51:23 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 16846-08 + for ; + Tue, 20 Apr 2004 22:51:19 -0300 (ADT) +Received: from stubee.d2hosting.net (d2hosting.net [66.70.41.160]) + by svr1.postgresql.org (Postfix) with ESMTP id C80EFD1ECD2 + for ; + Tue, 20 Apr 2004 12:49:29 -0300 (ADT) +Received: from idigx.com (stubee.d2hosting.net [66.70.41.160]) + by stubee.d2hosting.net (8.11.6/linuxconf) with ESMTP id i3KFnLM24882; + Tue, 20 Apr 2004 10:49:26 -0500 +Message-ID: <40854698.6070805@idigx.com> +Date: Tue, 20 Apr 2004 10:49:44 -0500 +From: Thomas Swan +User-Agent: Mozilla Thunderbird 0.6a (Windows/20040419) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Randolf Richardson +Cc: pgsql-performance@postgresql.org +Subject: Re: Persistent Connections +References: <20040124173209.933905A8170@kserver17.erfurt12.de> + <4013A85C.1010406@chuckie.co.uk> + +In-Reply-To: +X-Enigmail-Version: 0.83.6.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200404/325 +X-Sequence-Number: 6625 + +Randolf Richardson wrote: + +>"nicky@chuckie.co.uk (Nick Barr)" stated in +>comp.databases.postgresql.performance: +> +> +> +>>postgres@countup.de wrote: +>> +>> +>[sNip] +> +> +>>>Sorry I m a little bit confused about the persistent thing!! +>>>Is it smart to use persistent connections at all if i expect 100K +>>>Users to hit the script in an hour and the script calls up to 10-15 pg +>>>functions? +>>>I have at the mom one function but the server needs 500 ms, its a +>>>little bit too much i think, and it crashed when i had 20K users +>>> +>>> +>>Use the persistent connection but make sure the parameters in +>>postgresql.conf match up with the Apache config. The specific settings +>>are MaxClients in httpd.conf and max_connections in postgresql.conf. +>>Make sure that max_connections is at least as big as MaxClients for +>>every database that your PHP scripts connect to. +>> +>> +> +> Do you happen to have (or know where to get) some sample configuration +>files for Apache 2 and PostgreSQL for this? The documentation I've found +>so far is pretty sparse, and sample files would be very helpful. +> +> +> +> +Beware that persistent connections in PHP behave a little differently +than you would think. The connections stays open between an apache +process and postgres. So each process has its own connection and you +may not hit the same process on each request to the apache server. +Temporary tables are not dropped automatically between refreshes on +persistent connections. An example of this is to enable persistent +connections and execute "CREATE TEMPORARY TABLE foo ( id INTEGER );" + +$conn = pg_pconnect( ... ); +if (!$result = pg_query($conn, "CREATE TEMPORARY TABLE tmp_foo ( id +INTEGER );")) { + echo pg_result_error($result) ; +} else { + echo "created ok!"; +} + +After a couple of refreshes you will get an error that states the table +already exists. This was a pain to learn, especially while I was doing +these operations inside of transactions. + +On most of my servers the connect time for postgresql was 6ms or less, +so I disabled persistent connections altogether so that I could be +assured that temporary tables and all php launched postgresql sessions +were properly reset. + +As far as I know, there is no way to reset the sesssion ( cleaning up +temporary tables, etc ) automatically with an SQL statement without +closing the connection + + +From pgsql-performance-owner@postgresql.org Tue Apr 20 22:51:22 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 949EAD1B88E + for ; + Tue, 20 Apr 2004 22:48:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 15062-05 + for ; + Tue, 20 Apr 2004 22:48:22 -0300 (ADT) +Received: from trade-india.com (ns5.trade-india.com [66.234.10.13]) + by svr1.postgresql.org (Postfix) with SMTP id 4857BD1D9C2 + for ; + Tue, 20 Apr 2004 13:17:54 -0300 (ADT) +Received: (qmail 27939 invoked from network); 20 Apr 2004 12:48:42 -0000 +Received: from unknown (HELO trade-india.com) (203.145.130.142) + by ns5.trade-india.com with SMTP; 20 Apr 2004 12:48:42 -0000 +Message-ID: <40854D38.6040403@trade-india.com> +Date: Tue, 20 Apr 2004 21:48:00 +0530 +From: Rajesh Kumar Mallah +User-Agent: Mozilla Thunderbird 0.5 (X11/20040208) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Mark Stosberg +Cc: pgsql-performance@postgresql.org +Subject: Re: seeking consultant for high performance, complex searching +References: +In-Reply-To: +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/324 +X-Sequence-Number: 6624 + + +Have you checked Tsearch2 + +http://www.sai.msu.su/~megera/postgres/gist/tsearch/V2/ + +is the most feature rich Full text Search system available +for postgresql. We are also using the same system in +the revamped version of our website. + +Regds +Mallah. + + +Mark Stosberg wrote: + +>Hello, +> +>I work for Summersault, LLC. We've been using Postgres since the days of +>Postgres 6.5. We're focused on building database-driven websites using Perl and +>Postgres. We are currently seeking help developing a search system that needs +>to perform complex queries with high performance. Although we have strong +>skills in Perl and Postgres, we are new to the arena of complex, +>high-performance search systems. +> +>We are seeking to hire a consultant to help this as part of the re-vamp +>of the 1-800-Save-A-Pet.com website. +> +>1-800-Save-A-Pet.com is a not-for-profit organization whose website +>finds homes for homeless pets, promoting pet adoption and saving +>thousands of animal lives. Summersault, LLC is a website development +>firm focused on creating highly customized database driven websites. +> +>The ideal consultant has expert experience with the PostgreSQL RDBMS and +>the Perl programming language, and is intimately familiar with the +>architecture and implementation of complex database queries for +>high-traffic web applications. The consultant should also have a strong +>background in creating solutions complementary to this work, e.g. +>assessing hardware requirements, designing a hosting and network +>infrastructure, and optimizing the algorithm based on real-world +>feedback. The consultant will work with Summersault developers as a +>part of a larger application development process. +> +>Interested persons or organizations should contact Chris Hardie of +>Summersault, LLC at chris@summersault.com for more information. +> +>Thanks! +> +> Mark +> +> +> + + +From pgsql-performance-owner@postgresql.org Tue Apr 20 22:50:12 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8C02BD1E13D + for ; + Tue, 20 Apr 2004 22:49:46 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 14739-08 + for ; + Tue, 20 Apr 2004 22:49:44 -0300 (ADT) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id 824C0D1F388 + for ; + Tue, 20 Apr 2004 13:48:22 -0300 (ADT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i3KGmEV27394; + Tue, 20 Apr 2004 12:48:14 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200404201648.i3KGmEV27394@candle.pha.pa.us> +Subject: Re: Wierd context-switching issue on Xeon +In-Reply-To: <408533AD.40904@aeccom.com> +To: =?ISO-8859-1?Q?Dirk_Lutzeb=E4ck?= +Date: Tue, 20 Apr 2004 12:48:14 -0400 (EDT) +Cc: Tom Lane , Josh Berkus , + pgsql-performance@postgresql.org, Neil Conway +X-Mailer: ELM [version 2.4ME+ PL108 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Content-Type: text/plain; charset=UNKNOWN-8BIT +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/321 +X-Sequence-Number: 6621 + +Dirk Lutzeb�ck wrote: +> Dirk Lutzebaeck wrote: +> +> > c) Dual XEON DP, non-bigmem, HT on, E7500 Intel chipset (Supermicro) +> > +> > performs well and I could not observe context switch peaks here (one +> > user active), almost no extra semop calls +> +> Did Tom's test here: with 2 processes I'll reach 200k+ CS with peaks to +> 300k CS. Bummer.. Josh, I don't think you can bash the ServerWorks +> chipset here nor bigmem. + +Dave Cramer reproduced the problem on my SuperMicro dual Xeon on BSD/OS. + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-performance-owner@postgresql.org Tue Apr 20 22:50:29 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id BB0E2D1B895 + for ; + Tue, 20 Apr 2004 22:49:30 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 16846-02 + for ; + Tue, 20 Apr 2004 22:49:25 -0300 (ADT) +Received: from vt-pe2550-001.VANTAGE.vantage.com (unknown [64.80.203.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 7CFA8D1F398 + for ; + Tue, 20 Apr 2004 13:48:59 -0300 (ADT) +X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Wierd context-switching issue on Xeon +Date: Tue, 20 Apr 2004 12:48:58 -0400 +Message-ID: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78509814A@vt-pe2550-001.vantage.vantage.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Wierd context-switching issue on Xeon +Thread-Index: AcQm7otpHAx43BozTZu3cHFKf1c9lgAB8rAg +From: "Anjan Dave" +To: =?iso-8859-1?Q?Dirk_Lutzeb=E4ck?= , + "Tom Lane" , "Josh Berkus" +Cc: , + "Neil Conway" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/322 +X-Sequence-Number: 6622 + +If this helps -=20 + +Quad 2.0GHz XEON with highest load we have seen on the applications, DB per= +forming great -=20 + + procs memory swap io system = +cpu + r b w swpd free buff cache si so bi bo in cs us sy= + id + 1 0 0 1616 351820 66144 10813704 0 0 2 0 1 1 0 = + 2 7 + 3 0 0 1616 349712 66144 10813736 0 0 8 1634 1362 4650 4 = + 2 95 + 0 0 0 1616 347768 66144 10814120 0 0 188 1218 1158 4203 5 = + 1 93 + 0 0 1 1616 346596 66164 10814184 0 0 8 1972 1394 4773 4 = + 1 94 + 2 0 1 1616 345424 66164 10814272 0 0 20 1392 1184 4197 4 = + 2 94 + +Around 4k CS/sec +Chipset is Intel ServerWorks GC-HE. +Linux Kernel 2.4.20-28.9bigmem #1 SMP + +Thanks, +Anjan + + +-----Original Message----- +From: Dirk Lutzeb=E4ck [mailto:lutzeb@aeccom.com]=20 +Sent: Tuesday, April 20, 2004 10:29 AM +To: Tom Lane; Josh Berkus +Cc: pgsql-performance@postgreSQL.org; Neil Conway +Subject: Re: [PERFORM] Wierd context-switching issue on Xeon + +Dirk Lutzebaeck wrote: + +> c) Dual XEON DP, non-bigmem, HT on, E7500 Intel chipset (Supermicro) +> +> performs well and I could not observe context switch peaks here (one=20 +> user active), almost no extra semop calls + +Did Tom's test here: with 2 processes I'll reach 200k+ CS with peaks to=20 +300k CS. Bummer.. Josh, I don't think you can bash the ServerWorks=20 +chipset here nor bigmem. + +Dirk + + + +---------------------------(end of broadcast)--------------------------- +TIP 6: Have you searched our list archives? + + http://archives.postgresql.org + + + +From pgsql-performance-owner@postgresql.org Tue Apr 20 22:31:22 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 418F5D1B4E1 + for ; + Tue, 20 Apr 2004 22:31:15 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 05233-08 + for ; + Tue, 20 Apr 2004 22:31:12 -0300 (ADT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id B02D7D1F46F + for ; + Tue, 20 Apr 2004 14:00:11 -0300 (ADT) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4907935; Tue, 20 Apr 2004 10:01:35 -0700 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: "Anjan Dave" , + Dirk =?iso-8859-1?q?Lutzeb=E4ck?= , + "Tom Lane" +Subject: Re: Wierd context-switching issue on Xeon +Date: Tue, 20 Apr 2004 09:59:52 -0700 +User-Agent: KMail/1.4.3 +Cc: , + "Neil Conway" +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78509814A@vt-pe2550-001.vantage.vantage.com> +In-Reply-To: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78509814A@vt-pe2550-001.vantage.vantage.com> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200404200959.52813.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/320 +X-Sequence-Number: 6620 + +Anjan, + +> Quad 2.0GHz XEON with highest load we have seen on the applications, DB +> performing great - + +Can you run Tom's test? It takes a particular pattern of data access to +reproduce the issue. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Tue Apr 20 22:14:29 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id F108AD1EA95 + for ; + Tue, 20 Apr 2004 22:14:19 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 99387-07 + for ; + Tue, 20 Apr 2004 22:14:18 -0300 (ADT) +Received: from mwinf0803.wanadoo.fr (smtp8.wanadoo.fr [193.252.22.23]) + by svr1.postgresql.org (Postfix) with ESMTP id 6A13BD1F5AC + for ; + Tue, 20 Apr 2004 14:10:53 -0300 (ADT) +Received: from [192.168.0.2] (AMontsouris-108-1-29-252.w81-53.abo.wanadoo.fr + [81.53.158.252]) + by mwinf0803.wanadoo.fr (SMTP Server) with ESMTP id ED94E18000EB + for ; + Tue, 20 Apr 2004 19:10:52 +0200 (CEST) +Mime-Version: 1.0 (Apple Message framework v613) +In-Reply-To: +References: +Content-Type: text/plain; charset=ISO-8859-1; delsp=yes; format=flowed +Message-Id: +Content-Transfer-Encoding: quoted-printable +From: =?ISO-8859-1?Q?Pailloncy_Jean-G=E9rard?= +Subject: Re: 225 times slower +Date: Tue, 20 Apr 2004 19:10:50 +0200 +To: pgsql-performance@postgresql.org +X-Mailer: Apple Mail (2.613) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200404/317 +X-Sequence-Number: 6617 + +Hi, + +I apologize for the mistake. +So, I dump the database, I reload it then VACUUM ANALYZE. +For each statement: I then quit postgres, start it, execute one=20=20 +command, then quit. + +Le 14 avr. 04, =E0 14:39, Pailloncy Jean-G=E9rard a =E9crit : + +dps=3D# explain analyze SELECT rec_id FROM url WHERE crc32!=3D0 AND=20=20 +crc32=3D764518963 AND status IN (200,304,206) ORDER BY rec_id LIMIT 1; + QUERY PLAN +------------------------------------------------------------------------=20 +-------------------------------------------------------- + Limit (cost=3D169.79..169.79 rows=3D1 width=3D4) (actual=20=20 +time=3D502.397..502.398 rows=3D1 loops=3D1) + -> Sort (cost=3D169.79..169.86 rows=3D30 width=3D4) (actual=20=20 +time=3D502.393..502.393 rows=3D1 loops=3D1) + Sort Key: rec_id + -> Index Scan using url_crc on url (cost=3D0.00..169.05=20=20 +rows=3D30 width=3D4) (actual time=3D43.545..490.895 rows=3D56 loops=3D1) + Index Cond: (crc32 =3D 764518963) + Filter: ((crc32 <> 0) AND ((status =3D 200) OR (status =3D= +=20=20 +304) OR (status =3D 206))) + Total runtime: 502.520 ms +(7 rows) +dps=3D# \q + +dps=3D# explain analyze SELECT rec_id FROM url WHERE crc32!=3D0 AND=20=20 +crc32=3D764518963 AND status IN (200,304,206) ORDER BY crc32,rec_id LIMIT= +=20=20 +1; + QUERY PLAN +------------------------------------------------------------------------=20 +----------------------------------------------------- + Limit (cost=3D169.79..169.79 rows=3D1 width=3D8) (actual time=3D5.893..5= +.894=20=20 +rows=3D1 loops=3D1) + -> Sort (cost=3D169.79..169.86 rows=3D30 width=3D8) (actual=20=20 +time=3D5.889..5.889 rows=3D1 loops=3D1) + Sort Key: crc32, rec_id + -> Index Scan using url_crc on url (cost=3D0.00..169.05=20=20 +rows=3D30 width=3D8) (actual time=3D0.445..5.430 rows=3D56 loops=3D1) + Index Cond: (crc32 =3D 764518963) + Filter: ((crc32 <> 0) AND ((status =3D 200) OR (status =3D= +=20=20 +304) OR (status =3D 206))) + Total runtime: 6.020 ms +(7 rows) +dps=3D# \q + +dps=3D# explain analyze SELECT rec_id FROM url WHERE crc32!=3D0 AND=20=20 +crc32=3D419903683 AND status IN (200,304,206) ORDER BY rec_id LIMIT 1; + QUERY PLAN +------------------------------------------------------------------------=20 +---------------------------------------------------------- + Limit (cost=3D0.00..27.95 rows=3D1 width=3D4) (actual=20=20 +time=3D11021.875..11021.876 rows=3D1 loops=3D1) + -> Index Scan using url_pkey on url (cost=3D0.00..11625.49 rows=3D416= +=20=20 +width=3D4) (actual time=3D11021.868..11021.868 rows=3D1 loops=3D1) + Filter: ((crc32 <> 0) AND (crc32 =3D 419903683) AND ((status =3D= +=20=20 +200) OR (status =3D 304) OR (status =3D 206))) + Total runtime: 11021.986 ms +(4 rows) +dps=3D# \q + +dps=3D# explain analyze SELECT rec_id FROM url WHERE crc32!=3D0 AND=20=20 +crc32=3D419903683 AND status IN (200,304,206) ORDER BY crc32,rec_id LIMIT= +=20=20 +1; + QUERY PLAN +------------------------------------------------------------------------=20 +--------------------------------------------------------- + Limit (cost=3D2000.41..2000.41 rows=3D1 width=3D8) (actual=20=20 +time=3D48.503..48.504 rows=3D1 loops=3D1) + -> Sort (cost=3D2000.41..2001.45 rows=3D416 width=3D8) (actual=20=20 +time=3D48.499..48.499 rows=3D1 loops=3D1) + Sort Key: crc32, rec_id + -> Index Scan using url_crc on url (cost=3D0.00..1982.31=20=20 +rows=3D416 width=3D8) (actual time=3D4.848..45.452 rows=3D796 loops=3D1) + Index Cond: (crc32 =3D 419903683) + Filter: ((crc32 <> 0) AND ((status =3D 200) OR (status =3D= +=20=20 +304) OR (status =3D 206))) + Total runtime: 48.656 ms +(7 rows) +dps=3D# \q + +So, with all fresh data, everything rebuild from scratch, on a backend=20= +=20 +that will done one and only one query, the results is strange. +Why adding an ORDER BY clause on a column with one value speed up the=20=20 +stuff 502ms to 6ms ? +Why when crc32=3D419903683, which is one of the most often used value in=20= +=20 +the table, the query planner chose a plan so bad (225 times slower) ? + +Cordialement, +Jean-G=E9rard Pailloncy + + +From pgsql-performance-owner@postgresql.org Tue Apr 20 22:14:49 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A1504D1D1D5 + for ; + Tue, 20 Apr 2004 22:14:29 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 99419-07 + for ; + Tue, 20 Apr 2004 22:14:25 -0300 (ADT) +Received: from mx1.neopolitan.us (mx1.neopolitan.us [65.87.16.224]) + by svr1.postgresql.org (Postfix) with ESMTP id 82E62D1F66C + for ; + Tue, 20 Apr 2004 14:17:22 -0300 (ADT) +Received: from [65.87.16.98] (HELO [10.0.0.210]) + by mx1.neopolitan.us (CommuniGate Pro SMTP 4.1.8) + with ESMTP-TLS id 3996614; Tue, 20 Apr 2004 10:17:22 -0700 +Subject: Re: Wierd context-switching issue on Xeon +From: "J. Andrew Rogers" +To: Tom Lane +Cc: pgsql-performance@postgresql.org +In-Reply-To: <1407.1082419316@sss.pgh.pa.us> +References: + <40843E63.7050101@joeconway.com> <200404191455.04068.josh@agliodbs.com> + <1407.1082419316@sss.pgh.pa.us> +Content-Type: text/plain +Organization: +Message-Id: <1082481442.997.4.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.2.2 (1.2.2-5) +Date: 20 Apr 2004 10:17:22 -0700 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/318 +X-Sequence-Number: 6618 + +I verified problem on a Dual Opteron server. I temporarily killed the +normal load, so the server was largely idle when the test was run. + +Hardware: +2x Opteron 242 +Rioworks HDAMA server board +4Gb RAM + +OS Kernel: +RedHat9 + XFS + + +1 proc: 10-15 cs/sec +2 proc: 400,000-420,000 cs/sec + + + +j. andrew rogers + + + + +From pgsql-performance-owner@postgresql.org Tue Apr 20 21:42:04 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B27B4D1E8CB + for ; + Tue, 20 Apr 2004 21:41:42 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 87736-05 + for ; + Tue, 20 Apr 2004 21:41:37 -0300 (ADT) +Received: from wolff.to (wolff.to [66.93.249.74]) + by svr1.postgresql.org (Postfix) with SMTP id E12FFD1EEBE + for ; + Tue, 20 Apr 2004 14:52:33 -0300 (ADT) +Received: (qmail 11338 invoked by uid 500); 20 Apr 2004 17:56:32 -0000 +Date: Tue, 20 Apr 2004 12:56:32 -0500 +From: Bruno Wolff III +To: Chris Hoover +Cc: pgsql-performance@postgresql.org +Subject: Re: Use of subquery causes seq scan??? +Message-ID: <20040420175632.GB11203@wolff.to> +Mail-Followup-To: Chris Hoover , + pgsql-performance@postgresql.org +References: <200404151248.16067.jeremy.guthrie@berbee.com> + <200404201020.05699.revoohc@sermonaudio.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <200404201020.05699.revoohc@sermonaudio.com> +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/316 +X-Sequence-Number: 6616 + +Please don't reply to messages to start new threads. + +On Tue, Apr 20, 2004 at 10:20:05 -0400, + Chris Hoover wrote: +> I need some help. I have a query that refuses to use the provided index and +> is always sequentially scanning causing me large performance headaches. Here +> is the basic situation: +> +> Table A: +> inv_num int +> type char +> . +> . +> . +> pkey (inv_num, type) +> indx(inv_num) +> +> Table B (has the same primary key) +> +> Select * +> from table a +> where inv_num in (select inv_num from table b where ....) +> +> Doing this causes sequential scans of both tables. If I do a set +> enable_seqscan to false before the query, I get an index scan of table b but +> still seq scan table a. +> +> Is there anyway to force table a to use this index (or another) and not +> sequentially scan the table? +> +> I'm running 7.3.4 on RedHat EL 2.1. + +IN was slow in 7.3.x and before. The query will probably run much better +as is in 7.4 and above. In 7.3 you want to rewrite it as a join or using +EXISTS. + +From pgsql-performance-owner@postgresql.org Tue Apr 20 21:41:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id BBAD0D1BAFD + for ; + Tue, 20 Apr 2004 21:41:36 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 88358-02 + for ; + Tue, 20 Apr 2004 21:41:30 -0300 (ADT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id D698FD1EF67 + for ; + Tue, 20 Apr 2004 14:57:59 -0300 (ADT) +Received: from [64.81.245.111] (HELO 192.168.1.102) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4908282; Tue, 20 Apr 2004 10:59:24 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Dirk =?iso-8859-1?q?Lutzeb=E4ck?= , + Tom Lane +Subject: Re: Wierd context-switching issue on Xeon +Date: Tue, 20 Apr 2004 10:58:18 -0700 +User-Agent: KMail/1.5.4 +Cc: pgsql-performance@postgreSQL.org +References: <200311251419.36771.josh@agliodbs.com> + <40844223.9070200@aeccom.com> <408533AD.40904@aeccom.com> +In-Reply-To: <408533AD.40904@aeccom.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200404201058.18840.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 + tests=RCVD_NUMERIC_HELO +X-Spam-Level: +X-Archive-Number: 200404/315 +X-Sequence-Number: 6615 + +Dirk, Tom, + +OK, off IRC, I have the following reports: + +Linux 2.4.21 or 2.4.20 on dual Pentium III : problem verified +Linux 2.4.21 or 2.4.20 on dual Penitum II : problem cannot be reproduced +Solaris 2.6 on 6 cpu e4500 (using 8 processes) : problem not reproduced + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Tue Apr 20 20:35:06 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4B4B3D1F11A + for ; + Tue, 20 Apr 2004 20:34:56 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 55581-08 + for ; + Tue, 20 Apr 2004 20:34:52 -0300 (ADT) +Received: from www.postgresql.com (www.postgresql.com [200.46.204.209]) + by svr1.postgresql.org (Postfix) with ESMTP id E6FD1D20050 + for ; + Tue, 20 Apr 2004 19:00:32 -0300 (ADT) +Received: from flake.decibel.org (flake.decibel.org [66.143.173.58]) + by www.postgresql.com (Postfix) with SMTP id A51AFCF6658 + for ; + Tue, 20 Apr 2004 15:46:15 -0300 (ADT) +Received: (qmail 55520 invoked by uid 1001); 20 Apr 2004 18:46:10 -0000 +Date: Tue, 20 Apr 2004 13:46:10 -0500 +From: "Jim C. Nasby" +To: pgsql-performance@postgresql.org +Subject: Re: Horribly slow hash join +Message-ID: <20040420184610.GY87362@nasby.net> +References: <20040416154502.GF87362@nasby.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20040416154502.GF87362@nasby.net> +X-Operating-System: FreeBSD 4.9-RELEASE-p3 i386 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/312 +X-Sequence-Number: 6612 + +Dammit, I somehow deleted a bunch of replies to this. + +Did a TODO ever come out of this? +-- +Jim C. Nasby, Database Consultant jim@nasby.net +Member: Triangle Fraternity, Sports Car Club of America +Give your computer some brain candy! www.distributed.net Team #1828 + +Windows: "Where do you want to go today?" +Linux: "Where do you want to go tomorrow?" +FreeBSD: "Are you guys coming, or what?" + +From pgsql-performance-owner@postgresql.org Tue Apr 20 20:34:05 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5528ED1EAF2 + for ; + Tue, 20 Apr 2004 20:34:03 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 52979-07 + for ; + Tue, 20 Apr 2004 20:34:00 -0300 (ADT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 38475D1F976 + for ; + Tue, 20 Apr 2004 16:50:22 -0300 (ADT) +Received: from [134.22.69.199] (dyn-69-199.tor.dsl.tht.net [134.22.69.199]) + by tht.net (Postfix) with ESMTP + id A3AC976AD5; Tue, 20 Apr 2004 15:50:15 -0400 (EDT) +Subject: Re: Wierd context-switching issue on Xeon +From: Rod Taylor +To: Tom Lane +Cc: Josh Berkus , Joe Conway , + Scott Marlowe , + Bruce Momjian , lutzeb@aeccom.com, + Postgresql Performance , + Neil Conway +In-Reply-To: <1931.1082422389@sss.pgh.pa.us> +References: + <40843E63.7050101@joeconway.com> <200404191455.04068.josh@agliodbs.com> + <1407.1082419316@sss.pgh.pa.us> <1931.1082422389@sss.pgh.pa.us> +Content-Type: text/plain +Message-Id: <1082490529.80320.71.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Tue, 20 Apr 2004 15:48:50 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/309 +X-Sequence-Number: 6609 + +> It would be interesting to see results with non-Linux kernels, too. + +Dual Celeron 500Mhz (Abit BP6 mobo) - client & server on same machine + +2 processes FreeBSD (5.2.1): 1800cs +3 processes FreeBSD: 14000cs +4 processes FreeBSD: 14500cs + +2 processes Linux (2.4.18 kernel): 52000cs +3 processes Linux: 10000cs +4 processes Linux: 20000cs + + + +From pgsql-performance-owner@postgresql.org Tue Apr 20 20:18:32 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8F244D1EC80 + for ; + Tue, 20 Apr 2004 20:18:13 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 46256-06 + for ; + Tue, 20 Apr 2004 20:18:07 -0300 (ADT) +Received: from monsoon.he.net (monsoon.he.net [64.62.221.2]) + by svr1.postgresql.org (Postfix) with SMTP id B945ED1F9FA + for ; + Tue, 20 Apr 2004 17:02:44 -0300 (ADT) +Received: from [10.244.45.7] ([216.113.168.128]) by monsoon.he.net for + ; Tue, 20 Apr 2004 13:02:39 -0700 +In-Reply-To: <1931.1082422389@sss.pgh.pa.us> +References: + <40843E63.7050101@joeconway.com> + <200404191455.04068.josh@agliodbs.com> + <1407.1082419316@sss.pgh.pa.us> <1931.1082422389@sss.pgh.pa.us> +Mime-Version: 1.0 (Apple Message framework v613) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: +Content-Transfer-Encoding: 7bit +Cc: pgsql-performance@postgresql.org +From: Paul Tuckfield +Subject: Re: Wierd context-switching issue on Xeon +Date: Tue, 20 Apr 2004 13:02:43 -0700 +To: Tom Lane +X-Mailer: Apple Mail (2.613) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/308 +X-Sequence-Number: 6608 + +I tried to test how this is related to cache coherency, by forcing +affinity of the two test_run.sql processes to the two cores (pipelines? +threads) of a single hyperthreaded xeon processor in an smp xeon box. + +When the processes are allowed to run on distinct chips in the smp box, +the CS storm happens. When they are "bound" to the two cores of a +single hyperthreaded Xeon in the smp box, the CS storm *does* happen. + + + +I used the taskset command: +taskset 01 -p +taskset 01 -p + +I guess that 0 and 1 are the two cores (pipelines? hyper-threads?) on +the first Xeon processor in the box. + +I did this on RedHat Fedora core1 on an intel motherboard (I'll get the +part no if it matters) + +during storms : 300k CS/sec, 75% idle (on a dual xeon (four core)) +machine (suggesting serializing/sleeping processes) +no storm: 50k CS/sec, 50% idle (suggesting 2 cpu bound processes) + + +Maybe there's a "hot block" that is bouncing back and forth between +caches? or maybe the page holding semaphores? + +On Apr 19, 2004, at 5:53 PM, Tom Lane wrote: + +> I wrote: +>> Here is a test case. +> +> Hmmm ... I've been able to reproduce the CS storm on a dual Athlon, +> which seems to pretty much let the Xeon per se off the hook. Anybody +> got a multiple Opteron to try? Totally non-Intel CPUs? +> +> It would be interesting to see results with non-Linux kernels, too. +> +> regards, tom lane +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 4: Don't 'kill -9' the postmaster +> + + +From pgsql-performance-owner@postgresql.org Tue Apr 20 20:34:57 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0677DD1F12B + for ; + Tue, 20 Apr 2004 20:34:49 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 56866-05 + for ; + Tue, 20 Apr 2004 20:34:43 -0300 (ADT) +Received: from vt-pe2550-001.VANTAGE.vantage.com (unknown [64.80.203.242]) + by svr1.postgresql.org (Postfix) with ESMTP id DA3B6D1FB84 + for ; + Tue, 20 Apr 2004 17:20:35 -0300 (ADT) +X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C42714.F0CF1A43" +Subject: Moving postgres to FC disks +Date: Tue, 20 Apr 2004 16:20:36 -0400 +Message-ID: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78509814D@vt-pe2550-001.vantage.vantage.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: Moving postgres to FC disks +Thread-Index: AcQnFPDFxLhs3dQcQhCbbbl4TZlISg== +From: "Anjan Dave" +To: +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=HTML_60_70, + HTML_MESSAGE +X-Spam-Level: +X-Archive-Number: 200404/311 +X-Sequence-Number: 6611 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C42714.F0CF1A43 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + +I am planning to move the pg databases from the internal RAID to +external Fiber Channel over SAN. + +=20 + +Question is -=20 + +=20 + +-With the db size being as big as, say, 30+GB, how do I move it on the +new logical drive? (stop postgresql, and simply move it over somehow and +make a link?) + +-Currently, the internal RAID volume is ext3 filesystem. Any +recommendations for the filesystem on the new FC volume? Rieserfs? + +=20 + +DBs are 7.4.1(RH9), and 7.2.3 (RH8). + +=20 + +=20 + +Appreciate any pointers. + +=20 + +Thanks, +Anjan + + +------_=_NextPart_001_01C42714.F0CF1A43 +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + +
+ +

I am planning to move the pg databases from the internal +RAID to external Fiber Channel over SAN.

+ +

 

+ +

Question is –

+ +

 

+ +

-With the db size being as big as, say, 30+GB, how do I = +move +it on the new logical drive? (stop postgresql, and simply move it over some= +how +and make a link?)

+ +

-Currently, the internal RAID volume is ext3 filesystem.= + Any +recommendations for the filesystem on the new FC volume? Rieserfs?

+ +

 

+ +

DBs are 7.4.1(RH9), and 7.2.3 (RH8).

+ +

 

+ +

 

+ +

Appreciate any pointers.

+ +

 

+ +

Thanks,
+Anjan

+ +
+ + + + + +------_=_NextPart_001_01C42714.F0CF1A43-- + +From pgsql-performance-owner@postgresql.org Tue Apr 20 20:34:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 64BB8D1F11A + for ; + Tue, 20 Apr 2004 20:34:41 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 55788-07 + for ; + Tue, 20 Apr 2004 20:34:39 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id CEB66D1FB10 + for ; + Tue, 20 Apr 2004 18:58:29 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3KLwV2M022628; + Tue, 20 Apr 2004 17:58:31 -0400 (EDT) +To: "Chris Hoover" +Cc: pgsql-performance@postgresql.org +Subject: Re: Use of subquery causes seq scan??? +In-reply-to: <200404201020.05699.revoohc@sermonaudio.com> +References: <200404151248.16067.jeremy.guthrie@berbee.com> + <200404201020.05699.revoohc@sermonaudio.com> +Comments: In-reply-to "Chris Hoover" + message dated "Tue, 20 Apr 2004 10:20:05 -0400" +Date: Tue, 20 Apr 2004 17:58:31 -0400 +Message-ID: <22627.1082498311@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/310 +X-Sequence-Number: 6610 + +"Chris Hoover" writes: +> Select * +> from table a +> where inv_num in (select inv_num from table b where ....) + +> I'm running 7.3.4 on RedHat EL 2.1. + +IN (SELECT) constructs pretty well suck in PG releases before 7.4. +Update, or consult the FAQ about rewriting into an EXISTS form. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Apr 26 14:46:18 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5DFF3D1F864 + for ; + Tue, 20 Apr 2004 19:48:03 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 31860-01 + for ; + Tue, 20 Apr 2004 19:48:02 -0300 (ADT) +Received: from mail2.fbab.net (spectre.fbab.net [212.214.165.139]) + by svr1.postgresql.org (Postfix) with SMTP id BD532D1F879 + for ; + Tue, 20 Apr 2004 19:47:59 -0300 (ADT) +Received: (qmail 13066 invoked by uid 136); 20 Apr 2004 22:48:00 -0000 +Received: from mag@fbab.net by mail2.fbab.net by uid 133 with + qmail-scanner-1.20rc1 (avp: 4.0.3.0. Clear:RC:0:. + Processed in 2.472445 secs); 20 Apr 2004 22:48:00 -0000 +Received: from unknown (HELO fbab.net) (magpool1@212.214.165.129) + by mail2.fbab.net with SMTP; 20 Apr 2004 22:47:57 -0000 +Message-ID: <4085A895.6080403@fbab.net> +Date: Wed, 21 Apr 2004 00:47:49 +0200 +From: "Magnus Naeslund(t)" +User-Agent: Mozilla Thunderbird 0.5 (X11/20040321) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: josh@agliodbs.com, Joe Conway , + "scott.marlowe" , + Bruce Momjian , lutzeb@aeccom.com, + pgsql-performance@postgresql.org, Neil Conway +Subject: Re: Wierd context-switching issue on Xeon +References: + <40843E63.7050101@joeconway.com> + <200404191455.04068.josh@agliodbs.com> + <1407.1082419316@sss.pgh.pa.us> <1931.1082422389@sss.pgh.pa.us> +In-Reply-To: <1931.1082422389@sss.pgh.pa.us> +Content-Type: multipart/mixed; boundary="------------010806020208090107020602" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/438 +X-Sequence-Number: 6738 + +This is a multi-part message in MIME format. +--------------010806020208090107020602 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit + +Tom Lane wrote: +> +> Hmmm ... I've been able to reproduce the CS storm on a dual Athlon, +> which seems to pretty much let the Xeon per se off the hook. Anybody +> got a multiple Opteron to try? Totally non-Intel CPUs? +> +> It would be interesting to see results with non-Linux kernels, too. +> +> regards, tom lane + +I also tested on an dual Athlon MP Tyan Thunder motherboard (2xMP2800+, +2.5GB memory), and got the same high numbers. +I then ran with kernel 2.6.5, it lowered them a little, but it's still +some ping pong effect here. I wonder if this is some effect of the +scheduler, maybe the shed frequency alone (100HZ vs 1000HZ). + +It would be interesting to see what a locking implementation ala FUTEX +style would give on an 2.6 kernel, as i understood it that would work +cross process with some work. + +The first file attached is kernel 2.4 running one process then starting +up the other one. +Same with second file, but with kernel 2.6... + +Regards +Magnus + +--------------010806020208090107020602 +Content-Type: text/plain; + name="vmstat_1-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline; + filename="vmstat_1-1" + +procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu---- + r b swpd free buff cache si so bi bo in cs us sy id wa + 1 0 0 1828408 27852 528852 0 0 0 0 317 557 50 0 50 0 + 1 0 0 1828408 27852 528852 0 0 0 0 293 491 50 0 49 0 + 1 0 0 1828400 27860 528852 0 0 0 16 399 709 50 0 50 0 + 1 0 0 1828400 27860 528852 0 0 0 0 350 593 50 0 49 0 + 2 0 0 1828400 27860 528852 0 0 0 0 349 608 50 0 50 0 + 1 0 0 1828400 27860 528852 0 0 0 0 109 412 50 0 50 0 + 1 0 0 1828400 27860 528852 0 0 0 0 101 92 50 0 50 0 + 1 0 0 1828392 27868 528852 0 0 0 16 104 96 50 0 50 0 + 1 0 0 1828392 27868 528852 0 0 0 0 101 103 50 0 50 0 + 2 0 0 1827408 27892 528852 0 0 8 48 113 61197 45 9 46 0 + 2 0 0 1827408 27892 528852 0 0 0 0 101 167237 41 27 32 0 +procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu---- + r b swpd free buff cache si so bi bo in cs us sy id wa + 4 0 0 1827408 27892 528852 0 0 0 0 101 166145 39 25 36 0 + 2 0 0 1827400 27900 528852 0 0 0 48 105 149406 42 19 40 0 + 3 0 0 1827400 27900 528852 0 0 0 0 101 157559 43 26 32 0 + 2 0 0 1827400 27900 528852 0 0 0 0 101 163813 46 24 30 0 + 2 0 0 1827400 27900 528852 0 0 0 0 101 156872 44 26 30 0 + 2 0 0 1827400 27900 528852 0 0 0 0 103 160722 45 28 28 0 + 2 0 0 1827392 27908 528852 0 0 0 16 104 158644 41 23 37 0 + 3 0 0 1827392 27908 528852 0 0 0 0 101 157534 42 25 33 0 + 2 0 0 1827392 27908 528852 0 0 0 0 101 160007 37 28 35 0 + 3 0 0 1827392 27908 528852 0 0 0 0 101 161852 45 24 31 0 + 3 0 0 1827392 27908 528852 0 0 0 0 101 161616 42 25 33 0 + 2 0 0 1827392 27916 528852 0 0 0 68 114 152144 44 25 31 0 + 2 0 0 1827384 27916 528852 0 0 0 0 101 156485 35 28 37 0 + +--------------010806020208090107020602 +Content-Type: text/plain; + name="vmstat_1-2" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline; + filename="vmstat_1-2" + +procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu---- + r b swpd free buff cache si so bi bo in cs us sy id wa + 1 0 0 2436044 8844 90028 0 0 0 16 1010 235 50 0 50 0 + 1 0 0 2436108 8844 90028 0 0 0 0 1024 404 50 0 50 0 + 1 0 0 2436108 8844 90028 0 0 0 0 1008 199 50 0 50 0 + 1 0 0 2436108 8844 90028 0 0 0 0 1017 272 50 0 50 0 + 1 0 0 2436108 8844 90028 0 0 0 0 1013 253 50 0 50 0 + 1 1 0 2436108 8852 90020 0 0 0 16 1019 282 51 0 49 1 + 2 0 0 2435068 8852 90020 0 0 0 0 1005 23929 45 4 50 0 + 2 0 0 2435068 8852 90020 0 0 0 20 1008 95501 33 14 53 0 +procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu---- + r b swpd free buff cache si so bi bo in cs us sy id wa + 3 0 0 2435068 8852 90020 0 0 0 0 1002 103940 35 15 50 0 + 0 0 0 2435068 8852 90020 0 0 0 0 1003 104343 32 16 51 0 + 2 0 0 2435068 8860 90080 0 0 0 52 1006 102477 34 16 51 1 + 2 0 0 2435068 8860 90080 0 0 0 0 1002 92809 31 14 54 0 + 2 0 0 2435068 8860 90080 0 0 0 0 1002 100498 37 14 49 0 + 1 0 0 2435068 8860 90080 0 0 0 0 1002 108130 35 16 49 0 + 0 0 0 2435068 8860 90080 0 0 0 0 1002 94045 33 14 54 0 + 0 0 0 2435004 8868 90072 0 0 0 16 1005 104380 34 15 52 0 + 2 0 0 2435004 8868 90072 0 0 0 0 1002 100696 36 14 50 0 + 2 0 0 2435068 8868 90072 0 0 0 0 1002 98289 31 14 54 0 + 0 0 0 2435068 8868 90072 0 0 0 0 1002 97287 31 14 55 0 + 0 0 0 2435068 8868 90072 0 0 0 0 1002 92787 34 14 53 0 + 0 0 0 2435068 8876 90064 0 0 0 16 1005 98568 32 16 52 1 + 2 0 0 2435068 8876 90064 0 0 0 0 1003 107104 37 16 47 0 + +--------------010806020208090107020602-- + +From pgsql-performance-owner@postgresql.org Tue Apr 20 21:24:55 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B2FE2D1F001 + for ; + Tue, 20 Apr 2004 21:24:53 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 81108-04 + for ; + Tue, 20 Apr 2004 21:24:53 -0300 (ADT) +Received: from hosting.commandprompt.com (128.commandprompt.com + [207.173.200.128]) + by svr1.postgresql.org (Postfix) with ESMTP id 4B8E2D1EFB7 + for ; + Tue, 20 Apr 2004 21:24:50 -0300 (ADT) +Received: from commandprompt.com (clbb-248.saw.net [64.146.135.248]) + (authenticated) + by hosting.commandprompt.com (8.11.6/8.11.6) with ESMTP id i3L0Oou25853; + Tue, 20 Apr 2004 17:24:51 -0700 +Message-ID: <4085BFF0.4050604@commandprompt.com> +Date: Tue, 20 Apr 2004 17:27:28 -0700 +From: "Joshua D. Drake" +Organization: Command Prompt, Inc. +User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Anjan Dave +Cc: pgsql-performance@postgresql.org +Subject: Re: Moving postgres to FC disks +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78509814D@vt-pe2550-001.vantage.vantage.com> +In-Reply-To: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78509814D@vt-pe2550-001.vantage.vantage.com> +Content-Type: multipart/alternative; + boundary="------------030009030401050901060103" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.7 tagged_above=0.0 required=5.0 tests=HTML_50_60, + HTML_MESSAGE, HTML_TITLE_EMPTY +X-Spam-Level: +X-Archive-Number: 200404/313 +X-Sequence-Number: 6613 + +This is a multi-part message in MIME format. +--------------030009030401050901060103 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit + + +> -With the db size being as big as, say, 30+GB, how do I move it on the +> new logical drive? (stop postgresql, and simply move it over somehow +> and make a link?) +> +I would stop the database, move the data directory to the new volume +using rsync then start up postgresql pointed at the new data directory. +Providing everything is working correctly you can then remove the old +data directory. + +> -Currently, the internal RAID volume is ext3 filesystem. Any +> recommendations for the filesystem on the new FC volume? Rieserfs? +> +> +> +XFS + +> DBs are 7.4.1(RH9), and 7.2.3 (RH8). +> +> +> +> +> +> Appreciate any pointers. +> +> +> +> Thanks, +> Anjan +> + + +-- +Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC +Postgresql support, programming shared hosting and dedicated hosting. ++1-503-667-4564 - jd@commandprompt.com - http://www.commandprompt.com +PostgreSQL Replicator -- production quality replication for PostgreSQL + + +--------------030009030401050901060103 +Content-Type: text/html; charset=us-ascii +Content-Transfer-Encoding: 7bit + + + + + + + + +
+
+
+

-With the db size +being as big as, say, 30+GB, how do I move +it on the new logical drive? (stop postgresql, and simply move it over +somehow +and make a link?)

+
+
+I would stop the database, move the data directory to the new volume +using rsync then start up postgresql pointed at the new data directory.
+Providing everything is working correctly you can then remove the old +data directory.
+
+
+
+

+

-Currently, the +internal RAID volume is ext3 filesystem. Any +recommendations for the filesystem on the new FC volume? Rieserfs?

+

 

+
+
+XFS
+
+
+
+

DBs are +7.4.1(RH9), and 7.2.3 (RH8).

+

 

+

 

+

Appreciate any +pointers.

+

 

+

Thanks,
+Anjan

+
+
+
+
+
-- 
+Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC
+Postgresql support, programming shared hosting and dedicated hosting.
++1-503-667-4564 - jd@commandprompt.com - http://www.commandprompt.com
+PostgreSQL Replicator -- production quality replication for PostgreSQL
+ + + +--------------030009030401050901060103-- + +From pgsql-performance-owner@postgresql.org Tue Apr 20 21:34:16 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D3461D1B974 + for ; + Tue, 20 Apr 2004 21:34:15 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 82083-10 + for ; + Tue, 20 Apr 2004 21:34:16 -0300 (ADT) +Received: from monsoon.he.net (monsoon.he.net [64.62.221.2]) + by svr1.postgresql.org (Postfix) with SMTP id 04A2BD1E9FF + for ; + Tue, 20 Apr 2004 21:34:13 -0300 (ADT) +Received: from [10.244.45.7] ([216.113.168.128]) by monsoon.he.net for + ; Tue, 20 Apr 2004 17:34:08 -0700 +In-Reply-To: +References: + <40843E63.7050101@joeconway.com> + <200404191455.04068.josh@agliodbs.com> + <1407.1082419316@sss.pgh.pa.us> <1931.1082422389@sss.pgh.pa.us> + +Mime-Version: 1.0 (Apple Message framework v613) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <9D274446-932B-11D8-BA67-000393BD6C3E@tuckfield.com> +Content-Transfer-Encoding: 7bit +Cc: Tom Lane , pgsql-performance@postgresql.org +From: Paul Tuckfield +Subject: Re: Wierd context-switching issue on Xeon +Date: Tue, 20 Apr 2004 17:34:13 -0700 +To: Paul Tuckfield +X-Mailer: Apple Mail (2.613) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/314 +X-Sequence-Number: 6614 + +Ooops, what I meant to say was that 2 threads bound to one +(hyperthreaded) cpu does *NOT* cause the storm, even on an smp xeon. + +Therefore, the context switches may be a result of cache coherency +related delays. (2 threads on one hyperthreaded cpu presumably have +tightly coupled 1,l2 cache.) + +On Apr 20, 2004, at 1:02 PM, Paul Tuckfield wrote: + +> I tried to test how this is related to cache coherency, by forcing +> affinity of the two test_run.sql processes to the two cores +> (pipelines? threads) of a single hyperthreaded xeon processor in an +> smp xeon box. +> +> When the processes are allowed to run on distinct chips in the smp +> box, the CS storm happens. When they are "bound" to the two cores of +> a single hyperthreaded Xeon in the smp box, the CS storm *does* +> happen. +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ er, meant *NOT HAPPEN* +> +> +> +> I used the taskset command: +> taskset 01 -p +> taskset 01 -p +> +> I guess that 0 and 1 are the two cores (pipelines? hyper-threads?) on +> the first Xeon processor in the box. +> +> I did this on RedHat Fedora core1 on an intel motherboard (I'll get +> the part no if it matters) +> +> during storms : 300k CS/sec, 75% idle (on a dual xeon (four core)) +> machine (suggesting serializing/sleeping processes) +> no storm: 50k CS/sec, 50% idle (suggesting 2 cpu bound processes) +> +> +> Maybe there's a "hot block" that is bouncing back and forth between +> caches? or maybe the page holding semaphores? +> +> On Apr 19, 2004, at 5:53 PM, Tom Lane wrote: +> +>> I wrote: +>>> Here is a test case. +>> +>> Hmmm ... I've been able to reproduce the CS storm on a dual Athlon, +>> which seems to pretty much let the Xeon per se off the hook. Anybody +>> got a multiple Opteron to try? Totally non-Intel CPUs? +>> +>> It would be interesting to see results with non-Linux kernels, too. +>> +>> regards, tom lane +>> +>> ---------------------------(end of +>> broadcast)--------------------------- +>> TIP 4: Don't 'kill -9' the postmaster +>> +> +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 5: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faqs/FAQ.html +> + + +From pgsql-performance-owner@postgresql.org Tue Apr 20 22:21:16 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C8C0CD1DC22 + for ; + Tue, 20 Apr 2004 22:21:14 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 02987-07 + for ; + Tue, 20 Apr 2004 22:21:15 -0300 (ADT) +Received: from houston.familyhealth.com.au (fhnet.arach.net.au + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 98490D1D52E + for ; + Tue, 20 Apr 2004 22:21:11 -0300 (ADT) +Received: from familyhealth.com.au (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id + i3L1KWWL039645; Wed, 21 Apr 2004 09:20:47 +0800 (WST) + (envelope-from chriskl@familyhealth.com.au) +Message-ID: <4085CDC3.4090201@familyhealth.com.au> +Date: Wed, 21 Apr 2004 09:26:27 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "Shea,Dan [CIS]" +Cc: pgsql-performance@postgresql.org +Subject: Re: Why will vacuum not end? +References: +In-Reply-To: +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/319 +X-Sequence-Number: 6619 + +> No, but data is constantly being inserted by userid scores. It is postgres +> runnimg the vacuum. +> Dan. + +Well, inserts create some locks - perhaps that's the problem... + +Otherwise, check the pg_locks view to see if you can figure it out. + +Chris + + +From pgsql-performance-owner@postgresql.org Tue Apr 20 23:14:55 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 35F4DD1BAF5 + for ; + Tue, 20 Apr 2004 23:14:54 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 25195-10 + for ; + Tue, 20 Apr 2004 23:14:55 -0300 (ADT) +Received: from hotmail.com (law10-oe51.law10.hotmail.com [64.4.14.40]) + by svr1.postgresql.org (Postfix) with ESMTP id AF845D1B974 + for ; + Tue, 20 Apr 2004 23:14:51 -0300 (ADT) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Tue, 20 Apr 2004 19:14:51 -0700 +Received: from 67.81.102.201 by law10-oe51.law10.hotmail.com with DAV; + Wed, 21 Apr 2004 02:14:50 +0000 +X-Originating-IP: [67.81.102.201] +X-Originating-Email: [awerman2@hotmail.com] +X-Sender: awerman2@hotmail.com +From: "Aaron Werman" +To: "Joshua D. Drake" , "Anjan Dave" +Cc: +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78509814D@vt-pe2550-001.vantage.vantage.com> + <4085BFF0.4050604@commandprompt.com> +Subject: Re: Moving postgres to FC disks +Date: Tue, 20 Apr 2004 22:14:51 -0400 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0064_01C42724.E65B1010" +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1409 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 +Message-ID: +X-OriginalArrivalTime: 21 Apr 2004 02:14:51.0302 (UTC) + FILETIME=[6D96F460:01C42746] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=1.2 tagged_above=0.0 required=5.0 tests=HTML_40_50, + HTML_MESSAGE, HTML_TITLE_EMPTY, RCVD_IN_NJABL, RCVD_IN_SORBS +X-Spam-Level: * +X-Archive-Number: 200404/326 +X-Sequence-Number: 6626 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0064_01C42724.E65B1010 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +I agree on not linking and adding non-SAN disk dependancy to your DB. I'm t= +rying to understand your FS reasoning. I have never seen XFS run faster tha= +n ReiserFS in any situation (or for that matter beat any FS in performance = +except JFS). XFS has some nifty very large file features, but we're talking= + about 30G and all modern FSs support >2G files.=20 + +My tendancy would be to stay on ext3, since it is the default RH FS. I woul= +d review site preference and the SAN recommended FS and see if they add any= + compelling points. + +/Aaron + ----- Original Message -----=20 + From: Joshua D. Drake=20 + To: Anjan Dave=20 + Cc: pgsql-performance@postgresql.org=20 + Sent: Tuesday, April 20, 2004 8:27 PM + Subject: Re: [PERFORM] Moving postgres to FC disks + + + + + -With the db size being as big as, say, 30+GB, how do I move it on the = +new logical drive? (stop postgresql, and simply move it over somehow and ma= +ke a link?) + + I would stop the database, move the data directory to the new volume usin= +g rsync then start up postgresql pointed at the new data directory. + Providing everything is working correctly you can then remove the old dat= +a directory. + + + + -Currently, the internal RAID volume is ext3 filesystem. Any recommenda= +tions for the filesystem on the new FC volume? Rieserfs? + + + + XFS + + + DBs are 7.4.1(RH9), and 7.2.3 (RH8). + + + + + + Appreciate any pointers. + + + + Thanks, + Anjan + + + + +--=20 +Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC +Postgresql support, programming shared hosting and dedicated hosting. ++1-503-667-4564 - jd@commandprompt.com - http://www.commandprompt.com +PostgreSQL Replicator -- production quality replication for PostgreSQL +------=_NextPart_000_0064_01C42724.E65B1010 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
I agree on not linking and adding non-SAN = +disk=20 +dependancy to your DB. I'm trying to understand your FS reasoning. <= +FONT=20 +face=3DArial size=3D2>I have never seen XFS run faster than ReiserFS in any= +=20 +situation (or for that matter beat any FS in performance except JFS). XFS h= +as=20 +some nifty very large file features, but we're talking about 30G and all mo= +dern=20 +FSs support >2G files.
+
= + 
+
My tendancy would be to stay on ext3, sinc= +e it is=20 +the default RH FS. I would review site preference and the SAN recommended F= +S and=20 +see if they add any compelling points.
+
 
+
/Aaron
+
+
----- Original Message -----
+ Fro= +m:=20 + Josh= +ua D.=20 + Drake
+ +
Cc: pgsql-performance@postgr= +esql.org=20 +
+
Sent: Tuesday, April 20, 2004 8:27= +=20 + PM
+
Subject: Re: [PERFORM] Moving post= +gres to=20 + FC disks
+


+ +
+

-With t= +he db=20 + size being as big as, say, 30+GB, how do I move it on the new logical d= +rive?=20 + (stop postgresql, and simply move it over somehow and make a=20 + link?)

I would stop the database, m= +ove the=20 + data directory to the new volume using rsync then start up postgresql poi= +nted=20 + at the new data directory.
Providing everything is working correctly y= +ou=20 + can then remove the old data directory.

+ +
+

+

-Curren= +tly,=20 + the internal RAID volume is ext3 filesystem. Any recommendations for th= +e=20 + filesystem on the new FC volume? Rieserfs?

+

XFS

+ +
+

DBs are= +=20 + 7.4.1(RH9), and 7.2.3 (RH8).

+

+

+

Appreci= +ate any=20 + pointers.

+

+

Thanks,= +
Anjan



--=20
+Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC
+Postgresql support, programming shared hosting and dedicated hosting.
++1-503-667-4564 - jd@commandprompt.com - http://www.commandprompt.com
+PostgreSQL Replicator -- production quality replication for PostgreSQL
+
+------=_NextPart_000_0064_01C42724.E65B1010--
+
+From pgsql-performance-owner@postgresql.org  Tue Apr 20 23:38:24 2004
+X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org
+Received: from localhost (unknown [200.46.204.2])
+	by svr1.postgresql.org (Postfix) with ESMTP id 62510D1B91C
+	for ;
+	Tue, 20 Apr 2004 23:38:22 -0300 (ADT)
+Received: from svr1.postgresql.org ([200.46.204.71])
+	by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024)
+	with ESMTP id 37921-01
+	for ;
+	Tue, 20 Apr 2004 23:38:22 -0300 (ADT)
+Received: from net2.micro-automation.com (net2.micro-automation.com
+	[64.7.141.29])
+	by svr1.postgresql.org (Postfix) with SMTP id 2253DD1B974
+	for ;
+	Tue, 20 Apr 2004 23:38:19 -0300 (ADT)
+Received: (qmail 31760 invoked from network); 21 Apr 2004 02:38:17 -0000
+Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116)
+	by net2.micro-automation.com with SMTP; 21 Apr 2004 02:38:17 -0000
+Subject: Re: Wierd context-switching issue on Xeon
+From: Dave Cramer 
+Reply-To: pg@fastcrypt.com
+To: Josh Berkus 
+Cc: Anjan Dave ,
+	Dirk =?ISO-8859-1?Q?Lutzeb=E4ck?= ,
+	Tom Lane , pgsql-performance@postgreSQL.org,
+	Neil Conway 
+In-Reply-To: <200404200959.52813.josh@agliodbs.com>
+References: 
+ <4BAFBB6B9CC46F41B2AD7D9F4BBAF78509814A@vt-pe2550-001.vantage.vantage.com>
+	<200404200959.52813.josh@agliodbs.com>
+Content-Type: text/plain
+Organization: Cramer Consulting
+Message-Id: <1082515263.1558.214.camel@localhost.localdomain>
+Mime-Version: 1.0
+X-Mailer: Ximian Evolution 1.4.6 
+Date: Tue, 20 Apr 2004 22:41:03 -0400
+Content-Transfer-Encoding: 7bit
+X-AntiVirus: scanned for viruses by AMaViS 0.2.1 (http://amavis.org/)
+X-Virus-Scanned: by amavisd-new at postgresql.org
+X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests=
+X-Spam-Level: 
+X-Archive-Number: 200404/327
+X-Sequence-Number: 6627
+
+I modified the code in s_lock.c to remove the spins
+
+#define SPINS_PER_DELAY         1
+
+and it doesn't exhibit the behaviour
+
+This effectively changes the code to 
+
+
+while(TAS(lock))
+	select(10000); // 10ms
+
+Can anyone explain why executing TAS 100 times would increase context
+switches ?
+
+Dave
+
+
+On Tue, 2004-04-20 at 12:59, Josh Berkus wrote:
+> Anjan,
+> 
+> > Quad 2.0GHz XEON with highest load we have seen on the applications, DB
+> > performing great -
+> 
+> Can you run Tom's test?   It takes a particular pattern of data access to 
+> reproduce the issue.
+-- 
+Dave Cramer
+519 939 0336
+ICQ # 14675561
+
+
+From pgsql-performance-owner@postgresql.org  Tue Apr 20 23:51:23 2004
+X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org
+Received: from localhost (unknown [200.46.204.2])
+	by svr1.postgresql.org (Postfix) with ESMTP
+	id 6905BD1C518; Tue, 20 Apr 2004 23:51:17 -0300 (ADT)
+Received: from svr1.postgresql.org ([200.46.204.71])
+	by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024)
+	with ESMTP id 40830-02; Tue, 20 Apr 2004 23:51:18 -0300 (ADT)
+Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130])
+	by svr1.postgresql.org (Postfix) with ESMTP
+	id 18A8BD1C511; Tue, 20 Apr 2004 23:51:15 -0300 (ADT)
+Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1])
+	by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3L2pFvA025065;
+	Tue, 20 Apr 2004 22:51:15 -0400 (EDT)
+To: Bruce Momjian 
+Cc: PostgreSQL-development ,
+	pgsql-performance@postgresql.org
+Subject: Re: pgbench written in Pro*C 
+In-reply-to: <200404201548.i3KFmA814010@candle.pha.pa.us> 
+References: <200404201548.i3KFmA814010@candle.pha.pa.us>
+Comments: In-reply-to Bruce Momjian 
+	message dated "Tue, 20 Apr 2004 11:48:09 -0400"
+Date: Tue, 20 Apr 2004 22:51:15 -0400
+Message-ID: <25064.1082515875@sss.pgh.pa.us>
+From: Tom Lane 
+X-Virus-Scanned: by amavisd-new at postgresql.org
+X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests=
+X-Spam-Level: 
+X-Archive-Number: 200404/328
+X-Sequence-Number: 6628
+
+Bruce Momjian  writes:
+> I received a copy of pgbench rewritten in Pro*C, which is similar to
+> embedded C.  I think it was done so the same program could be tested on
+> Oracle and PostgreSQL.
+
+> Are folks interested in this code?  Should it be put on gborg or in our
+> /contrib/pgbench?
+
+If it requires non-free tools even to build, it is of no value.
+
+			regards, tom lane
+
+From pgsql-performance-owner@postgresql.org  Wed Apr 21 00:32:02 2004
+X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org
+Received: from localhost (unknown [200.46.204.2])
+	by svr1.postgresql.org (Postfix) with ESMTP
+	id B516ED1D0B8; Wed, 21 Apr 2004 00:31:59 -0300 (ADT)
+Received: from svr1.postgresql.org ([200.46.204.71])
+	by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024)
+	with ESMTP id 58060-01; Wed, 21 Apr 2004 00:31:57 -0300 (ADT)
+Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251])
+	by svr1.postgresql.org (Postfix) with ESMTP
+	id 5AC55D1CCA8; Wed, 21 Apr 2004 00:31:56 -0300 (ADT)
+Received: (from pgman@localhost)
+	by candle.pha.pa.us (8.11.6/8.11.6) id i3L3Vuk20705;
+	Tue, 20 Apr 2004 23:31:56 -0400 (EDT)
+From: Bruce Momjian 
+Message-Id: <200404210331.i3L3Vuk20705@candle.pha.pa.us>
+Subject: Re: pgbench written in Pro*C
+In-Reply-To: <25064.1082515875@sss.pgh.pa.us>
+To: Tom Lane 
+Date: Tue, 20 Apr 2004 23:31:56 -0400 (EDT)
+Cc: PostgreSQL-development ,
+	pgsql-performance@postgresql.org
+X-Mailer: ELM [version 2.4ME+ PL108 (25)]
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Content-Type: text/plain; charset=US-ASCII
+X-Virus-Scanned: by amavisd-new at postgresql.org
+X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests=
+X-Spam-Level: 
+X-Archive-Number: 200404/329
+X-Sequence-Number: 6629
+
+Tom Lane wrote:
+> Bruce Momjian  writes:
+> > I received a copy of pgbench rewritten in Pro*C, which is similar to
+> > embedded C.  I think it was done so the same program could be tested on
+> > Oracle and PostgreSQL.
+> 
+> > Are folks interested in this code?  Should it be put on gborg or in our
+> > /contrib/pgbench?
+> 
+> If it requires non-free tools even to build, it is of no value.
+
+OK, it's only value would be if we could modify it so it compiled using
+our ecpg and Pro*C and the comparison program could be run on both
+databases.
+
+I will tell the submitter to put it on gborg if they wish.
+
+-- 
+  Bruce Momjian                        |  http://candle.pha.pa.us
+  pgman@candle.pha.pa.us               |  (610) 359-1001
+  +  If your life is a hard drive,     |  13 Roberts Road
+  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
+
+From pgsql-performance-owner@postgresql.org  Wed Apr 21 00:47:55 2004
+X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org
+Received: from localhost (unknown [200.46.204.2])
+	by svr1.postgresql.org (Postfix) with ESMTP id C58F4D1D2B7
+	for ;
+	Wed, 21 Apr 2004 00:47:53 -0300 (ADT)
+Received: from svr1.postgresql.org ([200.46.204.71])
+	by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024)
+	with ESMTP id 55599-10
+	for ;
+	Wed, 21 Apr 2004 00:47:52 -0300 (ADT)
+Received: from joeconway.com (66-146-172-82.skyriver.net [66.146.172.82])
+	by svr1.postgresql.org (Postfix) with ESMTP id 251B5D1D267
+	for ;
+	Wed, 21 Apr 2004 00:47:51 -0300 (ADT)
+Received: from [192.168.4.3] (account jconway HELO joeconway.com)
+	by joeconway.com (CommuniGate Pro SMTP 4.1.8)
+	with ESMTP-TLS id 1476184; Tue, 20 Apr 2004 20:42:02 -0700
+Message-ID: <4085EEB2.5080007@joeconway.com>
+Date: Tue, 20 Apr 2004 20:46:58 -0700
+From: Joe Conway 
+User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US;
+	rv:1.6) Gecko/20040113
+X-Accept-Language: en-us, en
+MIME-Version: 1.0
+To: Tom Lane 
+Cc: josh@agliodbs.com, "scott.marlowe" ,
+	Bruce Momjian , lutzeb@aeccom.com,
+	pgsql-performance@postgresql.org, Neil Conway 
+Subject: Re: Wierd context-switching issue on Xeon
+References: 
+	<40843E63.7050101@joeconway.com>
+	<200404191455.04068.josh@agliodbs.com>
+	<1407.1082419316@sss.pgh.pa.us> <40849235.2070808@joeconway.com>
+In-Reply-To: <40849235.2070808@joeconway.com>
+Content-Type: text/plain; charset=us-ascii; format=flowed
+Content-Transfer-Encoding: 7bit
+X-Virus-Scanned: by amavisd-new at postgresql.org
+X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests=
+X-Spam-Level: 
+X-Archive-Number: 200404/330
+X-Sequence-Number: 6630
+
+Joe Conway wrote:
+>> In isolation, test_run.sql should do essentially no syscalls at all once
+>> it's past the initial ramp-up.  On a machine that's functioning per
+>> expectations, multiple copies of test_run show a relatively low rate of
+>> semop() calls --- a few per second, at most --- and maybe a delaying
+>> select() here and there.
+
+Here's results for 7.4 on a dual Athlon server running fedora core:
+
+CPU states:  cpu    user    nice  system    irq  softirq  iowait    idle
+            total   86.0%    0.0%   52.4%   0.0%     0.0%    0.0%   61.2%
+            cpu00   37.6%    0.0%   29.7%   0.0%     0.0%    0.0%   32.6%
+            cpu01   48.5%    0.0%   22.7%   0.0%     0.0%    0.0%   28.7%
+
+procs                      memory      swap          io     system 
+    cpu
+  r  b   swpd   free   buff  cache   si   so    bi    bo   in    cs
+  1  0 120448  25764  48300 1094576    0    0     0   124  170   187
+  1  0 120448  25780  48300 1094576    0    0     0     0  152    89
+  2  0 120448  25744  48300 1094580    0    0     0    60  141 78290
+  2  0 120448  25752  48300 1094580    0    0     0     0  131 140326
+  2  0 120448  25756  48300 1094576    0    0     0    40  122 140100
+  2  0 120448  25764  48300 1094584    0    0     0    60  133 136595
+  2  0 120448  24284  48300 1094584    0    0     0   200  138 135151
+
+The jump in cs corresponds to starting the query in the second session.
+
+Joe
+
+
+From pgsql-performance-owner@postgresql.org  Wed Apr 21 03:37:03 2004
+X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org
+Received: from localhost (unknown [200.46.204.2])
+	by svr1.postgresql.org (Postfix) with ESMTP id 113BBD1D08B
+	for ;
+	Wed, 21 Apr 2004 03:37:02 -0300 (ADT)
+Received: from svr1.postgresql.org ([200.46.204.71])
+	by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024)
+	with ESMTP id 03547-10
+	for ;
+	Wed, 21 Apr 2004 03:36:59 -0300 (ADT)
+Received: from mail.unisoftbg.com (unknown [194.12.229.207])
+	by svr1.postgresql.org (Postfix) with ESMTP id 1D66FD1C967
+	for ;
+	Wed, 21 Apr 2004 03:36:55 -0300 (ADT)
+Received: (qmail 22265 invoked by uid 507); 21 Apr 2004 06:44:01 -0000
+Received: from unknown (HELO t1.unisoftbg.com)
+	(pginfo%t1.unisoftbg.com@194.12.229.193)
+	by 0 with SMTP; 21 Apr 2004 06:44:01 -0000
+Message-ID: <40860509.C74D7457@t1.unisoftbg.com>
+Date: Wed, 21 Apr 2004 07:22:17 +0200
+From: pginfo 
+X-Mailer: Mozilla 4.03 [en] (Win95; I)
+MIME-Version: 1.0
+To: "pgsql-performance@postgresql.org" 
+Subject: Re: Wierd context-switching issue on Xeon
+Content-Type: text/plain; charset=us-ascii
+Content-Transfer-Encoding: 7bit
+X-Virus-Scanned: by amavisd-new at postgresql.org
+X-Spam-Status: No, hits=1.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_DSBL,
+	TO_ADDRESS_EQ_REAL
+X-Spam-Level: *
+X-Archive-Number: 200404/331
+X-Sequence-Number: 6631
+
+Hi,
+
+Dual Xeon P4 2.8
+linux RedHat AS 3
+kernel 2.4.21-4-EL-smp
+2 GB ram
+
+I can see the same problem:
+
+procs                      memory      swap          io
+system         cpu
+ r  b   swpd   free   buff  cache   si   so    bi    bo   in    cs us sy
+id wa
+1  0      0  96212  61056 1720240    0    0     0     0  101    11 25  0
+75  0
+ 1  0      0  96212  61056 1720240    0    0     0     0  108   139 25
+0 75  0
+ 1  0      0  96212  61056 1720240    0    0     0     0  104   173 25
+0 75  0
+ 1  0      0  96212  61056 1720240    0    0     0     0  102    11 25
+0 75  0
+ 1  0      0  96212  61056 1720240    0    0     0     0  101    11 25
+0 75  0
+ 2  0      0  96204  61056 1720240    0    0     0     0  110 53866 31
+4 65  0
+ 2  0      0  96204  61056 1720240    0    0     0     0  101 83176 41
+5 54  0
+ 2  0      0  96204  61056 1720240    0    0     0     0  102 86050 39
+6 55  0
+ 2  0      0  96204  61056 1720240    0    0     0    49  113 73642 41
+5 54  0
+ 2  0      0  96204  61056 1720240    0    0     0     0  102 84211 40
+5 55  0
+ 2  0      0  96204  61056 1720240    0    0     0     0  101 105165 39
+7 54  0
+ 2  0      0  96204  61056 1720240    0    0     0     0  103 97754 38
+6 56  0
+ 2  0      0  96204  61056 1720240    0    0     0     0  103 113668 36
+7 57  0
+ 2  0      0  96204  61056 1720240    0    0     0     0  103 112003 37
+7 56  0
+
+regards,
+ivan.
+
+
+From pgsql-performance-owner@postgresql.org  Wed Apr 21 04:17:27 2004
+X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org
+Received: from localhost (unknown [200.46.204.2])
+	by svr1.postgresql.org (Postfix) with ESMTP id 494B7D1D163
+	for ;
+	Wed, 21 Apr 2004 04:17:25 -0300 (ADT)
+Received: from svr1.postgresql.org ([200.46.204.71])
+	by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024)
+	with ESMTP id 21391-10
+	for ;
+	Wed, 21 Apr 2004 04:17:24 -0300 (ADT)
+Received: from FE-mail03.sfg.albacom.net (FE-mail03.albacom.net
+	[213.217.149.83])
+	by svr1.postgresql.org (Postfix) with ESMTP id B62A2D1CCB1
+	for ;
+	Wed, 21 Apr 2004 04:17:22 -0300 (ADT)
+Received: from axa.it (217.221.80.72) by FE-mail03.sfg.albacom.net (7.0.009)
+	id 40757CA50010913C for pgsql-performance@postgresql.org;
+	Wed, 21 Apr 2004 09:17:24 +0200
+Message-ID: <40862003.2090201@axa.it>
+Date: Wed, 21 Apr 2004 09:17:23 +0200
+From: Edoardo Ceccarelli 
+User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207)
+X-Accept-Language: it, en, en-us
+MIME-Version: 1.0
+To: pgsql-performance@postgresql.org
+Subject: slow seqscan
+Content-Type: text/plain; charset=us-ascii; format=flowed
+Content-Transfer-Encoding: 7bit
+X-Virus-Scanned: by amavisd-new at postgresql.org
+X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests=
+X-Spam-Level: 
+X-Archive-Number: 200404/332
+X-Sequence-Number: 6632
+
+My first post to this list :)
+
+Scenario:
+I have a database used only with search queries with only one table that
+holds about 450.000/500.000 records.
+The table is well indexed so that most of the queries are executed with
+index scan but since there is a big text field in the table (360chars)
+some search operation (with certain filters) ends up with seq scans.
+This table is not written during normal operation: twice per week there
+is a batch program that insert about 35.000 records and updates another
+40.000.
+
+last friday morning, after that batch has been executed, the database 
+started responding really slowly to queries (expecially seq scans), 
+after a "vacuum full analize" things did get something better.
+Yesterday the same: before the batch everything was perfect, after every 
+query was really slow, I've vacuum it again and now is ok.
+Since now the db was working fine, it's 4 month's old with two updates 
+per week and I vacuum about once per month.
+
+I am using version 7.3 do I need to upgrade to 7.4? also, I was thinking
+about setting this table in a kind of  "read-only" mode to improve
+performance, is this possible?
+
+Thank you for your help
+Edoardo Ceccarelli
+
+From pgsql-performance-owner@postgresql.org  Wed Apr 21 04:48:14 2004
+X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org
+Received: from localhost (unknown [200.46.204.2])
+	by svr1.postgresql.org (Postfix) with ESMTP id 4844AD1CCB1
+	for ;
+	Wed, 21 Apr 2004 04:48:09 -0300 (ADT)
+Received: from svr1.postgresql.org ([200.46.204.71])
+	by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024)
+	with ESMTP id 35026-07
+	for ;
+	Wed, 21 Apr 2004 04:48:08 -0300 (ADT)
+Received: from obie.mrkdns.com (obie.mrkdns.com [69.93.72.82])
+	by svr1.postgresql.org (Postfix) with ESMTP id D58EBD1BA6C
+	for ;
+	Wed, 21 Apr 2004 04:48:05 -0300 (ADT)
+Received: from [213.152.63.90] (helo=chuckie.co.uk)
+	by obie.mrkdns.com with asmtp (Exim 4.30)
+	id 1BGCSk-00018K-Bc; Wed, 21 Apr 2004 08:48:06 +0100
+Message-ID: <4086272E.2080102@chuckie.co.uk>
+Date: Wed, 21 Apr 2004 08:47:58 +0100
+From: Nick Barr 
+User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207)
+X-Accept-Language: en-us, en
+MIME-Version: 1.0
+To: Edoardo Ceccarelli 
+Cc: pgsql-performance@postgresql.org
+Subject: Re: slow seqscan
+References: <40862003.2090201@axa.it>
+In-Reply-To: <40862003.2090201@axa.it>
+Content-Type: text/plain; charset=ISO-8859-1; format=flowed
+Content-Transfer-Encoding: 7bit
+X-AntiAbuse: This header was added to track abuse,
+	please include it with any abuse report
+X-AntiAbuse: Primary Hostname - obie.mrkdns.com
+X-AntiAbuse: Original Domain - postgresql.org
+X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [47 12]
+X-AntiAbuse: Sender Address Domain - chuckie.co.uk
+X-Virus-Scanned: by amavisd-new at postgresql.org
+X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests=
+X-Spam-Level: 
+X-Archive-Number: 200404/334
+X-Sequence-Number: 6634
+
+Edoardo Ceccarelli wrote:
+
+> My first post to this list :)
+>
+> Scenario:
+> I have a database used only with search queries with only one table that
+> holds about 450.000/500.000 records.
+> The table is well indexed so that most of the queries are executed with
+> index scan but since there is a big text field in the table (360chars)
+> some search operation (with certain filters) ends up with seq scans.
+> This table is not written during normal operation: twice per week there
+> is a batch program that insert about 35.000 records and updates another
+> 40.000.
+>
+> last friday morning, after that batch has been executed, the database 
+> started responding really slowly to queries (expecially seq scans), 
+> after a "vacuum full analize" things did get something better.
+> Yesterday the same: before the batch everything was perfect, after 
+> every query was really slow, I've vacuum it again and now is ok.
+> Since now the db was working fine, it's 4 month's old with two updates 
+> per week and I vacuum about once per month.
+>
+> I am using version 7.3 do I need to upgrade to 7.4? also, I was thinking
+> about setting this table in a kind of  "read-only" mode to improve
+> performance, is this possible?
+>
+> Thank you for your help
+> Edoardo Ceccarelli
+>
+> ---------------------------(end of broadcast)---------------------------
+> TIP 8: explain analyze is your friend
+
+In general we are going to need more information, like what kind of 
+search filters you are using on the text field and an EXPLAIN ANALYZE. 
+But can you try and run the following, bearing in mind it will take a 
+while to complete.
+
+REINDEX TABLE 
+
+ From what I remember there were issues with index space not being 
+reclaimed in a vacuum. I believe this was fixed in 7.4. By not 
+reclaiming the space the indexes grow larger and larger over time, 
+causing PG to prefer a sequential scan over an index scan (I think).
+
+
+Hope that helps
+
+Nick
+
+
+
+From pgsql-performance-owner@postgresql.org  Wed Apr 21 04:46:59 2004
+X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org
+Received: from localhost (unknown [200.46.204.2])
+	by svr1.postgresql.org (Postfix) with ESMTP id 9BFBCD1B562
+	for ;
+	Wed, 21 Apr 2004 04:46:57 -0300 (ADT)
+Received: from svr1.postgresql.org ([200.46.204.71])
+	by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024)
+	with ESMTP id 38316-05
+	for ;
+	Wed, 21 Apr 2004 04:46:57 -0300 (ADT)
+Received: from houston.familyhealth.com.au (fhnet.arach.net.au
+ [203.22.197.21])
+	by svr1.postgresql.org (Postfix) with ESMTP id 9E145D1B507
+	for ;
+	Wed, 21 Apr 2004 04:46:54 -0300 (ADT)
+Received: from familyhealth.com.au (work-40.internal [192.168.0.40])
+	by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id
+	i3L7klWL048815; Wed, 21 Apr 2004 15:46:47 +0800 (WST)
+	(envelope-from chriskl@familyhealth.com.au)
+Message-ID: <40862857.4030008@familyhealth.com.au>
+Date: Wed, 21 Apr 2004 15:52:55 +0800
+From: Christopher Kings-Lynne 
+User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207)
+X-Accept-Language: en-us, en
+MIME-Version: 1.0
+To: Edoardo Ceccarelli 
+Cc: pgsql-performance@postgresql.org
+Subject: Re: slow seqscan
+References: <40862003.2090201@axa.it>
+In-Reply-To: <40862003.2090201@axa.it>
+Content-Type: text/plain; charset=us-ascii; format=flowed
+Content-Transfer-Encoding: 7bit
+X-Virus-Scanned: by amavisd-new at postgresql.org
+X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=HTML_MESSAGE,
+	HTML_TAG_BALANCE_TABLE
+X-Spam-Level: 
+X-Archive-Number: 200404/333
+X-Sequence-Number: 6633
+
+Hi Edoardo,
+
+> The table is well indexed so that most of the queries are executed with
+> index scan but since there is a big text field in the table (360chars)
+> some search operation (with certain filters) ends up with seq scans.
+
+Please paste the exact SELECT query that uses a seqscan, plus the 
+EXPLAIN ANALYZE of the SELECT, and the psql output of \d .
+
+> This table is not written during normal operation: twice per week there
+> is a batch program that insert about 35.000 records and updates another
+> 40.000.
+
+After such an update, you need to run VACUUM ANALYZE 
; Run it +before the update as well, if it doesn't take that long. + +> last friday morning, after that batch has been executed, the database +> started responding really slowly to queries (expecially seq scans), +> after a "vacuum full analize" things did get something better. +> Yesterday the same: before the batch everything was perfect, after every +> query was really slow, I've vacuum it again and now is ok. +> Since now the db was working fine, it's 4 month's old with two updates +> per week and I vacuum about once per month. + +You need to vacuum analyze (NOT full) once and HOUR, not once a month. +Add this command to your crontab to run once an hour and verify that +it's working: + +vacuumdb -a -z -q + +Otherwise, install the auto vacuum utility found in +contrib/pg_autovacuum in the postgres source. Set this up. It will +monitor postgres and run vacuums and analyzes when necessary. You can +then remove your cron job. + +> I am using version 7.3 do I need to upgrade to 7.4? also, I was thinking +> about setting this table in a kind of "read-only" mode to improve +> performance, is this possible? + +There's no read only mode to improve performance. + +Upgrading to 7.4 will more than likely improve the performance of your +database in general. Be careful to read the upgrade notes because there +were a few incompatibilities. + +Chris + + +From pgsql-performance-owner@postgresql.org Wed Apr 21 05:31:48 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DD4A4D1CCA8 + for ; + Wed, 21 Apr 2004 05:31:47 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 45864-06 + for ; + Wed, 21 Apr 2004 05:31:48 -0300 (ADT) +Received: from obie.mrkdns.com (obie.mrkdns.com [69.93.72.82]) + by svr1.postgresql.org (Postfix) with ESMTP id 1B463D1BB36 + for ; + Wed, 21 Apr 2004 05:31:46 -0300 (ADT) +Received: from [213.152.63.90] (helo=chuckie.co.uk) + by obie.mrkdns.com with asmtp (Exim 4.30) id 1BGD92-0003PT-Rg + for pgsql-performance@postgresql.org; Wed, 21 Apr 2004 09:31:48 +0100 +Message-ID: <4086316B.4050304@chuckie.co.uk> +Date: Wed, 21 Apr 2004 09:31:39 +0100 +From: Nick Barr +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: PgSQL Performance ML +Subject: MySQL vs PG TPC-H benchmarks +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-AntiAbuse: This header was added to track abuse, + please include it with any abuse report +X-AntiAbuse: Primary Hostname - obie.mrkdns.com +X-AntiAbuse: Original Domain - postgresql.org +X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [47 12] +X-AntiAbuse: Sender Address Domain - chuckie.co.uk +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/335 +X-Sequence-Number: 6635 + +Hi, + +Has anyone had a look at: + +http://people.ac.upc.es/zgomez/ + +I realize that MySQL & PG cannot really be compared (especially when you +consider the issues that MySQL has with things like data integrity) but +still surely PG would perform better than the stats show (i.e. #7 31.28 +seconds versus 42 minutes!!!). + +On a side note it certainly looks like linux kernel 2.6 is quite a bit +faster in comparision to 2.4. + +Nick + + + + +From pgsql-performance-owner@postgresql.org Wed Apr 21 05:34:54 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 777B4D1BACD + for ; + Wed, 21 Apr 2004 05:34:53 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 45089-08 + for ; + Wed, 21 Apr 2004 05:34:52 -0300 (ADT) +Received: from FE-mail04.sfg.albacom.net (FE-mail04.albacom.net + [213.217.149.84]) + by svr1.postgresql.org (Postfix) with ESMTP id ADF96D1BABD + for ; + Wed, 21 Apr 2004 05:34:50 -0300 (ADT) +Received: from axa.it (217.221.80.72) by FE-mail04.sfg.albacom.net (7.0.009) + id 40757DA1000F0A8A; Wed, 21 Apr 2004 10:34:48 +0200 +Message-ID: <40863228.907@axa.it> +Date: Wed, 21 Apr 2004 10:34:48 +0200 +From: Edoardo Ceccarelli +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: it, en, en-us +MIME-Version: 1.0 +To: Nick Barr +Cc: pgsql-performance@postgresql.org +Subject: Re: slow seqscan +References: <40862003.2090201@axa.it> <4086272E.2080102@chuckie.co.uk> +In-Reply-To: <4086272E.2080102@chuckie.co.uk> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/336 +X-Sequence-Number: 6636 + + +> +> In general we are going to need more information, like what kind of +> search filters you are using on the text field and an EXPLAIN ANALYZE. +> But can you try and run the following, bearing in mind it will take a +> while to complete. +> +> REINDEX TABLE +> +> From what I remember there were issues with index space not being +> reclaimed in a vacuum. I believe this was fixed in 7.4. By not +> reclaiming the space the indexes grow larger and larger over time, +> causing PG to prefer a sequential scan over an index scan (I think). +> +> + +The query is this: +SELECT *, oid FROM annuncio400 +WHERE rubric = 'DD' AND LOWER(testo) Like LOWER('cbr%') +OFFSET 0 LIMIT 11 + +dba400=# explain analyze SELECT *, oid FROM annuncio400 WHERE rubric = +'DD' AND LOWER(testo) Like LOWER('cbr%') OFFSET 0 LIMIT 11; + QUERY +PLAN +-------------------------------------------------------------------------------------------------------------------- + +Limit (cost=0.00..3116.00 rows=11 width=546) (actual time=51.47..56.42 +rows=11 loops=1) + -> Seq Scan on annuncio400 (cost=0.00..35490.60 rows=125 width=546) +(actual time=51.47..56.40 rows=12 loops=1) + Filter: ((rubric = 'DD'::bpchar) AND (lower((testo)::text) ~~ +'cbr%'::text)) +Total runtime: 56.53 msec +(4 rows) + + +But the strangest thing ever is that if I change the filter with another +one that represent a smaller amount of data it uses the index scan!!! +check this (same table, same query, different rubric=MA index): + +dba400=# explain analyze SELECT *, oid FROM annuncio400 WHERE rubric = +'MA' AND LOWER(testo) Like LOWER('cbr%') OFFSET 0 LIMIT 11; + QUERY +PLAN +------------------------------------------------------------------------------------------------------------------------------- + +Limit (cost=0.00..6630.72 rows=9 width=546) (actual time=42.74..42.74 +rows=0 loops=1) + -> Index Scan using rubric on annuncio400 (cost=0.00..6968.48 rows=9 +width=546) (actual time=42.73..42.73 rows=0 loops=1) + Index Cond: (rubric = 'MA'::bpchar) + Filter: (lower((testo)::text) ~~ 'cbr%'::text) +Total runtime: 42.81 msec +(5 rows) + + +Thanks for your help +Edoardo + +> +> + +From pgsql-performance-owner@postgresql.org Wed Apr 21 05:48:08 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B783DD1BACD + for ; + Wed, 21 Apr 2004 05:48:07 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 51863-06 + for ; + Wed, 21 Apr 2004 05:48:06 -0300 (ADT) +Received: from houston.familyhealth.com.au (fhnet.arach.net.au + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id B295BD1BABA + for ; + Wed, 21 Apr 2004 05:48:02 -0300 (ADT) +Received: from familyhealth.com.au (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id + i3L8llWL057799; Wed, 21 Apr 2004 16:47:48 +0800 (WST) + (envelope-from chriskl@familyhealth.com.au) +Message-ID: <408636A5.2050305@familyhealth.com.au> +Date: Wed, 21 Apr 2004 16:53:57 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Edoardo Ceccarelli +Cc: Nick Barr , pgsql-performance@postgresql.org +Subject: Re: slow seqscan +References: <40862003.2090201@axa.it> <4086272E.2080102@chuckie.co.uk> + <40863228.907@axa.it> +In-Reply-To: <40863228.907@axa.it> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/337 +X-Sequence-Number: 6637 + +> dba400=# explain analyze SELECT *, oid FROM annuncio400 WHERE rubric = +> 'DD' AND LOWER(testo) Like LOWER('cbr%') OFFSET 0 LIMIT 11; +> QUERY +> PLAN +> -------------------------------------------------------------------------------------------------------------------- +> +> Limit (cost=0.00..3116.00 rows=11 width=546) (actual time=51.47..56.42 +> rows=11 loops=1) +> -> Seq Scan on annuncio400 (cost=0.00..35490.60 rows=125 width=546) +> (actual time=51.47..56.40 rows=12 loops=1) +> Filter: ((rubric = 'DD'::bpchar) AND (lower((testo)::text) ~~ +> 'cbr%'::text)) +> Total runtime: 56.53 msec +> (4 rows) + +What happens if you go: + +CREATE INDEX annuncio400_rubric_testo_idx ON annuncio400(rubric, +LOWER(testo)); + +or even just: + +CREATE INDEX annuncio400_rubric_testo_idx ON annuncio400(LOWER(testo)); + +> But the strangest thing ever is that if I change the filter with another +> one that represent a smaller amount of data it uses the index scan!!! + +What's strange about that? The less data is going to be retrieved, the +more likely postgres is to use the index. + +I suggest maybe increasing the amount of stats recorded for your rubrik +column: + +ALTER TABLE annuncio400 ALTER rubrik SET STATISTICS 100; +ANALYZE annuncio400; + +You could also try reducing the random_page_cost value in your +postgresql.conf a little, say to 3 (if it's currently 4). That will +make postgres more likely to use index scans over seq scans. + +Chris + + +From pgsql-performance-owner@postgresql.org Wed Apr 21 06:41:23 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 19A43D1D206 + for ; + Wed, 21 Apr 2004 06:41:21 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 81683-02 + for ; + Wed, 21 Apr 2004 06:41:21 -0300 (ADT) +Received: from FE-mail03.sfg.albacom.net (FE-mail03.albacom.net + [213.217.149.83]) + by svr1.postgresql.org (Postfix) with ESMTP id 6BCF3D1C511 + for ; + Wed, 21 Apr 2004 06:41:19 -0300 (ADT) +Received: from axa.it (217.221.80.72) by FE-mail03.sfg.albacom.net (7.0.009) + id 40757CA50010E027; Wed, 21 Apr 2004 11:41:12 +0200 +Message-ID: <408641B7.5090808@axa.it> +Date: Wed, 21 Apr 2004 11:41:11 +0200 +From: Edoardo Ceccarelli +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: it, en, en-us +MIME-Version: 1.0 +To: Christopher Kings-Lynne +Cc: Nick Barr , pgsql-performance@postgresql.org +Subject: Re: slow seqscan +References: <40862003.2090201@axa.it> <4086272E.2080102@chuckie.co.uk> + <40863228.907@axa.it> <408636A5.2050305@familyhealth.com.au> +In-Reply-To: <408636A5.2050305@familyhealth.com.au> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/338 +X-Sequence-Number: 6638 + + +> What happens if you go: +> +> CREATE INDEX annuncio400_rubric_testo_idx ON annuncio400(rubric, +> LOWER(testo)); +> +> or even just: +> +> CREATE INDEX annuncio400_rubric_testo_idx ON annuncio400(LOWER(testo)); +> +I wasn't able to make this 2 field index with lower: + +dba400=# CREATE INDEX annuncio400_rubric_testo_idx ON +annuncio400(rubric, LOWER(testo)); +ERROR: parser: parse error at or near "(" at character 71 + +seems impossible to creat 2 field indexes with lower function. + +The other one does not make it use the index. + + +>> But the strangest thing ever is that if I change the filter with +>> another one that represent a smaller amount of data it uses the +>> index scan!!! +> +> +> What's strange about that? The less data is going to be retrieved, +> the more likely postgres is to use the index. +> +can't understand this policy: + +dba400=# SELECT count(*) from annuncio400 where rubric='DD'; + count +------- + 6753 +(1 row) + +dba400=# SELECT count(*) from annuncio400 where rubric='MA'; + count +------- + 2165 +(1 row) + +so it's using the index on 2000 rows and not for 6000? it's not that +big difference, isn't it? + + +> I suggest maybe increasing the amount of stats recorded for your +> rubrik column: +> +> ALTER TABLE annuncio400 ALTER rubrik SET STATISTICS 100; +> ANALYZE annuncio400; +> +done, almost the same, still not using index + +> You could also try reducing the random_page_cost value in your +> postgresql.conf a little, say to 3 (if it's currently 4). That will +> make postgres more likely to use index scans over seq scans. +> + +changed the setting on postgresql.conf, restarted the server, +nothing has changed. + +what about setting this to false? +#enable_seqscan = true + +thanks again +Edoardo + +From pgsql-performance-owner@postgresql.org Wed Apr 21 07:10:41 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C0768D1BA8F + for ; + Wed, 21 Apr 2004 07:10:16 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 83703-05 + for ; + Wed, 21 Apr 2004 07:10:12 -0300 (ADT) +Received: from FE-mail03.sfg.albacom.net (FE-mail03.albacom.net + [213.217.149.83]) + by svr1.postgresql.org (Postfix) with ESMTP id 10781D1BAA2 + for ; + Wed, 21 Apr 2004 07:10:10 -0300 (ADT) +Received: from axa.it (217.221.80.72) by FE-mail03.sfg.albacom.net (7.0.009) + id 40757CA50010EF88; Wed, 21 Apr 2004 12:10:03 +0200 +Message-ID: <4086487A.4090703@axa.it> +Date: Wed, 21 Apr 2004 12:10:02 +0200 +From: Edoardo Ceccarelli +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: it, en, en-us +MIME-Version: 1.0 +Cc: Christopher Kings-Lynne , + Nick Barr , pgsql-performance@postgresql.org +Subject: Re: slow seqscan +References: <40862003.2090201@axa.it> <4086272E.2080102@chuckie.co.uk> + <40863228.907@axa.it> <408636A5.2050305@familyhealth.com.au> + <408641B7.5090808@axa.it> +In-Reply-To: <408641B7.5090808@axa.it> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/339 +X-Sequence-Number: 6639 + +tried the + +enable_seqscan = false + +and I'm having all index scans, timing has improved from 600ms to 18ms + +wondering what other implications I might expect. + + + + +Edoardo Ceccarelli ha scritto: + +> +>> What happens if you go: +>> +>> CREATE INDEX annuncio400_rubric_testo_idx ON annuncio400(rubric, +>> LOWER(testo)); +>> +>> or even just: +>> +>> CREATE INDEX annuncio400_rubric_testo_idx ON annuncio400(LOWER(testo)); +>> +> I wasn't able to make this 2 field index with lower: +> +> dba400=# CREATE INDEX annuncio400_rubric_testo_idx ON +> annuncio400(rubric, LOWER(testo)); +> ERROR: parser: parse error at or near "(" at character 71 +> +> seems impossible to creat 2 field indexes with lower function. +> +> The other one does not make it use the index. +> +> +>>> But the strangest thing ever is that if I change the filter with +>>> another one that represent a smaller amount of data it uses the +>>> index scan!!! +>> +>> +>> +>> What's strange about that? The less data is going to be retrieved, +>> the more likely postgres is to use the index. +>> +> can't understand this policy: +> +> dba400=# SELECT count(*) from annuncio400 where rubric='DD'; +> count +> ------- +> 6753 +> (1 row) +> +> dba400=# SELECT count(*) from annuncio400 where rubric='MA'; +> count +> ------- +> 2165 +> (1 row) +> +> so it's using the index on 2000 rows and not for 6000? it's not that +> big difference, isn't it? +> +> +>> I suggest maybe increasing the amount of stats recorded for your +>> rubrik column: +>> +>> ALTER TABLE annuncio400 ALTER rubrik SET STATISTICS 100; +>> ANALYZE annuncio400; +>> +> done, almost the same, still not using index +> +>> You could also try reducing the random_page_cost value in your +>> postgresql.conf a little, say to 3 (if it's currently 4). That will +>> make postgres more likely to use index scans over seq scans. +>> +> +> changed the setting on postgresql.conf, restarted the server, +> nothing has changed. +> +> what about setting this to false? +> #enable_seqscan = true +> +> thanks again +> Edoardo +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: you can get off all lists at once with the unregister command +> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) +> +> +> + +From pgsql-performance-owner@postgresql.org Wed Apr 21 07:15:31 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 280C4D1BAD1 + for ; + Wed, 21 Apr 2004 07:15:28 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 94103-01 + for ; + Wed, 21 Apr 2004 07:15:28 -0300 (ADT) +Received: from vscan02.westnet.com.au (vscan02.westnet.com.au [203.10.1.132]) + by svr1.postgresql.org (Postfix) with ESMTP id B82F2D1BABA + for ; + Wed, 21 Apr 2004 07:15:25 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by localhost (Postfix) with ESMTP id C65DA10066F; + Wed, 21 Apr 2004 18:15:25 +0800 (WST) +Received: from familyhealth.com.au (dsl-202-72-133-22.wa.westnet.com.au + [202.72.133.22]) + by vscan02.westnet.com.au (Postfix) with ESMTP id 42B05100738; + Wed, 21 Apr 2004 18:15:24 +0800 (WST) +Message-ID: <408649C1.3000904@familyhealth.com.au> +Date: Wed, 21 Apr 2004 18:15:29 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.6b) Gecko/20031205 Thunderbird/0.4 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Edoardo Ceccarelli +Cc: Nick Barr , pgsql-performance@postgresql.org +Subject: Re: slow seqscan +References: <40862003.2090201@axa.it> <4086272E.2080102@chuckie.co.uk> + <40863228.907@axa.it> <408636A5.2050305@familyhealth.com.au> + <408641B7.5090808@axa.it> <4086487A.4090703@axa.it> +In-Reply-To: <4086487A.4090703@axa.it> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/340 +X-Sequence-Number: 6640 + + +> enable_seqscan = false +> +> and I'm having all index scans, timing has improved from 600ms to 18ms +> +> wondering what other implications I might expect. + +Lots of really bad implications...it's really not a good idea. + +Chris + + +From pgsql-performance-owner@postgresql.org Wed Apr 21 08:19:48 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id EE330D1D2B7 + for ; + Wed, 21 Apr 2004 08:18:56 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 14043-04 + for ; + Wed, 21 Apr 2004 08:18:58 -0300 (ADT) +Received: from server.pyrenet.fr (server.pyrenet.fr [194.250.190.1]) + by svr1.postgresql.org (Postfix) with ESMTP id CD8E8D1D067 + for ; + Wed, 21 Apr 2004 08:18:53 -0300 (ADT) +Received: from localhost (localhost [127.0.0.1]) + by localhost.pyrenet.fr (Postfix) with ESMTP + id 91FE011035; Wed, 21 Apr 2004 13:18:56 +0200 (MET DST) +Received: from server.pyrenet.fr ([127.0.0.1]) + by localhost (server [127.0.0.1]) (amavisd-new, port 10024) with ESMTP + id 07841-09; Wed, 21 Apr 2004 13:18:53 +0200 (MET DST) +Received: from server.pyrenet.fr (server.pyrenet.fr [194.250.190.1]) + by server.pyrenet.fr (Postfix) with ESMTP + id 0A9ED11034; Wed, 21 Apr 2004 13:18:53 +0200 (MET DST) +Date: Wed, 21 Apr 2004 13:18:53 +0200 (MET DST) +From: ohp@pyrenet.fr +Reply-To: ohp@pyrenet.fr +To: Tom Lane +Cc: josh@agliodbs.com, Joe Conway , + "scott.marlowe" , + Bruce Momjian , lutzeb@aeccom.com, + pgsql-performance@postgresql.org, Neil Conway +Subject: Re: Wierd context-switching issue on Xeon +In-Reply-To: <1407.1082419316@sss.pgh.pa.us> +Message-ID: +References: + <40843E63.7050101@joeconway.com> <200404191455.04068.josh@agliodbs.com> + <1407.1082419316@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at pyrenet.fr +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME +X-Spam-Level: +X-Archive-Number: 200404/341 +X-Sequence-Number: 6641 + +How long is this test supposed to run? + +I've launched just 1 for testing, the plan seems horrible; the test is cpu +bound and hasn't finished yet after 17:02 min of CPU time, dual XEON 2.6G +Unixware 713 + +The machine is a Fujitsu-Siemens TX 200 server + On Mon, 19 Apr 2004, Tom Lane wrote: + +> Date: Mon, 19 Apr 2004 20:01:56 -0400 +> From: Tom Lane +> To: josh@agliodbs.com +> Cc: Joe Conway , scott.marlowe , +> Bruce Momjian , lutzeb@aeccom.com, +> pgsql-performance@postgresql.org, Neil Conway +> Subject: Re: [PERFORM] Wierd context-switching issue on Xeon +> +> Here is a test case. To set up, run the "test_setup.sql" script once; +> then launch two copies of the "test_run.sql" script. (For those of +> you with more than two CPUs, see whether you need one per CPU to make +> trouble, or whether two test_runs are enough.) Check that you get a +> nestloops-with-index-scans plan shown by the EXPLAIN in test_run. +> +> In isolation, test_run.sql should do essentially no syscalls at all once +> it's past the initial ramp-up. On a machine that's functioning per +> expectations, multiple copies of test_run show a relatively low rate of +> semop() calls --- a few per second, at most --- and maybe a delaying +> select() here and there. +> +> What I actually see on Josh's client's machine is a context swap storm: +> "vmstat 1" shows CS rates around 170K/sec. strace'ing the backends +> shows a corresponding rate of semop() syscalls, with a few delaying +> select()s sprinkled in. top(1) shows system CPU percent of 25-30 +> and idle CPU percent of 16-20. +> +> I haven't bothered to check how long the test_run query takes, but if it +> ends while you're still examining the behavior, just start it again. +> +> Note the test case assumes you've got shared_buffers set to at least +> 1000; with smaller values, you may get some I/O syscalls, which will +> probably skew the results. +> +> regards, tom lane +> +> + +-- +Olivier PRENANT Tel: +33-5-61-50-97-00 (Work) +6, Chemin d'Harraud Turrou +33-5-61-50-97-01 (Fax) +31190 AUTERIVE +33-6-07-63-80-64 (GSM) +FRANCE Email: ohp@pyrenet.fr +------------------------------------------------------------------------------ +Make your life a dream, make your dream a reality. (St Exupery) + +From pgsql-performance-owner@postgresql.org Wed Apr 21 08:50:27 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8837FD1BABD + for ; + Wed, 21 Apr 2004 08:50:15 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 22221-07 + for ; + Wed, 21 Apr 2004 08:50:16 -0300 (ADT) +Received: from FE-mail04.sfg.albacom.net (FE-mail04.albacom.net + [213.217.149.84]) + by svr1.postgresql.org (Postfix) with ESMTP id AB941D1B482 + for ; + Wed, 21 Apr 2004 08:50:13 -0300 (ADT) +Received: from axa.it (217.221.80.72) by FE-mail04.sfg.albacom.net (7.0.009) + id 40757DA1000F5C81; Wed, 21 Apr 2004 13:50:05 +0200 +Message-ID: <40865FEC.9030500@axa.it> +Date: Wed, 21 Apr 2004 13:50:04 +0200 +From: Edoardo Ceccarelli +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: it, en, en-us +MIME-Version: 1.0 +To: Christopher Kings-Lynne +Cc: Nick Barr , pgsql-performance@postgresql.org +Subject: Re: slow seqscan +References: <40862003.2090201@axa.it> <4086272E.2080102@chuckie.co.uk> + <40863228.907@axa.it> <408636A5.2050305@familyhealth.com.au> + <408641B7.5090808@axa.it> <4086487A.4090703@axa.it> + <408649C1.3000904@familyhealth.com.au> +In-Reply-To: <408649C1.3000904@familyhealth.com.au> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/342 +X-Sequence-Number: 6642 + +just created a copy of the same database and it shows that is the +analyze that's messing things: + +Slow seqscan query executed on dba400 + +dba400=# explain analyze SELECT *, oid FROM annuncio400 WHERE rubric = +'DD' AND LOWER(testo) Like LOWER('cbr%') OFFSET 0 LIMIT 11; + QUERY +PLAN +-------------------------------------------------------------------------------------------------------------------- + Limit (cost=0.00..3116.00 rows=11 width=546) (actual time=46.66..51.40 +rows=11 loops=1) + -> Seq Scan on annuncio400 (cost=0.00..35490.60 rows=125 width=546) +(actual time=46.66..51.38 rows=12 loops=1) + Filter: ((rubric = 'DD'::bpchar) AND (lower((testo)::text) ~~ +'cbr%'::text)) + Total runtime: 51.46 msec +(4 rows) + + +fastest index scan query on dba400b (exact copy of dba400) + + +dba400b=# explain analyze SELECT *, oid FROM annuncio400 WHERE rubric = +'DD' AND LOWER(testo) Like LOWER('cbr%') OFFSET 0 LIMIT 11; + QUERY +PLAN +------------------------------------------------------------------------------------------------------------------------------ + Limit (cost=0.00..7058.40 rows=9 width=546) (actual time=1.36..8.18 +rows=11 loops=1) + -> Index Scan using rubric on annuncio400 (cost=0.00..7369.42 +rows=9 width=546) (actual time=1.35..8.15 rows=12 loops=1) + Index Cond: (rubric = 'DD'::bpchar) + Filter: (lower((testo)::text) ~~ 'cbr%'::text) + Total runtime: 8.28 msec +(5 rows) + + + +what about this index you suggested? it gives me sintax error while +trying to create it: + +CREATE INDEX annuncio400_rubric_testo_idx ON annuncio400(rubric, +LOWER(testo)); + + +Thanks +Edoardo + +Christopher Kings-Lynne ha scritto: + +> +>> enable_seqscan = false +>> +>> and I'm having all index scans, timing has improved from 600ms to 18ms +>> +>> wondering what other implications I might expect. +> +> +> Lots of really bad implications...it's really not a good idea. +> +> Chris +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 9: the planner will ignore your desire to choose an index scan if +> your +> joining column's datatypes do not match +> +> +> + +From pgsql-performance-owner@postgresql.org Wed Apr 21 09:12:19 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 533F0D1DC20 + for ; + Wed, 21 Apr 2004 09:10:56 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 28490-06 + for ; + Wed, 21 Apr 2004 09:10:56 -0300 (ADT) +Received: from mail2.aeccom.com (port-212-202-101-158.reverse.qsc.de + [212.202.101.158]) + by svr1.postgresql.org (Postfix) with ESMTP id A9097D1DC1C + for ; + Wed, 21 Apr 2004 09:10:52 -0300 (ADT) +Received: from aeccom.com (cayambe.core.aeccom.com [192.168.2.12]) + by mail2.aeccom.com (Postfix) with ESMTP + id 5DD3434; Wed, 21 Apr 2004 14:10:55 +0200 (CEST) +Message-ID: <408664CF.9040507@aeccom.com> +Date: Wed, 21 Apr 2004 14:10:55 +0200 +From: =?ISO-8859-1?Q?Dirk_Lutzeb=E4ck?= +Organization: AEC/communications GmbH, Berlin +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031016 +X-Accept-Language: de, en +MIME-Version: 1.0 +To: ohp@pyrenet.fr +Cc: Tom Lane , josh@agliodbs.com, + Joe Conway , "scott.marlowe" , + Bruce Momjian , + pgsql-performance@postgresql.org, Neil Conway +Subject: Re: Wierd context-switching issue on Xeon +References: + <40843E63.7050101@joeconway.com> + <200404191455.04068.josh@agliodbs.com> + <1407.1082419316@sss.pgh.pa.us> + +In-Reply-To: +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/343 +X-Sequence-Number: 6643 + +It is intended to run indefinately. + +Dirk + +ohp@pyrenet.fr wrote: + +>How long is this test supposed to run? +> +>I've launched just 1 for testing, the plan seems horrible; the test is cpu +>bound and hasn't finished yet after 17:02 min of CPU time, dual XEON 2.6G +>Unixware 713 +> +>The machine is a Fujitsu-Siemens TX 200 server +> +> + + + +From pgsql-performance-owner@postgresql.org Wed Apr 21 09:19:21 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 653E6D1DB5C + for ; + Wed, 21 Apr 2004 09:19:18 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 36767-05 + for ; + Wed, 21 Apr 2004 09:19:18 -0300 (ADT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id CA260D1DB23 + for ; + Wed, 21 Apr 2004 09:19:14 -0300 (ADT) +Received: from [134.22.70.203] (dyn-70-203.tor.dsl.tht.net [134.22.70.203]) + by tht.net (Postfix) with ESMTP + id DBA9376AC4; Wed, 21 Apr 2004 08:19:18 -0400 (EDT) +Subject: Re: MySQL vs PG TPC-H benchmarks +From: Rod Taylor +To: Nick Barr +Cc: PgSQL Performance ML +In-Reply-To: <4086316B.4050304@chuckie.co.uk> +References: <4086316B.4050304@chuckie.co.uk> +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="=-3w/jNW2iPKXXKOlc+nq6" +Message-Id: <1082549960.80320.108.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Wed, 21 Apr 2004 08:19:21 -0400 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/344 +X-Sequence-Number: 6644 + +--=-3w/jNW2iPKXXKOlc+nq6 +Content-Type: text/plain +Content-Transfer-Encoding: quoted-printable + +> I realize that MySQL & PG cannot really be compared (especially when you= +=20 +> consider the issues that MySQL has with things like data integrity) but= +=20 +> still surely PG would perform better than the stats show (i.e. #7 31.28= +=20 +> seconds versus 42 minutes!!!). + +We know that PostgreSQL 7.5 will perform much better than 7.4 did due to +the efforts of OSDN and Tom. + +I've enquired as to whether they ran ANALYZE after the data load. They +don't explicitly mention it, and given the mention it took 2.5days to +load 1GB of data, they're not regular PostgreSQL users. + +--=20 +Rod Taylor + +Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL +PGP Key: http://www.rbt.ca/signature.asc + +--=-3w/jNW2iPKXXKOlc+nq6 +Content-Type: application/pgp-signature; name=signature.asc +Content-Description: This is a digitally signed message part + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.4 (FreeBSD) + +iD8DBQBAhmbI6DETLow6vwwRAhRrAJ9/D8zePxGF2h84HiHyMaaf65/2LwCeInjq +OJ+5gmGE3tuldo5Yg5U3hog= +=79aK +-----END PGP SIGNATURE----- + +--=-3w/jNW2iPKXXKOlc+nq6-- + + +From pgsql-performance-owner@postgresql.org Wed Apr 21 09:22:38 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7E6C2D1DA3C + for ; + Wed, 21 Apr 2004 09:22:28 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 36767-07 + for ; + Wed, 21 Apr 2004 09:22:25 -0300 (ADT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0E4DDD1BABF + for ; + Wed, 21 Apr 2004 09:22:22 -0300 (ADT) +Received: from [134.22.70.203] (dyn-70-203.tor.dsl.tht.net [134.22.70.203]) + by tht.net (Postfix) with ESMTP + id 45E3476A11; Wed, 21 Apr 2004 08:22:27 -0400 (EDT) +Subject: Re: MySQL vs PG TPC-H benchmarks +From: Rod Taylor +To: Nick Barr +Cc: PgSQL Performance ML +In-Reply-To: <1082549960.80320.108.camel@jester> +References: <4086316B.4050304@chuckie.co.uk> + <1082549960.80320.108.camel@jester> +Content-Type: text/plain +Message-Id: <1082550148.80320.111.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Wed, 21 Apr 2004 08:22:29 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/345 +X-Sequence-Number: 6645 + +On Wed, 2004-04-21 at 08:19, Rod Taylor wrote: +> > I realize that MySQL & PG cannot really be compared (especially when you +> > consider the issues that MySQL has with things like data integrity) but +> > still surely PG would perform better than the stats show (i.e. #7 31.28 +> > seconds versus 42 minutes!!!). +> +> We know that PostgreSQL 7.5 will perform much better than 7.4 did due to +> the efforts of OSDN and Tom. + +OSDL not OSDN. + +> I've enquired as to whether they ran ANALYZE after the data load. They +> don't explicitly mention it, and given the mention it took 2.5days to +> load 1GB of data, they're not regular PostgreSQL users. + + +From pgsql-performance-owner@postgresql.org Wed Apr 21 09:56:03 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A5EE2D1D2AA + for ; + Wed, 21 Apr 2004 09:55:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 45681-07 + for ; + Wed, 21 Apr 2004 09:55:26 -0300 (ADT) +Received: from anchor-post-35.mail.demon.net (anchor-post-35.mail.demon.net + [194.217.242.85]) + by svr1.postgresql.org (Postfix) with ESMTP id 2AB4DD1D26C + for ; + Wed, 21 Apr 2004 09:55:22 -0300 (ADT) +Received: from tmsl-adsl.demon.co.uk ([80.177.114.181] + helo=bacon.tmsl.demon.co.uk) + by anchor-post-35.mail.demon.net with esmtp (Exim 3.35 #1) + id 1BGHG7-0002yb-0Z; Wed, 21 Apr 2004 13:55:23 +0100 +Date: Wed, 21 Apr 2004 13:55:21 +0100 +From: Paul Thomas +To: Nick Barr +Cc: "pgsql-performance @ postgresql . org" +Subject: Re: MySQL vs PG TPC-H benchmarks +Message-ID: <20040421135521.A23015@bacon> +References: <4086316B.4050304@chuckie.co.uk> +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed; charset=ISO-8859-1 +In-Reply-To: <4086316B.4050304@chuckie.co.uk>; + from nicky@chuckie.co.uk on Wed, Apr 21, 2004 at 09:31:39 +0100 +X-Mailer: Balsa 1.2.3 +Lines: 34 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/346 +X-Sequence-Number: 6646 + + +On 21/04/2004 09:31 Nick Barr wrote: +> Hi, +> +> Has anyone had a look at: +> +> http://people.ac.upc.es/zgomez/ +> +> I realize that MySQL & PG cannot really be compared (especially when you +> consider the issues that MySQL has with things like data integrity) but +> still surely PG would perform better than the stats show (i.e. #7 31.28 +> seconds versus 42 minutes!!!). + +Looks like he's using the default postgresql.conf settings in which case +I'm not suprised at pg looking so slow. His stated use of foreign keys +invalidates the tests anyway as MyISAM tables don't support FKs so we're +probably seeing FK check overheads in pg that are simply ignore by MySQL. +In an honest test, MySQL should be reported as failing those tests. + +Perhaps one of the advocay team will pick up the batton? +> +> On a side note it certainly looks like linux kernel 2.6 is quite a bit +> faster in comparision to 2.4. + +Yes, I've seen other benchmarks which also show that. + +-- +Paul Thomas ++------------------------------+---------------------------------------------+ +| Thomas Micro Systems Limited | Software Solutions for +Business | +| Computer Consultants | +http://www.thomas-micro-systems-ltd.co.uk | ++------------------------------+---------------------------------------------+ + +From pgsql-performance-owner@postgresql.org Wed Apr 21 10:32:03 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0347DD1D2AA + for ; + Wed, 21 Apr 2004 10:31:09 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 57905-09 + for ; + Wed, 21 Apr 2004 10:31:05 -0300 (ADT) +Received: from smtp.casablanca.sk (smtp.casablanca.sk [81.0.239.6]) + by svr1.postgresql.org (Postfix) with ESMTP id 766B4D1D26C + for ; + Wed, 21 Apr 2004 10:31:00 -0300 (ADT) +Received: from omikron.sk (cepr.nustep.sk [81.0.222.49]) + by smtp.casablanca.sk (8.12.9/8.12.9) with SMTP id i3LDXBI3028005 + for ; Wed, 21 Apr 2004 15:33:11 +0200 +Received: (qmail 11404 invoked from network); 21 Apr 2004 13:31:02 -0000 +Received: from unknown (HELO stratos) (158.195.31.19) + by 0 with SMTP; 21 Apr 2004 13:31:02 -0000 +Message-ID: <037701c427a4$e41a38a0$0200a8c0@stratos> +From: "Cestmir Hybl" +To: "Paul Thomas" , + "Nick Barr" +Cc: +References: <4086316B.4050304@chuckie.co.uk> <20040421135521.A23015@bacon> +Subject: Re: MySQL vs PG TPC-H benchmarks +Date: Wed, 21 Apr 2004 15:31:02 +0200 +Organization: NUSTEP s.r.o. +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1158 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/347 +X-Sequence-Number: 6647 + +> Looks like he's using the default postgresql.conf settings in which case +> I'm not suprised at pg looking so slow. + +The question also is, IMHO, why the hell, postgreSQL still comes out of the +box with so stupid configuration defaults, totally underestimated for todays +average hardware configuration (1+GHz, 0.5+GB RAM, fast FSB, fast HDD). + +It seems to me better strategy to force that 1% of users to "downgrade" cfg. +than vice-versa. + +regards +ch + + +From pgsql-performance-owner@postgresql.org Wed Apr 21 11:09:35 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D9931D1DD1F + for ; + Wed, 21 Apr 2004 11:08:13 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 72738-10 + for ; + Wed, 21 Apr 2004 11:08:15 -0300 (ADT) +Received: from anchor-post-33.mail.demon.net (anchor-post-33.mail.demon.net + [194.217.242.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 7F122D1DD1B + for ; + Wed, 21 Apr 2004 11:08:11 -0300 (ADT) +Received: from tmsl-adsl.demon.co.uk ([80.177.114.181] + helo=bacon.tmsl.demon.co.uk) + by anchor-post-33.mail.demon.net with esmtp (Exim 3.35 #1) + id 1BGIOd-0002eN-0X; Wed, 21 Apr 2004 15:08:15 +0100 +Date: Wed, 21 Apr 2004 15:08:09 +0100 +From: Paul Thomas +To: Cestmir Hybl +Cc: pgsql-performance@postgresql.org +Subject: Re: MySQL vs PG TPC-H benchmarks +Message-ID: <20040421150809.C23015@bacon> +References: <4086316B.4050304@chuckie.co.uk> <20040421135521.A23015@bacon> + <037701c427a4$e41a38a0$0200a8c0@stratos> +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed; charset=ISO-8859-1 +In-Reply-To: <037701c427a4$e41a38a0$0200a8c0@stratos>; + from cestmirl@freeside.sk on Wed, Apr 21, 2004 at 14:31:02 +0100 +X-Mailer: Balsa 1.2.3 +Lines: 29 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/348 +X-Sequence-Number: 6648 + +On 21/04/2004 14:31 Cestmir Hybl wrote: +> > Looks like he's using the default postgresql.conf settings in which +> case +> > I'm not suprised at pg looking so slow. +> +> The question also is, IMHO, why the hell, postgreSQL still comes out of +> the +> box with so stupid configuration defaults, totally underestimated for +> todays +> average hardware configuration (1+GHz, 0.5+GB RAM, fast FSB, fast HDD). +> +> It seems to me better strategy to force that 1% of users to "downgrade" +> cfg. +> than vice-versa. +> +> regards +> ch +> + +This has been discussed many times before. Check the archives. + +-- +Paul Thomas ++------------------------------+---------------------------------------------+ +| Thomas Micro Systems Limited | Software Solutions for +Business | +| Computer Consultants | +http://www.thomas-micro-systems-ltd.co.uk | ++------------------------------+---------------------------------------------+ + +From pgsql-performance-owner@postgresql.org Wed Apr 21 11:37:48 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6ABE9D1BB64 + for ; + Wed, 21 Apr 2004 11:31:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 79866-10 + for ; + Wed, 21 Apr 2004 11:31:27 -0300 (ADT) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id 44F9FD1BABD + for ; + Wed, 21 Apr 2004 11:31:23 -0300 (ADT) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id 380D935A6C; Wed, 21 Apr 2004 07:31:27 -0700 (PDT) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id 3672F35A68; Wed, 21 Apr 2004 07:31:27 -0700 (PDT) +Date: Wed, 21 Apr 2004 07:31:27 -0700 (PDT) +From: Stephan Szabo +To: Edoardo Ceccarelli +Cc: Christopher Kings-Lynne , + Nick Barr , pgsql-performance@postgresql.org +Subject: Re: slow seqscan +In-Reply-To: <408641B7.5090808@axa.it> +Message-ID: <20040421072156.K55057@megazone.bigpanda.com> +References: <40862003.2090201@axa.it> <4086272E.2080102@chuckie.co.uk> + <40863228.907@axa.it> <408636A5.2050305@familyhealth.com.au> + <408641B7.5090808@axa.it> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/349 +X-Sequence-Number: 6649 + + +On Wed, 21 Apr 2004, Edoardo Ceccarelli wrote: + +> +> > What happens if you go: +> > +> > CREATE INDEX annuncio400_rubric_testo_idx ON annuncio400(rubric, +> > LOWER(testo)); +> > +> > or even just: +> > +> > CREATE INDEX annuncio400_rubric_testo_idx ON annuncio400(LOWER(testo)); +> > +> I wasn't able to make this 2 field index with lower: +> +> dba400=# CREATE INDEX annuncio400_rubric_testo_idx ON +> annuncio400(rubric, LOWER(testo)); +> ERROR: parser: parse error at or near "(" at character 71 + +That's a 7.4 feature I think (and I think the version with two columns +may need extra parens around the lower()). I think the only way to do +something equivalent in 7.3 is to make a function that concatenates the +two in some fashion after having applied the lower to the one part and +then using that in the queries as well. Plus, if you're not in "C" +locale, I'm not sure that it'd help in 7.3 anyway. + +> >> But the strangest thing ever is that if I change the filter with +> >> another one that represent a smaller amount of data it uses the +> >> index scan!!! +> > +> > +> > What's strange about that? The less data is going to be retrieved, +> > the more likely postgres is to use the index. +> > +> can't understand this policy: +> +> dba400=# SELECT count(*) from annuncio400 where rubric='DD'; +> count +> ------- +> 6753 +> (1 row) +> +> dba400=# SELECT count(*) from annuncio400 where rubric='MA'; +> count +> ------- +> 2165 +> (1 row) +> +> so it's using the index on 2000 rows and not for 6000? it's not that +> big difference, isn't it? + +It's a question of how many pages it thinks it's going to have to retrieve +in order to handle the request. If it say needs (or think it needs) to +retrieve 50% of the pages, then given a random_page_cost of 4, it's going +to expect the index scan to be about twice the cost. + +Generally speaking one good way to compare is to try the query with +explain analyze and then change parameters like enable_seqscan and try the +query with explain analyze again and compare the estimated rows and costs. +That'll give an idea of how it expects the two versions of the query to +compare speed wise. + +From pgsql-performance-owner@postgresql.org Wed Apr 21 12:06:29 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 434EAD1B47D + for ; + Wed, 21 Apr 2004 12:02:48 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 95716-06 + for ; + Wed, 21 Apr 2004 12:02:46 -0300 (ADT) +Received: from net2.micro-automation.com (net2.micro-automation.com + [64.7.141.29]) + by svr1.postgresql.org (Postfix) with SMTP id D702CD1DD93 + for ; + Wed, 21 Apr 2004 12:02:45 -0300 (ADT) +Received: (qmail 9877 invoked from network); 21 Apr 2004 15:02:37 -0000 +Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) + by net2.micro-automation.com with SMTP; 21 Apr 2004 15:02:37 -0000 +Subject: Re: Wierd context-switching issue on Xeon +From: Dave Cramer +Reply-To: pg@fastcrypt.com +To: =?ISO-8859-1?Q?Dirk=5FLutzeb=E4ck?= +Cc: ohp@pyrenet.fr, Tom Lane , + Josh Berkus , Joe Conway , + "scott.marlowe" , + Bruce Momjian , + pgsql-performance@postgresql.org, Neil Conway +In-Reply-To: <408664CF.9040507@aeccom.com> +References: + <40843E63.7050101@joeconway.com> <200404191455.04068.josh@agliodbs.com> + <1407.1082419316@sss.pgh.pa.us> + + <408664CF.9040507@aeccom.com> +Content-Type: text/plain; charset=ISO-8859-1 +Organization: Cramer Consulting +Message-Id: <1082559931.1557.235.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Wed, 21 Apr 2004 11:05:31 -0400 +Content-Transfer-Encoding: 8bit +X-AntiVirus: scanned for viruses by AMaViS 0.2.1 (http://amavis.org/) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, + hits=2.0 tagged_above=0.0 required=5.0 tests=DRASTIC_REDUCED +X-Spam-Level: * +X-Archive-Number: 200404/350 +X-Sequence-Number: 6650 + +After some testing if you use the current head code for s_lock.c which +has some mods in it to alleviate this situation, and change +SPINS_PER_DELAY to 10 you can drastically reduce the cs with tom's test. +I am seeing a slight degradation in throughput using pgbench -c 10 -t +1000 but it might be liveable, considering the alternative is unbearable +in some situations. + +Can anyone else replicate my results? + +Dave +On Wed, 2004-04-21 at 08:10, Dirk_Lutzeb�ck wrote: +> It is intended to run indefinately. +> +> Dirk +> +> ohp@pyrenet.fr wrote: +> +> >How long is this test supposed to run? +> > +> >I've launched just 1 for testing, the plan seems horrible; the test is cpu +> >bound and hasn't finished yet after 17:02 min of CPU time, dual XEON 2.6G +> >Unixware 713 +> > +> >The machine is a Fujitsu-Siemens TX 200 server +> > +> > +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: you can get off all lists at once with the unregister command +> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) +> +> +> +> !DSPAM:40866735106778584283649! +> +> +-- +Dave Cramer +519 939 0336 +ICQ # 14675561 + + +From pgsql-performance-owner@postgresql.org Wed Apr 21 12:46:11 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B9061D1B482 + for ; + Wed, 21 Apr 2004 12:34:21 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 11447-04 + for ; + Wed, 21 Apr 2004 12:34:20 -0300 (ADT) +Received: from mail.astudios.com (unknown [66.49.77.3]) + by svr1.postgresql.org (Postfix) with ESMTP id 4D361D1B47D + for ; + Wed, 21 Apr 2004 12:34:19 -0300 (ADT) +thread-index: AcQntpQqm5wXS2HIRF2GRclnFZOqtg== +Content-Class: urn:content-classes:message +Importance: normal +Received: from [10.4.2.163] ([66.194.26.150]) by mail.astudios.com with + Microsoft SMTPSVC(6.0.3790.0); Wed, 21 Apr 2004 11:37:39 -0400 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.132 +From: "Chris Hoover" +To: +Subject: Help understanding stat tables +Date: Wed, 21 Apr 2004 11:34:16 -0400 +User-Agent: KMail/1.6.1 +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Message-ID: <200404211134.16876.revoohc@sermonaudio.com> +X-OriginalArrivalTime: 21 Apr 2004 15:37:39.0562 (UTC) + FILETIME=[941C24A0:01C427B6] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/351 +X-Sequence-Number: 6651 + +I just want to make sure that I am interpreting this data correctly. + +=46rom pg_statio_user_tables, I have pulled relname, heap_blks_read,=20 +heap_blks_hit. I get several rows like this: +relname heap_bkls_read heap_blks_hit + clmhdr 8607161 196547165=09=09=09=09=09=09=09=09= +=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09= +=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09= +=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09= +=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09= +=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09= +=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09= +=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09= +=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09= +=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09= +=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09 + + +So this means that I am getting over a 100% cache hit ratio for this table,= +=20 +right? If not, please help me understand what these numbers mean. + +Thanks, + +Chris + + +From pgsql-performance-owner@postgresql.org Wed Apr 21 13:42:36 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 43E9FD1BA8F + for ; + Wed, 21 Apr 2004 13:23:27 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 25305-07 + for ; + Wed, 21 Apr 2004 13:23:23 -0300 (ADT) +Received: from smtp1.aruba.it (smtp1.aruba.it [62.149.128.200]) + by svr1.postgresql.org (Postfix) with SMTP id 75B59D1DF75 + for ; + Wed, 21 Apr 2004 13:23:22 -0300 (ADT) +Received: (qmail 14567 invoked from network); 21 Apr 2004 16:23:10 -0000 +Received: from unknown (HELO axa.it) (80.183.237.70) + by smtp1.aruba.it with SMTP; 21 Apr 2004 16:23:10 -0000 +Message-ID: <40869FF0.6090100@axa.it> +Date: Wed, 21 Apr 2004 18:23:12 +0200 +From: Edoardo Ceccarelli +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: it, en, en-us +MIME-Version: 1.0 +To: Stephan Szabo +Cc: Christopher Kings-Lynne , + Nick Barr , pgsql-performance@postgresql.org +Subject: Re: slow seqscan +References: <40862003.2090201@axa.it> <4086272E.2080102@chuckie.co.uk> + <40863228.907@axa.it> <408636A5.2050305@familyhealth.com.au> + <408641B7.5090808@axa.it> + <20040421072156.K55057@megazone.bigpanda.com> +In-Reply-To: <20040421072156.K55057@megazone.bigpanda.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Spam-Rating: smtp1.aruba.it 1.6.2 0/1000/N +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=RCVD_IN_NJABL, + RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200404/354 +X-Sequence-Number: 6654 + + +>>can't understand this policy: +>> +>>dba400=# SELECT count(*) from annuncio400 where rubric='DD'; +>> count +>>------- +>> 6753 +>>(1 row) +>> +>>dba400=# SELECT count(*) from annuncio400 where rubric='MA'; +>> count +>>------- +>> 2165 +>>(1 row) +>> +>>so it's using the index on 2000 rows and not for 6000? it's not that +>>big difference, isn't it? +>> +>> +> +>It's a question of how many pages it thinks it's going to have to retrieve +>in order to handle the request. If it say needs (or think it needs) to +>retrieve 50% of the pages, then given a random_page_cost of 4, it's going +>to expect the index scan to be about twice the cost. +> +>Generally speaking one good way to compare is to try the query with +>explain analyze and then change parameters like enable_seqscan and try the +>query with explain analyze again and compare the estimated rows and costs. +>That'll give an idea of how it expects the two versions of the query to +>compare speed wise. +> +> +> +> +Ok then how do you explain this? +just created a copy of the same database + +Slow seqscan query executed on dba400 + +dba400=# explain analyze SELECT *, oid FROM annuncio400 WHERE rubric = +'DD' AND LOWER(testo) Like LOWER('cbr%') OFFSET 0 LIMIT 11; + QUERY +PLAN +-------------------------------------------------------------------------------------------------------------------- + +Limit (cost=0.00..3116.00 rows=11 width=546) (actual time=46.66..51.40 +rows=11 loops=1) + -> Seq Scan on annuncio400 (cost=0.00..35490.60 rows=125 width=546) +(actual time=46.66..51.38 rows=12 loops=1) + Filter: ((rubric = 'DD'::bpchar) AND (lower((testo)::text) ~~ +'cbr%'::text)) +Total runtime: 51.46 msec +(4 rows) + + +fastest index scan query on dba400b (exact copy of dba400) + + +dba400b=# explain analyze SELECT *, oid FROM annuncio400 WHERE rubric = +'DD' AND LOWER(testo) Like LOWER('cbr%') OFFSET 0 LIMIT 11; + QUERY +PLAN +------------------------------------------------------------------------------------------------------------------------------ + +Limit (cost=0.00..7058.40 rows=9 width=546) (actual time=1.36..8.18 +rows=11 loops=1) + -> Index Scan using rubric on annuncio400 (cost=0.00..7369.42 rows=9 +width=546) (actual time=1.35..8.15 rows=12 loops=1) + Index Cond: (rubric = 'DD'::bpchar) + Filter: (lower((testo)::text) ~~ 'cbr%'::text) +Total runtime: 8.28 msec +(5 rows) + + +anyway, shall I try to lower the random_page value since I get an index +scan? I mean that in my case I've already noted that with index scan +that query get executed in 1/10 of the seqscan speed. + +Thank you +Edoardo + +From pgsql-performance-owner@postgresql.org Wed Apr 21 13:42:04 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1BB4AD1DF5D + for ; + Wed, 21 Apr 2004 13:25:33 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 25457-06 + for ; + Wed, 21 Apr 2004 13:25:31 -0300 (ADT) +Received: from mail.astudios.com (unknown [66.49.77.3]) + by svr1.postgresql.org (Postfix) with ESMTP id A77CCD1BAA2 + for ; + Wed, 21 Apr 2004 13:25:00 -0300 (ADT) +thread-index: AcQnvZuLnERkrY/KQWur/4uiE99PJA== +Received: from [10.4.2.163] ([66.194.26.150]) by mail.astudios.com with + Microsoft SMTPSVC(6.0.3790.0); Wed, 21 Apr 2004 12:27:58 -0400 +Content-Class: urn:content-classes:message +Importance: normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.132 +From: "Chris Hoover" +To: +Subject: Re: Help understanding stat tables +Date: Wed, 21 Apr 2004 12:24:35 -0400 +User-Agent: KMail/1.6.1 +References: <200404211134.16876.revoohc@sermonaudio.com> +In-Reply-To: <200404211134.16876.revoohc@sermonaudio.com> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Message-ID: <200404211224.35696.revoohc@sermonaudio.com> +X-OriginalArrivalTime: 21 Apr 2004 16:27:58.0437 (UTC) + FILETIME=[9B7FE950:01C427BD] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/353 +X-Sequence-Number: 6653 + +I think I have figured my problem out. + +I was taking heap_blks_hit / heap_blks_read for my hit pct. + +It should be heap_blks_hit/(heap_blks_read+heap_blks_hit), correct? + +Thanks +On Wednesday 21 April 2004 11:34, Chris Hoover wrote: +> I just want to make sure that I am interpreting this data correctly. +> +> From pg_statio_user_tables, I have pulled relname, heap_blks_read, +> heap_blks_hit. I get several rows like this: +> relname heap_bkls_read heap_blks_hit +> clmhdr 8607161 196547165 +> +> +> So this means that I am getting over a 100% cache hit ratio for this tabl= +e, +> right? If not, please help me understand what these numbers mean. +> +> Thanks, +> +> Chris +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 3: if posting/reading through Usenet, please send an appropriate +> subscribe-nomail command to majordomo@postgresql.org so that your +> message can get through to the mailing list cleanly + + +From pgsql-performance-owner@postgresql.org Wed Apr 21 13:35:48 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0C062D1BAA2 + for ; + Wed, 21 Apr 2004 13:29:13 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 28269-08 + for ; + Wed, 21 Apr 2004 13:29:10 -0300 (ADT) +Received: from gin.mims.be (gin.mims.be [217.145.39.2]) + by svr1.postgresql.org (Postfix) with SMTP id 659AFD1B4C3 + for ; + Wed, 21 Apr 2004 13:29:08 -0300 (ADT) +Received: (qmail 50561 invoked from network); 21 Apr 2004 16:29:05 -0000 +Received: from localhost by gin.mims.be (uid 82) with SMTP (mims-scanner-1.3, + 0.378714 s); 21 Apr 2004 16:29:05 -0000 +Received: from 213-193-172-189.adsl.easynet.be (HELO frmims) (213.193.172.189) + by gin.mims.be with SMTP; 21 Apr 2004 16:29:05 -0000 +Message-ID: <009901c427bd$c4752410$c601a8c0@MIMS> +From: =?iso-8859-1?Q?Fr=E9d=E9ric_Robinet?= +To: +Subject: Shared buffers, Sort memory, Effective Cache Size +Date: Wed, 21 Apr 2004 18:29:06 +0200 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 8bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1409 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 +X-Virus-Flag: NO +X-Virus-Scanner: F-Prot v4.4.1 (engine v3.14.11) +X-Virus-Definitions: SIGN.DEF (21 April 2004), SIGN2.DEF (21 April 2004), + MACRO.DEF (21 April 2004) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/352 +X-Sequence-Number: 6652 + +Hello, + +I have a bi-PIII server with 2Gb of RAM with Debian and a PostgreSQL 7.4 +running on. What are the bests settings for shared buffers, sort memory and +effective cache size? + +My main database have a small/mid range size: some tables may have 1 or 2 +millions of records. + +Thanks + +Fr�d�ric Robinet +Fr@Mims.be + + +From pgsql-performance-owner@postgresql.org Mon Apr 26 14:47:13 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 719D7D1E029 + for ; + Wed, 21 Apr 2004 14:01:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 41794-04 + for ; + Wed, 21 Apr 2004 14:01:33 -0300 (ADT) +Received: from leo.supplyfx.com (adsl-67-119-155-141.dsl.lsan03.pacbell.net + [67.119.155.141]) + by svr1.postgresql.org (Postfix) with ESMTP id 8D0A9D1DFA1 + for ; + Wed, 21 Apr 2004 14:01:32 -0300 (ADT) +Received: from [10.0.100.21] (leo6.supplyfx.com [10.0.100.21]) + by leo.supplyfx.com (Postfix) with ESMTP + id 7037E330BC; Wed, 21 Apr 2004 10:01:32 -0700 (PDT) +In-Reply-To: <009901c427bd$c4752410$c601a8c0@MIMS> +References: <009901c427bd$c4752410$c601a8c0@MIMS> +Mime-Version: 1.0 (Apple Message framework v613) +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Message-Id: <8937BC90-93B5-11D8-AC12-000A95AB8896@supplyfx.com> +Content-Transfer-Encoding: quoted-printable +Cc: +From: Qing Zhao +Subject: Re: Shared buffers, Sort memory, Effective Cache Size +Date: Wed, 21 Apr 2004 10:01:30 -0700 +To: =?ISO-8859-1?Q?Fr=E9d=E9ric_Robinet?= +X-Mailer: Apple Mail (2.613) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=2.6 tagged_above=0.0 required=5.0 + tests=RCVD_IN_DYNABLOCK, RCVD_IN_SORBS +X-Spam-Level: ** +X-Archive-Number: 200404/439 +X-Sequence-Number: 6739 + +Hello, + +I have recently configured my PG7.3 on a G5 (8GB RAM) with +shmmax set to 512MB and shared_buffer=3D50000, sort_mem=3D4096 +and effective cache size =3D 10000. It seems working great so far but +I am wondering if I should make effctive cache size larger myself. + +Tnaks! + +Qing +On Apr 21, 2004, at 9:29 AM, Fr=E9d=E9ric Robinet wrote: + +> Hello, +> +> I have a bi-PIII server with 2Gb of RAM with Debian and a PostgreSQL=20 +> 7.4 +> running on. What are the bests settings for shared buffers, sort=20 +> memory and +> effective cache size? +> +> My main database have a small/mid range size: some tables may have 1=20 +> or 2 +> millions of records. +> +> Thanks +> +> Fr=E9d=E9ric Robinet +> Fr@Mims.be +> +> +> ---------------------------(end of=20 +> broadcast)--------------------------- +> TIP 4: Don't 'kill -9' the postmaster +> + + +From pgsql-performance-owner@postgresql.org Wed Apr 21 14:30:25 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D4664D1BABD + for ; + Wed, 21 Apr 2004 14:30:19 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 51908-03 + for ; + Wed, 21 Apr 2004 14:30:13 -0300 (ADT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 09197D1BA6C + for ; + Wed, 21 Apr 2004 14:30:11 -0300 (ADT) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4915415; Wed, 21 Apr 2004 10:31:33 -0700 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: pg@fastcrypt.com, =?iso-8859-1?q?Dirk=5FLutzeb=E4ck?= +Subject: Re: Wierd context-switching issue on Xeon +Date: Wed, 21 Apr 2004 10:29:43 -0700 +User-Agent: KMail/1.4.3 +Cc: ohp@pyrenet.fr, Tom Lane , + Joe Conway , "scott.marlowe" , + Bruce Momjian , + pgsql-performance@postgresql.org, Neil Conway +References: + <408664CF.9040507@aeccom.com> + <1082559931.1557.235.camel@localhost.localdomain> +In-Reply-To: <1082559931.1557.235.camel@localhost.localdomain> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200404211029.43675.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, + hits=2.0 tagged_above=0.0 required=5.0 tests=DRASTIC_REDUCED +X-Spam-Level: * +X-Archive-Number: 200404/355 +X-Sequence-Number: 6655 + +Dave, + +> After some testing if you use the current head code for s_lock.c which +> has some mods in it to alleviate this situation, and change +> SPINS_PER_DELAY to 10 you can drastically reduce the cs with tom's test. +> I am seeing a slight degradation in throughput using pgbench -c 10 -t +> 1000 but it might be liveable, considering the alternative is unbearable +> in some situations. +> +> Can anyone else replicate my results? + +Can you produce a patch against 7.4.1? I'd like to test your fix against a +real-world database. + + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-advocacy-owner@postgresql.org Wed Apr 21 14:32:00 2004 +X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A8F0CD1BABA + for ; + Wed, 21 Apr 2004 14:31:59 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 47883-10 + for ; + Wed, 21 Apr 2004 14:31:58 -0300 (ADT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id E4C9AD1BA6C + for ; + Wed, 21 Apr 2004 14:31:56 -0300 (ADT) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4915417 for pgsql-advocacy@postgresql.org; + Wed, 21 Apr 2004 10:33:20 -0700 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +Subject: Fwd: Re: [PERFORM] MySQL vs PG TPC-H benchmarks +Date: Wed, 21 Apr 2004 10:31:31 -0700 +User-Agent: KMail/1.4.3 +To: pgsql-advocacy@postgresql.org +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200404211031.31007.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/111 +X-Sequence-Number: 4083 + + + +---------- Forwarded Message ---------- + +Subject: Re: [PERFORM] MySQL vs PG TPC-H benchmarks +Date: Wed, 21 Apr 2004 13:55:21 +0100 +From: Paul Thomas +To: Nick Barr +Cc: "pgsql-performance @ postgresql . org" + +On 21/04/2004 09:31 Nick Barr wrote: +> Hi, +> +> Has anyone had a look at: +> +> http://people.ac.upc.es/zgomez/ +> +> I realize that MySQL & PG cannot really be compared (especially when you +> consider the issues that MySQL has with things like data integrity) but +> still surely PG would perform better than the stats show (i.e. #7 31.28 +> seconds versus 42 minutes!!!). + +Looks like he's using the default postgresql.conf settings in which case +I'm not suprised at pg looking so slow. His stated use of foreign keys +invalidates the tests anyway as MyISAM tables don't support FKs so we're +probably seeing FK check overheads in pg that are simply ignore by MySQL. +In an honest test, MySQL should be reported as failing those tests. + +Perhaps one of the advocay team will pick up the batton? + +> On a side note it certainly looks like linux kernel 2.6 is quite a bit +> faster in comparision to 2.4. + +Yes, I've seen other benchmarks which also show that. + +-- +Paul Thomas ++------------------------------+--------------------------------------------- ++ + +| Thomas Micro Systems Limited | Software Solutions for + +Business | + +| Computer Consultants | + +http://www.thomas-micro-systems-ltd.co.uk | ++------------------------------+--------------------------------------------- ++ + +---------------------------(end of broadcast)--------------------------- +TIP 2: you can get off all lists at once with the unregister command + (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) + +------------------------------------------------------- + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-advocacy-owner@postgresql.org Wed Apr 21 14:47:37 2004 +X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id D304BD1BA6C; Wed, 21 Apr 2004 14:47:31 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 55141-10; Wed, 21 Apr 2004 14:47:31 -0300 (ADT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP + id C8F26D1B52F; Wed, 21 Apr 2004 14:47:29 -0300 (ADT) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4915510; Wed, 21 Apr 2004 10:48:53 -0700 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: pgsql-advocacy@postgresql.org +Subject: Re: [PERFORM] MySQL vs PG TPC-H benchmarks +Date: Wed, 21 Apr 2004 10:47:03 -0700 +User-Agent: KMail/1.4.3 +References: <200404211031.31007.josh@agliodbs.com> +In-Reply-To: <200404211031.31007.josh@agliodbs.com> +Cc: pgsql-performance@postgreSQL.org +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200404211047.03808.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/112 +X-Sequence-Number: 4084 + +Folks, + +I've sent a polite e-mail to Mr. Gomez offering our help. Please, nobody +flame him! + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Wed Apr 21 15:19:59 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id CBA9CD1CCD5 + for ; + Wed, 21 Apr 2004 15:19:52 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 73995-03 + for ; + Wed, 21 Apr 2004 15:19:47 -0300 (ADT) +Received: from monsoon.he.net (monsoon.he.net [64.62.221.2]) + by svr1.postgresql.org (Postfix) with SMTP id A1FC6D1D10E + for ; + Wed, 21 Apr 2004 15:19:45 -0300 (ADT) +Received: from [10.244.45.7] ([216.113.168.128]) by monsoon.he.net for + ; Wed, 21 Apr 2004 11:19:42 -0700 +In-Reply-To: <1082515263.1558.214.camel@localhost.localdomain> +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78509814A@vt-pe2550-001.vantage.vantage.com> + <200404200959.52813.josh@agliodbs.com> + <1082515263.1558.214.camel@localhost.localdomain> +Mime-Version: 1.0 (Apple Message framework v613) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <78427208-93C0-11D8-BA67-000393BD6C3E@tuckfield.com> +Content-Transfer-Encoding: 7bit +Cc: Anjan Dave , Josh Berkus , + Neil Conway , + =?ISO-8859-1?Q?Dirk_Lutzeb=E4ck?= , + pgsql-performance@postgresql.org, Tom Lane +From: Paul Tuckfield +Subject: Re: Wierd context-switching issue on Xeon +Date: Wed, 21 Apr 2004 11:19:46 -0700 +To: pg@fastcrypt.com +X-Mailer: Apple Mail (2.613) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/357 +X-Sequence-Number: 6657 + +Dave: + +Why would test and set increase context swtches: +Note that it *does not increase* context swtiches when the two threads +are on the two cores of a single Xeon processor. (use taskset to force +affinity on linux) + +Scenario: +If the two test and set processes are testing and setting the same bit +as each other, then they'll see worst case cache coherency misses. +They'll ping a cache line back and forth between CPUs. Another case, +might be that they're tesing and setting different bits or words, but +those bits or words are always in the same cache line, again causing +worst case cache coherency and misses. The fact that tis doesn't +happen when the threads are bound to the 2 cores of a single Xeon +suggests it's because they're now sharing L1 cache. No pings/bounces. + + +I wonder do the threads stall so badly when pinging cache lines back +and forth, that the kernel sees it as an opportunity to put the +process to sleep? or do these worst case misses cause an interrupt? + +My question is: What is it that the two threads waiting for when they +spin? Is it exactly the same resource, or two resources that happen to +have test-and-set flags in the same cache line? + +On Apr 20, 2004, at 7:41 PM, Dave Cramer wrote: + +> I modified the code in s_lock.c to remove the spins +> +> #define SPINS_PER_DELAY 1 +> +> and it doesn't exhibit the behaviour +> +> This effectively changes the code to +> +> +> while(TAS(lock)) +> select(10000); // 10ms +> +> Can anyone explain why executing TAS 100 times would increase context +> switches ? +> +> Dave +> +> +> On Tue, 2004-04-20 at 12:59, Josh Berkus wrote: +>> Anjan, +>> +>>> Quad 2.0GHz XEON with highest load we have seen on the applications, +>>> DB +>>> performing great - +>> +>> Can you run Tom's test? It takes a particular pattern of data +>> access to +>> reproduce the issue. +> -- +> Dave Cramer +> 519 939 0336 +> ICQ # 14675561 +> +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 8: explain analyze is your friend +> + + +From pgsql-performance-owner@postgresql.org Wed Apr 21 15:20:49 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9890FD1B967 + for ; + Wed, 21 Apr 2004 15:20:38 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 74453-05 + for ; + Wed, 21 Apr 2004 15:20:36 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id C4979D1D085 + for ; + Wed, 21 Apr 2004 15:20:33 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3LIKP1v013306; + Wed, 21 Apr 2004 14:20:25 -0400 (EDT) +To: Edoardo Ceccarelli +Cc: Christopher Kings-Lynne , + Nick Barr , pgsql-performance@postgresql.org +Subject: Re: slow seqscan +In-reply-to: <408641B7.5090808@axa.it> +References: <40862003.2090201@axa.it> <4086272E.2080102@chuckie.co.uk> + <40863228.907@axa.it> <408636A5.2050305@familyhealth.com.au> + <408641B7.5090808@axa.it> +Comments: In-reply-to Edoardo Ceccarelli + message dated "Wed, 21 Apr 2004 11:41:11 +0200" +Date: Wed, 21 Apr 2004 14:20:25 -0400 +Message-ID: <13305.1082571625@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/358 +X-Sequence-Number: 6658 + +Edoardo Ceccarelli writes: +> I wasn't able to make this 2 field index with lower: + +> dba400=# CREATE INDEX annuncio400_rubric_testo_idx ON +> annuncio400(rubric, LOWER(testo)); +> ERROR: parser: parse error at or near "(" at character 71 + +> seems impossible to creat 2 field indexes with lower function. + +You need 7.4 to do that; previous releases don't support multi-column +functional indexes. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Apr 21 15:51:43 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 44F0FD1D2AA + for ; + Wed, 21 Apr 2004 15:51:37 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 82348-09 + for ; + Wed, 21 Apr 2004 15:51:36 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 53100D1D26C + for ; + Wed, 21 Apr 2004 15:51:34 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3LIpV4g014265; + Wed, 21 Apr 2004 14:51:31 -0400 (EDT) +To: Paul Tuckfield +Cc: pg@fastcrypt.com, Anjan Dave , + Josh Berkus , Neil Conway , + =?ISO-8859-1?Q?Dirk_Lutzeb=E4ck?= , + pgsql-performance@postgresql.org +Subject: Re: Wierd context-switching issue on Xeon +In-reply-to: <78427208-93C0-11D8-BA67-000393BD6C3E@tuckfield.com> +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78509814A@vt-pe2550-001.vantage.vantage.com> + <200404200959.52813.josh@agliodbs.com> + <1082515263.1558.214.camel@localhost.localdomain> + <78427208-93C0-11D8-BA67-000393BD6C3E@tuckfield.com> +Comments: In-reply-to Paul Tuckfield + message dated "Wed, 21 Apr 2004 11:19:46 -0700" +Date: Wed, 21 Apr 2004 14:51:31 -0400 +Message-ID: <14264.1082573491@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/359 +X-Sequence-Number: 6659 + +Paul Tuckfield writes: +> I wonder do the threads stall so badly when pinging cache lines back +> and forth, that the kernel sees it as an opportunity to put the +> process to sleep? or do these worst case misses cause an interrupt? + +No; AFAICS the kernel could not even be aware of that behavior. + +The context swap storm is happening because of contention at the next +level up (LWLocks rather than spinlocks). It could be an independent +issue that just happens to be triggered by the same sort of access +pattern. I put forward a hypothesis that the cache miss storm caused by +the test-and-set ops induces the context swap storm by making the code +more likely to be executing in certain places at certain times ... but +it's only a hypothesis. + +Yesterday evening I had pretty well convinced myself that they were +indeed independent issues: profiling on a single-CPU machine was telling +me that the test case I proposed spends over 10% of its time inside +ReadBuffer, which certainly seems like enough to explain a high rate of +contention on the BufMgrLock, without any assumptions about funny +behavior at the hardware level. However, your report and Dave's suggest +that there really is some linkage. So I'm still confused. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Apr 21 15:57:30 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 77CA2D1D26A + for ; + Wed, 21 Apr 2004 15:57:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 83545-10 + for ; + Wed, 21 Apr 2004 15:57:25 -0300 (ADT) +Received: from outbound.mailhop.org (outbound.mailhop.org [63.208.196.171]) + by svr1.postgresql.org (Postfix) with ESMTP id B08E9D1D263 + for ; + Wed, 21 Apr 2004 15:57:23 -0300 (ADT) +Received: from ool-4353b51a.dyn.optonline.net ([67.83.181.26] helo=zeut.net) + by outbound.mailhop.org with asmtp (Exim 4.20) + id 1BGMuL-0006K9-K8; Wed, 21 Apr 2004 14:57:17 -0400 +Message-ID: <4086C40C.5020703@zeut.net> +Date: Wed, 21 Apr 2004 14:57:16 -0400 +From: "Matthew T. O'Connor" +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Paul Thomas +Cc: Nick Barr , "pgsql-performance @ postgresql . org" + +Subject: Re: MySQL vs PG TPC-H benchmarks +References: <4086316B.4050304@chuckie.co.uk> <20040421135521.A23015@bacon> +In-Reply-To: <20040421135521.A23015@bacon> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Mail-Handler: MailHop Outbound by DynDNS.org +X-Report-Abuse-To: abuse@dyndns.org +X-MHO-User: zeut +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=RCVD_IN_NJABL, + RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200404/360 +X-Sequence-Number: 6660 + +Paul Thomas wrote: + +> Looks like he's using the default postgresql.conf settings in which +> case I'm not suprised at pg looking so slow. His stated use of foreign +> keys invalidates the tests anyway as MyISAM tables don't support FKs +> so we're probably seeing FK check overheads in pg that are simply +> ignore by MySQL. In an honest test, MySQL should be reported as +> failing those tests. + + +Either failures, or they should not have been using MyISAM, they should +have used the table format that supports FK's. This is just not apples +to apples. + + + +From pgsql-performance-owner@postgresql.org Wed Apr 21 16:09:19 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1270BD1D263 + for ; + Wed, 21 Apr 2004 16:04:52 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 84383-10 + for ; + Wed, 21 Apr 2004 16:04:52 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 210D1D1BABF + for ; + Wed, 21 Apr 2004 16:04:50 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3LJ4pxi014420; + Wed, 21 Apr 2004 15:04:51 -0400 (EDT) +To: "Chris Hoover" +Cc: pgsql-performance@postgresql.org +Subject: Re: Help understanding stat tables +In-reply-to: <200404211224.35696.revoohc@sermonaudio.com> +References: <200404211134.16876.revoohc@sermonaudio.com> + <200404211224.35696.revoohc@sermonaudio.com> +Comments: In-reply-to "Chris Hoover" + message dated "Wed, 21 Apr 2004 12:24:35 -0400" +Date: Wed, 21 Apr 2004 15:04:50 -0400 +Message-ID: <14419.1082574290@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/361 +X-Sequence-Number: 6661 + +"Chris Hoover" writes: +> I was taking heap_blks_hit / heap_blks_read for my hit pct. +> It should be heap_blks_hit/(heap_blks_read+heap_blks_hit), correct? + +Right. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Apr 21 16:13:54 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id AEE2ED1D290 + for ; + Wed, 21 Apr 2004 16:10:42 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 93929-04 + for ; + Wed, 21 Apr 2004 16:10:41 -0300 (ADT) +Received: from net2.micro-automation.com (net2.micro-automation.com + [64.7.141.29]) + by svr1.postgresql.org (Postfix) with SMTP id 11398D1D238 + for ; + Wed, 21 Apr 2004 16:10:39 -0300 (ADT) +Received: (qmail 28183 invoked from network); 21 Apr 2004 19:10:33 -0000 +Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) + by net2.micro-automation.com with SMTP; 21 Apr 2004 19:10:33 -0000 +Subject: Re: Wierd context-switching issue on Xeon +From: Dave Cramer +Reply-To: pg@fastcrypt.com +To: Paul Tuckfield +Cc: Anjan Dave , Josh Berkus , + Neil Conway , + Dirk =?ISO-8859-1?Q?Lutzeb=E4ck?= , + pgsql-performance@postgresql.org, Tom Lane +In-Reply-To: <78427208-93C0-11D8-BA67-000393BD6C3E@tuckfield.com> +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78509814A@vt-pe2550-001.vantage.vantage.com> + <200404200959.52813.josh@agliodbs.com> + <1082515263.1558.214.camel@localhost.localdomain> + <78427208-93C0-11D8-BA67-000393BD6C3E@tuckfield.com> +Content-Type: text/plain +Organization: Cramer Consulting +Message-Id: <1082574808.1558.243.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Wed, 21 Apr 2004 15:13:28 -0400 +Content-Transfer-Encoding: 7bit +X-AntiVirus: scanned for viruses by AMaViS 0.2.1 (http://amavis.org/) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/362 +X-Sequence-Number: 6662 + +FYI, + +I am doing my testing on non hyperthreading dual athlons. + +Also, the test and set is attempting to set the same resource, and not +simply a bit. It's really an lock;xchg in assemblelr. + +Also we are using the PAUSE mnemonic, so we should not be seeing any +cache coherency issues, as the cache is being taken out of the picture +AFAICS ? + +Dave + +On Wed, 2004-04-21 at 14:19, Paul Tuckfield wrote: +> Dave: +> +> Why would test and set increase context swtches: +> Note that it *does not increase* context swtiches when the two threads +> are on the two cores of a single Xeon processor. (use taskset to force +> affinity on linux) +> +> Scenario: +> If the two test and set processes are testing and setting the same bit +> as each other, then they'll see worst case cache coherency misses. +> They'll ping a cache line back and forth between CPUs. Another case, +> might be that they're tesing and setting different bits or words, but +> those bits or words are always in the same cache line, again causing +> worst case cache coherency and misses. The fact that tis doesn't +> happen when the threads are bound to the 2 cores of a single Xeon +> suggests it's because they're now sharing L1 cache. No pings/bounces. +> +> +> I wonder do the threads stall so badly when pinging cache lines back +> and forth, that the kernel sees it as an opportunity to put the +> process to sleep? or do these worst case misses cause an interrupt? +> +> My question is: What is it that the two threads waiting for when they +> spin? Is it exactly the same resource, or two resources that happen to +> have test-and-set flags in the same cache line? +> +> On Apr 20, 2004, at 7:41 PM, Dave Cramer wrote: +> +> > I modified the code in s_lock.c to remove the spins +> > +> > #define SPINS_PER_DELAY 1 +> > +> > and it doesn't exhibit the behaviour +> > +> > This effectively changes the code to +> > +> > +> > while(TAS(lock)) +> > select(10000); // 10ms +> > +> > Can anyone explain why executing TAS 100 times would increase context +> > switches ? +> > +> > Dave +> > +> > +> > On Tue, 2004-04-20 at 12:59, Josh Berkus wrote: +> >> Anjan, +> >> +> >>> Quad 2.0GHz XEON with highest load we have seen on the applications, +> >>> DB +> >>> performing great - +> >> +> >> Can you run Tom's test? It takes a particular pattern of data +> >> access to +> >> reproduce the issue. +> > -- +> > Dave Cramer +> > 519 939 0336 +> > ICQ # 14675561 +> > +> > +> > ---------------------------(end of +> > broadcast)--------------------------- +> > TIP 8: explain analyze is your friend +> > +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 9: the planner will ignore your desire to choose an index scan if your +> joining column's datatypes do not match +> +> +> +> !DSPAM:4086c4d0263544680737483! +> +> +-- +Dave Cramer +519 939 0336 +ICQ # 14675561 + + +From pgsql-advocacy-owner@postgresql.org Wed Apr 21 16:39:05 2004 +X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id AD29AD1DA3C + for ; + Wed, 21 Apr 2004 16:38:57 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 01561-04 + for ; + Wed, 21 Apr 2004 16:38:57 -0300 (ADT) +Received: from smtp016.mail.yahoo.com (smtp016.mail.yahoo.com + [216.136.174.113]) + by svr1.postgresql.org (Postfix) with SMTP id DD163D1D614 + for ; + Wed, 21 Apr 2004 16:38:53 -0300 (ADT) +Received: from unknown (HELO europa.janwieck.net) (janwieck@68.80.245.191 with + login) + by smtp016.mail.yahoo.com with SMTP; 21 Apr 2004 19:38:54 -0000 +Received: from Yahoo.com (ismtp.afilias.com [216.217.55.254]) (authenticated) + by europa.janwieck.net (8.11.6/8.11.6) with ESMTP id i3LJcrj11150; + Wed, 21 Apr 2004 15:38:53 -0400 +Message-ID: <4086CDC7.5000204@Yahoo.com> +Date: Wed, 21 Apr 2004 15:38:47 -0400 +From: Jan Wieck +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.4) Gecko/20030624 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Josh Berkus +Cc: pgsql-advocacy@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: [PERFORM] MySQL vs PG TPC-H benchmarks +References: <200404211031.31007.josh@agliodbs.com> + <200404211047.03808.josh@agliodbs.com> +In-Reply-To: <200404211047.03808.josh@agliodbs.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=2.6 tagged_above=0.0 required=5.0 + tests=RCVD_IN_DYNABLOCK, RCVD_IN_SORBS +X-Spam-Level: ** +X-Archive-Number: 200404/114 +X-Sequence-Number: 4086 + +Josh Berkus wrote: + +> Folks, +> +> I've sent a polite e-mail to Mr. Gomez offering our help. Please, nobody +> flame him! +> + +Please keep in mind that the entire test has, other than a similar +database schema and query types maybe, nothing to do with a TPC-H. I +don't see any kind of SUT. Foreign key support on the DB level is not +required by any of the TPC benchmarks. But the System Under Test, which +is the combination of middleware application and database together with +all computers and network components these parts are running on, must +implement all the required semantics, like ACID properties, referential +integrity &c. One could implement a TPC-H with flat files, it's just a +major pain in the middleware. + +A proper TPC benchmark implementation would for example be a complete +PHP+DB application, where the user interaction is done by an emulated +"browser" and what is measured is the http response times, not anything +going on between PHP and the DB. Assuming that all requirements of the +TPC specification are implemented by either using available DB features, +or including appropriate workarounds in the PHP code, that would very +well lead to something that can compare PHP+MySQL vs. PHP+PostgreSQL. + +All TPC benchmarks I have seen are performed by timing such a system +after a considerable rampup time, giving the DB system a chance to +properly populate caches and so forth. Rebooting the machine just before +the test is the wrong thing here and will especially kill any advanced +cache algorithms like ARC. + + +Jan + +-- +#======================================================================# +# It's easier to get forgiveness for being wrong than for being right. # +# Let's break this rule - forgive me. # +#================================================== JanWieck@Yahoo.com # + + +From pgsql-performance-owner@postgresql.org Wed Apr 21 17:47:02 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 630E5D1DA3C + for ; + Wed, 21 Apr 2004 17:47:00 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 31545-05 + for ; + Wed, 21 Apr 2004 17:46:59 -0300 (ADT) +Received: from net2.micro-automation.com (net2.micro-automation.com + [64.7.141.29]) + by svr1.postgresql.org (Postfix) with SMTP id 72A8BD1D8BF + for ; + Wed, 21 Apr 2004 17:46:57 -0300 (ADT) +Received: (qmail 22072 invoked from network); 21 Apr 2004 20:46:51 -0000 +Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) + by net2.micro-automation.com with SMTP; 21 Apr 2004 20:46:51 -0000 +Subject: Re: Wierd context-switching issue on Xeon patch for 7.4.1 +From: Dave Cramer +Reply-To: pg@fastcrypt.com +To: Paul Tuckfield +Cc: Anjan Dave , Josh Berkus , + Neil Conway , + Dirk =?ISO-8859-1?Q?Lutzeb=E4ck?= , + pgsql-performance@postgresql.org, Tom Lane +In-Reply-To: <1082574808.1558.243.camel@localhost.localdomain> +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78509814A@vt-pe2550-001.vantage.vantage.com> + <200404200959.52813.josh@agliodbs.com> + <1082515263.1558.214.camel@localhost.localdomain> + <78427208-93C0-11D8-BA67-000393BD6C3E@tuckfield.com> + <1082574808.1558.243.camel@localhost.localdomain> +Content-Type: multipart/mixed; boundary="=-sFlYaGnQ+RAFjH6Z5gg/" +Organization: Cramer Consulting +Message-Id: <1082580588.13371.260.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Wed, 21 Apr 2004 16:49:48 -0400 +X-AntiVirus: scanned for viruses by AMaViS 0.2.1 (http://amavis.org/) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/364 +X-Sequence-Number: 6664 + +--=-sFlYaGnQ+RAFjH6Z5gg/ +Content-Type: text/plain +Content-Transfer-Encoding: 7bit + +attached. +-- +Dave Cramer +519 939 0336 +ICQ # 14675561 + +--=-sFlYaGnQ+RAFjH6Z5gg/ +Content-Disposition: attachment; filename=spinlock.patch +Content-Type: text/x-patch; name=spinlock.patch; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit + +Index: backend/storage/lmgr/s_lock.c +=================================================================== +RCS file: /usr/local/cvs/pgsql-server/src/backend/storage/lmgr/s_lock.c,v +retrieving revision 1.16 +diff -c -r1.16 s_lock.c +*** backend/storage/lmgr/s_lock.c 8 Aug 2003 21:42:00 -0000 1.16 +--- backend/storage/lmgr/s_lock.c 21 Apr 2004 20:27:34 -0000 +*************** +*** 76,82 **** + * The select() delays are measured in centiseconds (0.01 sec) because 10 + * msec is a common resolution limit at the OS level. + */ +! #define SPINS_PER_DELAY 100 + #define NUM_DELAYS 1000 + #define MIN_DELAY_CSEC 1 + #define MAX_DELAY_CSEC 100 +--- 76,82 ---- + * The select() delays are measured in centiseconds (0.01 sec) because 10 + * msec is a common resolution limit at the OS level. + */ +! #define SPINS_PER_DELAY 10 + #define NUM_DELAYS 1000 + #define MIN_DELAY_CSEC 1 + #define MAX_DELAY_CSEC 100 +*************** +*** 88,93 **** +--- 88,94 ---- + + while (TAS(lock)) + { ++ __asm__ __volatile__ ( "rep;nop": : :"memory"); + if (++spins > SPINS_PER_DELAY) + { + if (++delays > NUM_DELAYS) +Index: include/storage/s_lock.h +=================================================================== +RCS file: /usr/local/cvs/pgsql-server/src/include/storage/s_lock.h,v +retrieving revision 1.115.2.1 +diff -c -r1.115.2.1 s_lock.h +*** include/storage/s_lock.h 4 Nov 2003 09:43:56 -0000 1.115.2.1 +--- include/storage/s_lock.h 21 Apr 2004 20:26:25 -0000 +*************** +*** 103,110 **** + register slock_t _res = 1; + + __asm__ __volatile__( +! " lock \n" + " xchgb %0,%1 \n" + : "=q"(_res), "=m"(*lock) + : "0"(_res)); + return (int) _res; +--- 103,113 ---- + register slock_t _res = 1; + + __asm__ __volatile__( +! " cmpb $0,%1 \n" +! " jne 1f \n" +! " lock \n" + " xchgb %0,%1 \n" ++ " 1:\n" + : "=q"(_res), "=m"(*lock) + : "0"(_res)); + return (int) _res; + +--=-sFlYaGnQ+RAFjH6Z5gg/-- + + +From pgsql-performance-owner@postgresql.org Wed Apr 21 18:50:22 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 15230D1D501 + for ; + Wed, 21 Apr 2004 18:50:17 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 55255-03 + for ; + Wed, 21 Apr 2004 18:50:14 -0300 (ADT) +Received: from jinx.internetstaff.com (jinx.internetstaff.com + [63.214.174.240]) + by svr1.postgresql.org (Postfix) with ESMTP id 907C8D1D08B + for ; + Wed, 21 Apr 2004 18:50:11 -0300 (ADT) +Received: from localhost (localhost [127.0.0.1]) + by jinx.internetstaff.com (Postfix) with ESMTP id 97A874BC0B6 + for ; + Wed, 21 Apr 2004 14:50:13 -0700 (MST) +Received: from jinx.internetstaff.com ([127.0.0.1]) + by localhost (jinx [127.0.0.1]) (amavisd-new, port 10024) with LMTP + id 05056-01-18 for ; + Wed, 21 Apr 2004 14:50:13 -0700 (MST) +Received: from [10.10.4.32] (unknown [65.161.175.209]) + by jinx.internetstaff.com (Postfix) with ESMTP id 4937C4BC0B2 + for ; + Wed, 21 Apr 2004 14:50:13 -0700 (MST) +Subject: Re: Moving postgres to FC disks +From: Cott Lang +To: pgsql-performance@postgresql.org +In-Reply-To: <4085BFF0.4050604@commandprompt.com> +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78509814D@vt-pe2550-001.vantage.vantage.com> + <4085BFF0.4050604@commandprompt.com> +Content-Type: text/plain +Message-Id: <1082584212.2356.14.camel@blackbox.vcommerce.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-1) +Date: Wed, 21 Apr 2004 14:50:12 -0700 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at internetstaff.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/365 +X-Sequence-Number: 6665 + +On Tue, 2004-04-20 at 17:27, Joshua D. Drake wrote: + +> > -Currently, the internal RAID volume is ext3 filesystem. Any +> > recommendations for the filesystem on the new FC volume? Rieserfs? +> > +> > +> XFS + +What Linux distributions are popular in here for PG+XFS? + +I'm very disappointed that Redhat Enterprise 3 doesn't appear to support +XFS/JFS, or anything else. Suse Server 8 seems very dated, at least from +the eval I downloaded. I'm curious as to where other people have gone +with the death of RH9. I'd have gone on to Redhat 3 if I wasn't +interested in getting some of the benefits of XFS at the same time ... + + + + +From pgsql-performance-owner@postgresql.org Mon Apr 26 14:51:25 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 90717D1CCD5 + for ; + Wed, 21 Apr 2004 19:02:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 54475-08 + for ; + Wed, 21 Apr 2004 19:02:36 -0300 (ADT) +Received: from is.rice.edu (is.rice.edu [128.42.42.24]) + by svr1.postgresql.org (Postfix) with ESMTP id ADB76D1CCCA + for ; + Wed, 21 Apr 2004 19:02:33 -0300 (ADT) +Received: from localhost (localhost [127.0.0.1]) + by localhost.is.rice.edu (Postfix) with ESMTP + id 24C7B4190C; Wed, 21 Apr 2004 17:02:36 -0500 (CDT) +Received: from is.rice.edu ([127.0.0.1]) + by localhost (it.is.rice.edu [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 25811-10; Wed, 21 Apr 2004 17:02:32 -0500 (CDT) +Received: by is.rice.edu (Postfix, from userid 18612) + id 4F31F4196A; Wed, 21 Apr 2004 17:02:32 -0500 (CDT) +Date: Wed, 21 Apr 2004 17:02:31 -0500 +From: Kenneth Marshall +To: Tom Lane +Cc: pgsql-performance@postgresql.org +Subject: Re: Wierd context-switching issue on Xeon +Message-ID: <20040421220231.GA18010@it.is.rice.edu> +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78509814A@vt-pe2550-001.vantage.vantage.com> + <200404200959.52813.josh@agliodbs.com> + <1082515263.1558.214.camel@localhost.localdomain> + <78427208-93C0-11D8-BA67-000393BD6C3E@tuckfield.com> + <14264.1082573491@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <14264.1082573491@sss.pgh.pa.us> +User-Agent: Mutt/1.4.2i +X-Virus-Scanned: by amavis-20030314-p2 at is.rice.edu +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/441 +X-Sequence-Number: 6741 + +On Wed, Apr 21, 2004 at 02:51:31PM -0400, Tom Lane wrote: +> The context swap storm is happening because of contention at the next +> level up (LWLocks rather than spinlocks). It could be an independent +> issue that just happens to be triggered by the same sort of access +> pattern. I put forward a hypothesis that the cache miss storm caused by +> the test-and-set ops induces the context swap storm by making the code +> more likely to be executing in certain places at certain times ... but +> it's only a hypothesis. +> +If the context swap storm derives from LWLock contention, maybe using +a random order to assign buffer locks in buf_init.c would prevent +simple adjacency of buffer allocation to cause the storm. Just offsetting +the assignment by the cacheline size should work. I notice that when +initializing the buffers in shared memory, both the buf->meta_data_lock +and the buf->cntx_lock are immediately adjacent in memory. I am not +familiar enough with the flow through postgres to see if there could +be "fighting" for those two locks. If so, offsetting those by the cache +line size would also stop the context swap storm. + +--Ken + +From pgsql-performance-owner@postgresql.org Wed Apr 21 22:46:16 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6CF8CD1DB23 + for ; + Wed, 21 Apr 2004 22:45:54 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 26062-08 + for ; + Wed, 21 Apr 2004 22:45:55 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 6AE10D1DA3C + for ; + Wed, 21 Apr 2004 22:45:51 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3M1js0j017857; + Wed, 21 Apr 2004 21:45:54 -0400 (EDT) +To: Kenneth Marshall +Cc: pgsql-performance@postgresql.org +Subject: Re: Wierd context-switching issue on Xeon +In-reply-to: <20040421220231.GA18010@it.is.rice.edu> +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78509814A@vt-pe2550-001.vantage.vantage.com> + <200404200959.52813.josh@agliodbs.com> + <1082515263.1558.214.camel@localhost.localdomain> + <78427208-93C0-11D8-BA67-000393BD6C3E@tuckfield.com> + <14264.1082573491@sss.pgh.pa.us> + <20040421220231.GA18010@it.is.rice.edu> +Comments: In-reply-to Kenneth Marshall + message dated "Wed, 21 Apr 2004 17:02:31 -0500" +Date: Wed, 21 Apr 2004 21:45:54 -0400 +Message-ID: <17856.1082598354@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/366 +X-Sequence-Number: 6666 + +Kenneth Marshall writes: +> If the context swap storm derives from LWLock contention, maybe using +> a random order to assign buffer locks in buf_init.c would prevent +> simple adjacency of buffer allocation to cause the storm. + +Good try, but no cigar ;-). The test cases I've been looking at take +only shared locks on the per-buffer locks, so that's not where the +context swaps are coming from. The swaps have to be caused by the +BufMgrLock, because that's the only exclusive lock being taken. + +I did try increasing the allocated size of the spinlocks to 128 bytes +to see if it would do anything. It didn't ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Apr 21 23:36:17 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 38739D1D72D + for ; + Wed, 21 Apr 2004 23:35:39 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 38444-05 + for ; + Wed, 21 Apr 2004 23:35:41 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id B7375D1D707 + for ; + Wed, 21 Apr 2004 23:35:36 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3M2ZUBQ018323; + Wed, 21 Apr 2004 22:35:30 -0400 (EDT) +To: pg@fastcrypt.com +Cc: Paul Tuckfield , + Anjan Dave , Josh Berkus , + Neil Conway , + Dirk =?ISO-8859-1?Q?Lutzeb=E4ck?= , + pgsql-performance@postgresql.org +Subject: Re: Wierd context-switching issue on Xeon patch for 7.4.1 +In-reply-to: <1082580588.13371.260.camel@localhost.localdomain> +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78509814A@vt-pe2550-001.vantage.vantage.com> + <200404200959.52813.josh@agliodbs.com> + <1082515263.1558.214.camel@localhost.localdomain> + <78427208-93C0-11D8-BA67-000393BD6C3E@tuckfield.com> + <1082574808.1558.243.camel@localhost.localdomain> + <1082580588.13371.260.camel@localhost.localdomain> +Comments: In-reply-to Dave Cramer + message dated "Wed, 21 Apr 2004 16:49:48 -0400" +Date: Wed, 21 Apr 2004 22:35:30 -0400 +Message-ID: <18322.1082601330@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/367 +X-Sequence-Number: 6667 + +Dave Cramer writes: +> diff -c -r1.16 s_lock.c +> *** backend/storage/lmgr/s_lock.c 8 Aug 2003 21:42:00 -0000 1.16 +> --- backend/storage/lmgr/s_lock.c 21 Apr 2004 20:27:34 -0000 +> *************** +> *** 76,82 **** +> * The select() delays are measured in centiseconds (0.01 sec) because 10 +> * msec is a common resolution limit at the OS level. +> */ +> ! #define SPINS_PER_DELAY 100 +> #define NUM_DELAYS 1000 +> #define MIN_DELAY_CSEC 1 +> #define MAX_DELAY_CSEC 100 +> --- 76,82 ---- +> * The select() delays are measured in centiseconds (0.01 sec) because 10 +> * msec is a common resolution limit at the OS level. +> */ +> ! #define SPINS_PER_DELAY 10 +> #define NUM_DELAYS 1000 +> #define MIN_DELAY_CSEC 1 +> #define MAX_DELAY_CSEC 100 + + +As far as I can tell, this does reduce the rate of semop's +significantly, but it does so by bringing the overall processing rate +to a crawl :-(. I see 97% CPU idle time when using this patch. +I believe what is happening is that the select() delay in s_lock.c is +being hit frequently because the spin loop isn't allowed to run long +enough to let the other processor get out of the spinlock. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Apr 21 23:56:26 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8B6CED1D707 + for ; + Wed, 21 Apr 2004 23:53:55 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 46573-03 + for ; + Wed, 21 Apr 2004 23:53:55 -0300 (ADT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 7A9BCD1CCB1 + for ; + Wed, 21 Apr 2004 23:53:50 -0300 (ADT) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4918812; Wed, 21 Apr 2004 19:55:20 -0700 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: Tom Lane , pg@fastcrypt.com +Subject: Re: Wierd context-switching issue on Xeon patch for 7.4.1 +Date: Wed, 21 Apr 2004 19:53:24 -0700 +User-Agent: KMail/1.4.3 +Cc: Paul Tuckfield , + Anjan Dave , Neil Conway , + Dirk =?iso-8859-1?q?Lutzeb=E4ck?= , + pgsql-performance@postgresql.org +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78509814A@vt-pe2550-001.vantage.vantage.com> + <1082580588.13371.260.camel@localhost.localdomain> + <18322.1082601330@sss.pgh.pa.us> +In-Reply-To: <18322.1082601330@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200404211953.24898.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/368 +X-Sequence-Number: 6668 + +Tom, + +> As far as I can tell, this does reduce the rate of semop's +> significantly, but it does so by bringing the overall processing rate +> to a crawl :-(. I see 97% CPU idle time when using this patch. +> I believe what is happening is that the select() delay in s_lock.c is +> being hit frequently because the spin loop isn't allowed to run long +> enough to let the other processor get out of the spinlock. + +Also, I tested it on production data, and it reduces the CSes by about 40%. +An improvement, but not a magic bullet. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Thu Apr 22 03:44:56 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2586BD1DB96 + for ; + Thu, 22 Apr 2004 03:04:53 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 94654-09 + for ; + Thu, 22 Apr 2004 03:04:43 -0300 (ADT) +Received: from www.postgresql.com (www.postgresql.com [200.46.204.209]) + by svr1.postgresql.org (Postfix) with ESMTP id 15BD5D1EB82 + for ; + Thu, 22 Apr 2004 03:02:32 -0300 (ADT) +Received: from net2.micro-automation.com (net2.micro-automation.com + [64.7.141.29]) + by www.postgresql.com (Postfix) with SMTP id BAD7DCF64A3 + for ; + Thu, 22 Apr 2004 00:03:49 -0300 (ADT) +Received: (qmail 9328 invoked from network); 22 Apr 2004 03:03:41 -0000 +Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) + by net2.micro-automation.com with SMTP; 22 Apr 2004 03:03:41 -0000 +Subject: Re: Wierd context-switching issue on Xeon patch for 7.4.1 +From: Dave Cramer +Reply-To: pg@fastcrypt.com +To: Tom Lane +Cc: Paul Tuckfield , + Anjan Dave , Josh Berkus , + Neil Conway , + Dirk =?ISO-8859-1?Q?Lutzeb=E4ck?= , + pgsql-performance@postgresql.org +In-Reply-To: <18322.1082601330@sss.pgh.pa.us> +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78509814A@vt-pe2550-001.vantage.vantage.com> + <200404200959.52813.josh@agliodbs.com> + <1082515263.1558.214.camel@localhost.localdomain> + <78427208-93C0-11D8-BA67-000393BD6C3E@tuckfield.com> + <1082574808.1558.243.camel@localhost.localdomain> + <1082580588.13371.260.camel@localhost.localdomain> + <18322.1082601330@sss.pgh.pa.us> +Content-Type: text/plain +Organization: Cramer Consulting +Message-Id: <1082603201.1556.272.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Wed, 21 Apr 2004 23:06:41 -0400 +Content-Transfer-Encoding: 7bit +X-AntiVirus: scanned for viruses by AMaViS 0.2.1 (http://amavis.org/) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/375 +X-Sequence-Number: 6675 + +Yeah, I did some more testing myself, and actually get better numbers +with increasing spins per delay to 1000, but my suspicion is that it is +highly dependent on finding the right delay for the processor you are +on. + +My hypothesis is that if you spin approximately the same or more time +than the average time it takes to get finished with the shared resource +then this should reduce cs. + +Certainly more ideas are required here. + +Dave +On Wed, 2004-04-21 at 22:35, Tom Lane wrote: +> Dave Cramer writes: +> > diff -c -r1.16 s_lock.c +> > *** backend/storage/lmgr/s_lock.c 8 Aug 2003 21:42:00 -0000 1.16 +> > --- backend/storage/lmgr/s_lock.c 21 Apr 2004 20:27:34 -0000 +> > *************** +> > *** 76,82 **** +> > * The select() delays are measured in centiseconds (0.01 sec) because 10 +> > * msec is a common resolution limit at the OS level. +> > */ +> > ! #define SPINS_PER_DELAY 100 +> > #define NUM_DELAYS 1000 +> > #define MIN_DELAY_CSEC 1 +> > #define MAX_DELAY_CSEC 100 +> > --- 76,82 ---- +> > * The select() delays are measured in centiseconds (0.01 sec) because 10 +> > * msec is a common resolution limit at the OS level. +> > */ +> > ! #define SPINS_PER_DELAY 10 +> > #define NUM_DELAYS 1000 +> > #define MIN_DELAY_CSEC 1 +> > #define MAX_DELAY_CSEC 100 +> +> +> As far as I can tell, this does reduce the rate of semop's +> significantly, but it does so by bringing the overall processing rate +> to a crawl :-(. I see 97% CPU idle time when using this patch. +> I believe what is happening is that the select() delay in s_lock.c is +> being hit frequently because the spin loop isn't allowed to run long +> enough to let the other processor get out of the spinlock. +> +> regards, tom lane +> +> +> +> !DSPAM:40872f7e21492906114513! +> +> +-- +Dave Cramer +519 939 0336 +ICQ # 14675561 + + +From pgsql-performance-owner@postgresql.org Thu Apr 22 03:04:11 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 83028D1DD99 + for ; + Thu, 22 Apr 2004 03:03:49 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 94654-05 + for ; + Thu, 22 Apr 2004 03:03:43 -0300 (ADT) +Received: from www.postgresql.com (www.postgresql.com [200.46.204.209]) + by svr1.postgresql.org (Postfix) with ESMTP id 4FD2BD1EAAC + for ; + Thu, 22 Apr 2004 03:01:56 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by www.postgresql.com (Postfix) with ESMTP id 98C40CF64A0 + for ; + Thu, 22 Apr 2004 00:10:44 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3M3Ah8A018621; + Wed, 21 Apr 2004 23:10:43 -0400 (EDT) +To: Paul Tuckfield +Cc: pgsql-performance@postgresql.org +Subject: Re: Wierd context-switching issue on Xeon +In-reply-to: <9D274446-932B-11D8-BA67-000393BD6C3E@tuckfield.com> +References: + <40843E63.7050101@joeconway.com> + <200404191455.04068.josh@agliodbs.com> + <1407.1082419316@sss.pgh.pa.us> <1931.1082422389@sss.pgh.pa.us> + + <9D274446-932B-11D8-BA67-000393BD6C3E@tuckfield.com> +Comments: In-reply-to Paul Tuckfield + message dated "Tue, 20 Apr 2004 17:34:13 -0700" +Date: Wed, 21 Apr 2004 23:10:43 -0400 +Message-ID: <18620.1082603443@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/374 +X-Sequence-Number: 6674 + +Paul Tuckfield writes: +>> I used the taskset command: +>> taskset 01 -p +>> taskset 01 -p +>> +>> I guess that 0 and 1 are the two cores (pipelines? hyper-threads?) on +>> the first Xeon processor in the box. + +AFAICT, what you've actually done here is to bind both backends to the +first logical processor of the first Xeon. If you'd used 01 and 02 +as the affinity masks then you'd have bound them to the two cores of +that Xeon, but what you actually did simply reduces the system to a +uniprocessor. In that situation the context swap rate will be normally +one swap per scheduler timeslice, and at worst two swaps per timeslice +(if a process is swapped away from while it holds a lock the other one +wants). It doesn't prove a lot about our SMP problem though. + +I don't have access to a Xeon with both taskset and hyperthreading +enabled, so I can't check what happens when you do the taskset correctly +... could you retry? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Apr 22 04:17:06 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id CDF4FD1EAC3 + for ; + Thu, 22 Apr 2004 03:01:58 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 86178-07 + for ; + Thu, 22 Apr 2004 03:01:44 -0300 (ADT) +Received: from www.postgresql.com (www.postgresql.com [200.46.204.209]) + by svr1.postgresql.org (Postfix) with ESMTP id BEC5AD1E0F1 + for ; + Thu, 22 Apr 2004 03:01:32 -0300 (ADT) +Received: from net2.micro-automation.com (net2.micro-automation.com + [64.7.141.29]) + by www.postgresql.com (Postfix) with SMTP id 1CC98CF6671 + for ; + Thu, 22 Apr 2004 00:15:53 -0300 (ADT) +Received: (qmail 11674 invoked from network); 22 Apr 2004 03:15:46 -0000 +Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) + by net2.micro-automation.com with SMTP; 22 Apr 2004 03:15:46 -0000 +Subject: Re: Wierd context-switching issue on Xeon patch for 7.4.1 +From: Dave Cramer +Reply-To: pg@fastcrypt.com +To: Josh Berkus +Cc: Tom Lane , + Paul Tuckfield , Anjan Dave , + Neil Conway , + Dirk =?ISO-8859-1?Q?Lutzeb=E4ck?= , + pgsql-performance@postgresql.org +In-Reply-To: <200404211953.24898.josh@agliodbs.com> +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78509814A@vt-pe2550-001.vantage.vantage.com> + <1082580588.13371.260.camel@localhost.localdomain> + <18322.1082601330@sss.pgh.pa.us> <200404211953.24898.josh@agliodbs.com> +Content-Type: text/plain +Organization: Cramer Consulting +Message-Id: <1082603927.1558.279.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Wed, 21 Apr 2004 23:18:47 -0400 +Content-Transfer-Encoding: 7bit +X-AntiVirus: scanned for viruses by AMaViS 0.2.1 (http://amavis.org/) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/376 +X-Sequence-Number: 6676 + +More data.... + +On a dual xeon with HTT enabled: + +I tried increasing the NUM_SPINS to 1000 and it works better. + +NUM_SPINLOCKS CS ID pgbench + +100 250K 59% 230 TPS +1000 125K 55% 228 TPS + +This is certainly heading in the right direction ? Although it looks +like it is highly dependent on the system you are running on. + +--dc-- + + + +On Wed, 2004-04-21 at 22:53, Josh Berkus wrote: +> Tom, +> +> > As far as I can tell, this does reduce the rate of semop's +> > significantly, but it does so by bringing the overall processing rate +> > to a crawl :-(. I see 97% CPU idle time when using this patch. +> > I believe what is happening is that the select() delay in s_lock.c is +> > being hit frequently because the spin loop isn't allowed to run long +> > enough to let the other processor get out of the spinlock. +> +> Also, I tested it on production data, and it reduces the CSes by about 40%. +> An improvement, but not a magic bullet. +-- +Dave Cramer +519 939 0336 +ICQ # 14675561 + + +From pgsql-performance-owner@postgresql.org Thu Apr 22 03:03:36 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DAF42D1DF80 + for ; + Thu, 22 Apr 2004 03:03:17 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 94710-04 + for ; + Thu, 22 Apr 2004 03:03:10 -0300 (ADT) +Received: from www.postgresql.com (www.postgresql.com [200.46.204.209]) + by svr1.postgresql.org (Postfix) with ESMTP id CA090D1E9E9 + for ; + Thu, 22 Apr 2004 03:01:48 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by www.postgresql.com (Postfix) with ESMTP id 67520CF6879 + for ; + Thu, 22 Apr 2004 01:15:15 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3M4FDVO019516; + Thu, 22 Apr 2004 00:15:13 -0400 (EDT) +To: =?ISO-8859-1?Q?Pailloncy_Jean-G=E9rard?= +Cc: pgsql-performance@postgresql.org +Subject: Re: 225 times slower +In-reply-to: +References: + +Comments: In-reply-to =?ISO-8859-1?Q?Pailloncy_Jean-G=E9rard?= + + message dated "Tue, 20 Apr 2004 19:10:50 +0200" +Date: Thu, 22 Apr 2004 00:15:13 -0400 +Message-ID: <19515.1082607313@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/373 +X-Sequence-Number: 6673 + +=?ISO-8859-1?Q?Pailloncy_Jean-G=E9rard?= writes: +> dps=# explain analyze SELECT rec_id FROM url WHERE crc32!=0 AND +> crc32=419903683 AND status IN (200,304,206) ORDER BY rec_id LIMIT 1; +> QUERY PLAN +> ------------------------------------------------------------------------ +> ---------------------------------------------------------- +> Limit (cost=0.00..27.95 rows=1 width=4) (actual +> time=11021.875..11021.876 rows=1 loops=1) +> -> Index Scan using url_pkey on url (cost=0.00..11625.49 rows=416 +> width=4) (actual time=11021.868..11021.868 rows=1 loops=1) +> Filter: ((crc32 <> 0) AND (crc32 = 419903683) AND ((status = +> 200) OR (status = 304) OR (status = 206))) +> Total runtime: 11021.986 ms +> (4 rows) +> dps=# \q + +The planner is guessing that scanning in rec_id order will produce a +matching row fairly quickly (sooner than selecting all the matching rows +and sorting them would do). It's wrong in this case, but I'm not sure +it could do better without very detailed cross-column statistics. Am I +right to guess that the rows that match the WHERE clause are not evenly +distributed in the rec_id order, but rather there are no such rows till +you get well up in the ordering? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Apr 22 01:24:14 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1C66AD1BB36 + for ; + Thu, 22 Apr 2004 01:23:31 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 46049-08 + for ; + Thu, 22 Apr 2004 01:23:30 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 5F84BD1BACC + for ; + Thu, 22 Apr 2004 01:23:29 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3M4NPoK019597; + Thu, 22 Apr 2004 00:23:25 -0400 (EDT) +To: pg@fastcrypt.com +Cc: Josh Berkus , + Paul Tuckfield , Anjan Dave , + Neil Conway , + Dirk =?ISO-8859-1?Q?Lutzeb=E4ck?= , + pgsql-performance@postgresql.org +Subject: Re: Wierd context-switching issue on Xeon patch for 7.4.1 +In-reply-to: <1082603927.1558.279.camel@localhost.localdomain> +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78509814A@vt-pe2550-001.vantage.vantage.com> + <1082580588.13371.260.camel@localhost.localdomain> + <18322.1082601330@sss.pgh.pa.us> + <200404211953.24898.josh@agliodbs.com> + <1082603927.1558.279.camel@localhost.localdomain> +Comments: In-reply-to Dave Cramer + message dated "Wed, 21 Apr 2004 23:18:47 -0400" +Date: Thu, 22 Apr 2004 00:23:24 -0400 +Message-ID: <19596.1082607804@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/369 +X-Sequence-Number: 6669 + +Dave Cramer writes: +> I tried increasing the NUM_SPINS to 1000 and it works better. + +Doesn't surprise me. The value of 100 is about right on the assumption +that the spinlock instruction per se is not too much more expensive than +any other instruction. What I was seeing from oprofile suggested that +the spinlock instruction cost about 100x more than an ordinary +instruction :-( ... so maybe 200 or so would be good on a Xeon. + +> This is certainly heading in the right direction ? Although it looks +> like it is highly dependent on the system you are running on. + +Yeah. I don't know a reasonable way to tune this number automatically +for particular systems ... but at the very least we'd need to find a way +to distinguish uniprocessor from multiprocessor, because on a +uniprocessor the optimal value is surely 1. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Apr 22 01:37:36 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B24D0D1D0B8 + for ; + Thu, 22 Apr 2004 01:37:34 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 67990-05 + for ; + Thu, 22 Apr 2004 01:37:33 -0300 (ADT) +Received: from houston.familyhealth.com.au (fhnet.arach.net.au + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id D0F6AD1BCC2 + for ; + Thu, 22 Apr 2004 01:37:31 -0300 (ADT) +Received: from familyhealth.com.au (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id + i3M4bFWL087263; Thu, 22 Apr 2004 12:37:15 +0800 (WST) + (envelope-from chriskl@familyhealth.com.au) +Message-ID: <40874D97.5030401@familyhealth.com.au> +Date: Thu, 22 Apr 2004 12:44:07 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: pg@fastcrypt.com, Josh Berkus , + Paul Tuckfield , Anjan Dave , + Neil Conway , + =?ISO-8859-1?Q?Dirk_Lutzeb=E4ck?= , + pgsql-performance@postgresql.org +Subject: Re: Wierd context-switching issue on Xeon patch for 7.4.1 +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78509814A@vt-pe2550-001.vantage.vantage.com> + <1082580588.13371.260.camel@localhost.localdomain> + <18322.1082601330@sss.pgh.pa.us> + <200404211953.24898.josh@agliodbs.com> + <1082603927.1558.279.camel@localhost.localdomain> + <19596.1082607804@sss.pgh.pa.us> +In-Reply-To: <19596.1082607804@sss.pgh.pa.us> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/370 +X-Sequence-Number: 6670 + +> Yeah. I don't know a reasonable way to tune this number automatically +> for particular systems ... but at the very least we'd need to find a way +> to distinguish uniprocessor from multiprocessor, because on a +> uniprocessor the optimal value is surely 1. + + From TODO: + +* Add code to detect an SMP machine and handle spinlocks accordingly +from distributted.net, http://www1.distributed.net/source, in +client/common/cpucheck.cpp + +Chris + + +From pgsql-performance-owner@postgresql.org Thu Apr 22 01:56:34 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B907AD1D096 + for ; + Thu, 22 Apr 2004 01:56:31 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 74325-04 + for ; + Thu, 22 Apr 2004 01:56:31 -0300 (ADT) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id 5FCE3D1D0B8 + for ; + Thu, 22 Apr 2004 01:56:29 -0300 (ADT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i3M4uFv04710; + Thu, 22 Apr 2004 00:56:15 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200404220456.i3M4uFv04710@candle.pha.pa.us> +Subject: Re: Wierd context-switching issue on Xeon patch for 7.4.1 +In-Reply-To: <19596.1082607804@sss.pgh.pa.us> +To: Tom Lane +Date: Thu, 22 Apr 2004 00:56:15 -0400 (EDT) +Cc: pg@fastcrypt.com, Josh Berkus , + Paul Tuckfield , Anjan Dave , + Neil Conway , + =?ISO-8859-1?Q?Dirk_Lutzeb=E4ck?= , + pgsql-performance@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL108 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/371 +X-Sequence-Number: 6671 + +Tom Lane wrote: +> Dave Cramer writes: +> > I tried increasing the NUM_SPINS to 1000 and it works better. +> +> Doesn't surprise me. The value of 100 is about right on the assumption +> that the spinlock instruction per se is not too much more expensive than +> any other instruction. What I was seeing from oprofile suggested that +> the spinlock instruction cost about 100x more than an ordinary +> instruction :-( ... so maybe 200 or so would be good on a Xeon. +> +> > This is certainly heading in the right direction ? Although it looks +> > like it is highly dependent on the system you are running on. +> +> Yeah. I don't know a reasonable way to tune this number automatically +> for particular systems ... but at the very least we'd need to find a way +> to distinguish uniprocessor from multiprocessor, because on a +> uniprocessor the optimal value is surely 1. + +Have you looked at the code pointed to by our TODO item: + + * Add code to detect an SMP machine and handle spinlocks accordingly + from distributted.net, http://www1.distributed.net/source, + in client/common/cpucheck.cpp + +For BSDOS it has: + + #if (CLIENT_OS == OS_FREEBSD) || (CLIENT_OS == OS_BSDOS) || \ + (CLIENT_OS == OS_OPENBSD) || (CLIENT_OS == OS_NETBSD) + { /* comment out if inappropriate for your *bsd - cyp (25/may/1999) */ + int ncpus; size_t len = sizeof(ncpus); + int mib[2]; mib[0] = CTL_HW; mib[1] = HW_NCPU; + if (sysctl( &mib[0], 2, &ncpus, &len, NULL, 0 ) == 0) + //if (sysctlbyname("hw.ncpu", &ncpus, &len, NULL, 0 ) == 0) + cpucount = ncpus; + } + +and I can confirm that on my computer it works: + + hw.ncpu = 2 + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-performance-owner@postgresql.org Thu Apr 22 02:13:59 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id CEE5AD1B44F + for ; + Thu, 22 Apr 2004 02:13:57 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 75956-09 + for ; + Thu, 22 Apr 2004 02:13:57 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 0F88AD1B441 + for ; + Thu, 22 Apr 2004 02:13:56 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3M5Dl3J020172; + Thu, 22 Apr 2004 01:13:47 -0400 (EDT) +To: Bruce Momjian +Cc: pg@fastcrypt.com, Josh Berkus , + Paul Tuckfield , Anjan Dave , + Neil Conway , + =?ISO-8859-1?Q?Dirk_Lutzeb=E4ck?= , + pgsql-performance@postgresql.org +Subject: Re: Wierd context-switching issue on Xeon patch for 7.4.1 +In-reply-to: <200404220456.i3M4uFv04710@candle.pha.pa.us> +References: <200404220456.i3M4uFv04710@candle.pha.pa.us> +Comments: In-reply-to Bruce Momjian + message dated "Thu, 22 Apr 2004 00:56:15 -0400" +Date: Thu, 22 Apr 2004 01:13:47 -0400 +Message-ID: <20171.1082610827@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/372 +X-Sequence-Number: 6672 + +Bruce Momjian writes: +> For BSDOS it has: + +> #if (CLIENT_OS == OS_FREEBSD) || (CLIENT_OS == OS_BSDOS) || \ +> (CLIENT_OS == OS_OPENBSD) || (CLIENT_OS == OS_NETBSD) +> { /* comment out if inappropriate for your *bsd - cyp (25/may/1999) */ +> int ncpus; size_t len = sizeof(ncpus); +> int mib[2]; mib[0] = CTL_HW; mib[1] = HW_NCPU; +> if (sysctl( &mib[0], 2, &ncpus, &len, NULL, 0 ) == 0) +> //if (sysctlbyname("hw.ncpu", &ncpus, &len, NULL, 0 ) == 0) +> cpucount = ncpus; +> } + +Multiplied by how many platforms? Ewww... + +I was wondering about some sort of dynamic adaptation, roughly along the +lines of "whenever a spin loop successfully gets the lock after +spinning, decrease the allowed loop count by one; whenever we fail to +get the lock after spinning, increase by 100; if the loop count reaches, +say, 10000, decide we are on a uniprocessor and irreversibly set it to +1." As written this would tend to incur a select() delay once per +hundred spinlock acquisitions, which is way too much, but I think we +could make it work with a sufficiently slow adaptation rate. The tricky +part is that a slow adaptation rate means we can't have every backend +figuring this out for itself --- the right value would have to be +maintained globally, and I'm not sure how to do that without adding a +lot of overhead. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Apr 26 14:55:13 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id EDFD9D1C4EC + for ; + Sat, 24 Apr 2004 01:32:23 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 27329-04 + for ; + Sat, 24 Apr 2004 01:32:22 -0300 (ADT) +Received: from ganymede.hub.org (u46n208.hfx.eastlink.ca [24.222.46.208]) + by svr1.postgresql.org (Postfix) with ESMTP id C4428D1B43A + for ; + Sat, 24 Apr 2004 01:32:21 -0300 (ADT) +Received: by ganymede.hub.org (Postfix, from userid 1000) + id 8068434356; Sat, 24 Apr 2004 01:32:21 -0300 (ADT) +Received: from localhost (localhost [127.0.0.1]) + by ganymede.hub.org (Postfix) with ESMTP id 7F68E34323 + for ; + Sat, 24 Apr 2004 01:32:21 -0300 (ADT) +X-Received: from localhost ([unix socket]) + by ganymede.hub.org (Cyrus v2.2.3) with LMTP; + Thu, 22 Apr 2004 08:05:48 -0300 +X-Sieve: CMU Sieve 2.2 +X-Received: from localhost (localhost [127.0.0.1]) + by ganymede.hub.org (Postfix) with ESMTP id 3B82836B79 + for ; Thu, 22 Apr 2004 08:05:41 -0300 (ADT) +X-Received: from mail.postgresql.org [200.46.204.71] + by localhost with IMAP (fetchmail-6.2.5) + for scrappy@localhost (single-drop); + Thu, 22 Apr 2004 08:05:41 -0300 (ADT) +X-Received: from svr1.postgresql.org ([unix socket]) + by svr1.postgresql.org (Cyrus v2.2.3) with LMTP; + Thu, 22 Apr 2004 08:02:15 -0300 +X-Sieve: CMU Sieve 2.2 +X-Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B70F1D1DFA5 + for ; Thu, 22 Apr 2004 08:02:15 -0300 (ADT) +X-Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 98010-06 for ; + Thu, 22 Apr 2004 08:02:15 -0300 (ADT) +X-Received: from minnie.omroep.nl (minnie.omroep.nl [145.58.30.4]) + by svr1.postgresql.org (Postfix) with ESMTP id 86711D1E0FE + for ; Thu, 22 Apr 2004 08:02:12 -0300 (ADT) +X-Received: from tron.omroep.nl (tron.omroep.nl [145.58.31.20]) + by minnie.omroep.nl (Postfix) with ESMTP + id DA6601CF5524; Thu, 22 Apr 2004 13:02:14 +0200 (CDT) +X-Received: from michiel.omroep.nl (michiel.omroep.nl [145.58.67.10]) + by tron.omroep.nl (Postfix) with ESMTP + id 926C710056BD; Thu, 22 Apr 2004 13:02:14 +0200 (CEST) +X-Received: from michiel by michiel.omroep.nl with local (Exim 3.35 #1 + (Debian)) id 1BGbyA-0006Vo-00; Thu, 22 Apr 2004 13:02:14 +0200 +Date: Thu, 22 Apr 2004 13:02:14 +0200 +From: Michiel Meeuwissen +To: Rod Taylor +Cc: performance@postgresql.org +Subject: Re: order by index, and inheritance +Message-ID: <20040422110214.GH6870@michiel.omroep.nl> +Reply-To: Michiel Meeuwissen +References: <20040419113013.GA32186@michiel.omroep.nl> + <1082455997.57436.10.camel@jester> + <20040420104518.GF1618@michiel.omroep.nl> + <1082461767.57436.93.camel@jester> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1082461767.57436.93.camel@jester> +Organization: Publieke Omroep []() +User-Agent: Mutt/1.5.5.1+cvs20040105i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-DCC: : +X-Spam-Pyzor: +ReSent-Date: Sat, 24 Apr 2004 01:32:14 -0300 (ADT) +Resent-From: "Marc G. Fournier" +Resent-To: pgsql-performance@postgresql.org +ReSent-Subject: Re: [PERFORM] order by index, and inheritance +ReSent-Message-ID: <20040424013214.A42925@ganymede.hub.org> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/444 +X-Sequence-Number: 6744 + +Rod Taylor wrote: +> The scan is picking the best method for grabbing everything within the +> table, since it is not aware that we do not require everything. + +Hmm. That is a bit silly. Why does it use the index if select only from +mm_mediasources? + +> You can explicitly tell it what you want to do via: +> +> SELECT * +> FROM (SELECT * FROM mm_mediasources ORDER BY number DESC LIMIT 20 +> UNION SELECT * FROM ORDER BY number DESC LIMIT 20) AS tab +> ORDER BY number DESC LIMIT 20 + +I think you meant 'only mm_mediasources', and btw order by and limit are not +accepted before union, so the above query does not compile. + +I can't figure out any acceptable work-around. Even if something as the +above would work, it still would be hardly elegant, and you can as well have +no support for inheritance (actually, you can _better_ have no inheritance, +because at least it is clear what works then). + +Michiel + +btw. Why are these messages not appearing on the list itself? + +-- +Michiel Meeuwissen +Mediapark C101 Hilversum ++31 (0)35 6772979 +nl_NL eo_XX en_US +mihxil' + [] () + +From pgsql-performance-owner@postgresql.org Thu Apr 22 09:37:05 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 623EED1B560 + for ; + Thu, 22 Apr 2004 09:36:34 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 31012-05 + for ; + Thu, 22 Apr 2004 09:36:34 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id EA8A2D1B43A + for ; + Thu, 22 Apr 2004 09:36:30 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3MCaTOc025059; + Thu, 22 Apr 2004 08:36:29 -0400 (EDT) +To: pg@fastcrypt.com +Cc: Paul Tuckfield , + Anjan Dave , Josh Berkus , + Neil Conway , + Dirk =?ISO-8859-1?Q?Lutzeb=E4ck?= , + pgsql-performance@postgresql.org +Subject: Re: Wierd context-switching issue on Xeon patch for 7.4.1 +In-reply-to: <1082603201.1556.272.camel@localhost.localdomain> +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78509814A@vt-pe2550-001.vantage.vantage.com> + <200404200959.52813.josh@agliodbs.com> + <1082515263.1558.214.camel@localhost.localdomain> + <78427208-93C0-11D8-BA67-000393BD6C3E@tuckfield.com> + <1082574808.1558.243.camel@localhost.localdomain> + <1082580588.13371.260.camel@localhost.localdomain> + <18322.1082601330@sss.pgh.pa.us> + <1082603201.1556.272.camel@localhost.localdomain> +Comments: In-reply-to Dave Cramer + message dated "Wed, 21 Apr 2004 23:06:41 -0400" +Date: Thu, 22 Apr 2004 08:36:28 -0400 +Message-ID: <25058.1082637388@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/377 +X-Sequence-Number: 6677 + +Dave Cramer writes: +> My hypothesis is that if you spin approximately the same or more time +> than the average time it takes to get finished with the shared resource +> then this should reduce cs. + +The only thing we use spinlocks for nowadays is to protect LWLocks, so +the "average time" involved is fairly small and stable --- or at least +that was the design intention. What we seem to be seeing is that on SMP +machines, cache coherency issues cause the TAS step itself to be +expensive and variable. However, in the experiments I did, strace'ing +showed that actual spin timeouts (manifested by the execution of a +delaying select()) weren't actually that common; the big source of +context switches is semop(), which indicates contention at the LWLock +level rather than the spinlock level. So while tuning the spinlock +limit count might be a useful thing to do in general, I think it will +have only negligible impact on the particular problems we're discussing +in this thread. + + regards, tom lane + +From pgsql-advocacy-owner@postgresql.org Mon Apr 26 11:21:09 2004 +X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5B0E9D1DC96 + for ; + Thu, 22 Apr 2004 09:53:17 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 39106-03 + for ; + Thu, 22 Apr 2004 09:53:19 -0300 (ADT) +Received: from web60601.mail.yahoo.com (web60601.mail.yahoo.com + [216.109.118.221]) + by svr1.postgresql.org (Postfix) with SMTP id 05A5FD1D079 + for ; + Thu, 22 Apr 2004 09:53:15 -0300 (ADT) +Message-ID: <20040422125318.26053.qmail@web60601.mail.yahoo.com> +Received: from [200.17.210.82] by web60601.mail.yahoo.com via HTTP; + Thu, 22 Apr 2004 05:53:18 PDT +Date: Thu, 22 Apr 2004 05:53:18 -0700 (PDT) +From: Eduardo Almeida +Subject: Re: [PERFORM] MySQL vs PG TPC-H benchmarks +To: Jan Wieck , Josh Berkus +Cc: pgsql-advocacy@postgresql.org, pgsql-performance@postgresql.org +In-Reply-To: <4086CDC7.5000204@Yahoo.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/209 +X-Sequence-Number: 4181 + +Folks, + +I�m doing the 100GB TPC-H and I�ll show the previous +results to our community (Postgres) in 3 weeks before +finishing the study. + +My intention is to carry through a test with a VLDB in +a low cost platform (PostgreSQL, Linux and cheap HW) +and not to compare with another DBMS. + +So far I can tell you that the load time on PG 7.4.2 +with kernel 2.6.5 on Opteron 64 model 240 in RAID 0 +with 8 disks (960 GB) loaded the database in less than +24 hours. +About 7hs:30min to load the data and 16:09:25 to +create the indexes + +The Power test still running and that�s why I�ll not +present anything so far. Now I�ll just send to the +list my environment configuration. + +- The configuration of the machine is: +Dual opteron 64 bits model 240 +4GB RAM +960 GB on RAID 0 +Mandrake Linux 64 with Kernel 2.6.5 (I compiled a +kernel for this test) +Java SDK java version "1.4.2_04" +PostgreSQL JDBC pg74.1jdbc3.jar + +- The TPC-H configuration is: +TPC-H 2.0.0 +100GB +load using flat files +Refresh functions using java + +- The PostgreSQL 7.4.2 configuration is: + +add_missing_from | on + australian_timezones | off + authentication_timeout | 60 + check_function_bodies | on + checkpoint_segments | 128 + checkpoint_timeout | 300 + checkpoint_warning | 30 + client_encoding | SQL_ASCII + client_min_messages | notice + commit_delay | 0 + commit_siblings | 5 + cpu_index_tuple_cost | 0.001 + cpu_operator_cost | 0.0025 + cpu_tuple_cost | 0.01 + DateStyle | ISO, MDY + db_user_namespace | off + deadlock_timeout | 1000 + debug_pretty_print | off + debug_print_parse | off + debug_print_plan | off + debug_print_rewritten | off + default_statistics_target | 10 + default_transaction_isolation | read committed + default_transaction_read_only | off + dynamic_library_path | $libdir + effective_cache_size | 150000 + enable_hashagg | on + enable_hashjoin | on + enable_indexscan | on + enable_mergejoin | on + enable_nestloop | on + enable_seqscan | on + enable_sort | on + enable_tidscan | on + explain_pretty_print | on + extra_float_digits | 0 + from_collapse_limit | 8 + fsync | off + geqo | on + geqo_effort | 1 + geqo_generations | 0 +geqo_pool_size | 0 + geqo_selection_bias | 2 + geqo_threshold | 11 + join_collapse_limit | 8 + krb_server_keyfile | unset + lc_collate | en_US + lc_ctype | en_US + lc_messages | C + lc_monetary | C + lc_numeric | C + lc_time | C + log_connections | off + log_duration | off + log_error_verbosity | default + log_executor_stats | off + log_hostname | off + log_min_duration_statement | -1 + log_min_error_statement | panic + log_min_messages | notice + log_parser_stats | off + log_pid | off + log_planner_stats | off + log_source_port | off + log_statement | off + log_statement_stats | off + log_timestamp | off + max_connections | 10 + max_expr_depth | 10000 + max_files_per_process | 1000 + max_fsm_pages | 20000 + max_fsm_relations | 1000 + max_locks_per_transaction | 64 + password_encryption | on + port | 5432 + pre_auth_delay | 0 + preload_libraries | unset + random_page_cost | 1.25 + regex_flavor | advanced + rendezvous_name | unset + search_path | $user,public + server_encoding | SQL_ASCII + server_version | 7.4.2 + shared_buffers | 40000 + silent_mode | off +sort_mem | 65536 + sql_inheritance | on + ssl | off + statement_timeout | 10000000 + stats_block_level | off + stats_command_string | off + stats_reset_on_server_start | on + stats_row_level | off + stats_start_collector | on + superuser_reserved_connections | 2 + syslog | 0 + syslog_facility | LOCAL0 + syslog_ident | postgres + tcpip_socket | on + TimeZone | unknown + trace_notify | off + transaction_isolation | read committed + transaction_read_only | off + transform_null_equals | off + unix_socket_directory | unset + unix_socket_group | unset + unix_socket_permissions | 511 + vacuum_mem | 65536 + virtual_host | unset + wal_buffers | 32 + wal_debug | 0 + wal_sync_method | fdatasync + zero_damaged_pages | off +(113 rows) + + +suggestions, doubts and commentaries are very welcome + +regards +______________________________ +Eduardo Cunha de Almeida +Administra��o de Banco de Dados +UFPR - CCE ++55-41-361-3321 +eduardo.almeida@ufpr.br +edalmeida@yahoo.com + +--- Jan Wieck wrote: +> Josh Berkus wrote: +> +> > Folks, +> > +> > I've sent a polite e-mail to Mr. Gomez offering +> our help. Please, nobody +> > flame him! +> > +> +> Please keep in mind that the entire test has, other +> than a similar +> database schema and query types maybe, nothing to do +> with a TPC-H. I +> don't see any kind of SUT. Foreign key support on +> the DB level is not +> required by any of the TPC benchmarks. But the +> System Under Test, which +> is the combination of middleware application and +> database together with +> all computers and network components these parts are +> running on, must +> implement all the required semantics, like ACID +> properties, referential +> integrity &c. One could implement a TPC-H with flat +> files, it's just a +> major pain in the middleware. +> +> A proper TPC benchmark implementation would for +> example be a complete +> PHP+DB application, where the user interaction is +> done by an emulated +> "browser" and what is measured is the http response +> times, not anything +> going on between PHP and the DB. Assuming that all +> requirements of the +> TPC specification are implemented by either using +> available DB features, +> or including appropriate workarounds in the PHP +> code, that would very +> well lead to something that can compare PHP+MySQL +> vs. PHP+PostgreSQL. +> +> All TPC benchmarks I have seen are performed by +> timing such a system +> after a considerable rampup time, giving the DB +> system a chance to +> properly populate caches and so forth. Rebooting the +> machine just before +> the test is the wrong thing here and will especially +> kill any advanced +> cache algorithms like ARC. +> +> +> Jan +> +> -- +> +#======================================================================# +> # It's easier to get forgiveness for being wrong +> than for being right. # +> # Let's break this rule - forgive me. +> # +> #================================================== +> JanWieck@Yahoo.com # +> +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 5: Have you checked our extensive FAQ? +> +> +> http://www.postgresql.org/docs/faqs/FAQ.htmlIP 5: +> Have you checked our extensive FAQ? +> +> +http://www.postgresql.org/docs/faqs/FAQ.html + + + + + +__________________________________ +Do you Yahoo!? +Yahoo! Photos: High-quality 4x6 digital prints for 25� +http://photos.yahoo.com/ph/print_splash + +From pgsql-advocacy-owner@postgresql.org Mon Apr 26 11:17:46 2004 +X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 3C1D2D1BACD; Thu, 22 Apr 2004 10:42:58 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 56629-02; Thu, 22 Apr 2004 10:42:55 -0300 (ADT) +Received: from elbereth.noviforum.si (unknown [193.189.169.66]) + by svr1.postgresql.org (Postfix) with ESMTP + id 5A783D1B579; Thu, 22 Apr 2004 10:42:50 -0300 (ADT) +Received: from elbereth.noviforum.si (localhost [127.0.0.1]) + by elbereth.noviforum.si (8.12.10/8.12.10) with ESMTP id i3MDgnHh014369; + Thu, 22 Apr 2004 15:42:49 +0200 +Received: (from gregab@localhost) + by elbereth.noviforum.si (8.12.10/8.12.10/Submit) id i3MDgn2C014368; + Thu, 22 Apr 2004 15:42:49 +0200 +Date: Thu, 22 Apr 2004 15:42:49 +0200 +From: Grega Bremec +To: Eduardo Almeida +Cc: Jan Wieck , Josh Berkus , + pgsql-advocacy@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: [PERFORM] MySQL vs PG TPC-H benchmarks +Message-ID: <20040422134249.GA14342@elbereth.noviforum.si> +References: <4086CDC7.5000204@Yahoo.com> + <20040422125318.26053.qmail@web60601.mail.yahoo.com> +Mime-Version: 1.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; boundary="xHFwDpU9dbj6ez1V" +Content-Disposition: inline +In-Reply-To: <20040422125318.26053.qmail@web60601.mail.yahoo.com> +User-Agent: Mutt/1.4.2i +Organization: Noviforum, Ltd., Software & Media +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/206 +X-Sequence-Number: 4178 + +--xHFwDpU9dbj6ez1V +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +Content-Transfer-Encoding: quoted-printable + +...and on Thu, Apr 22, 2004 at 05:53:18AM -0700, Eduardo Almeida used the k= +eyboard: +>=20 +> - The configuration of the machine is: +> Dual opteron 64 bits model 240 +> 4GB RAM +> 960 GB on RAID 0 +> Mandrake Linux 64 with Kernel 2.6.5 (I compiled a +> kernel for this test) +> Java SDK java version "1.4.2_04" +> PostgreSQL JDBC pg74.1jdbc3.jar +>=20 +> - The TPC-H configuration is: +> TPC-H 2.0.0 +> 100GB +> load using flat files +> Refresh functions using java +>=20 + +I'll just add for the reference, to those that aren't aware of it, the Java +virtual machine for x86_64 only exists in the 1.5 branch so far, and it's so +utterly unstable that most every notable shuffling around in the memory +crashes it. :) + +Hence the 1.4.2_04 is a 32-bit application running in 32-bit mode. + +I won't be getting into how much this affects the benchmarks as I didn't +really get into how CPU- and memory-intensive the refresh functions are in +these, so as I said - let's keep it a reference. + +Cheers, +--=20 + Grega Bremec + Senior Administrator + Noviforum Ltd., Software & Media + http://www.noviforum.si/ + +--xHFwDpU9dbj6ez1V +Content-Type: application/pgp-signature +Content-Disposition: inline + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.3 (GNU/Linux) + +iD8DBQFAh8vZDo/EMYD4+osRAtE8AJ9p6blMEGRKc8wHc9ti+YcKBwk/+QCfaswM +TvcECDmUWoW4yiuQX1WNhoY= +=F8Wo +-----END PGP SIGNATURE----- + +--xHFwDpU9dbj6ez1V-- + +From pgsql-performance-owner@postgresql.org Sat Apr 24 01:28:56 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 77571D1B470 + for ; + Sat, 24 Apr 2004 01:28:53 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 03923-10 + for ; + Sat, 24 Apr 2004 01:28:51 -0300 (ADT) +Received: from ganymede.hub.org (u46n208.hfx.eastlink.ca [24.222.46.208]) + by svr1.postgresql.org (Postfix) with ESMTP id 2FF7ED1B43A + for ; + Sat, 24 Apr 2004 01:28:51 -0300 (ADT) +Received: by ganymede.hub.org (Postfix, from userid 1000) + id CF15C341C6; Sat, 24 Apr 2004 01:28:50 -0300 (ADT) +Received: from localhost (localhost [127.0.0.1]) + by ganymede.hub.org (Postfix) with ESMTP id CC53D33C79 + for ; + Sat, 24 Apr 2004 01:28:50 -0300 (ADT) +X-Received: from localhost ([unix socket]) + by ganymede.hub.org (Cyrus v2.2.3) with LMTP; + Thu, 22 Apr 2004 10:51:19 -0300 +X-Sieve: CMU Sieve 2.2 +X-Received: from localhost (localhost [127.0.0.1]) + by ganymede.hub.org (Postfix) with ESMTP id B8E5E37452 + for ; Thu, 22 Apr 2004 10:50:57 -0300 (ADT) +X-Received: from mail.postgresql.org [200.46.204.71] + by localhost with IMAP (fetchmail-6.2.5) + for scrappy@localhost (single-drop); + Thu, 22 Apr 2004 10:50:57 -0300 (ADT) +X-Received: from svr1.postgresql.org ([unix socket]) + by svr1.postgresql.org (Cyrus v2.2.3) with LMTP; + Thu, 22 Apr 2004 10:46:54 -0300 +X-Sieve: CMU Sieve 2.2 +X-Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DE67CD1C50D + for ; Thu, 22 Apr 2004 10:46:53 -0300 (ADT) +X-Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 58271-05 for ; + Thu, 22 Apr 2004 10:46:55 -0300 (ADT) +X-Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 08D54D1BACD + for ; Thu, 22 Apr 2004 10:46:51 -0300 (ADT) +X-Received: from [134.22.70.203] (dyn-70-203.tor.dsl.tht.net [134.22.70.203]) + by tht.net (Postfix) with ESMTP + id 329A376A31; Thu, 22 Apr 2004 09:46:56 -0400 (EDT) +Subject: Re: order by index, and inheritance +From: Rod Taylor +To: Michiel Meeuwissen +Cc: performance@postgresql.org +In-Reply-To: <20040422110214.GH6870@michiel.omroep.nl> +References: <20040419113013.GA32186@michiel.omroep.nl> + <1082455997.57436.10.camel@jester> + <20040420104518.GF1618@michiel.omroep.nl> + <1082461767.57436.93.camel@jester> + <20040422110214.GH6870@michiel.omroep.nl> +Content-Type: text/plain +Message-Id: <1082641607.91360.2.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Thu, 22 Apr 2004 09:46:48 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-DCC: : +X-Spam-Pyzor: +ReSent-Date: Sat, 24 Apr 2004 01:28:46 -0300 (ADT) +Resent-From: "Marc G. Fournier" +Resent-To: pgsql-performance@postgresql.org +ReSent-Subject: Re: [PERFORM] order by index, and inheritance +ReSent-Message-ID: <20040424012846.R42925@ganymede.hub.org> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/422 +X-Sequence-Number: 6722 + +On Thu, 2004-04-22 at 07:02, Michiel Meeuwissen wrote: +> Rod Taylor wrote: +> > The scan is picking the best method for grabbing everything within the +> > table, since it is not aware that we do not require everything. +> +> Hmm. That is a bit silly. Why does it use the index if select only from +> mm_mediasources? +> +> > You can explicitly tell it what you want to do via: +> > +> > SELECT * +> > FROM (SELECT * FROM mm_mediasources ORDER BY number DESC LIMIT 20 +> > UNION SELECT * FROM ORDER BY number DESC LIMIT 20) AS tab +> > ORDER BY number DESC LIMIT 20 +> +> I think you meant 'only mm_mediasources', and btw order by and limit are not +> accepted before union, so the above query does not compile. + +Yes, I did mean only. Try putting another set of brackets around the +selects to get ORDER BY, etc. accepted. You can add another layer of +subselects in the from if that doesn't work. + + +From pgsql-advocacy-owner@postgresql.org Mon Apr 26 11:22:57 2004 +X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 574A6D1E12B + for ; + Thu, 22 Apr 2004 10:59:09 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 65063-03 + for ; + Thu, 22 Apr 2004 10:59:11 -0300 (ADT) +Received: from web60607.mail.yahoo.com (web60607.mail.yahoo.com + [216.109.118.245]) + by svr1.postgresql.org (Postfix) with SMTP id F004DD1DC74 + for ; + Thu, 22 Apr 2004 10:59:06 -0300 (ADT) +Message-ID: <20040422135910.24475.qmail@web60607.mail.yahoo.com> +Received: from [200.17.210.82] by web60607.mail.yahoo.com via HTTP; + Thu, 22 Apr 2004 06:59:10 PDT +Date: Thu, 22 Apr 2004 06:59:10 -0700 (PDT) +From: Eduardo Almeida +Subject: Re: [PERFORM] MySQL vs PG TPC-H benchmarks +To: Grega Bremec +Cc: Jan Wieck , Josh Berkus , + pgsql-advocacy@postgresql.org, pgsql-performance@postgresql.org +In-Reply-To: <20040422134249.GA14342@elbereth.noviforum.si> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/210 +X-Sequence-Number: 4182 + +Grega, + +That�s why I used java 32bits and needed to compile +the kernel 2.6.5 with the 32bits modules. +To reference, Sun has java 64bits just to IA64 and +Solaris Sparc 64 not to Opteron. + +regards, +Eduardo +--- Grega Bremec wrote: +> ...and on Thu, Apr 22, 2004 at 05:53:18AM -0700, +> Eduardo Almeida used the keyboard: +> > +> > - The configuration of the machine is: +> > Dual opteron 64 bits model 240 +> > 4GB RAM +> > 960 GB on RAID 0 +> > Mandrake Linux 64 with Kernel 2.6.5 (I compiled a +> > kernel for this test) +> > Java SDK java version "1.4.2_04" +> > PostgreSQL JDBC pg74.1jdbc3.jar +> > +> > - The TPC-H configuration is: +> > TPC-H 2.0.0 +> > 100GB +> > load using flat files +> > Refresh functions using java +> > +> +> I'll just add for the reference, to those that +> aren't aware of it, the Java +> virtual machine for x86_64 only exists in the 1.5 +> branch so far, and it's so +> utterly unstable that most every notable shuffling +> around in the memory +> crashes it. :) +> +> Hence the 1.4.2_04 is a 32-bit application running +> in 32-bit mode. +> +> I won't be getting into how much this affects the +> benchmarks as I didn't +> really get into how CPU- and memory-intensive the +> refresh functions are in +> these, so as I said - let's keep it a reference. +> +> Cheers, +> -- +> Grega Bremec +> Senior Administrator +> Noviforum Ltd., Software & Media +> http://www.noviforum.si/ +> + +> ATTACHMENT part 2 application/pgp-signature + + + + + + +__________________________________ +Do you Yahoo!? +Yahoo! Photos: High-quality 4x6 digital prints for 25� +http://photos.yahoo.com/ph/print_splash + +From pgsql-performance-owner@postgresql.org Mon Apr 26 14:55:03 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E045BD1B498 + for ; + Sat, 24 Apr 2004 01:29:33 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 27547-01 + for ; + Sat, 24 Apr 2004 01:29:32 -0300 (ADT) +Received: from ganymede.hub.org (u46n208.hfx.eastlink.ca [24.222.46.208]) + by svr1.postgresql.org (Postfix) with ESMTP id F231CD1B43A + for ; + Sat, 24 Apr 2004 01:29:30 -0300 (ADT) +Received: by ganymede.hub.org (Postfix, from userid 1000) + id B3D2033CD9; Sat, 24 Apr 2004 01:29:30 -0300 (ADT) +Received: from localhost (localhost [127.0.0.1]) + by ganymede.hub.org (Postfix) with ESMTP id B2CAA33C79 + for ; + Sat, 24 Apr 2004 01:29:30 -0300 (ADT) +X-Received: from localhost ([unix socket]) + by ganymede.hub.org (Cyrus v2.2.3) with LMTP; + Thu, 22 Apr 2004 11:40:56 -0300 +X-Sieve: CMU Sieve 2.2 +X-Received: from localhost (localhost [127.0.0.1]) + by ganymede.hub.org (Postfix) with ESMTP id C4084375F5 + for ; Thu, 22 Apr 2004 11:40:38 -0300 (ADT) +X-Received: from mail.postgresql.org [200.46.204.71] + by localhost with IMAP (fetchmail-6.2.5) + for scrappy@localhost (single-drop); + Thu, 22 Apr 2004 11:40:38 -0300 (ADT) +X-Received: from svr1.postgresql.org ([unix socket]) + by svr1.postgresql.org (Cyrus v2.2.3) with LMTP; + Thu, 22 Apr 2004 11:40:27 -0300 +X-Sieve: CMU Sieve 2.2 +X-Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 00B86D1CCB1 + for ; Thu, 22 Apr 2004 11:40:27 -0300 (ADT) +X-Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 70106-10 for ; + Thu, 22 Apr 2004 11:40:24 -0300 (ADT) +X-Received: from minnie.omroep.nl (minnie.omroep.nl [145.58.30.4]) + by svr1.postgresql.org (Postfix) with ESMTP id A4E13D1CACD + for ; Thu, 22 Apr 2004 11:40:19 -0300 (ADT) +X-Received: from tron.omroep.nl (tron.omroep.nl [145.58.31.20]) + by minnie.omroep.nl (Postfix) with ESMTP + id BFA351CD0D27; Thu, 22 Apr 2004 16:40:23 +0200 (CDT) +X-Received: from michiel.omroep.nl (michiel.omroep.nl [145.58.67.10]) + by tron.omroep.nl (Postfix) with ESMTP + id B0F6610056BD; Thu, 22 Apr 2004 16:40:23 +0200 (CEST) +X-Received: from michiel by michiel.omroep.nl with local (Exim 3.35 #1 + (Debian)) id 1BGfNH-0007OS-00; Thu, 22 Apr 2004 16:40:23 +0200 +Date: Thu, 22 Apr 2004 16:40:23 +0200 +From: Michiel Meeuwissen +To: Rod Taylor +Cc: performance@postgresql.org +Subject: Re: order by index, and inheritance +Message-ID: <20040422144023.GI6870@michiel.omroep.nl> +Reply-To: Michiel Meeuwissen +References: <20040419113013.GA32186@michiel.omroep.nl> + <1082455997.57436.10.camel@jester> + <20040420104518.GF1618@michiel.omroep.nl> + <1082461767.57436.93.camel@jester> + <20040422110214.GH6870@michiel.omroep.nl> + <1082641607.91360.2.camel@jester> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1082641607.91360.2.camel@jester> +Organization: Publieke Omroep []() +User-Agent: Mutt/1.5.5.1+cvs20040105i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-DCC: : +X-Spam-Pyzor: +ReSent-Date: Sat, 24 Apr 2004 01:29:25 -0300 (ADT) +Resent-From: "Marc G. Fournier" +Resent-To: pgsql-performance@postgresql.org +ReSent-Subject: Re: [PERFORM] order by index, and inheritance +ReSent-Message-ID: <20040424012925.V42925@ganymede.hub.org> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/443 +X-Sequence-Number: 6743 + +Rod Taylor wrote: +> On Thu, 2004-04-22 at 07:02, Michiel Meeuwissen wrote: +> > Rod Taylor wrote: +> > > The scan is picking the best method for grabbing everything within the +> > > table, since it is not aware that we do not require everything. +> > +> > Hmm. That is a bit silly. Why does it use the index if select only from +> > mm_mediasources? +> > +> > > You can explicitly tell it what you want to do via: +> > > +> > > SELECT * +> > > FROM (SELECT * FROM mm_mediasources ORDER BY number DESC LIMIT 20 +> > > UNION SELECT * FROM ORDER BY number DESC LIMIT 20) AS tab +> > > ORDER BY number DESC LIMIT 20 +> > +> > I think you meant 'only mm_mediasources', and btw order by and limit are not +> > accepted before union, so the above query does not compile. +> +> Yes, I did mean only. Try putting another set of brackets around the +> selects to get ORDER BY, etc. accepted. You can add another layer of +> subselects in the from if that doesn't work. + + +Ok, I can get it working: + +select number,url + from ( select number,url from (select number,url from only mm_mediasources order by number desc limit 20) as A + union select number,url from (select number,url from mm_audiosources order by number desc limit 20) as B + union select number,url from (select number,url from mm_videosources order by number desc limit 20) as C + ) as TAB order by number desc limit 20; + +This indeeds performs good (about 10000 times faster then select number,url +from mm_mediasources order by number desc limit 20) . But hardly beautiful, +and quite useless too because of course I am now going to want to use an +offset (limit 20 offset 20, you see..), which seems more or less impossible +in this way, isn't it. + +select number,url + from ( select number,url from (select number,url from only mm_mediasources order by number desc limit 100020) as A + union select number,url from (select number,url from mm_audiosources order by number desc limit 100020) as B + union select number,url from (select number,url from mm_videosources order by number desc limit 100020) as C + ) as TAB order by number desc limit 20 offset 100000; + +This would be it, I think, but this performs, expectedly, quit bad again, +though still 5 times faster then select url,number from mm_mediasources order by number desc limit 20 offset 100000; + + +I'm thinking of dropping inheritance all together and using foreign keys or +so for the extra fields, to simulate inheritance. That might perhaps work a whole lot better? + +Thanks anyway, + +-- +Michiel Meeuwissen +Mediapark C101 Hilversum ++31 (0)35 6772979 +nl_NL eo_XX en_US +mihxil' + [] () + +From pgsql-performance-owner@postgresql.org Sat Apr 24 01:29:46 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9BEF3D1CCA2 + for ; + Sat, 24 Apr 2004 01:29:40 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 05183-06 + for ; + Sat, 24 Apr 2004 01:29:39 -0300 (ADT) +Received: from ganymede.hub.org (u46n208.hfx.eastlink.ca [24.222.46.208]) + by svr1.postgresql.org (Postfix) with ESMTP id D7F49D1CB1D + for ; + Sat, 24 Apr 2004 01:29:38 -0300 (ADT) +Received: by ganymede.hub.org (Postfix, from userid 1000) + id 52E8B3429B; Sat, 24 Apr 2004 01:29:38 -0300 (ADT) +Received: from localhost (localhost [127.0.0.1]) + by ganymede.hub.org (Postfix) with ESMTP id 521D0341C6 + for ; + Sat, 24 Apr 2004 01:29:38 -0300 (ADT) +X-Received: from localhost ([unix socket]) + by ganymede.hub.org (Cyrus v2.2.3) with LMTP; + Thu, 22 Apr 2004 11:50:38 -0300 +X-Sieve: CMU Sieve 2.2 +X-Received: from localhost (localhost [127.0.0.1]) + by ganymede.hub.org (Postfix) with ESMTP id 94BA537628 + for ; Thu, 22 Apr 2004 11:50:35 -0300 (ADT) +X-Received: from mail.postgresql.org [200.46.204.71] + by localhost with IMAP (fetchmail-6.2.5) + for scrappy@localhost (single-drop); + Thu, 22 Apr 2004 11:50:35 -0300 (ADT) +X-Received: from svr1.postgresql.org ([unix socket]) + by svr1.postgresql.org (Cyrus v2.2.3) with LMTP; + Thu, 22 Apr 2004 11:46:45 -0300 +X-Sieve: CMU Sieve 2.2 +X-Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 842ECD1D09C + for ; Thu, 22 Apr 2004 11:46:44 -0300 (ADT) +X-Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 84786-01 for ; + Thu, 22 Apr 2004 11:46:47 -0300 (ADT) +X-Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DEC58D1CCB1 + for ; Thu, 22 Apr 2004 11:46:42 -0300 (ADT) +X-Received: from [134.22.70.203] (dyn-70-203.tor.dsl.tht.net [134.22.70.203]) + by tht.net (Postfix) with ESMTP + id 1677976AA2; Thu, 22 Apr 2004 10:46:50 -0400 (EDT) +Subject: Re: order by index, and inheritance +From: Rod Taylor +To: Michiel Meeuwissen +Cc: performance@postgresql.org +In-Reply-To: <20040422144023.GI6870@michiel.omroep.nl> +References: <20040419113013.GA32186@michiel.omroep.nl> + <1082455997.57436.10.camel@jester> + <20040420104518.GF1618@michiel.omroep.nl> + <1082461767.57436.93.camel@jester> + <20040422110214.GH6870@michiel.omroep.nl> + <1082641607.91360.2.camel@jester> + <20040422144023.GI6870@michiel.omroep.nl> +Content-Type: text/plain +Message-Id: <1082645200.91360.24.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Thu, 22 Apr 2004 10:46:40 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-DCC: : +X-Spam-Pyzor: +ReSent-Date: Sat, 24 Apr 2004 01:29:33 -0300 (ADT) +Resent-From: "Marc G. Fournier" +Resent-To: pgsql-performance@postgresql.org +ReSent-Subject: Re: [PERFORM] order by index, and inheritance +ReSent-Message-ID: <20040424012933.R42925@ganymede.hub.org> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/423 +X-Sequence-Number: 6723 + + +> This indeeds performs good (about 10000 times faster then select number,url +> from mm_mediasources order by number desc limit 20) . But hardly beautiful, +> and quite useless too because of course I am now going to want to use an +> offset (limit 20 offset 20, you see..), which seems more or less impossible +> in this way, isn't it. + +Yes, and the offset is a good reason why PostgreSQL will not be able to +do it by itself either. + +Is "number" unique across the board? + +If so, instead of the offset you could use WHERE number > $lastValue. + + +From pgsql-advocacy-owner@postgresql.org Thu Apr 22 14:34:06 2004 +X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id CB5A6D1D3BE + for ; + Thu, 22 Apr 2004 12:54:50 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 06636-03 + for ; + Thu, 22 Apr 2004 12:54:49 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 024E2D1D067 + for ; + Thu, 22 Apr 2004 12:54:49 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3MFsmGD007445; + Thu, 22 Apr 2004 11:54:48 -0400 (EDT) +To: Eduardo Almeida +Cc: Jan Wieck , Josh Berkus , + pgsql-advocacy@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: [PERFORM] MySQL vs PG TPC-H benchmarks +In-reply-to: <20040422125318.26053.qmail@web60601.mail.yahoo.com> +References: <20040422125318.26053.qmail@web60601.mail.yahoo.com> +Comments: In-reply-to Eduardo Almeida + message dated "Thu, 22 Apr 2004 05:53:18 -0700" +Date: Thu, 22 Apr 2004 11:54:48 -0400 +Message-ID: <7444.1082649288@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/125 +X-Sequence-Number: 4097 + +Eduardo Almeida writes: +> About 7hs:30min to load the data and 16:09:25 to +> create the indexes + +You could probably improve the index-create time by temporarily +increasing sort_mem. It wouldn't be unreasonable to give CREATE INDEX +several hundred meg to work in. (You don't want sort_mem that big +normally, because there may be many sorts happening in parallel, +but in a data-loading context there'll just be one active sort.) + + regards, tom lane + +From pgsql-advocacy-owner@postgresql.org Thu Apr 22 13:44:02 2004 +X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4631FD1D2B7 + for ; + Thu, 22 Apr 2004 13:20:00 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 17346-04 + for ; + Thu, 22 Apr 2004 13:19:57 -0300 (ADT) +Received: from smtp011.mail.yahoo.com (smtp011.mail.yahoo.com + [216.136.173.31]) + by svr1.postgresql.org (Postfix) with SMTP id E1E75D1CCAD + for ; + Thu, 22 Apr 2004 13:19:55 -0300 (ADT) +Received: from unknown (HELO europa.janwieck.net) (janwieck@68.80.245.191 with + login) + by smtp011.mail.yahoo.com with SMTP; 22 Apr 2004 16:19:55 -0000 +Received: from Yahoo.com (ismtp.afilias.com [216.217.55.254]) (authenticated) + by europa.janwieck.net (8.11.6/8.11.6) with ESMTP id i3MGJrj15217; + Thu, 22 Apr 2004 12:19:53 -0400 +Message-ID: <4087F0A3.6040009@Yahoo.com> +Date: Thu, 22 Apr 2004 12:19:47 -0400 +From: Jan Wieck +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.4) Gecko/20030624 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Eduardo Almeida +Cc: Josh Berkus , pgsql-advocacy@postgresql.org, + pgsql-performance@postgresql.org +Subject: Re: [PERFORM] MySQL vs PG TPC-H benchmarks +References: <20040422125318.26053.qmail@web60601.mail.yahoo.com> +In-Reply-To: <20040422125318.26053.qmail@web60601.mail.yahoo.com> +Content-Type: text/plain; charset=windows-1252; format=flowed +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=2.6 tagged_above=0.0 required=5.0 + tests=RCVD_IN_DYNABLOCK, RCVD_IN_SORBS +X-Spam-Level: ** +X-Archive-Number: 200404/124 +X-Sequence-Number: 4096 + +Eduardo Almeida wrote: + +> Folks, +> +> I�m doing the 100GB TPC-H and I�ll show the previous +> results to our community (Postgres) in 3 weeks before +> finishing the study. +> +> My intention is to carry through a test with a VLDB in +> a low cost platform (PostgreSQL, Linux and cheap HW) +> and not to compare with another DBMS. + +QphH and Price/QphH will be enought for us to see where in the list we +are. Unfortunately there are only Sybase and MS SQL results published in +the 100 GB category. The 300 GB has DB2 as well. Oracle starts at 1 TB +and in the 10 TB category Oracle and DB2 are the only players left. + + +Jan + +> +> So far I can tell you that the load time on PG 7.4.2 +> with kernel 2.6.5 on Opteron 64 model 240 in RAID 0 +> with 8 disks (960 GB) loaded the database in less than +> 24 hours. +> About 7hs:30min to load the data and 16:09:25 to +> create the indexes +> +> The Power test still running and that�s why I�ll not +> present anything so far. Now I�ll just send to the +> list my environment configuration. +> +> - The configuration of the machine is: +> Dual opteron 64 bits model 240 +> 4GB RAM +> 960 GB on RAID 0 +> Mandrake Linux 64 with Kernel 2.6.5 (I compiled a +> kernel for this test) +> Java SDK java version "1.4.2_04" +> PostgreSQL JDBC pg74.1jdbc3.jar +> +> - The TPC-H configuration is: +> TPC-H 2.0.0 +> 100GB +> load using flat files +> Refresh functions using java +> +> - The PostgreSQL 7.4.2 configuration is: +> +> add_missing_from | on +> australian_timezones | off +> authentication_timeout | 60 +> check_function_bodies | on +> checkpoint_segments | 128 +> checkpoint_timeout | 300 +> checkpoint_warning | 30 +> client_encoding | SQL_ASCII +> client_min_messages | notice +> commit_delay | 0 +> commit_siblings | 5 +> cpu_index_tuple_cost | 0.001 +> cpu_operator_cost | 0.0025 +> cpu_tuple_cost | 0.01 +> DateStyle | ISO, MDY +> db_user_namespace | off +> deadlock_timeout | 1000 +> debug_pretty_print | off +> debug_print_parse | off +> debug_print_plan | off +> debug_print_rewritten | off +> default_statistics_target | 10 +> default_transaction_isolation | read committed +> default_transaction_read_only | off +> dynamic_library_path | $libdir +> effective_cache_size | 150000 +> enable_hashagg | on +> enable_hashjoin | on +> enable_indexscan | on +> enable_mergejoin | on +> enable_nestloop | on +> enable_seqscan | on +> enable_sort | on +> enable_tidscan | on +> explain_pretty_print | on +> extra_float_digits | 0 +> from_collapse_limit | 8 +> fsync | off +> geqo | on +> geqo_effort | 1 +> geqo_generations | 0 +> geqo_pool_size | 0 +> geqo_selection_bias | 2 +> geqo_threshold | 11 +> join_collapse_limit | 8 +> krb_server_keyfile | unset +> lc_collate | en_US +> lc_ctype | en_US +> lc_messages | C +> lc_monetary | C +> lc_numeric | C +> lc_time | C +> log_connections | off +> log_duration | off +> log_error_verbosity | default +> log_executor_stats | off +> log_hostname | off +> log_min_duration_statement | -1 +> log_min_error_statement | panic +> log_min_messages | notice +> log_parser_stats | off +> log_pid | off +> log_planner_stats | off +> log_source_port | off +> log_statement | off +> log_statement_stats | off +> log_timestamp | off +> max_connections | 10 +> max_expr_depth | 10000 +> max_files_per_process | 1000 +> max_fsm_pages | 20000 +> max_fsm_relations | 1000 +> max_locks_per_transaction | 64 +> password_encryption | on +> port | 5432 +> pre_auth_delay | 0 +> preload_libraries | unset +> random_page_cost | 1.25 +> regex_flavor | advanced +> rendezvous_name | unset +> search_path | $user,public +> server_encoding | SQL_ASCII +> server_version | 7.4.2 +> shared_buffers | 40000 +> silent_mode | off +> sort_mem | 65536 +> sql_inheritance | on +> ssl | off +> statement_timeout | 10000000 +> stats_block_level | off +> stats_command_string | off +> stats_reset_on_server_start | on +> stats_row_level | off +> stats_start_collector | on +> superuser_reserved_connections | 2 +> syslog | 0 +> syslog_facility | LOCAL0 +> syslog_ident | postgres +> tcpip_socket | on +> TimeZone | unknown +> trace_notify | off +> transaction_isolation | read committed +> transaction_read_only | off +> transform_null_equals | off +> unix_socket_directory | unset +> unix_socket_group | unset +> unix_socket_permissions | 511 +> vacuum_mem | 65536 +> virtual_host | unset +> wal_buffers | 32 +> wal_debug | 0 +> wal_sync_method | fdatasync +> zero_damaged_pages | off +> (113 rows) +> +> +> suggestions, doubts and commentaries are very welcome +> +> regards +> ______________________________ +> Eduardo Cunha de Almeida +> Administra��o de Banco de Dados +> UFPR - CCE +> +55-41-361-3321 +> eduardo.almeida@ufpr.br +> edalmeida@yahoo.com +> +> --- Jan Wieck wrote: +>> Josh Berkus wrote: +>> +>> > Folks, +>> > +>> > I've sent a polite e-mail to Mr. Gomez offering +>> our help. Please, nobody +>> > flame him! +>> > +>> +>> Please keep in mind that the entire test has, other +>> than a similar +>> database schema and query types maybe, nothing to do +>> with a TPC-H. I +>> don't see any kind of SUT. Foreign key support on +>> the DB level is not +>> required by any of the TPC benchmarks. But the +>> System Under Test, which +>> is the combination of middleware application and +>> database together with +>> all computers and network components these parts are +>> running on, must +>> implement all the required semantics, like ACID +>> properties, referential +>> integrity &c. One could implement a TPC-H with flat +>> files, it's just a +>> major pain in the middleware. +>> +>> A proper TPC benchmark implementation would for +>> example be a complete +>> PHP+DB application, where the user interaction is +>> done by an emulated +>> "browser" and what is measured is the http response +>> times, not anything +>> going on between PHP and the DB. Assuming that all +>> requirements of the +>> TPC specification are implemented by either using +>> available DB features, +>> or including appropriate workarounds in the PHP +>> code, that would very +>> well lead to something that can compare PHP+MySQL +>> vs. PHP+PostgreSQL. +>> +>> All TPC benchmarks I have seen are performed by +>> timing such a system +>> after a considerable rampup time, giving the DB +>> system a chance to +>> properly populate caches and so forth. Rebooting the +>> machine just before +>> the test is the wrong thing here and will especially +>> kill any advanced +>> cache algorithms like ARC. +>> +>> +>> Jan +>> +>> -- +>> +> #======================================================================# +>> # It's easier to get forgiveness for being wrong +>> than for being right. # +>> # Let's break this rule - forgive me. +>> # +>> #================================================== +>> JanWieck@Yahoo.com # +>> +>> +>> ---------------------------(end of +>> broadcast)--------------------------- +>> TIP 5: Have you checked our extensive FAQ? +>> +>> +>> http://www.postgresql.org/docs/faqs/FAQ.htmlIP 5: +>> Have you checked our extensive FAQ? +>> +>> +> http://www.postgresql.org/docs/faqs/FAQ.html +> +> +> +> +> +> __________________________________ +> Do you Yahoo!? +> Yahoo! Photos: High-quality 4x6 digital prints for 25� +> http://photos.yahoo.com/ph/print_splash + + +-- +#======================================================================# +# It's easier to get forgiveness for being wrong than for being right. # +# Let's break this rule - forgive me. # +#================================================== JanWieck@Yahoo.com # + + +From pgsql-advocacy-owner@postgresql.org Mon Apr 26 11:23:41 2004 +X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8D18CD1DA3C + for ; + Thu, 22 Apr 2004 14:11:07 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 38476-02 + for ; + Thu, 22 Apr 2004 14:11:05 -0300 (ADT) +Received: from web60607.mail.yahoo.com (web60607.mail.yahoo.com + [216.109.118.245]) + by svr1.postgresql.org (Postfix) with SMTP id 8D53CD1D26C + for ; + Thu, 22 Apr 2004 14:11:03 -0300 (ADT) +Message-ID: <20040422171034.91737.qmail@web60607.mail.yahoo.com> +Received: from [200.17.210.82] by web60607.mail.yahoo.com via HTTP; + Thu, 22 Apr 2004 10:10:34 PDT +Date: Thu, 22 Apr 2004 10:10:34 -0700 (PDT) +From: Eduardo Almeida +Subject: Re: [PERFORM] MySQL vs PG TPC-H benchmarks +To: Jan Wieck +Cc: Josh Berkus , pgsql-advocacy@postgresql.org, + pgsql-performance@postgresql.org +In-Reply-To: <4087F0A3.6040009@Yahoo.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/212 +X-Sequence-Number: 4184 + +Folks, + +I forgot to mention that I used Shell scripts to load +the data and use Java just to run the refresh +functions. + +Talking about sort_mem config, I used 65000 but in the +TPCH specification they said that you are not able to +change the configs when you start the benchmark, is +that a big problem to use 65000? In the TPCH 100GB we +run 5 streams in parallel for the throughput test! To +power test I think is not a problem because it runs +one query after another. + +Another thing is that I put statement_timeout = +10000000 + +Some queries may exceed this timeout and I�ll send the +EXPLAIN for this ones. + +The last thing is that Jan forgets to mention that +Teradata doesn�t show up now but in older lists shows +3TB and 10TB results. + +regards +Eduardo +--- Jan Wieck wrote: +> Eduardo Almeida wrote: +> +> > Folks, +> > +> > I�m doing the 100GB TPC-H and I�ll show the +> previous +> > results to our community (Postgres) in 3 weeks +> before +> > finishing the study. +> > +> > My intention is to carry through a test with a +> VLDB in +> > a low cost platform (PostgreSQL, Linux and cheap +> HW) +> > and not to compare with another DBMS. +> +> QphH and Price/QphH will be enought for us to see +> where in the list we +> are. Unfortunately there are only Sybase and MS SQL +> results published in +> the 100 GB category. The 300 GB has DB2 as well. +> Oracle starts at 1 TB +> and in the 10 TB category Oracle and DB2 are the +> only players left. +> +> +> Jan +> +> > +> > So far I can tell you that the load time on PG +> 7.4.2 +> > with kernel 2.6.5 on Opteron 64 model 240 in RAID +> 0 +> > with 8 disks (960 GB) loaded the database in less +> than +> > 24 hours. +> > About 7hs:30min to load the data and 16:09:25 to +> > create the indexes +> > +> > The Power test still running and that�s why I�ll +> not +> > present anything so far. Now I�ll just send to the +> > list my environment configuration. +> > +> > - The configuration of the machine is: +> > Dual opteron 64 bits model 240 +> > 4GB RAM +> > 960 GB on RAID 0 +> > Mandrake Linux 64 with Kernel 2.6.5 (I compiled a +> > kernel for this test) +> > Java SDK java version "1.4.2_04" +> > PostgreSQL JDBC pg74.1jdbc3.jar +> > +> > - The TPC-H configuration is: +> > TPC-H 2.0.0 +> > 100GB +> > load using flat files +> > Refresh functions using java +> > +> > - The PostgreSQL 7.4.2 configuration is: +> > +> > add_missing_from | on +> > australian_timezones | off +> > authentication_timeout | 60 +> > check_function_bodies | on +> > checkpoint_segments | 128 +> > checkpoint_timeout | 300 +> > checkpoint_warning | 30 +> > client_encoding | SQL_ASCII +> > client_min_messages | notice +> > commit_delay | 0 +> > commit_siblings | 5 +> > cpu_index_tuple_cost | 0.001 +> > cpu_operator_cost | 0.0025 +> > cpu_tuple_cost | 0.01 +> > DateStyle | ISO, MDY +> > db_user_namespace | off +> > deadlock_timeout | 1000 +> > debug_pretty_print | off +> > debug_print_parse | off +> > debug_print_plan | off +> > debug_print_rewritten | off +> > default_statistics_target | 10 +> > default_transaction_isolation | read committed +> > default_transaction_read_only | off +> > dynamic_library_path | $libdir +> > effective_cache_size | 150000 +> > enable_hashagg | on +> > enable_hashjoin | on +> > enable_indexscan | on +> > enable_mergejoin | on +> > enable_nestloop | on +> > enable_seqscan | on +> > enable_sort | on +> > enable_tidscan | on +> > explain_pretty_print | on +> > extra_float_digits | 0 +> > from_collapse_limit | 8 +> > fsync | off +> > geqo | on +> > geqo_effort | 1 +> > geqo_generations | 0 +> > geqo_pool_size | 0 +> > geqo_selection_bias | 2 +> > geqo_threshold | 11 +> > join_collapse_limit | 8 +> > krb_server_keyfile | unset +> > lc_collate | en_US +> > lc_ctype | en_US +> > lc_messages | C +> > lc_monetary | C +> > lc_numeric | C +> > lc_time | C +> > log_connections | off +> > log_duration | off +> > log_error_verbosity | default +> > log_executor_stats | off +> > log_hostname | off +> > log_min_duration_statement | -1 +> > log_min_error_statement | panic +> > log_min_messages | notice +> > log_parser_stats | off +> > log_pid | off +> > log_planner_stats | off +> > log_source_port | off +> > log_statement | off +> > log_statement_stats | off +> > log_timestamp | off +> > max_connections | 10 +> > max_expr_depth | 10000 +> > max_files_per_process | 1000 +> > max_fsm_pages | 20000 +> > max_fsm_relations | 1000 +> > max_locks_per_transaction | 64 +> > password_encryption | on +> > port | 5432 +> > pre_auth_delay | 0 +> > preload_libraries | unset +> > random_page_cost | 1.25 +> > regex_flavor | advanced +> > rendezvous_name | unset +> > search_path | $user,public +> > server_encoding | SQL_ASCII +> > server_version | 7.4.2 +> > shared_buffers | 40000 +> > silent_mode | off +> > sort_mem | 65536 +> > sql_inheritance | on +> > ssl | off +> > statement_timeout | 10000000 +> > stats_block_level | off +> > stats_command_string | off +> > stats_reset_on_server_start | on +> > stats_row_level | off +> > stats_start_collector | on +> > superuser_reserved_connections | 2 +> > syslog | 0 +> > syslog_facility | LOCAL0 +> > syslog_ident | postgres +> > tcpip_socket | on +> > TimeZone | unknown +> > trace_notify | off +> > transaction_isolation | read committed +> > transaction_read_only | off +> > transform_null_equals | off +> > unix_socket_directory | unset +> > unix_socket_group | unset +> > unix_socket_permissions | 511 +> > vacuum_mem | 65536 +> > virtual_host | unset +> > wal_buffers | 32 +> > wal_debug | 0 +> > wal_sync_method | fdatasync +> > zero_damaged_pages | off +> > (113 rows) +> > +> > +> > suggestions, doubts and commentaries are very +> welcome +> > +> > regards +> > ______________________________ +> > Eduardo Cunha de Almeida +> > Administra��o de Banco de Dados +> > UFPR - CCE +> > +55-41-361-3321 +> > eduardo.almeida@ufpr.br +> > edalmeida@yahoo.com +> > +> > --- Jan Wieck wrote: +> >> Josh Berkus wrote: +> >> +> >> > Folks, +> >> > +> >> > I've sent a polite e-mail to Mr. Gomez offering +> >> our help. Please, nobody +> >> > flame him! +> >> > +> >> +> >> Please keep in mind that the entire test has, +> other +> +=== message truncated === + + + + + +__________________________________ +Do you Yahoo!? +Yahoo! Photos: High-quality 4x6 digital prints for 25� +http://photos.yahoo.com/ph/print_splash + +From pgsql-performance-owner@postgresql.org Thu Apr 22 16:25:21 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 13792D1DF8B + for ; + Thu, 22 Apr 2004 14:37:47 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 45280-07 + for ; + Thu, 22 Apr 2004 14:37:46 -0300 (ADT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 002A7D1E0F2 + for ; + Thu, 22 Apr 2004 14:37:44 -0300 (ADT) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4922627; Thu, 22 Apr 2004 10:39:10 -0700 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: Tom Lane , + Bruce Momjian +Subject: Re: Wierd context-switching issue on Xeon patch for 7.4.1 +Date: Thu, 22 Apr 2004 10:37:10 -0700 +User-Agent: KMail/1.4.3 +Cc: pg@fastcrypt.com, Paul Tuckfield , + Anjan Dave , Neil Conway , + Dirk =?iso-8859-1?q?Lutzeb=E4ck?= , + pgsql-performance@postgresql.org +References: <200404220456.i3M4uFv04710@candle.pha.pa.us> + <20171.1082610827@sss.pgh.pa.us> +In-Reply-To: <20171.1082610827@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200404221037.10097.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/384 +X-Sequence-Number: 6684 + +Tom, + +> The tricky +> part is that a slow adaptation rate means we can't have every backend +> figuring this out for itself --- the right value would have to be +> maintained globally, and I'm not sure how to do that without adding a +> lot of overhead. + +This may be a moot point, since you've stated that changing the loop timing +won't solve the problem, but what about making the test part of make? I +don't think too many systems are going to change processor architectures once +in production, and those that do can be told to re-compile. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Thu Apr 22 14:54:13 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E3178D1E124 + for ; + Thu, 22 Apr 2004 14:46:27 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 53004-02 + for ; + Thu, 22 Apr 2004 14:46:25 -0300 (ADT) +Received: from mail.deg.cc (mail.deg.cc [198.70.16.196]) + by svr1.postgresql.org (Postfix) with ESMTP id 5D451D1E104 + for ; + Thu, 22 Apr 2004 14:46:24 -0300 (ADT) +Received: from deg.cc (barney.deg.cc [198.70.16.205]) + by mail.deg.cc (Postfix) with ESMTP id D6A3955F7D + for ; + Thu, 22 Apr 2004 13:46:17 -0400 (EDT) +Message-ID: <4088062E.2050901@deg.cc> +Date: Thu, 22 Apr 2004 13:51:42 -0400 +From: Pallav Kalva +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.2) Gecko/20040308 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Setting Shared Buffers , Effective Cache, Sort Mem Parameters +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/383 +X-Sequence-Number: 6683 + +Hi + + We are in the process of building a new machine for our production +database. Below you will see some of the harware specs for the machine. +I need some help with setting these parameters (shared buffers, +effective cache, sort mem) in the pg_conf file. Also can anyone explain +the difference between shared buffers and effective cache , how these +are allocated in the main memory (the docs are not clear on this). + +Here are the Hardware details: +Operating System: Red Hat 9 +Database Ver: Postgres 7.4 +CPU'S : 4 +RAM : 4 gig +Datafile layout : RAID 1+0 +Transaction log : on different RAID1 Array +RAID Stripe Size: 8k + + +Thanks! +Pallav + + +From pgsql-performance-owner@postgresql.org Thu Apr 22 18:02:24 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 57232D1DF75 + for ; + Thu, 22 Apr 2004 14:56:03 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 54670-07 + for ; + Thu, 22 Apr 2004 14:56:02 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id BFB1ED1DF5D + for ; + Thu, 22 Apr 2004 14:56:00 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3MHtr7h008584; + Thu, 22 Apr 2004 13:55:53 -0400 (EDT) +To: Josh Berkus +Cc: Bruce Momjian , pg@fastcrypt.com, + Paul Tuckfield , Anjan Dave , + Neil Conway , + Dirk =?iso-8859-1?q?Lutzeb=E4ck?= , + pgsql-performance@postgresql.org +Subject: Re: Wierd context-switching issue on Xeon patch for 7.4.1 +In-reply-to: <200404221037.10097.josh@agliodbs.com> +References: <200404220456.i3M4uFv04710@candle.pha.pa.us> + <20171.1082610827@sss.pgh.pa.us> + <200404221037.10097.josh@agliodbs.com> +Comments: In-reply-to Josh Berkus + message dated "Thu, 22 Apr 2004 10:37:10 -0700" +Date: Thu, 22 Apr 2004 13:55:53 -0400 +Message-ID: <8583.1082656553@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/390 +X-Sequence-Number: 6690 + +Josh Berkus writes: +> This may be a moot point, since you've stated that changing the loop timing +> won't solve the problem, but what about making the test part of make? I +> don't think too many systems are going to change processor architectures once +> in production, and those that do can be told to re-compile. + +Having to recompile to run on single- vs dual-processor machines doesn't +seem like it would fly. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Apr 22 17:45:27 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C9937D1DF89 + for ; + Thu, 22 Apr 2004 15:11:24 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 58883-07 + for ; + Thu, 22 Apr 2004 15:11:24 -0300 (ADT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id E8978D1DF87 + for ; + Thu, 22 Apr 2004 15:11:22 -0300 (ADT) +Received: from [64.81.245.111] (HELO 192.168.1.102) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4922814; Thu, 22 Apr 2004 11:12:48 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Tom Lane +Subject: Re: Wierd context-switching issue on Xeon patch for 7.4.1 +Date: Thu, 22 Apr 2004 11:11:43 -0700 +User-Agent: KMail/1.5.4 +Cc: Bruce Momjian , pg@fastcrypt.com, + Paul Tuckfield , Anjan Dave , + Neil Conway , + Dirk =?iso-8859-1?q?Lutzeb=E4ck?= , + pgsql-performance@postgresql.org +References: <200404220456.i3M4uFv04710@candle.pha.pa.us> + <200404221037.10097.josh@agliodbs.com> + <8583.1082656553@sss.pgh.pa.us> +In-Reply-To: <8583.1082656553@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200404221111.43151.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 + tests=RCVD_NUMERIC_HELO +X-Spam-Level: +X-Archive-Number: 200404/389 +X-Sequence-Number: 6689 + +Tom, + +> Having to recompile to run on single- vs dual-processor machines doesn't +> seem like it would fly. + +Oh, I don't know. Many applications require compiling for a target +architecture; SQL Server, for example, won't use a 2nd processor without +re-installation. I'm not sure about Oracle. + +It certainly wasn't too long ago that Linux gurus were esposing re-compiling +the kernel for the machine. + +And it's not like they would *have* to re-compile to use PostgreSQL after +adding an additional processor. Just if they wanted to maximize peformance +benefit. + +Also, this is a fairly rare circumstance, I think; to judge by my clients, +once a database server is in production nobody touches the hardware. + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Thu Apr 22 17:31:19 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4116AD1D52E + for ; + Thu, 22 Apr 2004 15:21:46 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 58883-10 + for ; + Thu, 22 Apr 2004 15:21:46 -0300 (ADT) +Received: from web11.manitu.net (web11.manitu.net [217.11.48.111]) + by svr1.postgresql.org (Postfix) with ESMTP id 52E61D1D2B7 + for ; + Thu, 22 Apr 2004 15:21:44 -0300 (ADT) +Received: from [192.168.0.1] (dsl-082-082-191-254.arcor-ip.net + [82.82.191.254]) + (authenticated) + by web11.manitu.net (8.10.2-SOL3/8.10.2) with ESMTP id i3MIKhM15894; + Thu, 22 Apr 2004 20:20:43 +0200 +Subject: Re: [pgsql-advocacy] MySQL vs PG TPC-H benchmarks +From: Markus Bertheau +To: Tom Lane +Cc: Eduardo Almeida , + Jan Wieck , Josh Berkus , + pgsql-performance@postgresql.org +In-Reply-To: <7444.1082649288@sss.pgh.pa.us> +References: <20040422125318.26053.qmail@web60601.mail.yahoo.com> + <7444.1082649288@sss.pgh.pa.us> +Content-Type: text/plain; charset=UTF-8 +Message-Id: <1082658047.4524.0.camel@yarrow.bertheau.de> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-1) +Date: Thu, 22 Apr 2004 20:20:47 +0200 +Content-Transfer-Encoding: quoted-printable +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/388 +X-Sequence-Number: 6688 + +=D0=92 =D0=A7=D1=82=D0=B2, 22.04.2004, =D0=B2 17:54, Tom Lane =D0=BF=D0=B8= +=D1=88=D0=B5=D1=82: +> Eduardo Almeida writes: +> > About 7hs:30min to load the data and 16:09:25 to +> > create the indexes +>=20 +> You could probably improve the index-create time by temporarily +> increasing sort_mem. It wouldn't be unreasonable to give CREATE INDEX +> several hundred meg to work in. (You don't want sort_mem that big +> normally, because there may be many sorts happening in parallel, +> but in a data-loading context there'll just be one active sort.) + +Doesn't this provide a reason for CREATE INDEX not to honour sort_mem? + +--=20 +Markus Bertheau + + +From pgsql-performance-owner@postgresql.org Thu Apr 22 17:24:08 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id ADF17D1CCAD + for ; + Thu, 22 Apr 2004 15:31:56 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 70736-02 + for ; + Thu, 22 Apr 2004 15:31:54 -0300 (ADT) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id 3C84AD1CCA8 + for ; + Thu, 22 Apr 2004 15:31:52 -0300 (ADT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i3MIVMl22821; + Thu, 22 Apr 2004 14:31:22 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200404221831.i3MIVMl22821@candle.pha.pa.us> +Subject: Re: Wierd context-switching issue on Xeon patch for 7.4.1 +In-Reply-To: <200404221111.43151.josh@agliodbs.com> +To: josh@agliodbs.com +Date: Thu, 22 Apr 2004 14:31:22 -0400 (EDT) +Cc: Tom Lane , pg@fastcrypt.com, + Paul Tuckfield , Anjan Dave , + Neil Conway , + =?ISO-8859-1?Q?Dirk_Lutzeb=E4ck?= , + pgsql-performance@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL108 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/387 +X-Sequence-Number: 6687 + +Josh Berkus wrote: +> Tom, +> +> > Having to recompile to run on single- vs dual-processor machines doesn't +> > seem like it would fly. +> +> Oh, I don't know. Many applications require compiling for a target +> architecture; SQL Server, for example, won't use a 2nd processor without +> re-installation. I'm not sure about Oracle. +> +> It certainly wasn't too long ago that Linux gurus were esposing re-compiling +> the kernel for the machine. +> +> And it's not like they would *have* to re-compile to use PostgreSQL after +> adding an additional processor. Just if they wanted to maximize peformance +> benefit. +> +> Also, this is a fairly rare circumstance, I think; to judge by my clients, +> once a database server is in production nobody touches the hardware. + +A much simpler solution would be for the postmaster to run a test during +startup. + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-performance-owner@postgresql.org Thu Apr 22 17:05:17 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1312CD1DCAC + for ; + Thu, 22 Apr 2004 15:47:19 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 68438-07 + for ; + Thu, 22 Apr 2004 15:47:18 -0300 (ADT) +Received: from mwinf0303.wanadoo.fr (smtp3.wanadoo.fr [193.252.22.28]) + by svr1.postgresql.org (Postfix) with ESMTP id 58826D1D10E + for ; + Thu, 22 Apr 2004 15:47:16 -0300 (ADT) +Received: from [192.168.0.2] (AMontsouris-108-1-20-220.w217-128.abo.wanadoo.fr + [217.128.143.220]) + by mwinf0303.wanadoo.fr (SMTP Server) with ESMTP id 449AB5001438 + for ; + Thu, 22 Apr 2004 20:47:16 +0200 (CEST) +Mime-Version: 1.0 (Apple Message framework v613) +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Resent-Date: Thu, 22 Apr 2004 20:47:16 +0200 +Message-Id: <79BD69C1-948D-11D8-ACE1-000A95DE2550@ifrance.com> +Content-Transfer-Encoding: quoted-printable +Resent-To: pgsql-performance@postgresql.org +Resent-Message-Id: <6B54817E-948D-11D8-ACE1-000A95DE2550@ifrance.com> +From: =?ISO-8859-1?Q?Pailloncy_Jean-G=E9rard?= +Subject: Re: 225 times slower +Resent-From: =?ISO-8859-1?Q?Pailloncy_Jean-G=E9rard?= +Date: Thu, 22 Apr 2004 20:46:51 +0200 +To: Tom Lane +X-Mailer: Apple Mail (2.613) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200404/386 +X-Sequence-Number: 6686 + +> The planner is guessing that scanning in rec_id order will produce a +> matching row fairly quickly (sooner than selecting all the matching=20 +> rows +> and sorting them would do). It's wrong in this case, but I'm not sure +> it could do better without very detailed cross-column statistics. + +> Am I +> right to guess that the rows that match the WHERE clause are not evenly +> distributed in the rec_id order, but rather there are no such rows till +> you get well up in the ordering? + +I must agree that the data are not evenly distributed.... + +For table url: +count 271.395 +min rec_id 1 +max rec_id 3.386.962 + +dps=3D> select * from url where crc32=3D419903683; +count 852 +min rec_id 264.374 +max rec_id 2.392.046 + +I do +dps=3D> select ctid, rec_id from url where crc32=3D419903683 order by=20 +crc32,rec_id; +And then in a text edit extract the "page_id" from ctid +and there is 409 distinct pages for the 852 rows. +There is 4592 pages for the tables url. + +dps=3D> select (rec_id/25), count(*) from url where crc32=3D419903683 group= +=20 +by rec_id/25 having count(*)>4 order by count(*) desc; + ?column? | count +----------+------- + 30289 | 25 + 11875 | 24 + 11874 | 24 + 11876 | 24 + 28154 | 23 + 26164 | 21 + 26163 | 21 + 55736 | 21 + 40410 | 20 + 47459 | 20 + 30290 | 20 + 28152 | 20 + 26162 | 19 + 30291 | 19 + 37226 | 19 + 60357 | 18 + 28150 | 18 + 12723 | 17 + 40413 | 17 + 40412 | 16 + 33167 | 15 + 40415 | 15 + 12961 | 15 + 40414 | 15 + 28151 | 14 + 63961 | 14 + 26165 | 13 + 11873 | 13 + 63960 | 12 + 37225 | 12 + 37224 | 12 + 20088 | 11 + 30288 | 11 + 91450 | 11 + 20087 | 11 + 26892 | 10 + 47458 | 10 + 40411 | 10 + 91451 | 10 + 12722 | 10 + 28153 | 9 + 43488 | 9 + 60358 | 7 + 60356 | 7 + 11877 | 7 + 33168 | 6 + 91448 | 6 + 26161 | 6 + 40409 | 5 + 28155 | 5 + 28318 | 5 + 30292 | 5 + 26891 | 5 + 95666 | 5 +(54 rows) + + + +An other question, with VACUUM VERBOSE ANALYZE, I see: +> INFO: "url": removed 568107 row versions in 4592 pages +> DETAIL: CPU 0.51s/1.17u sec elapsed 174.74 sec. +And I run pg_autovacuum. +Does the big number (568107) of removed row indicates I should set a=20 +higher max_fsm_pages ? + + > grep fsm /var/pgsql/postgresql.conf +max_fsm_pages =3D 60000 # min max_fsm_relations*16, 6 bytes each +max_fsm_relations =3D 200 # min 100, ~50 bytes each + +dps=3D> VACUUM VERBOSE ANALYSE url; +INFO: vacuuming "public.url" +INFO: index "url_crc" now contains 211851 row versions in 218 pages +DETAIL: 129292 index row versions were removed. +0 index pages have been deleted, 0 are currently reusable. +CPU 0.00s/1.38u sec elapsed 5.71 sec. +INFO: index "url_seed" now contains 272286 row versions in 644 pages +DETAIL: 568107 index row versions were removed. +0 index pages have been deleted, 0 are currently reusable. +CPU 0.10s/2.96u sec elapsed 13.06 sec. +INFO: index "url_referrer" now contains 272292 row versions in 603=20 +pages +DETAIL: 568107 index row versions were removed. +4 index pages have been deleted, 0 are currently reusable. +CPU 0.10s/2.98u sec elapsed 22.30 sec. +INFO: index "url_next_index_time" now contains 272292 row versions in=20 +684 pages +DETAIL: 568107 index row versions were removed. +42 index pages have been deleted, 0 are currently reusable. +CPU 0.07s/1.80u sec elapsed 9.50 sec. +INFO: index "url_status" now contains 272298 row versions in 638 pages +DETAIL: 568107 index row versions were removed. +12 index pages have been deleted, 0 are currently reusable. +CPU 0.03s/2.18u sec elapsed 13.66 sec. +INFO: index "url_bad_since_time" now contains 272317 row versions in=20 +611 pages +DETAIL: 568107 index row versions were removed. +4 index pages have been deleted, 0 are currently reusable. +CPU 0.07s/2.40u sec elapsed 10.99 sec. +INFO: index "url_hops" now contains 272317 row versions in 637 pages +DETAIL: 568107 index row versions were removed. +5 index pages have been deleted, 0 are currently reusable. +CPU 0.04s/2.24u sec elapsed 12.46 sec. +INFO: index "url_siteid" now contains 272321 row versions in 653 pages +DETAIL: 568107 index row versions were removed. +13 index pages have been deleted, 0 are currently reusable. +CPU 0.14s/2.05u sec elapsed 11.63 sec. +INFO: index "url_serverid" now contains 272321 row versions in 654=20 +pages +DETAIL: 568107 index row versions were removed. +8 index pages have been deleted, 0 are currently reusable. +CPU 0.10s/2.27u sec elapsed 11.45 sec. +INFO: index "url_url" now contains 272065 row versions in 1892 pages +DETAIL: 193884 index row versions were removed. +5 index pages have been deleted, 0 are currently reusable. +CPU 0.39s/1.50u sec elapsed 36.99 sec. +INFO: index "url_last_mod_time" now contains 272071 row versions in=20 +317 pages +DETAIL: 193884 index row versions were removed. +7 index pages have been deleted, 0 are currently reusable. +CPU 0.03s/1.38u sec elapsed 5.61 sec. +INFO: index "url_pkey" now contains 272086 row versions in 328 pages +DETAIL: 193884 index row versions were removed. +0 index pages have been deleted, 0 are currently reusable. +CPU 0.05s/1.60u sec elapsed 60.64 sec. +INFO: "url": removed 568107 row versions in 4592 pages +DETAIL: CPU 0.51s/1.17u sec elapsed 174.74 sec. +INFO: "url": found 568107 removable, 272027 nonremovable row versions=20 +in 4614 pages +DETAIL: 402 dead row versions cannot be removed yet. +There were 0 unused item pointers. +0 pages are entirely empty. +CPU 1.98s/26.08u sec elapsed 466.27 sec. +INFO: vacuuming "pg_toast.pg_toast_137628026" +INFO: index "pg_toast_137628026_index" now contains 0 row versions in=20 +1 pages +DETAIL: 0 index pages have been deleted, 0 are currently reusable. +CPU 0.00s/0.00u sec elapsed 0.06 sec. +INFO: "pg_toast_137628026": found 0 removable, 0 nonremovable row=20 +versions in 0 pages +DETAIL: 0 dead row versions cannot be removed yet. +There were 0 unused item pointers. +0 pages are entirely empty. +CPU 0.00s/0.00u sec elapsed 0.07 sec. +INFO: analyzing "public.url" +INFO: "url": 4624 pages, 150000 rows sampled, 577419 estimated total=20 +rows +VACUUM + +Cordialement, +Jean-G=E9rard Pailloncy + + +From pgsql-performance-owner@postgresql.org Thu Apr 22 16:47:02 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E7D75D1D10E + for ; + Thu, 22 Apr 2004 16:22:55 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 91082-04 + for ; + Thu, 22 Apr 2004 16:22:56 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 2B495D1D09C + for ; + Thu, 22 Apr 2004 16:22:54 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3MJMpav009414; + Thu, 22 Apr 2004 15:22:52 -0400 (EDT) +To: Markus Bertheau +Cc: Eduardo Almeida , + Jan Wieck , Josh Berkus , + pgsql-performance@postgresql.org +Subject: Re: [pgsql-advocacy] MySQL vs PG TPC-H benchmarks +In-reply-to: <1082658047.4524.0.camel@yarrow.bertheau.de> +References: <20040422125318.26053.qmail@web60601.mail.yahoo.com> + <7444.1082649288@sss.pgh.pa.us> + <1082658047.4524.0.camel@yarrow.bertheau.de> +Comments: In-reply-to Markus Bertheau + message dated "Thu, 22 Apr 2004 20:20:47 +0200" +Date: Thu, 22 Apr 2004 15:22:51 -0400 +Message-ID: <9413.1082661771@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/385 +X-Sequence-Number: 6685 + +Markus Bertheau writes: +>> You could probably improve the index-create time by temporarily +>> increasing sort_mem. It wouldn't be unreasonable to give CREATE INDEX +>> several hundred meg to work in. (You don't want sort_mem that big +>> normally, because there may be many sorts happening in parallel, +>> but in a data-loading context there'll just be one active sort.) + +> Doesn't this provide a reason for CREATE INDEX not to honour sort_mem? + +Already done for 7.5. + +http://archives.postgresql.org/pgsql-committers/2004-02/msg00025.php + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Apr 22 20:12:09 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id AF422D1CCCA + for ; + Thu, 22 Apr 2004 18:20:38 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 29661-07 + for ; + Thu, 22 Apr 2004 18:20:39 -0300 (ADT) +Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) + by svr1.postgresql.org (Postfix) with ESMTP id A5156D1CC7F + for ; + Thu, 22 Apr 2004 18:20:36 -0300 (ADT) +Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) + by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i3MLK1Il023568; + Thu, 22 Apr 2004 15:20:02 -0600 (MDT) +Date: Thu, 22 Apr 2004 15:16:41 -0600 (MDT) +From: "scott.marlowe" +To: Pallav Kalva +Cc: +Subject: Re: Setting Shared Buffers , Effective Cache, Sort Mem +In-Reply-To: <4088062E.2050901@deg.cc> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-IHS-MailScanner: Found to be clean +X-IHS-MailScanner-SpamCheck: +X-IHS-MailScanner-Envelope-Sender: scott.marlowe@ihs.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/396 +X-Sequence-Number: 6696 + +On Thu, 22 Apr 2004, Pallav Kalva wrote: + +> Hi +> +> We are in the process of building a new machine for our production +> database. Below you will see some of the harware specs for the machine. +> I need some help with setting these parameters (shared buffers, +> effective cache, sort mem) in the pg_conf file. Also can anyone explain +> the difference between shared buffers and effective cache , how these +> are allocated in the main memory (the docs are not clear on this). +> +> Here are the Hardware details: +> Operating System: Red Hat 9 +> Database Ver: Postgres 7.4 +> CPU'S : 4 +> RAM : 4 gig +> Datafile layout : RAID 1+0 +> Transaction log : on different RAID1 Array +> RAID Stripe Size: 8k + +Read this first: + +http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html + +Basically shared buffers are the "play area" for the database backends to +toss data in the air and munge it together. The effective cache size +reflects the approximate amount of space your operating system is using to +buffer Postgresql data. On a dedicated database machine this is about the +same as the size of the kernel buffer shown in top. On a mixed machine, +you'll have to see how much of what data is getting buffered to get a +guesstimate of how much kernel cache is being used for pgsql and how much +for other processes. Then divide that number in bytes by 8192, the +default block size. On a machine with 1.2 gigs of kernel cache, that'd be +about 150,000 blocks. + +Buffer sizes from 1000 to 10000 blocks are common. Block sizes from 10000 +to 50000 can somtimes increase performance, but those sizes only really +make sense for machines with lots of ram, and very large datasets being +operated on. + + +From pgsql-performance-owner@postgresql.org Thu Apr 22 20:09:03 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 23BD0D1E0F1 + for ; + Thu, 22 Apr 2004 18:21:40 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 33981-02 + for ; + Thu, 22 Apr 2004 18:21:36 -0300 (ADT) +Received: from mx-2.sollentuna.net (mx-2.sollentuna.net [195.84.163.199]) + by svr1.postgresql.org (Postfix) with ESMTP id A6361D1DFA5 + for ; + Thu, 22 Apr 2004 18:21:33 -0300 (ADT) +Received: from ALGOL.sollentuna.se (janus-en.sollentuna.se [195.84.163.194]) + by mx-2.sollentuna.net (Postfix) with ESMTP + id 415348F2B4; Thu, 22 Apr 2004 23:21:34 +0200 (CEST) +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 +Subject: Re: Wierd context-switching issue on Xeon patch for 7.4.1 +Date: Thu, 22 Apr 2004 23:21:33 +0200 +Message-ID: <6BCB9D8A16AC4241919521715F4D8BCE171658@algol.sollentuna.se> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Wierd context-switching issue on Xeon patch for 7.4.1 +Thread-Index: AcQorMHfolQ6yLncSkOOjBB/+NYT/gAAindg +From: "Magnus Hagander" +To: , "Tom Lane" +Cc: "Bruce Momjian" , , + "Paul Tuckfield" , + "Anjan Dave" , "Neil Conway" , + =?iso-8859-1?Q?Dirk_Lutzeb=E4ck?= , + +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/395 +X-Sequence-Number: 6695 + +>> Having to recompile to run on single- vs dual-processor=20 +>machines doesn't +>> seem like it would fly. +> +>Oh, I don't know. Many applications require compiling for a target=20 +>architecture; SQL Server, for example, won't use a 2nd=20 +>processor without=20 +>re-installation. I'm not sure about Oracle. + +Uh, that is not quite true - at leasdt not for current versions. SQL Server= + will pick up and use whatever processors the underlying OS supports. Now, = +depending on how you install the OS (Windows, that is) you may have ended u= +p with a kernel and HAL that does not support multiprocessor. In this case,= + you have to change HAL. But you certainly don't have to reinstalsl SQL Ser= +ver or Windows. Just a reboot (pretty normal when you add a CPU...) + +Now, there can be licensing issues if you are in per-processor licensing, b= +ut that's a completely different issue. Also, the "Standard Edition" only u= +ses up to 4 CPUs, but again, that's a different issue. + +//Magnus + +From pgsql-performance-owner@postgresql.org Thu Apr 22 20:07:59 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 42A5DD1CCCA + for ; + Thu, 22 Apr 2004 18:22:27 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 25992-09 + for ; + Thu, 22 Apr 2004 18:22:23 -0300 (ADT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A515ED1CCA8 + for ; + Thu, 22 Apr 2004 18:22:20 -0300 (ADT) +Received: from [134.22.70.203] (dyn-70-203.tor.dsl.tht.net [134.22.70.203]) + by tht.net (Postfix) with ESMTP + id 1756376A2B; Thu, 22 Apr 2004 17:22:26 -0400 (EDT) +Subject: Re: Wierd context-switching issue on Xeon patch for 7.4.1 +From: Rod Taylor +To: Tom Lane +Cc: Josh Berkus , + Bruce Momjian , pg@fastcrypt.com, + Paul Tuckfield , Anjan Dave , + Neil Conway , + Dirk =?ISO-8859-1?Q?Lutzeb=E4ck?= , + Postgresql Performance +In-Reply-To: <8583.1082656553@sss.pgh.pa.us> +References: <200404220456.i3M4uFv04710@candle.pha.pa.us> + <20171.1082610827@sss.pgh.pa.us> <200404221037.10097.josh@agliodbs.com> + <8583.1082656553@sss.pgh.pa.us> +Content-Type: text/plain +Message-Id: <1082668930.94537.0.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Thu, 22 Apr 2004 17:22:11 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/394 +X-Sequence-Number: 6694 + +On Thu, 2004-04-22 at 13:55, Tom Lane wrote: +> Josh Berkus writes: +> > This may be a moot point, since you've stated that changing the loop timing +> > won't solve the problem, but what about making the test part of make? I +> > don't think too many systems are going to change processor architectures once +> > in production, and those that do can be told to re-compile. +> +> Having to recompile to run on single- vs dual-processor machines doesn't +> seem like it would fly. + +Is it something the postmaster could quickly determine and set a global +during the startup cycle? + + + +From pgsql-performance-owner@postgresql.org Thu Apr 22 19:28:43 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E5105D1B560 + for ; + Thu, 22 Apr 2004 18:57:16 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 45778-04 + for ; + Thu, 22 Apr 2004 18:57:17 -0300 (ADT) +Received: from audiogram.mail.pas.earthlink.net + (audiogram.mail.pas.earthlink.net [207.217.120.253]) + by svr1.postgresql.org (Postfix) with ESMTP id F375BD1B470 + for ; + Thu, 22 Apr 2004 18:57:14 -0300 (ADT) +Received: from dpcbw098074.direcpc.com ([65.88.98.74] helo=earthlink.net) + by audiogram.mail.pas.earthlink.net with asmtp (Exim 3.36 #4) + id 1BGmC1-0006L2-00 + for pgsql-performance@postgresql.org; Thu, 22 Apr 2004 14:57:15 -0700 +Message-ID: <40883FAB.3070109@earthlink.net> +Date: Thu, 22 Apr 2004 17:56:59 -0400 +From: Sean Shanny +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040113 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Looking for ideas on how to speed up warehouse loading +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-ELNK-Trace: + 6ca696a38bf90a1a1de288fa2098067a1aa676d7e74259b7b3291a7d08dfec792ac252445810def34516d470db6023d3350badd9bab72f9c350badd9bab72f9c +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/392 +X-Sequence-Number: 6692 + +To all, + +Essentials: Running 7.4.1 on OSX on a loaded G5 with dual procs, 8GB +memory, direct attached via fibre channel to a fully optioned 3.5TB +XRaid (14 spindles, 2 sets of 7 in RAID 5) box running RAID 50. + +Background: We are loading what are essentially xml based access logs +from about 20+ webservers daily, about 6GB of raw data. We have a +classic star schema. All the ETL tools are custom java code or standard +*nix tools like sort, uniq etc... + +The problem: We have about 46 million rows in a table with the +following schema: + +Table "public.d_referral" + Column | Type | Modifiers +--------------------+---------+----------- + id | integer | not null + referral_raw_url | text | not null + job_control_number | integer | not null +Indexes: + "d_referral_pkey" primary key, btree (id) + "idx_referral_url" btree (referral_raw_url) + +This is one of our dimension tables. Part of the daily ETL process is +to match all the new referral URL's against existing data in the +d_referral table. Some of the values in referral_raw_url can be 5000 +characters long :-( . The avg length is : 109.57 characters. + +I sort and uniq all the incoming referrals and load them into a temp table. + +Table "public.referral_temp" + Column | Type | Modifiers +--------+------+----------- + url | text | not null +Indexes: + "referral_temp_pkey" primary key, btree (url) + +I then do a left join + +SELECT t1.id, t2.url FROM referral_temp t2 LEFT OUTER JOIN d_referral t1 +ON t2.url = t1.referral_raw_url ORDER BY t1.id + +This is the output from an explain analyze (Please note that I do a set +enable_index_scan = false prior to issuing this because it takes forever +using indexes.): + +explain analyze SELECT t1.id, t2.url FROM referral_temp t2 LEFT OUTER +JOIN d_referral t1 ON t2.url = t1.referral_raw_url ORDER BY t1.id; + +QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------------------ + Sort (cost=4012064.81..4013194.45 rows=451856 width=115) (actual +time=1297320.823..1297739.813 rows=476176 loops=1) + Sort Key: t1.id + -> Hash Left Join (cost=1052345.95..3969623.10 rows=451856 +width=115) (actual time=1146650.487..1290230.590 rows=476176 loops=1) + Hash Cond: ("outer".url = "inner".referral_raw_url) + -> Seq Scan on referral_temp t2 (cost=0.00..6645.56 +rows=451856 width=111) (actual time=20.285..1449.634 rows=476176 loops=1) + -> Hash (cost=729338.16..729338.16 rows=46034716 width=124) +(actual time=1146440.710..1146440.710 rows=0 loops=1) + -> Seq Scan on d_referral t1 (cost=0.00..729338.16 +rows=46034716 width=124) (actual time=14.502..-1064277.123 rows=46034715 +loops=1) + Total runtime: 1298153.193 ms +(8 rows) + + + +What I would like to know is if there are better ways to do the join? I +need to get all the rows back from the referral_temp table as they are +used for assigning FK's for the fact table later in processing. When I +iterate over the values that I get back those with t1.id = null I assign +a new FK and push both into the d_referral table as new entries as well +as a text file for later use. The matching records are written to a +text file for later use. + +If we cannot improve the join performance my question becomes are there +better tools to match up the 46 million and growing at the rate of 1 +million every 3 days, strings outside of postgresql? We don't want to +have to invest in zillions of dollars worth of hardware but if we have +to we will. I just want to make sure we have all the non hardware +possibilities for improvement covered before we start investing in large +disk arrays. + +Thanks. + +--sean + +From pgsql-performance-owner@postgresql.org Thu Apr 22 19:57:00 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D6A20D1CACD + for ; + Thu, 22 Apr 2004 19:48:13 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 60200-07 + for ; + Thu, 22 Apr 2004 19:48:14 -0300 (ADT) +Received: from email06.aon.at (WARSL402PIP3.highway.telekom.at [195.3.96.75]) + by svr1.postgresql.org (Postfix) with SMTP id 85B5CD1BB74 + for ; + Thu, 22 Apr 2004 19:48:11 -0300 (ADT) +Received: (qmail 141892 invoked from network); 22 Apr 2004 22:48:12 -0000 +Received: from m169p017.dipool.highway.telekom.at (HELO PASCAL) + ([62.46.11.17]) (envelope-sender ) + by qmail6rs.highway.telekom.at (qmail-ldap-1.03) with SMTP + for ; 22 Apr 2004 22:48:12 -0000 +From: Manfred Koizar +To: Pallav Kalva +Cc: pgsql-performance@postgresql.org +Subject: Re: Setting Shared Buffers , Effective Cache, Sort Mem Parameters +Date: Fri, 23 Apr 2004 00:50:37 +0200 +Message-ID: +References: <4088062E.2050901@deg.cc> +In-Reply-To: <4088062E.2050901@deg.cc> +X-Mailer: Forte Agent 1.93/32.576 English (American) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200404/393 +X-Sequence-Number: 6693 + +On Thu, 22 Apr 2004 13:51:42 -0400, Pallav Kalva wrote: +>I need some help with setting these parameters (shared buffers, +>effective cache, sort mem) in the pg_conf file. + +It really depends on the kind of queries you intend to run, the number +of concurrent active connections, the size of the working set (active +part of the database), what else is running on the machine, and and and +... + +Setting shared_buffers to 10000, effective_cache_size to 400000 (80% of +installed RAM), and sort_mem to a few thousand might be a good start. + +> Also can anyone explain +>the difference between shared buffers and effective cache , how these +>are allocated in the main memory (the docs are not clear on this). + +Shared_buffers directly controls how many pages are allocated as +internal cache. Effective_cache_size doesn't allocate anything, it is +just a hint to the planner how much cache is available on the system +level. + +Servus + Manfred + +From pgsql-performance-owner@postgresql.org Mon Apr 26 14:51:28 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DCF19D1B470 + for ; + Thu, 22 Apr 2004 20:13:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 66747-09 + for ; + Thu, 22 Apr 2004 20:13:37 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 9924CD1E104 + for ; + Thu, 22 Apr 2004 20:13:34 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i3MNDVSx074795 + for ; Thu, 22 Apr 2004 23:13:31 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i3MN4EWp073325 + for pgsql-performance@postgresql.org; Thu, 22 Apr 2004 23:04:14 GMT +From: CoL +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Looking for ideas on how to speed up warehouse loading +Date: Fri, 23 Apr 2004 01:05:20 +0200 +Organization: Hub.Org Networking Services +Lines: 19 +Message-ID: +References: <40883FAB.3070109@earthlink.net> +Reply-To: col@mportal.hu +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.7b) Gecko/20040421 +X-Accept-Language: en-us, en +In-Reply-To: <40883FAB.3070109@earthlink.net> +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/442 +X-Sequence-Number: 6742 + +hi, + +Sean Shanny wrote, On 4/22/2004 23:56: +> +> SELECT t1.id, t2.url FROM referral_temp t2 LEFT OUTER JOIN d_referral t1 +> ON t2.url = t1.referral_raw_url ORDER BY t1.id + +index on url (text) has no sense. Try to use and md5 (char(32) column) +which contains the md5 hash of url field. and join these ones. You can +have a better index on this char 32 field. + +do not forget to analyze the tables after data load, and you can fine +tune you postgresql.conf, default_statistics_target for better index +info, and others. +check this info pages: +http://www.varlena.com/varlena/GeneralBits/Tidbits/annotated_conf_e.html +http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html + +C. + +From pgsql-performance-owner@postgresql.org Thu Apr 22 20:54:57 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C897FD1BC54 + for ; + Thu, 22 Apr 2004 20:31:05 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 73749-08 + for ; + Thu, 22 Apr 2004 20:31:07 -0300 (ADT) +Received: from mynah.mail.pas.earthlink.net (mynah.mail.pas.earthlink.net + [207.217.120.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 60D2BD1BABA + for ; + Thu, 22 Apr 2004 20:31:03 -0300 (ADT) +Received: from dpcbw098074.direcpc.com ([65.88.98.74] helo=earthlink.net) + by mynah.mail.pas.earthlink.net with asmtp (Exim 3.36 #4) + id 1BGneo-0006jt-00 + for pgsql-performance@postgresql.org; Thu, 22 Apr 2004 16:31:03 -0700 +Message-ID: <408855AD.4090500@earthlink.net> +Date: Thu, 22 Apr 2004 19:30:53 -0400 +From: Sean Shanny +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040113 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Looking for ideas on how to speed up warehouse loading +References: <40883FAB.3070109@earthlink.net> +In-Reply-To: <40883FAB.3070109@earthlink.net> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-ELNK-Trace: + 6ca696a38bf90a1a1de288fa2098067a1aa676d7e74259b7b3291a7d08dfec79f9464016687b596ee7bf1ce92ae5b783350badd9bab72f9c350badd9bab72f9c +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/397 +X-Sequence-Number: 6697 + +I should have included this as well: + + show all; + name | setting +--------------------------------+---------------- + add_missing_from | on + australian_timezones | off + authentication_timeout | 60 + check_function_bodies | on + checkpoint_segments | 64 + checkpoint_timeout | 30 + checkpoint_warning | 30 + client_encoding | UNICODE + client_min_messages | notice + commit_delay | 0 + commit_siblings | 5 + cpu_index_tuple_cost | 0.001 + cpu_operator_cost | 0.0025 + cpu_tuple_cost | 0.01 + DateStyle | ISO, MDY + db_user_namespace | off + deadlock_timeout | 1000 + debug_pretty_print | off + debug_print_parse | off + debug_print_plan | off + debug_print_rewritten | off + default_statistics_target | 1000 + default_transaction_isolation | read committed + default_transaction_read_only | off + dynamic_library_path | $libdir + effective_cache_size | 400000 + enable_hashagg | on + enable_hashjoin | on + enable_indexscan | on + enable_mergejoin | on + enable_nestloop | on + enable_seqscan | on + enable_sort | on + enable_tidscan | on + explain_pretty_print | on + extra_float_digits | 0 + from_collapse_limit | 8 + fsync | on + geqo | on + geqo_effort | 1 + geqo_generations | 0 + geqo_pool_size | 0 + geqo_selection_bias | 2 + geqo_threshold | 11 + join_collapse_limit | 8 + krb_server_keyfile | unset + lc_collate | C + lc_ctype | C + lc_messages | C + lc_monetary | C + lc_numeric | C + lc_time | C + log_connections | off + log_duration | off + log_error_verbosity | default + log_executor_stats | off + log_hostname | off + log_min_duration_statement | -1 + log_min_error_statement | panic + log_min_messages | notice + log_parser_stats | off + log_pid | off + log_planner_stats | off + log_source_port | off + log_statement | off + log_statement_stats | off + log_timestamp | on + max_connections | 100 + max_expr_depth | 10000 + max_files_per_process | 1000 + max_fsm_pages | 20000 + max_fsm_relations | 1000 + max_locks_per_transaction | 64 + password_encryption | on + port | 5432 + pre_auth_delay | 0 + preload_libraries | unset + random_page_cost | 4 + regex_flavor | advanced + rendezvous_name | unset + search_path | $user,public + server_encoding | UNICODE + server_version | 7.4.1 + shared_buffers | 4000 + silent_mode | off + sort_mem | 64000 + sql_inheritance | on + ssl | off + statement_timeout | 0 + stats_block_level | on + stats_command_string | on + stats_reset_on_server_start | off + stats_row_level | on + stats_start_collector | on + superuser_reserved_connections | 2 + syslog | 0 + syslog_facility | LOCAL0 + syslog_ident | postgres + tcpip_socket | on + TimeZone | unknown + trace_notify | off + transaction_isolation | read committed + transaction_read_only | off + transform_null_equals | off + unix_socket_directory | unset + unix_socket_group | unset + unix_socket_permissions | 511 + vacuum_mem | 64000 + virtual_host | unset + wal_buffers | 1024 + wal_debug | 0 + wal_sync_method | open_sync + zero_damaged_pages | off + + +Sean Shanny wrote: + +> To all, +> +> Essentials: Running 7.4.1 on OSX on a loaded G5 with dual procs, 8GB +> memory, direct attached via fibre channel to a fully optioned 3.5TB +> XRaid (14 spindles, 2 sets of 7 in RAID 5) box running RAID 50. +> +> Background: We are loading what are essentially xml based access logs +> from about 20+ webservers daily, about 6GB of raw data. We have a +> classic star schema. All the ETL tools are custom java code or +> standard *nix tools like sort, uniq etc... +> +> The problem: We have about 46 million rows in a table with the +> following schema: +> +> Table "public.d_referral" +> Column | Type | Modifiers +> --------------------+---------+----------- +> id | integer | not null +> referral_raw_url | text | not null +> job_control_number | integer | not null +> Indexes: +> "d_referral_pkey" primary key, btree (id) +> "idx_referral_url" btree (referral_raw_url) +> +> This is one of our dimension tables. Part of the daily ETL process is +> to match all the new referral URL's against existing data in the +> d_referral table. Some of the values in referral_raw_url can be 5000 +> characters long :-( . The avg length is : 109.57 characters. +> +> I sort and uniq all the incoming referrals and load them into a temp +> table. +> +> Table "public.referral_temp" +> Column | Type | Modifiers +> --------+------+----------- +> url | text | not null +> Indexes: +> "referral_temp_pkey" primary key, btree (url) +> +> I then do a left join +> +> SELECT t1.id, t2.url FROM referral_temp t2 LEFT OUTER JOIN d_referral +> t1 ON t2.url = t1.referral_raw_url ORDER BY t1.id +> +> This is the output from an explain analyze (Please note that I do a +> set enable_index_scan = false prior to issuing this because it takes +> forever using indexes.): +> +> explain analyze SELECT t1.id, t2.url FROM referral_temp t2 LEFT OUTER +> JOIN d_referral t1 ON t2.url = t1.referral_raw_url ORDER BY t1.id; +> +> QUERY PLAN +> ------------------------------------------------------------------------------------------------------------------------------------------------------ +> +> Sort (cost=4012064.81..4013194.45 rows=451856 width=115) (actual +> time=1297320.823..1297739.813 rows=476176 loops=1) +> Sort Key: t1.id +> -> Hash Left Join (cost=1052345.95..3969623.10 rows=451856 +> width=115) (actual time=1146650.487..1290230.590 rows=476176 loops=1) +> Hash Cond: ("outer".url = "inner".referral_raw_url) +> -> Seq Scan on referral_temp t2 (cost=0.00..6645.56 +> rows=451856 width=111) (actual time=20.285..1449.634 rows=476176 loops=1) +> -> Hash (cost=729338.16..729338.16 rows=46034716 width=124) +> (actual time=1146440.710..1146440.710 rows=0 loops=1) +> -> Seq Scan on d_referral t1 (cost=0.00..729338.16 +> rows=46034716 width=124) (actual time=14.502..-1064277.123 +> rows=46034715 loops=1) +> Total runtime: 1298153.193 ms +> (8 rows) +> +> +> +> What I would like to know is if there are better ways to do the join? +> I need to get all the rows back from the referral_temp table as they +> are used for assigning FK's for the fact table later in processing. +> When I iterate over the values that I get back those with t1.id = null +> I assign a new FK and push both into the d_referral table as new +> entries as well as a text file for later use. The matching records +> are written to a text file for later use. +> If we cannot improve the join performance my question becomes are +> there better tools to match up the 46 million and growing at the rate +> of 1 million every 3 days, strings outside of postgresql? We don't +> want to have to invest in zillions of dollars worth of hardware but if +> we have to we will. I just want to make sure we have all the non +> hardware possibilities for improvement covered before we start +> investing in large disk arrays. +> Thanks. +> +> --sean +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 9: the planner will ignore your desire to choose an index scan if +> your +> joining column's datatypes do not match +> + +From pgsql-performance-owner@postgresql.org Thu Apr 22 21:56:26 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D3237D1E11A + for ; + Thu, 22 Apr 2004 21:54:22 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 97491-10 + for ; + Thu, 22 Apr 2004 21:54:24 -0300 (ADT) +Received: from mx.tripadvisor.com (unknown [151.203.96.35]) + by svr1.postgresql.org (Postfix) with ESMTP id 35E53D1E0ED + for ; + Thu, 22 Apr 2004 21:54:20 -0300 (ADT) +Received: from [192.168.0.102] (h0080c8aa8d54.ne.client2.attbi.com + [24.147.6.138]) + by mx.tripadvisor.com (8.12.10/8.12.10) with SMTP id i3N0sFQ8093722; + Thu, 22 Apr 2004 20:54:15 -0400 (EDT) + (envelope-from nshanny@tripadvisor.com) +In-Reply-To: <408855AD.4090500@earthlink.net> +References: <40883FAB.3070109@earthlink.net> <408855AD.4090500@earthlink.net> +Mime-Version: 1.0 (Apple Message framework v613) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: +Content-Transfer-Encoding: 7bit +Cc: pgsql-performance@postgresql.org +From: Nicholas Shanny +Subject: Re: Looking for ideas on how to speed up warehouse loading +Date: Thu, 22 Apr 2004 20:54:15 -0400 +To: Sean Shanny +X-Mailer: Apple Mail (2.613) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/398 +X-Sequence-Number: 6698 + +One other thing: we are running with a block size of 32K. + + +Nick Shanny +(Brother of above person) + +On Apr 22, 2004, at 7:30 PM, Sean Shanny wrote: + +> I should have included this as well: +> +> show all; +> name | setting +> --------------------------------+---------------- +> add_missing_from | on +> australian_timezones | off +> authentication_timeout | 60 +> check_function_bodies | on +> checkpoint_segments | 64 +> checkpoint_timeout | 30 +> checkpoint_warning | 30 +> client_encoding | UNICODE +> client_min_messages | notice +> commit_delay | 0 +> commit_siblings | 5 +> cpu_index_tuple_cost | 0.001 +> cpu_operator_cost | 0.0025 +> cpu_tuple_cost | 0.01 +> DateStyle | ISO, MDY +> db_user_namespace | off +> deadlock_timeout | 1000 +> debug_pretty_print | off +> debug_print_parse | off +> debug_print_plan | off +> debug_print_rewritten | off +> default_statistics_target | 1000 +> default_transaction_isolation | read committed +> default_transaction_read_only | off +> dynamic_library_path | $libdir +> effective_cache_size | 400000 +> enable_hashagg | on +> enable_hashjoin | on +> enable_indexscan | on +> enable_mergejoin | on +> enable_nestloop | on +> enable_seqscan | on +> enable_sort | on +> enable_tidscan | on +> explain_pretty_print | on +> extra_float_digits | 0 +> from_collapse_limit | 8 +> fsync | on +> geqo | on +> geqo_effort | 1 +> geqo_generations | 0 +> geqo_pool_size | 0 +> geqo_selection_bias | 2 +> geqo_threshold | 11 +> join_collapse_limit | 8 +> krb_server_keyfile | unset +> lc_collate | C +> lc_ctype | C +> lc_messages | C +> lc_monetary | C +> lc_numeric | C +> lc_time | C +> log_connections | off +> log_duration | off +> log_error_verbosity | default +> log_executor_stats | off +> log_hostname | off +> log_min_duration_statement | -1 +> log_min_error_statement | panic +> log_min_messages | notice +> log_parser_stats | off +> log_pid | off +> log_planner_stats | off +> log_source_port | off +> log_statement | off +> log_statement_stats | off +> log_timestamp | on +> max_connections | 100 +> max_expr_depth | 10000 +> max_files_per_process | 1000 +> max_fsm_pages | 20000 +> max_fsm_relations | 1000 +> max_locks_per_transaction | 64 +> password_encryption | on +> port | 5432 +> pre_auth_delay | 0 +> preload_libraries | unset +> random_page_cost | 4 +> regex_flavor | advanced +> rendezvous_name | unset +> search_path | $user,public +> server_encoding | UNICODE +> server_version | 7.4.1 +> shared_buffers | 4000 +> silent_mode | off +> sort_mem | 64000 +> sql_inheritance | on +> ssl | off +> statement_timeout | 0 +> stats_block_level | on +> stats_command_string | on +> stats_reset_on_server_start | off +> stats_row_level | on +> stats_start_collector | on +> superuser_reserved_connections | 2 +> syslog | 0 +> syslog_facility | LOCAL0 +> syslog_ident | postgres +> tcpip_socket | on +> TimeZone | unknown +> trace_notify | off +> transaction_isolation | read committed +> transaction_read_only | off +> transform_null_equals | off +> unix_socket_directory | unset +> unix_socket_group | unset +> unix_socket_permissions | 511 +> vacuum_mem | 64000 +> virtual_host | unset +> wal_buffers | 1024 +> wal_debug | 0 +> wal_sync_method | open_sync +> zero_damaged_pages | off +> +> +> Sean Shanny wrote: +> +>> To all, +>> +>> Essentials: Running 7.4.1 on OSX on a loaded G5 with dual procs, 8GB +>> memory, direct attached via fibre channel to a fully optioned 3.5TB +>> XRaid (14 spindles, 2 sets of 7 in RAID 5) box running RAID 50. +>> +>> Background: We are loading what are essentially xml based access +>> logs from about 20+ webservers daily, about 6GB of raw data. We have +>> a classic star schema. All the ETL tools are custom java code or +>> standard *nix tools like sort, uniq etc... +>> +>> The problem: We have about 46 million rows in a table with the +>> following schema: +>> +>> Table "public.d_referral" +>> Column | Type | Modifiers +>> --------------------+---------+----------- +>> id | integer | not null +>> referral_raw_url | text | not null +>> job_control_number | integer | not null +>> Indexes: +>> "d_referral_pkey" primary key, btree (id) +>> "idx_referral_url" btree (referral_raw_url) +>> +>> This is one of our dimension tables. Part of the daily ETL process +>> is to match all the new referral URL's against existing data in the +>> d_referral table. Some of the values in referral_raw_url can be 5000 +>> characters long :-( . The avg length is : 109.57 characters. +>> +>> I sort and uniq all the incoming referrals and load them into a temp +>> table. +>> +>> Table "public.referral_temp" +>> Column | Type | Modifiers +>> --------+------+----------- +>> url | text | not null +>> Indexes: +>> "referral_temp_pkey" primary key, btree (url) +>> +>> I then do a left join +>> +>> SELECT t1.id, t2.url FROM referral_temp t2 LEFT OUTER JOIN d_referral +>> t1 ON t2.url = t1.referral_raw_url ORDER BY t1.id +>> +>> This is the output from an explain analyze (Please note that I do a +>> set enable_index_scan = false prior to issuing this because it takes +>> forever using indexes.): +>> +>> explain analyze SELECT t1.id, t2.url FROM referral_temp t2 LEFT OUTER +>> JOIN d_referral t1 ON t2.url = t1.referral_raw_url ORDER BY t1.id; +>> +>> QUERY PLAN +>> ---------------------------------------------------------------------- +>> ---------------------------------------------------------------------- +>> ---------- +>> Sort (cost=4012064.81..4013194.45 rows=451856 width=115) (actual +>> time=1297320.823..1297739.813 rows=476176 loops=1) +>> Sort Key: t1.id +>> -> Hash Left Join (cost=1052345.95..3969623.10 rows=451856 +>> width=115) (actual time=1146650.487..1290230.590 rows=476176 loops=1) +>> Hash Cond: ("outer".url = "inner".referral_raw_url) +>> -> Seq Scan on referral_temp t2 (cost=0.00..6645.56 +>> rows=451856 width=111) (actual time=20.285..1449.634 rows=476176 +>> loops=1) +>> -> Hash (cost=729338.16..729338.16 rows=46034716 width=124) +>> (actual time=1146440.710..1146440.710 rows=0 loops=1) +>> -> Seq Scan on d_referral t1 (cost=0.00..729338.16 +>> rows=46034716 width=124) (actual time=14.502..-1064277.123 +>> rows=46034715 loops=1) +>> Total runtime: 1298153.193 ms +>> (8 rows) +>> +>> +>> +>> What I would like to know is if there are better ways to do the join? +>> I need to get all the rows back from the referral_temp table as they +>> are used for assigning FK's for the fact table later in processing. +>> When I iterate over the values that I get back those with t1.id = +>> null I assign a new FK and push both into the d_referral table as new +>> entries as well as a text file for later use. The matching records +>> are written to a text file for later use. +>> If we cannot improve the join performance my question becomes are +>> there better tools to match up the 46 million and growing at the rate +>> of 1 million every 3 days, strings outside of postgresql? We don't +>> want to have to invest in zillions of dollars worth of hardware but +>> if we have to we will. I just want to make sure we have all the non +>> hardware possibilities for improvement covered before we start +>> investing in large disk arrays. +>> Thanks. +>> +>> --sean +>> +>> ---------------------------(end of +>> broadcast)--------------------------- +>> TIP 9: the planner will ignore your desire to choose an index scan if +>> your +>> joining column's datatypes do not match +>> +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 8: explain analyze is your friend +> + + +From pgsql-performance-owner@postgresql.org Thu Apr 22 23:03:52 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D9464D1E14F + for ; + Thu, 22 Apr 2004 23:03:12 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 16770-03 + for ; + Thu, 22 Apr 2004 23:03:15 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id B6A64D1E147 + for ; + Thu, 22 Apr 2004 23:03:09 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3N23Cav014460; + Thu, 22 Apr 2004 22:03:12 -0400 (EDT) +To: Sean Shanny +Cc: pgsql-performance@postgresql.org +Subject: Re: Looking for ideas on how to speed up warehouse loading +In-reply-to: <40883FAB.3070109@earthlink.net> +References: <40883FAB.3070109@earthlink.net> +Comments: In-reply-to Sean Shanny + message dated "Thu, 22 Apr 2004 17:56:59 -0400" +Date: Thu, 22 Apr 2004 22:03:12 -0400 +Message-ID: <14459.1082685792@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/399 +X-Sequence-Number: 6699 + +Sean Shanny writes: +> explain analyze SELECT t1.id, t2.url FROM referral_temp t2 LEFT OUTER +> JOIN d_referral t1 ON t2.url = t1.referral_raw_url ORDER BY t1.id; + +> QUERY PLAN +> ------------------------------------------------------------------------------------------------------------------------------------------------------ +> Sort (cost=4012064.81..4013194.45 rows=451856 width=115) (actual +> time=1297320.823..1297739.813 rows=476176 loops=1) +> Sort Key: t1.id +> -> Hash Left Join (cost=1052345.95..3969623.10 rows=451856 +> width=115) (actual time=1146650.487..1290230.590 rows=476176 loops=1) +> Hash Cond: ("outer".url = "inner".referral_raw_url) +> -> Seq Scan on referral_temp t2 (cost=0.00..6645.56 +> rows=451856 width=111) (actual time=20.285..1449.634 rows=476176 loops=1) +> -> Hash (cost=729338.16..729338.16 rows=46034716 width=124) +> (actual time=1146440.710..1146440.710 rows=0 loops=1) +> -> Seq Scan on d_referral t1 (cost=0.00..729338.16 +> rows=46034716 width=124) (actual time=14.502..-1064277.123 rows=46034715 +> loops=1) +> Total runtime: 1298153.193 ms +> (8 rows) + +> What I would like to know is if there are better ways to do the join? + +What have you got sort_mem set to? You might try increasing it to a gig +or so, since you seem to have plenty of RAM in that box ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Apr 22 23:28:59 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A569FD1E148 + for ; + Thu, 22 Apr 2004 23:27:54 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 18953-09 + for ; + Thu, 22 Apr 2004 23:27:56 -0300 (ADT) +Received: from vt-pe2550-001.VANTAGE.vantage.com (unknown [64.80.203.242]) + by svr1.postgresql.org (Postfix) with ESMTP id BA0F5D1E144 + for ; + Thu, 22 Apr 2004 23:27:51 -0300 (ADT) +X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: multipart/mixed; + boundary="----_=_NextPart_001_01C428DA.95C5DCB2" +Subject: Re: Wierd context-switching issue on Xeon +Date: Thu, 22 Apr 2004 22:27:55 -0400 +Message-ID: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098157@vt-pe2550-001.vantage.vantage.com> +X-MS-Has-Attach: yes +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Wierd context-switching issue on Xeon +Thread-Index: AcQnQtAtXqbOYp+aQp2pIsOo9mab0wBlwiJV +From: "Anjan Dave" +To: "Josh Berkus" , + =?utf-8?Q?Dirk_Lutzeb=C3=A4ck?= , + "Tom Lane" +Cc: , + "Neil Conway" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/400 +X-Sequence-Number: 6700 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C428DA.95C5DCB2 +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: base64 + +VGVzdGVkIHRoZSBzcWwgb24gUXVhZCAyLjBHSHogWEVPTi84R0IgUkFNOg0K +IA0KRHVyaW5nIHRoZSBmaXJzdCBydW4sIHRoZSBDUyBzaG9vdGVkIHVwIG1v +cmUgdGhhbiAxMDBrLCBhbmQgd2FzIHJhbmRvbWx5IGhpZ2gvbG93DQpTZWNv +bmQgcHJvY2VzcyBtYWRlIGl0IGNvbnNpc3RlbnRseSBoaWdoIDEwMGsrDQpU +aGlyZCBicm91Z2h0IGl0IGRvd24gdG8gYW5hdmVyYWdlIDgwLTkwaw0KRm91 +cnRoIGJyb3VnaHQgaXQgZG93biB0byBhbiBhdmVyYWdlIG9mIDUwLTYway9z +DQogDQpCeSBjYW5jZWxsaW5nIHRoZSBxdWVyaWVzIG9uZS1ieS1vbmUsIHRo +ZSBDUyBzdGFydGVkIGdvaW5nIHVwIGFnYWluLg0KIA0KOCBsb2dpY2FsIENQ +VXMgaW4gJ3RvcCcsIGFsbCBvZiB0aGVtIG5vdCBhdCBhbGwgdG9vIGJ1c3ks +IGxvYWQgYXZlcmFnZSBzdG9vZCBhcm91bmQgMiBhbGwgdGhlIHRpbWUuDQog +DQpUaGFua3MuDQpBbmphbg0KIA0KLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0t +LS0gDQpGcm9tOiBKb3NoIEJlcmt1cyBbbWFpbHRvOmpvc2hAYWdsaW9kYnMu +Y29tXSANClNlbnQ6IFR1ZSA0LzIwLzIwMDQgMTI6NTkgUE0gDQpUbzogQW5q +YW4gRGF2ZTsgRGlyayBMdXR6ZWLDpGNrOyBUb20gTGFuZSANCkNjOiBwZ3Nx +bC1wZXJmb3JtYW5jZUBwb3N0Z3JlU1FMLm9yZzsgTmVpbCBDb253YXkgDQpT +dWJqZWN0OiBSZTogW1BFUkZPUk1dIFdpZXJkIGNvbnRleHQtc3dpdGNoaW5n +IGlzc3VlIG9uIFhlb24NCg0KDQoNCglBbmphbiwNCgkNCgk+IFF1YWQgMi4w +R0h6IFhFT04gd2l0aCBoaWdoZXN0IGxvYWQgd2UgaGF2ZSBzZWVuIG9uIHRo +ZSBhcHBsaWNhdGlvbnMsIERCDQoJPiBwZXJmb3JtaW5nIGdyZWF0IC0NCgkN +CglDYW4geW91IHJ1biBUb20ncyB0ZXN0PyAgIEl0IHRha2VzIGEgcGFydGlj +dWxhciBwYXR0ZXJuIG9mIGRhdGEgYWNjZXNzIHRvDQoJcmVwcm9kdWNlIHRo +ZSBpc3N1ZS4NCgkNCgktLQ0KCUpvc2ggQmVya3VzDQoJQWdsaW8gRGF0YWJh +c2UgU29sdXRpb25zDQoJU2FuIEZyYW5jaXNjbw0KCQ0KCS0tLS0tLS0tLS0t +LS0tLS0tLS0tLS0tLS0tLShlbmQgb2YgYnJvYWRjYXN0KS0tLS0tLS0tLS0t +LS0tLS0tLS0tLS0tLS0tLQ0KCVRJUCA5OiB0aGUgcGxhbm5lciB3aWxsIGln +bm9yZSB5b3VyIGRlc2lyZSB0byBjaG9vc2UgYW4gaW5kZXggc2NhbiBpZiB5 +b3VyDQoJICAgICAgam9pbmluZyBjb2x1bW4ncyBkYXRhdHlwZXMgZG8gbm90 +IG1hdGNoDQoJDQoNCg== + +------_=_NextPart_001_01C428DA.95C5DCB2 +Content-Type: text/richtext; + name="Context-Switching.rtf" +Content-Transfer-Encoding: base64 +Content-Description: Context-Switching.rtf +Content-Disposition: attachment; + filename="Context-Switching.rtf" + +e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZGVmZjBcZGVmbGFuZzEwMzN7XGZv +bnR0Ymx7XGYwXGZzd2lzc1xmY2hhcnNldDAgQXJpYWw7fX0NClx2aWV3a2lu +ZDRcdWMxXHBhcmRcZjBcZnMyMCBbcm9vdEB2bC1wZTY2NTAtMDAyIHJvb3Rd +IyB2bXN0YXQgMlxwYXINCiAgIHByb2NzICAgICAgICAgICAgICAgICAgICAg +IG1lbW9yeSAgICBzd2FwICAgICAgICAgIGlvICAgICBzeXN0ZW0gICAgICAg +ICBjcHVccGFyDQogciAgYiAgdyAgIHN3cGQgICBmcmVlICAgYnVmZiAgY2Fj +aGUgIHNpICBzbyAgICBiaSAgICBibyAgIGluICAgIGNzICB1cyAgc3kgIGlk +XHBhcg0KIDIgIDAgIDQgIDI1MDY4ICAzMDc1MiAzMzkxNjQgNjg5OTY2MCAg +IDAgICAwICAgICAxICAgICAyICAgIDAgICAgIDIgICAwICAgMSAgIDJccGFy +DQogMSAgMSAgMiAgMjUwNjggIDIxNjA4IDMzOTE2NCA2OTA5MjkyICAgMCAg +IDAgICAgIDAgMjAyNDAgIDYyMyAzMTAyNSAgMTIgICA5ICA3OVxwYXINCiAy +ICAxICAxICAyNTA2OCAgMjQ1ODAgMzM5MTY4IDY5MDkyOTIgICAwICAgMCAg +ICAgMCAyMjQ0NiAgNTIzICAgODI0ICAxMiAgIDEgIDg3XHBhcg0KIDEgIDAg +IDAgIDI1MDY4IDI0MTI0NCAzMzkxNjggNjY5MTM3MiAgIDAgICAwICAgICAw +ICAgNDk4ICAxNDEgNzk5OTUgIDEzICAgNiAgODFccGFyDQogMSAgMCAgMCAg +MjUwNjggMjQxMTcyIDMzOTE2OCA2NjkxMzcyICAgMCAgIDAgICAgIDAgICAg +IDAgIDExNyAgICAyMyAgMTMgICAyICA4NlxwYXINCiAxICAwICAwICAyNTA2 +OCAyNDEyMDggMzM5MTY4IDY2OTEzNzIgICAwICAgMCAgICAgMCAgICA2OCAg +MTI0ICAgIDMyICAxMyAgIDAgIDg4XHBhcg0KIDEgIDAgIDEgIDI1MDY4IDI0 +MTIwOCAzMzkxNjggNjY5MTM3MiAgIDAgICAwICAgICAwICAgICAwICAxMTkg +ICAgMjMgIDEzICAgMCAgODhccGFyDQogMSAgMCAgMCAgMjUwNjggMjQxMjA4 +IDMzOTE2OCA2NjkxMzcyICAgMCAgIDAgICAgIDAgICAgIDAgIDExNCAgICAy +MyAgMTMgICAyICA4NlxwYXINCiAxICAwICAwICAyNTA2OCAyNDEyMDggMzM5 +MTY4IDY2OTEzNzIgICAwICAgMCAgICAgMCAgICA3NCAgMTMyICAgMjg0ICAx +MyAgIDAgIDg4XHBhcg0KIDEgIDAgIDAgIDI1MDY4IDI0MTIwOCAzMzkxNjgg +NjY5MTM3MiAgIDAgICAwICAgICAwICAgICAwICAxMTcgICAgMTggIDEzICAg +MiAgODZccGFyDQogMiAgMCAgMCAgMjUwNjggMjQwMjU2IDMzOTE2OCA2Njkx +Mzc2ICAgMCAgIDAgICAgIDAgICAgODIgIDE0NSAxMzkwNSAgMTQgICAyICA4 +NFxwYXINCiAxICAwICAwICAyNTA2OCAyNDAxNjggMzM5MTY4IDY2OTEzODAg +ICAwICAgMCAgICAgMCAgIDMzOCAgMTc3ICA0NzQ2ICAxMyAgIDEgIDg2XHBh +cg0KIDEgIDAgIDAgIDI1MDY4IDI0MDE2OCAzMzkxNjggNjY5MTM4MCAgIDAg +ICAwICAgICAwICAgIDU2ICAxMjggICAyMjEgIDEyICAgMiAgODZccGFyDQog +MSAgMCAgMCAgMjUwNjggMjQwMTgwIDMzOTE2OCA2NjkxMzgwICAgMCAgIDAg +ICAgIDAgICAgOTAgIDEzMSAxMjYzMyAgMTQgICAxICA4NVxwYXINCiAyICAw +ICAxICAyNTA2OCAyNDAxNDAgMzM5MTY4IDY2OTEzODAgICAwICAgMCAgICAg +MCAgIDEwNCAgMTQ0IDEwMDkxOSAgMTggICA2ICA3NlxwYXINCiAyICAwICAw +ICAyNTA2OCAyNDAxMzYgMzM5MTY4IDY2OTEzODAgICAwICAgMCAgICAgMCAg +IDEzOCAgMTM4IDEwNjU2NyAgMTggICA1ICA3N1xwYXINCiAyICAwICAwICAy +NTA2OCAyNDAxMzIgMzM5MTY4IDY2OTEzODAgICAwICAgMCAgICAgMCAgICA1 +MCAgMTM4IDEwODI1NCAgMTYgICA1ICA3OVxwYXINCiAyICAwICAwICAyNTA2 +OCAyNDAxMjggMzM5MTY4IDY2OTEzODAgICAwICAgMCAgICAgMCAgICA4NiAg +MTI3IDEwMjE4MyAgMTYgICA3ICA3N1xwYXINCiAxICAwICAwICAyNTA2OCAy +NDAxMzIgMzM5MTY4IDY2OTEzODAgICAwICAgMCAgICAgMCAgICAgMCAgMTE5 +IDExMDM4MiAgMTcgICA1ICA3OFxwYXINCiAyICAwICAwICAyNTA2OCAyMzk5 +ODAgMzM5MTY4IDY2OTEzODAgICAwICAgMCAgICAgMCAgICAgMCAgMTI1IDEw +Njk3MCAgMTggICA0ICA3OFxwYXINCiAyICAwICAwICAyNTA2OCAyMzk5NzIg +MzM5MTY4IDY2OTEzODAgICAwICAgMCAgICAgMCAgIDEzNiAgMTQwIDEwMzM4 +OSAgMTcgICA3ICA3NlxwYXINCiAgIHByb2NzICAgICAgICAgICAgICAgICAg +ICAgIG1lbW9yeSAgICBzd2FwICAgICAgICAgIGlvICAgICBzeXN0ZW0gICAg +ICAgICBjcHVccGFyDQogciAgYiAgdyAgIHN3cGQgICBmcmVlICAgYnVmZiAg +Y2FjaGUgIHNpICBzbyAgICBiaSAgICBibyAgIGluICAgIGNzICB1cyAgc3kg +IGlkXHBhcg0KIDIgIDAgIDAgIDI1MDY4IDI0MDAwOCAzMzkxNjggNjY5MTM4 +MCAgIDAgICAwICAgICAwICAgIDgyICAxMzQgMTA3NjI3ICAxOSAgIDQgIDc3 +XHBhcg0KIDIgIDAgIDAgIDI1MDY4IDI0MDAxMiAzMzkxNjggNjY5MTM4MCAg +IDAgICAwICAgICAwICAgIDkwICAxMjggOTQxODMgIDE2ICAgOSAgNzVccGFy +DQogMiAgMCAgMCAgMjUwNjggMjEzNTIwIDMzOTE2OCA2NzE1OTg4ICAgMCAg +IDAgICAgIDAgICAxMTQgIDE1NiA4Mjc4MSAgMTYgICA3ICA3OFxwYXINCiAy +ICAwICAxICAyNTA2OCAxMjAzNTYgMzM5MTY4IDY4MDM2OTIgICAwICAgMCAg +ICAgMCAzMDc5MCAgNTIyIDMxODY2ICAxNSAgMTAgIDc2XHBhcg0KIDEgIDEg +IDMgIDI1MDY4ICA1NTM4NCAzMzkxNjggNjg3MDk0MCAgIDAgICAwICAgICAw +IDIxOTA0ICA0NjYgMjU1NDkgIDE1ICAxMSAgNzNccGFyDQogMSAgMSAgMiAg +MjUwNjggIDIyODA0IDMzOTE2OCA2OTAzOTk2ICAgMCAgIDAgICAgIDAgMjE3 +ODYgIDUzOCAyOTQ0NSAgMTMgICA3ICA4MFxwYXINCiAxICAxICAxICAyNTA2 +OCAgMjIyODQgMzM5MTY4IDY5MDUwMzYgICAwICAgMCAgICAgMCAyMDY3OCAg +NjM0ICAzNDI4ICAxMiAgIDEgIDg3XHBhcg0KIDIgIDAgIDAgIDI1MDY4ICAy +NjIzMiAzMzkxNjggNjkwNjAyOCAgIDAgICAwICAgICAwIDEyMDU0ICAzMzIg +IDM1NzcgIDEyICAgMyAgODRccGFyDQpccGFyDQpccGFyDQoyIFByb2Nlc3Nl +cyBydW5uaW5nIC0gXHBhcg0KICAgcHJvY3MgICAgICAgICAgICAgICAgICAg +ICAgbWVtb3J5ICAgIHN3YXAgICAgICAgICAgaW8gICAgIHN5c3RlbSAgICAg +ICAgIGNwdVxwYXINCiByICBiICB3ICAgc3dwZCAgIGZyZWUgICBidWZmICBj +YWNoZSAgc2kgIHNvICAgIGJpICAgIGJvICAgaW4gICAgY3MgIHVzICBzeSAg +aWRccGFyDQogMiAgMCAgMCAgMjUwNjggMjQ0NDEyIDMzOTE5MiA2NjkxMzky +ICAgMCAgIDAgICAgIDAgICAgNjYgIDE1MCAxNDQwNTkgIDE0ICAgNyAgNzlc +cGFyDQogMiAgMCAgMSAgMjUwNjggMjQ0MzY4IDMzOTE5NiA2NjkxMzg4ICAg +MCAgIDAgICAgIDAgICAxMzQgIDEyMyAxNDc1MTcgIDE2ICAgNyAgNzdccGFy +DQogMiAgMCAgMCAgMjUwNjggMjQ0MzU2IDMzOTE5NiA2NjkxMzg4ICAgMCAg +IDAgICAgIDAgICAgIDAgIDExOSAxMzQ1NzYgIDE2ICAgOCAgNzZccGFyDQog +MiAgMCAgMCAgMjUwNjggMjQ0MzQwIDMzOTE5NiA2NjkxMzg4ICAgMCAgIDAg +ICAgIDAgICAgOTIgIDE0MyAxMDMzMzYgIDE3ICAgNCAgNzlccGFyDQogMiAg +MCAgMCAgMjUwNjggMjQ0MTcyIDMzOTE5NiA2NjkxMzg4ICAgMCAgIDAgICAg +IDAgICAxNTYgIDE1OCAxMDUzMzYgIDE4ICAgNiAgNzVccGFyDQogMiAgMCAg +MCAgMjUwNjggMjQ0MTA0IDMzOTE5NiA2NjkxMzg4ICAgMCAgIDAgICAgIDAg +ICAgIDAgIDExOCAxMDUyMjIgIDE4ICAgNSAgNzdccGFyDQogMiAgMCAgMCAg +MjUwNjggMjQ0MTA0IDMzOTE5NiA2NjkxMzg4ICAgMCAgIDAgICAgIDAgICAg +NjAgIDEyNCAxMDY4MTUgIDE4ICAgNSAgNzdccGFyDQogMiAgMCAgMCAgMjUw +NjggMjQ0MTA0IDMzOTE5NiA2NjkxMzg4ICAgMCAgIDAgICAgIDAgICAgIDAg +IDExOCAxMDYwMTMgIDE4ICAgNyAgNzVccGFyDQogMSAgMCAgMCAgMjUwNjgg +MjQyNzc2IDMzOTE5NiA2NjkxMzg4ICAgMCAgIDAgICAgIDAgICAgNzAgIDE2 +NiA4MjIyNyAgMTcgICA1ICA3OFxwYXINCiAzICAwICAxICAyNTA2OCAyNDI2 +MjAgMzM5MTk2IDY2OTEzOTIgICAwICAgMCAgICAgMCAgIDQ0NCAgMTk5IDg2 +NTc4ICAxNyAgIDcgIDc2XHBhcg0KIDIgIDAgIDAgIDI1MDY4IDI0MjQwMCAz +MzkyMDQgNjY5MTM4OCAgIDAgICAwICAgICAwICAgMjM2ICAxNDggMTA3MjAx +ICAxOSAgIDUgIDc2XHBhcg0KIDIgIDAgIDAgIDI1MDY4IDI0MjMzNiAzMzky +MDQgNjY5MTM4OCAgIDAgICAwICAgICAwICAgIDQ2ICAxMjEgMTAwODc0ICAx +OCAgIDQgIDc4XHBhcg0KIDMgIDAgIDAgIDI1MDY4IDI0MjMzNiAzMzkyMDQg +NjY5MTM4OCAgIDAgICAwICAgICAwICAgICAwICAxMTQgMTAzMDkzICAxOSAg +IDYgIDc1XHBhcg0KIDEgIDAgIDAgIDI1MDY4IDI0MTcwNCAzMzkyMDQgNjY5 +MTM5NiAgIDAgICAwICAgICAwICAgMTc2ICAxODQgOTUwNDEgIDE4ICAgNSAg +NzhccGFyDQogMiAgMCAgMCAgMjUwNjggMjQxNzA0IDMzOTIwNCA2NjkxMzk2 +ICAgMCAgIDAgICAgIDAgICAgNjggIDEyNiAxMDIwMTEgIDE3ICAgNSAgNzhc +cGFyDQogMyAgMCAgMCAgMjUwNjggMjQxNjU2IDMzOTIwNCA2NjkxMzk2ICAg +MCAgIDAgICAgIDAgICAgIDAgIDExNiAxMTAwOTUgIDE2ICAxMCAgNzNccGFy +DQogMyAgMCAgMCAgMjUwNjggMjM3NzY4IDMzOTIwNCA2Njk0MzMyICAgMCAg +IDAgICAgIDAgICA1NDAgIDEzOCAxMzI2MDAgIDE4ICAgNyAgNzVccGFyDQog +MSAgMCAgMSAgMjUwNjggMTc0MDY4IDMzOTIwNCA2NzU2MTA4ICAgMCAgIDAg +ICAgIDAgMTYxODQgIDM1MiAxMTY2OTIgIDE3ICAxNSAgNlxwYXINClxwYXIN +ClxwYXINCjMgcHJvY2Vzc2VzIC0gXHBhcg0KICBwcm9jcyAgICAgICAgICAg +ICAgICAgICAgICBtZW1vcnkgICAgc3dhcCAgICAgICAgICBpbyAgICAgc3lz +dGVtICAgICAgICAgY3B1XHBhcg0KIHIgIGIgIHcgICBzd3BkICAgZnJlZSAg +IGJ1ZmYgIGNhY2hlICBzaSAgc28gICAgYmkgICAgYm8gICBpbiAgICBjcyAg +dXMgIHN5ICBpZFxwYXINCiAxICAwICAwICAyNTA2OCAyMzM0ODggMzM5MjIw +IDY2OTE0MzYgICAwICAgMCAgICAgMSAgICAgMiAgICAwICAgICAwICAgMCAg +IDEgICAyXHBhcg0KIDEgIDAgIDMgIDI1MDY4IDIzMzQ5MiAzMzkyMjQgNjY5 +MTQzMiAgIDAgICAwICAgICAwICAgIDc0ICAxMjcgMTQ0Mjg1ICAxNyAgIDYg +IDc3XHBhcg0KIDIgIDAgIDAgIDI1MDY4IDIzMzQ5MiAzMzkyMjQgNjY5MTQz +MiAgIDAgICAwICAgICAwICAgICAwICAxMTggMTM5ODUyICAxOSAgIDQgIDc3 +XHBhcg0KIDIgIDAgIDAgIDI1MDY4IDIzMzI3NiAzMzkyMjQgNjY5MTQzMiAg +IDAgICAwICAgICAwICAgIDQ4ICAxNDkgMTQ3Mjc2ICAxOSAgIDcgIDczXHBh +cg0KIDIgIDAgIDAgIDI1MDY4IDIzMzMxNiAzMzkyMjQgNjY5MTQzMiAgIDAg +ICAwICAgICAwICAgIDc0ICAxMjQgMTM3OTc4ICAxNyAgIDYgIDc3XHBhcg0K +IDEgIDAgIDAgIDI1MDY4IDIzMzMxNiAzMzkyMjQgNjY5MTQzMiAgIDAgICAw +ICAgICAwICAgICAwICAxMTggMTM1Mzc0ICAxNyAgIDcgIDc1XHBhcg0KIDIg +IDAgIDAgIDI1MDY4IDIzMzMxNiAzMzkyMjQgNjY5MTQzMiAgIDAgICAwICAg +ICAwICAgIDY0ICAxMjYgMTM3NjE2ICAxOCAgIDYgIDc3XHBhcg0KIDIgIDAg +IDAgIDI1MDY4IDIzMzM0MCAzMzkyMjQgNjY5MTQzMiAgIDAgICAwICAgICAw +ICAgIDQyICAxMzkgMTMzMjE0ICAxOSAgIDUgIDc3XHBhcg0KIDAgIDAgIDAg +IDI1MDY4IDIzMzIzNiAzMzkyMjQgNjY5MTQzMiAgIDAgICAwICAgICAwICAg +ICAwICAxMjYgMTI5MTg3ICAxOSAgIDcgIDc0XHBhcg0KIDAgIDAgIDAgIDI1 +MDY4IDIzMzI1NiAzMzkyMjQgNjY5MTQzMiAgIDAgICAwICAgICAwICAgMTc0 +ICAxNDUgODk0NjcgIDE2ICAgNCAgODBccGFyDQogMiAgMCAgMSAgMjUwNjgg +MjMzMjU2IDMzOTIyNCA2NjkxNDMyICAgMCAgIDAgICAgIDAgICAgIDAgIDEx +NyA5MjgwNCAgMTYgICAzICA4MFxwYXINCiAyICAwICAwICAyNTA2OCAyMzMy +NTYgMzM5MjI0IDY2OTE0MzIgICAwICAgMCAgICAgMCAgICA2MCAgMTI3IDc4 +NTI4ICAxNSAgIDQgIDgwXHBhcg0KIDAgIDAgIDAgIDI1MDY4IDIzMjkxMiAz +MzkyMjQgNjY5MTQzMiAgIDAgICAwICAgICAwICAgIDE2ICAxMzYgNzkzODUg +IDE0ICAgNCAgODJccGFyDQogMCAgMCAgMCAgMjUwNjggMjMzNzI0IDMzOTIy +NCA2NjkxNDMyICAgMCAgIDAgICAgIDAgICAgIDAgIDEyNyA0NjIzMiAgMTEg +IDEwICA3OVxwYXINCiAyICAwICAwICAyNTA2OCAyMzQ3MTIgMzM5MjI0IDY2 +OTE0MzYgICAwICAgMCAgICAgMCAgIDU0NCAgMTk4IDgxNjUwICAxNyAgIDQg +IDgwXHBhcg0KIDIgIDAgIDAgIDI1MDY4IDIzNDcxMiAzMzkyMjQgNjY5MTQ0 +NCAgIDAgICAwICAgICAwICAgIDg2ICAxMzIgODk3NzQgIDE2ICAgNCAgODFc +cGFyDQogMCAgMCAgMCAgMjUwNjggMjM2MzQwIDMzOTIyNCA2NjkxNDQ0ICAg +MCAgIDAgICAgIDAgICAyNDAgIDE2NiA4Mjk1MyAgMTYgICA1ICA3OVxwYXIN +CiAxICAwICAwICAyNTA2OCAyMzYzNDggMzM5MjI0IDY2OTE0NDQgICAwICAg +MCAgICAgMCAgICAgMCAgMTIzIDg5ODQ1ICAxNiAgIDMgIDgxXHBhcg0KIDEg +IDAgIDEgIDI1MDY4IDIzNjM1MiAzMzkyMjQgNjY5MTQ0NCAgIDAgICAwICAg +ICAwICAgICAwICAxMjAgODAzMzIgIDE2ICAgNCAgODBccGFyDQogMyAgMCAg +MCAgMjUwNjggMjM2NDAwIDMzOTIyNCA2NjkxNDQ0ICAgMCAgIDAgICAgIDAg +ICAgNzggIDEyMiA5MTI5NCAgMTYgICA0ICA4MFxwYXINCiAyICAwICAwICAy +NTA2OCAyMzY0MDQgMzM5MjI0IDY2OTE0NDQgICAwICAgMCAgICAgMCAgICAg +MCAgMTE3IDg5MDYwICAxNiAgIDMgIDgxXHBhcg0KICAgcHJvY3MgICAgICAg +ICAgICAgICAgICAgICAgbWVtb3J5ICAgIHN3YXAgICAgICAgICAgaW8gICAg +IHN5c3RlbSAgICAgICAgIGNwdVxwYXINCiByICBiICB3ICAgc3dwZCAgIGZy +ZWUgICBidWZmICBjYWNoZSAgc2kgIHNvICAgIGJpICAgIGJvICAgaW4gICAg +Y3MgIHVzICBzeSAgaWRccGFyDQogMCAgMCAgMCAgMjUwNjggMjM2NDE2IDMz +OTIyNCA2NjkxNDQ0ICAgMCAgIDAgICAgIDAgICAgNDIgIDEyMSA4Mjg4NiAg +MTQgICA2ICA4MFxwYXINCiAzICAwICAwICAyNTA2OCAyMzY0MjAgMzM5MjI0 +IDY2OTE0NDQgICAwICAgMCAgICAgMCAgICAgMCAgMTE3IDg5OTUzICAxNiAg +IDQgIDgwXHBhcg0KIDIgIDAgIDAgIDI1MDY4IDIzNjQyMCAzMzkyMjQgNjY5 +MTQ0NCAgIDAgICAwICAgICAwICAgICAwICAxMjEgODYwMTIgIDE2ICAgMyAg +ODFccGFyDQogMyAgMCAgMCAgMjUwNjggMjM2NDIwIDMzOTIyNCA2NjkxNDQ0 +ICAgMCAgIDAgICAgIDAgICAxMDggIDEyNiA3NTk1MSAgMTQgICA2ICA4MFxw +YXINClxwYXINClxwYXINCjQgcHJvY2Vzc2VzIC0gXHBhcg0KICBwcm9jcyAg +ICAgICAgICAgICAgICAgICAgICBtZW1vcnkgICAgc3dhcCAgICAgICAgICBp +byAgICAgc3lzdGVtICAgICAgICAgY3B1XHBhcg0KIHIgIGIgIHcgICBzd3Bk +ICAgZnJlZSAgIGJ1ZmYgIGNhY2hlICBzaSAgc28gICAgYmkgICAgYm8gICBp +biAgICBjcyAgdXMgIHN5ICBpZFxwYXINCiAzICAwICAwICAyNTA2OCAyMzI5 +NzIgMzM5MjMyIDY2OTE0NjAgICAwICAgMCAgICAgMSAgICAgMiAgICAwICAg +ICAxICAgMCAgIDEgICAyXHBhcg0KIDEgIDAgIDAgIDI1MDY4IDIzMjk3NiAz +MzkyMzIgNjY5MTQ2MCAgIDAgICAwICAgICAwICAgICAwICAxMTQgNTM0OTcg +IDExICAgNCAgODVccGFyDQogMSAgMCAgMCAgMjUwNjggMjMyOTgwIDMzOTIz +NiA2NjkxNDU2ICAgMCAgIDAgICAgIDAgICAgMzAgIDEyMiA1OTM2NSAgMTMg +ICAzICA4NFxwYXINCiAwICAwICAwICAyNTA2OCAyMzI5ODAgMzM5MjM2IDY2 +OTE0NTYgICAwICAgMCAgICAgMCAgICAgMCAgMTE3IDU2Nzc4ICAxNCAgIDMg +IDgzXHBhcg0KIDIgIDAgIDAgIDI1MDY4IDIzMjkwNCAzMzkyMzYgNjY5MTQ1 +NiAgIDAgICAwICAgICAwICAgICAwICAxMTcgNTY0NDEgIDExICAgNSAgODRc +cGFyDQogMCAgMCAgMCAgMjUwNjggMjMyOTQ4IDMzOTIzNiA2NjkxNDU2ICAg +MCAgIDAgICAgIDAgICAgNjYgIDEyMyA2MjEwNyAgMTQgICAyICA4NFxwYXIN +CiAxICAwICAwICAyNTA2OCAyMzI4ODggMzM5MjM2IDY2OTE0NTIgICAwICAg +MCAgICAgMCAgICAgMCAgMTIwIDU3NTk4ICAxMiAgIDQgIDgzXHBhcg0KIDEg +IDAgIDAgIDI1MDY4IDIzMjg4OCAzMzkyMzYgNjY5MTQ1MiAgIDAgICAwICAg +ICAwICAgMTUwICAxNDAgNTE1ODMgIDEzICAgMiAgODRccGFyDQogMiAgMCAg +MCAgMjUwNjggMjMyODkyIDMzOTIzNiA2NjkxNDUyICAgMCAgIDAgICAgIDAg +ICAgIDAgIDExNyA1NzU1NyAgMTQgICAzICA4M1xwYXINCiAyICAwICAwICAy +NTA2OCAyMzQyMjAgMzM5MjM2IDY2OTE0NTIgICAwICAgMCAgICAgMCAgICAg +MCAgMTE4IDYwNjQ2ICAxNCAgIDQgIDgyXHBhcg0KIDAgIDAgIDAgIDI1MDY4 +IDIzNDI0MCAzMzkyMzYgNjY5MTQ1MiAgIDAgICAwICAgICAwICAgIDYyICAx +MjQgNjIzODggIDE1ICAgMyAgODNccGFyDQogMSAgMCAgMCAgMjUwNjggMjM0 +MjQ0IDMzOTIzNiA2NjkxNDUyICAgMCAgIDAgICAgIDAgICAgIDAgIDExNiA1 +Mzk0OCAgMTMgICAzICA4NFxwYXINCiAxICAwICAwICAyNTA2OCAyMzYwMDgg +MzM5MjM2IDY2OTE0NTIgICAwICAgMCAgICAgMCAgICAxMCAgMTIwIDU2NTMy +ICAxMyAgIDUgIDgyXHBhcg0KIDIgIDAgIDAgIDI1MDY4IDIzNjAwOCAzMzky +MzYgNjY5MTQ1MiAgIDAgICAwICAgICAwICAgICAwICAxMTQgNzAwODcgIDE1 +ICAgNCAgODFccGFyDQogMCAgMCAgMCAgMjUwNjggMjM2MDA4IDMzOTIzNiA2 +NjkxNDUyICAgMCAgIDAgICAgIDAgICAgIDAgIDEyMSA0OTYwNyAgMTMgICA1 +ICA4MlxwYXINCiAxICAwICAwICAyNTA2OCAyMzYwMDQgMzM5MjM2IDY2OTE0 +NTIgICAwICAgMCAgICAgMCAgICA4MCAgMTQyIDYyNDIzICAxNiAgIDIgIDgy +XHBhcg0KIDAgIDAgIDAgIDI1MDY4IDIzNjAwNCAzMzkyMzYgNjY5MTQ1MiAg +IDAgICAwICAgICAwICAgIDQyICAxMjUgNTEwNDkgIDEzICAgMyAgODRccGFy +DQogMCAgMCAgMCAgMjUwNjggMjM2MDc2IDMzOTIzNiA2NjkxNDUyICAgMCAg +IDAgICAgIDAgICAgOTYgIDEyOCA1MTU2OCAgMTMgICA1ICA4MlxwYXINClxw +YXINClxwYXINClxwYXINCn0NCgA= + +------_=_NextPart_001_01C428DA.95C5DCB2-- + +From pgsql-performance-owner@postgresql.org Fri Apr 23 01:39:26 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 74907D1D077 + for ; + Fri, 23 Apr 2004 01:39:17 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 56323-04 + for ; + Fri, 23 Apr 2004 01:39:16 -0300 (ADT) +Received: from joeconway.com (66-146-172-82.skyriver.net [66.146.172.82]) + by svr1.postgresql.org (Postfix) with ESMTP id A384DD1CCCA + for ; + Fri, 23 Apr 2004 01:39:15 -0300 (ADT) +Received: from [192.168.4.3] (account jconway HELO joeconway.com) + by joeconway.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP-TLS id 1519993; Thu, 22 Apr 2004 21:33:27 -0700 +Message-ID: <40889DAD.6080703@joeconway.com> +Date: Thu, 22 Apr 2004 21:38:05 -0700 +From: Joe Conway +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.6) Gecko/20040113 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Sean Shanny +Cc: pgsql-performance@postgresql.org +Subject: Re: Looking for ideas on how to speed up warehouse loading +References: <40883FAB.3070109@earthlink.net> +In-Reply-To: <40883FAB.3070109@earthlink.net> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/401 +X-Sequence-Number: 6701 + +Sean Shanny wrote: +> explain analyze SELECT t1.id, t2.url FROM referral_temp t2 LEFT OUTER +> JOIN d_referral t1 ON t2.url = t1.referral_raw_url ORDER BY t1.id; + +> What I would like to know is if there are better ways to do the join? I +> need to get all the rows back from the referral_temp table as they are +> used for assigning FK's for the fact table later in processing. When I +> iterate over the values that I get back those with t1.id = null I assign +> a new FK and push both into the d_referral table as new entries as well +> as a text file for later use. The matching records are written to a +> text file for later use. + +Would something like this work any better (without disabling index scans): + +SELECT t1.id, t2.url +FROM referral_temp t2, d_referral t1 +WHERE t1.referral_raw_url = t2.url; + + + +SELECT t1.id, t2.url +FROM referral_temp t2 +WHERE NOT EXISTS +(select 1 FROM d_referral t1 WHERE t1.referral_raw_url = t2.url); + + + +? + +Joe + +From pgsql-performance-owner@postgresql.org Fri Apr 23 09:19:43 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 58242D1C9E8 + for ; + Fri, 23 Apr 2004 09:19:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 86772-07 + for ; + Fri, 23 Apr 2004 09:19:35 -0300 (ADT) +Received: from hotmail.com (bay18-dav4.bay18.hotmail.com [65.54.187.184]) + by svr1.postgresql.org (Postfix) with ESMTP id 79ACFD1C9B7 + for ; + Fri, 23 Apr 2004 09:19:31 -0300 (ADT) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Fri, 23 Apr 2004 05:19:30 -0700 +Received: from 67.81.102.201 by bay18-dav4.bay18.hotmail.com with DAV; + Fri, 23 Apr 2004 12:19:30 +0000 +X-Originating-IP: [67.81.102.201] +X-Originating-Email: [awerman2@hotmail.com] +X-Sender: awerman2@hotmail.com +From: "Aaron Werman" +To: "Joe Conway" , + "Sean Shanny" +Cc: +References: <40883FAB.3070109@earthlink.net> <40889DAD.6080703@joeconway.com> +Subject: Re: Looking for ideas on how to speed up warehouse loading +Date: Fri, 23 Apr 2004 08:19:36 -0400 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1409 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 +Message-ID: +X-OriginalArrivalTime: 23 Apr 2004 12:19:30.0871 (UTC) + FILETIME=[3AB95C70:01C4292D] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=RCVD_IN_NJABL, + RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200404/402 +X-Sequence-Number: 6702 + +By definition, it is equivalent to: + +SELECT t1.id, t2.url FROM referral_temp t2 LEFT /*OUTER*/ JOIN d_referral t1 +ON t2.url = t1.referral_raw_url +union all +SELECT null, url FROM referral_temp WHERE url is null +ORDER BY 1; + + + +/Aaron + +----- Original Message ----- +From: "Joe Conway" +To: "Sean Shanny" +Cc: +Sent: Friday, April 23, 2004 12:38 AM +Subject: Re: [PERFORM] Looking for ideas on how to speed up warehouse +loading + + +> Sean Shanny wrote: +> > explain analyze SELECT t1.id, t2.url FROM referral_temp t2 LEFT OUTER +> > JOIN d_referral t1 ON t2.url = t1.referral_raw_url ORDER BY t1.id; +> +> > What I would like to know is if there are better ways to do the join? I +> > need to get all the rows back from the referral_temp table as they are +> > used for assigning FK's for the fact table later in processing. When I +> > iterate over the values that I get back those with t1.id = null I assign +> > a new FK and push both into the d_referral table as new entries as well +> > as a text file for later use. The matching records are written to a +> > text file for later use. +> +> Would something like this work any better (without disabling index scans): +> +> SELECT t1.id, t2.url +> FROM referral_temp t2, d_referral t1 +> WHERE t1.referral_raw_url = t2.url; +> +> +> +> SELECT t1.id, t2.url +> FROM referral_temp t2 +> WHERE NOT EXISTS +> (select 1 FROM d_referral t1 WHERE t1.referral_raw_url = t2.url); +> +> +> +> ? +> +> Joe +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 7: don't forget to increase your free space map settings +> + +From pgsql-performance-owner@postgresql.org Fri Apr 23 10:32:09 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9CAA9D1BA98 + for ; + Fri, 23 Apr 2004 10:31:19 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 16875-01 + for ; + Fri, 23 Apr 2004 10:31:21 -0300 (ADT) +Received: from mail.astudios.com (unknown [66.49.77.3]) + by svr1.postgresql.org (Postfix) with ESMTP id 1EBB5D1B98D + for ; + Fri, 23 Apr 2004 10:31:16 -0300 (ADT) +thread-index: AcQpN7xPOA4ilzVLQ6yUbo1GCcCURw== +Content-Class: urn:content-classes:message +Importance: normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.132 +Received: from [10.4.2.155] ([66.194.26.150]) by mail.astudios.com with + Microsoft SMTPSVC(6.0.3790.0); Fri, 23 Apr 2004 09:34:42 -0400 +From: "Chris Hoover" +To: +Subject: Help with performance problems +Date: Fri, 23 Apr 2004 09:31:17 -0400 +User-Agent: KMail/1.6.1 +Cc: +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Message-ID: <200404230931.17850.revoohc@sermonaudio.com> +X-OriginalArrivalTime: 23 Apr 2004 13:34:43.0156 (UTC) + FILETIME=[BC416940:01C42937] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/403 +X-Sequence-Number: 6703 + +I need some help. I have 5 db servers running our database servers, and th= +ey=20 +all are having various degrees of performance problems. The problems we ar= +e=20 +experiencing are: + +1. General slowness +2. High loads + +All of our db's are running on Dell Poweredge 2650 with 2 P4 Xeons (2.8 ->= +=20 +3.06 GHz) with 8 to 12 GB of memory. The databases are running on attached= +=20 +Dell Powervault 220s running raid5. + +The databases were created and taken into production before I started worki= +ng=20 +here and are very flat. Most of the major tables have a combined primary k= +ey=20 +using an int field and a single char field. There are some additional=20 +indexes on some tables. Most queries I see in the logs are running at les= +s=20 +than .01 seconds with many significantly slower. + +We are trying to narrow down the performance problem to either the db or th= +e=20 +hardware. As the dba, I need to try and get these db's tuned to the best= +=20 +possible way considering the current db state. We are in the beginning of = +a=20 +complete db redesign and application re-write, but the completion and=20 +deployment of the new db and app are quite a ways off. + +Anyway, we are running the following: +PE 2650 w/ 2 cpus (2.8-3.06) - HT on +8-12 GB memory +OS on raid 0 +DB's on Powervaults 220S using raid 5 (over 6 disks) +Each Postgresql cluster has 2 db up to almost 170db's (project to level out= +=20 +the num of db's/cluster is being started) +DB's are no bigger than a few GB in size (largest is about 11GB according t= +o a=20 +du -h) +Running RH ES 2.1 + +Here is the postgresql.conf from the server with the 11GB db: + +max_connections =3D 64 +shared_buffers =3D 32768 # 256MB=3D32768(buffs)*8192(bytes/buff) +max_fsm_relations =3D 1000 # min 10, fsm is free space map, ~40 bytes +max_fsm_pages =3D 10000 # min 1000, fsm is free space map, ~6 bytes +sort_mem =3D 4096 # 256MB=3D4096(bytes/proc)*64(procs or conns) +checkpoint_segments =3D 16 # in logfile segments, min 1, 16MB each +checkpoint_timeout =3D 30 # range 30-3600, in seconds +effective_cache_size =3D 131072 # typically 8KB each +log_connections =3D true +log_pid =3D true +log_statement =3D true +log_duration =3D true +log_timestamp =3D true +stats_start_collector =3D true +stats_reset_on_server_start =3D true +stats_command_string =3D true +stats_row_level =3D true +stats_block_level =3D true +LC_MESSAGES =3D 'en_US' +LC_MONETARY =3D 'en_US' +LC_NUMERIC =3D 'en_US' +LC_TIME =3D 'en_US' + +Here is top (server running pretty good right now) + 9:28am up 25 days, 16:02, 2 users, load average: 0.54, 0.33, 0.22 +94 processes: 91 sleeping, 3 running, 0 zombie, 0 stopped +CPU0 states: 64.0% user, 0.1% system, 0.0% nice, 34.0% idle +CPU1 states: 29.0% user, 9.0% system, 0.0% nice, 60.0% idle +CPU2 states: 2.0% user, 0.1% system, 0.0% nice, 96.0% idle +CPU3 states: 0.0% user, 0.0% system, 0.0% nice, 100.0% idle +Mem: 7720072K av, 7711648K used, 8424K free, 265980K shrd, 749888K bu= +ff +Swap: 2096440K av, 22288K used, 2074152K free 6379304K=20 +cached + +Here is top from another server (with the most db's):=20 + 9:31am up 25 days, 16:05, 5 users, load average: 2.34, 3.39, 4.28 +147 processes: 145 sleeping, 2 running, 0 zombie, 0 stopped +CPU0 states: 6.0% user, 1.0% system, 0.0% nice, 91.0% idle +CPU1 states: 9.0% user, 4.0% system, 0.0% nice, 85.0% idle +CPU2 states: 9.0% user, 3.0% system, 0.0% nice, 86.0% idle +CPU3 states: 9.0% user, 4.0% system, 0.0% nice, 85.0% idle +Mem: 7721096K av, 7708040K used, 13056K free, 266132K shrd, 3151336K bu= +ff +Swap: 2096440K av, 24208K used, 2072232K free 3746596K=20 +cached + +Thanks for any help/advice, + +Chris + + +From pgsql-performance-owner@postgresql.org Fri Apr 23 13:16:02 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 31DE8D1B911 + for ; + Fri, 23 Apr 2004 12:16:11 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 48035-08 + for ; + Fri, 23 Apr 2004 12:16:09 -0300 (ADT) +Received: from hotmail.com (bay18-dav43.bay18.hotmail.com [65.54.187.223]) + by svr1.postgresql.org (Postfix) with ESMTP id 99028D1B91B + for ; + Fri, 23 Apr 2004 12:16:08 -0300 (ADT) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Fri, 23 Apr 2004 08:16:07 -0700 +Received: from 67.81.102.201 by bay18-dav43.bay18.hotmail.com with DAV; + Fri, 23 Apr 2004 15:16:07 +0000 +X-Originating-IP: [67.81.102.201] +X-Originating-Email: [awerman2@hotmail.com] +X-Sender: awerman2@hotmail.com +From: "Aaron Werman" +To: "Chris Hoover" , + +Cc: +References: <200404230931.17850.revoohc@sermonaudio.com> +Subject: Re: Help with performance problems +Date: Fri, 23 Apr 2004 11:16:13 -0400 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1409 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 +Message-ID: +X-OriginalArrivalTime: 23 Apr 2004 15:16:07.0654 (UTC) + FILETIME=[E6E62060:01C42945] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=RCVD_IN_NJABL, + RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200404/404 +X-Sequence-Number: 6704 + +Your second server has queuing (load averages are highish), only 2 processes +running, and almost all cycles are idle. You need to track down your +bottleneck. Have you looked at iostat/vmstat? I think it would be useful to +post these, ideally both before and after full vacuum analyze. + +/Aaron + + +----- Original Message ----- +From: "Chris Hoover" +To: +Cc: +Sent: Friday, April 23, 2004 9:31 AM +Subject: [PERFORM] Help with performance problems + + +I need some help. I have 5 db servers running our database servers, and +they +all are having various degrees of performance problems. The problems we are +experiencing are: + +1. General slowness +2. High loads + +All of our db's are running on Dell Poweredge 2650 with 2 P4 Xeons (2.8 -> +3.06 GHz) with 8 to 12 GB of memory. The databases are running on attached +Dell Powervault 220s running raid5. + +The databases were created and taken into production before I started +working +here and are very flat. Most of the major tables have a combined primary +key +using an int field and a single char field. There are some additional +indexes on some tables. Most queries I see in the logs are running at less +than .01 seconds with many significantly slower. + +We are trying to narrow down the performance problem to either the db or the +hardware. As the dba, I need to try and get these db's tuned to the best +possible way considering the current db state. We are in the beginning of a +complete db redesign and application re-write, but the completion and +deployment of the new db and app are quite a ways off. + +Anyway, we are running the following: +PE 2650 w/ 2 cpus (2.8-3.06) - HT on +8-12 GB memory +OS on raid 0 +DB's on Powervaults 220S using raid 5 (over 6 disks) +Each Postgresql cluster has 2 db up to almost 170db's (project to level out +the num of db's/cluster is being started) +DB's are no bigger than a few GB in size (largest is about 11GB according to +a +du -h) +Running RH ES 2.1 + +Here is the postgresql.conf from the server with the 11GB db: + +max_connections = 64 +shared_buffers = 32768 # 256MB=32768(buffs)*8192(bytes/buff) +max_fsm_relations = 1000 # min 10, fsm is free space map, ~40 bytes +max_fsm_pages = 10000 # min 1000, fsm is free space map, ~6 bytes +sort_mem = 4096 # 256MB=4096(bytes/proc)*64(procs or conns) +checkpoint_segments = 16 # in logfile segments, min 1, 16MB each +checkpoint_timeout = 30 # range 30-3600, in seconds +effective_cache_size = 131072 # typically 8KB each +log_connections = true +log_pid = true +log_statement = true +log_duration = true +log_timestamp = true +stats_start_collector = true +stats_reset_on_server_start = true +stats_command_string = true +stats_row_level = true +stats_block_level = true +LC_MESSAGES = 'en_US' +LC_MONETARY = 'en_US' +LC_NUMERIC = 'en_US' +LC_TIME = 'en_US' + +Here is top (server running pretty good right now) + 9:28am up 25 days, 16:02, 2 users, load average: 0.54, 0.33, 0.22 +94 processes: 91 sleeping, 3 running, 0 zombie, 0 stopped +CPU0 states: 64.0% user, 0.1% system, 0.0% nice, 34.0% idle +CPU1 states: 29.0% user, 9.0% system, 0.0% nice, 60.0% idle +CPU2 states: 2.0% user, 0.1% system, 0.0% nice, 96.0% idle +CPU3 states: 0.0% user, 0.0% system, 0.0% nice, 100.0% idle +Mem: 7720072K av, 7711648K used, 8424K free, 265980K shrd, 749888K +buff +Swap: 2096440K av, 22288K used, 2074152K free 6379304K +cached + +Here is top from another server (with the most db's): + 9:31am up 25 days, 16:05, 5 users, load average: 2.34, 3.39, 4.28 +147 processes: 145 sleeping, 2 running, 0 zombie, 0 stopped +CPU0 states: 6.0% user, 1.0% system, 0.0% nice, 91.0% idle +CPU1 states: 9.0% user, 4.0% system, 0.0% nice, 85.0% idle +CPU2 states: 9.0% user, 3.0% system, 0.0% nice, 86.0% idle +CPU3 states: 9.0% user, 4.0% system, 0.0% nice, 85.0% idle +Mem: 7721096K av, 7708040K used, 13056K free, 266132K shrd, 3151336K +buff +Swap: 2096440K av, 24208K used, 2072232K free 3746596K +cached + +Thanks for any help/advice, + +Chris + + +---------------------------(end of broadcast)--------------------------- +TIP 2: you can get off all lists at once with the unregister command + (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) + +From pgsql-performance-owner@postgresql.org Fri Apr 23 13:29:06 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 71789D1C9B4 + for ; + Fri, 23 Apr 2004 13:29:05 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 75194-10 + for ; + Fri, 23 Apr 2004 13:29:03 -0300 (ADT) +Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) + by svr1.postgresql.org (Postfix) with ESMTP id 5B870D1BB4C + for ; + Fri, 23 Apr 2004 13:29:02 -0300 (ADT) +Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) + by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i3NGSRIl004047; + Fri, 23 Apr 2004 10:28:27 -0600 (MDT) +Date: Fri, 23 Apr 2004 10:25:01 -0600 (MDT) +From: "scott.marlowe" +To: Sean Shanny +Cc: +Subject: Re: Looking for ideas on how to speed up warehouse loading +In-Reply-To: <408855AD.4090500@earthlink.net> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-IHS-MailScanner: Found to be clean +X-IHS-MailScanner-SpamCheck: +X-IHS-MailScanner-Envelope-Sender: scott.marlowe@ihs.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/405 +X-Sequence-Number: 6705 + + +On Thu, 22 Apr 2004, Sean Shanny wrote: + +> I should have included this as well: +> fsync | on +> shared_buffers | 4000 +> sort_mem | 64000 + +For purposes of loading only, you can try turning off fsync, assuming this +is a virgin load and you can just re-initdb should bad things happen (OS, +postgresql crash, power plug pulled, etc...) + +Also increasing sort_mem and shared_buffers might help. Especially +sort_mem. But turn it back down to something reasonable after the import. + +And turn fsync back on after the import too. Note you have to restart +postgresql to make fsync = off take effect. + + +From pgsql-performance-owner@postgresql.org Fri Apr 23 13:43:41 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0E824D1C9F3 + for ; + Fri, 23 Apr 2004 13:43:33 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 86750-05 + for ; + Fri, 23 Apr 2004 13:43:32 -0300 (ADT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id DE36AD1BAD5 + for ; + Fri, 23 Apr 2004 13:43:30 -0300 (ADT) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4929127; Fri, 23 Apr 2004 09:44:55 -0700 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: "Chris Hoover" , + +Subject: Re: Help with performance problems +Date: Fri, 23 Apr 2004 09:42:48 -0700 +User-Agent: KMail/1.4.3 +Cc: +References: <200404230931.17850.revoohc@sermonaudio.com> +In-Reply-To: <200404230931.17850.revoohc@sermonaudio.com> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200404230942.48290.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/406 +X-Sequence-Number: 6706 + +Chris, + +> I need some help. I have 5 db servers running our database servers, and +> they all are having various degrees of performance problems. The problems +> we are experiencing are: + +I'mm confused. You're saying "general slowness" but say that most queries run +in under .01 seconds. And you say "high loads" but the TOP snapshots you +provide show servers with 2 CPUs idle. + +Are you sure you actually *have* a performance issue? + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Fri Apr 23 14:16:12 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id BFD5DD1B98D + for ; + Fri, 23 Apr 2004 14:16:08 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 97714-03 + for ; + Fri, 23 Apr 2004 14:16:06 -0300 (ADT) +Received: from mail.astudios.com (unknown [66.49.77.3]) + by svr1.postgresql.org (Postfix) with ESMTP id CE93ED1B91B + for ; + Fri, 23 Apr 2004 14:16:04 -0300 (ADT) +thread-index: AcQpVyJlIsB8KxyHSGGj2MXxoKHPug== +Content-Class: urn:content-classes:message +Received: from [10.4.2.155] ([66.194.26.150]) by mail.astudios.com with + Microsoft SMTPSVC(6.0.3790.0); Fri, 23 Apr 2004 13:19:28 -0400 +Importance: normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.132 +From: "Chris Hoover" +To: "Josh Berkus" +Subject: Re: Help with performance problems +Date: Fri, 23 Apr 2004 13:16:03 -0400 +User-Agent: KMail/1.6.1 +Cc: +References: <200404230931.17850.revoohc@sermonaudio.com> + <200404230942.48290.josh@agliodbs.com> +In-Reply-To: <200404230942.48290.josh@agliodbs.com> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Message-ID: <200404231316.03447.revoohc@sermonaudio.com> +X-OriginalArrivalTime: 23 Apr 2004 17:19:28.0843 (UTC) + FILETIME=[2259F1B0:01C42957] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/407 +X-Sequence-Number: 6707 + +I know the numbers look ok, but we are definetly suffering. Also, if I try= + to=20 +run any sort of vacuum or other db activity during normal business hours,= +=20 +load goes through the roof. I have seen loads of over 10 when trying to=20 +vacuum the larger cluster and would have to kill the vacuums due to=20 +complaints.=20=20 + +I think this is probably related to the hardware configuration, but I want = +to=20 +make sure that there are no changes I could make configuration wise to the = +db=20 +that might lighten the problem. + +I'm especially want to make sure that I have the memory parameters set to g= +ood=20 +numbers for my db's so that I can minimize thrashing between the postgres= +=20 +memory pools and the hard drive. I am thinking that this may be a big issu= +e=20 +here? + +Thanks for any help, + +Chris +On Friday 23 April 2004 12:42, Josh Berkus wrote: +> Chris, +> +> > I need some help. I have 5 db servers running our database servers, and +> > they all are having various degrees of performance problems. The +> > problems we are experiencing are: +> +> I'mm confused. You're saying "general slowness" but say that most queries +> run in under .01 seconds. And you say "high loads" but the TOP snapshots +> you provide show servers with 2 CPUs idle. +> +> Are you sure you actually *have* a performance issue? + + +From pgsql-performance-owner@postgresql.org Fri Apr 23 14:25:38 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 42A21D1D63E + for ; + Fri, 23 Apr 2004 14:25:20 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 96510-08 + for ; + Fri, 23 Apr 2004 14:25:17 -0300 (ADT) +Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) + by svr1.postgresql.org (Postfix) with ESMTP id A03CAD1D370 + for ; + Fri, 23 Apr 2004 14:25:16 -0300 (ADT) +Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) + by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i3NHOxIl010294; + Fri, 23 Apr 2004 11:24:59 -0600 (MDT) +Date: Fri, 23 Apr 2004 11:21:32 -0600 (MDT) +From: "scott.marlowe" +To: Chris Hoover +Cc: +Subject: Re: Help with performance problems +In-Reply-To: <200404230931.17850.revoohc@sermonaudio.com> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-IHS-MailScanner: Found to be clean +X-IHS-MailScanner-SpamCheck: +X-IHS-MailScanner-Envelope-Sender: scott.marlowe@ihs.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/408 +X-Sequence-Number: 6708 + +On Fri, 23 Apr 2004, Chris Hoover wrote: + +> DB's on Powervaults 220S using raid 5 (over 6 disks) + +What controller is this, the adaptec? We've found it to be slower than +the LSI megaraid based controller, but YMMV. + +> Running RH ES 2.1 + +Are you running the latest kernel for ES 2.1? Early 2.4 kernels are +pretty pokey and have some odd behaviour under load that later 2.4 +kernels seemed to fix. + +> Here is the postgresql.conf from the server with the 11GB db: +> +> max_connections = 64 +> shared_buffers = 32768 # 256MB=32768(buffs)*8192(bytes/buff) +> max_fsm_relations = 1000 # min 10, fsm is free space map, ~40 bytes +> max_fsm_pages = 10000 # min 1000, fsm is free space map, ~6 bytes + +IF you're doing lots of updates and such, you might want these higher. +Have you vacuumed full the databases since taking over? + +> sort_mem = 4096 # 256MB=4096(bytes/proc)*64(procs or conns) + +Sorry, that's wrong. sort_mem is measure in kbytes. i.e. 8192 means 8 +megs sort_mem. Try setting it a bit higher (you've got LOTS of ram in these +boxes) to something like 16 or 32 meg. + +> checkpoint_segments = 16 # in logfile segments, min 1, 16MB each +> checkpoint_timeout = 30 # range 30-3600, in seconds +> effective_cache_size = 131072 # typically 8KB each + +This still looks low. On one machine you're showing kernel cache of about +.7 gig, on the other it's 6 gig. 6 gigs of kernel cache would be a +setting of 800000. It's more of a nudge factor than an exact science, so +don't worry too much. + +If you've got fast I/O look at lowering random page cost to something +between 1 and 2. We use 1.3 to 1.4 on most of our machines with fast +drives under them. + +I'd use vmstat to see if you're I/O bound. + +also, look for index bloat. Before 7.4 it was a serious problem. With +7.4 regular vacuuming should reclaim most lost space, but there are corner +cases where you still might need to re-index. + + +From pgsql-performance-owner@postgresql.org Fri Apr 23 14:53:24 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id CF359D1B4B6 + for ; + Fri, 23 Apr 2004 14:53:22 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 15815-01 + for ; + Fri, 23 Apr 2004 14:53:20 -0300 (ADT) +Received: from mail.astudios.com (unknown [66.49.77.3]) + by svr1.postgresql.org (Postfix) with ESMTP id C24A2D1C4EC + for ; + Fri, 23 Apr 2004 14:53:18 -0300 (ADT) +thread-index: AcQpXFZpF1kw81j3T6iDrHUVhr260A== +Content-Class: urn:content-classes:message +Received: from [10.4.2.155] ([66.194.26.150]) by mail.astudios.com with + Microsoft SMTPSVC(6.0.3790.0); Fri, 23 Apr 2004 13:56:43 -0400 +Importance: normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.132 +From: "Chris Hoover" +To: +Subject: Re: Help with performance problems +Date: Fri, 23 Apr 2004 13:53:17 -0400 +User-Agent: KMail/1.6.1 +References: <200404230931.17850.revoohc@sermonaudio.com> + <200404231316.03447.revoohc@sermonaudio.com> + <4089561B.8010001@speedfc.com> +In-Reply-To: <4089561B.8010001@speedfc.com> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Message-ID: <200404231353.17234.revoohc@sermonaudio.com> +X-OriginalArrivalTime: 23 Apr 2004 17:56:43.0515 (UTC) + FILETIME=[5651D4B0:01C4295C] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/409 +X-Sequence-Number: 6709 + +Sorry for the confusion here. I can't run any sort of vacuum durin the day= +=20 +due to performance hits. However, I have run vacuums at night. Several=20 +nights a week I run a vacuumdb -f -z on all of the clusters. I can take= +=20 +serveral hours to complete, but it does complete. + +During the day, I have tried to run a vacuumdb -v and a vacuumdb -z -v duri= +ng=20 +the day since I read it is supposed to help performance, but as I said, it= +=20 +causes to much of a stress on the system. + +I did change the vacuumdb script to do set the vacuum_mem to 512 when=20 +vacuuming to try and help the situation (from the script: ${PATHNAME}psql= +=20 +$PSQLOPT $ECHOOPT -c "SET vacuum_mem=3D524288;SET autocommit TO 'on';VACUUM= +=20 +$full $verbose $analyze $table" -d $db ), and I reset it to 8192 at the end. + +Anyway, thank you for the ideas so far, and any additional will be greatly= +=20 +appreciated. + +Chris +On Friday 23 April 2004 13:44, Kevin Barnard wrote: +> Chris Hoover wrote: +> >I know the numbers look ok, but we are definetly suffering. Also, if I +> > try to run any sort of vacuum or other db activity during normal busine= +ss +> > hours, load goes through the roof. I have seen loads of over 10 when +> > trying to vacuum the larger cluster and would have to kill the vacuums +> > due to complaints. +> +> This is your problem then. You have to regularly vacuum the DB. You +> might want to dump and reload or schedule a vacuum full. If you don't +> it doesn't matter what you do you will never get decent performance. +> Make sure you vacuum as a superuser this way you get system tables as wel= +l. +> +> Killing a vacuum is bad it tends to make the situation worse. If you +> need to vaccuum one table at a time. +> +> >I think this is probably related to the hardware configuration, but I wa= +nt +> > to make sure that there are no changes I could make configuration wise = +to +> > the db that might lighten the problem. +> > +> >I'm especially want to make sure that I have the memory parameters set to +> > good numbers for my db's so that I can minimize thrashing between the +> > postgres memory pools and the hard drive. I am thinking that this may = +be +> > a big issue here? +> +> Get the vacuum done and don't worry about the hardware or the settings +> until afterwords. + + +From pgsql-performance-owner@postgresql.org Fri Apr 23 15:01:40 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E7D47D1BA98 + for ; + Fri, 23 Apr 2004 15:01:34 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 15115-06 + for ; + Fri, 23 Apr 2004 15:01:33 -0300 (ADT) +Received: from mail.astudios.com (unknown [66.49.77.3]) + by svr1.postgresql.org (Postfix) with ESMTP id 6D806D1BAD5 + for ; + Fri, 23 Apr 2004 15:01:30 -0300 (ADT) +thread-index: AcQpXXtoDiNBWFjzQYyCZJaeKYDeqg== +Content-Class: urn:content-classes:message +Received: from [10.4.2.155] ([66.194.26.150]) by mail.astudios.com with + Microsoft SMTPSVC(6.0.3790.0); Fri, 23 Apr 2004 14:04:54 -0400 +Importance: normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.132 +From: "Chris Hoover" +To: "scott.marlowe" +Subject: Re: Help with performance problems +Date: Fri, 23 Apr 2004 14:01:29 -0400 +User-Agent: KMail/1.6.1 +Cc: +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Message-ID: <200404231401.29144.revoohc@sermonaudio.com> +X-OriginalArrivalTime: 23 Apr 2004 18:04:55.0031 (UTC) + FILETIME=[7B493870:01C4295D] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/410 +X-Sequence-Number: 6710 + +On Friday 23 April 2004 13:21, scott.marlowe wrote: +> On Fri, 23 Apr 2004, Chris Hoover wrote: +> > DB's on Powervaults 220S using raid 5 (over 6 disks) +> +> What controller is this, the adaptec? We've found it to be slower than +> the LSI megaraid based controller, but YMMV. +> +We are using the perc3/di controller. Believe it is using the megaraid=20 +driver. +> > Running RH ES 2.1 +> +> Are you running the latest kernel for ES 2.1? Early 2.4 kernels are +> pretty pokey and have some odd behaviour under load that later 2.4 +> kernels seemed to fix. +> +I'm not sure we are at the latest and greatest for 2.1, but I am trying to = +get=20 +there. Management won't let me do the upgrade w/o first testing/proving it= +=20 +will not cause any more issues. Due to all of the current issues, and the= +=20 +criticality of these systems to our bottom line, they are being very carefu= +l=20 +with any change that may impact our users further. + +We are waiting on our datacenter to plug in our test server and powervault = +so=20 +that we can test the upgrades the the latest RH 2.1 kernel. +> > Here is the postgresql.conf from the server with the 11GB db: +> > +> > max_connections =3D 64 +> > shared_buffers =3D 32768 # 256MB=3D32768(buffs)*8192(bytes/buff) +> > max_fsm_relations =3D 1000 # min 10, fsm is free space map, ~40 bytes +> > max_fsm_pages =3D 10000 # min 1000, fsm is free space map, ~6 bytes +> +> IF you're doing lots of updates and such, you might want these higher. +> Have you vacuumed full the databases since taking over? +> +> > sort_mem =3D 4096 # 256MB=3D4096(bytes/proc)*64(procs or conns) +> +> Sorry, that's wrong. sort_mem is measure in kbytes. i.e. 8192 means 8 +> megs sort_mem. Try setting it a bit higher (you've got LOTS of ram in +> these boxes) to something like 16 or 32 meg. +> +> > checkpoint_segments =3D 16 # in logfile segments, min 1, 16MB each +> > checkpoint_timeout =3D 30 # range 30-3600, in seconds +> > effective_cache_size =3D 131072 # typically 8KB each +> +> This still looks low. On one machine you're showing kernel cache of about +> .7 gig, on the other it's 6 gig. 6 gigs of kernel cache would be a +> setting of 800000. It's more of a nudge factor than an exact science, so +> don't worry too much. +I believe changing this requires a restart of the cluster (correct?). If s= +o,=20 +I'll try bumping up the effective_cache_size over the weekend. + +Also, will all of the memory available to these machines, should I be runni= +ng=20 +with larger shared_buffers? It seems like 256M is a bit small. +> +> If you've got fast I/O look at lowering random page cost to something +> between 1 and 2. We use 1.3 to 1.4 on most of our machines with fast +> drives under them. +> +> I'd use vmstat to see if you're I/O bound. +> +If we end up being I/O bound, should the random page cost be set higher? + +> also, look for index bloat. Before 7.4 it was a serious problem. With +> 7.4 regular vacuuming should reclaim most lost space, but there are corner +> cases where you still might need to re-index. +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 6: Have you searched our list archives? +> +> http://archives.postgresql.org +Thanks for the help, + +Chris + + +From pgsql-performance-owner@postgresql.org Fri Apr 23 15:16:13 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C2BE4D1C9F3 + for ; + Fri, 23 Apr 2004 15:16:08 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 22035-03 + for ; + Fri, 23 Apr 2004 15:16:07 -0300 (ADT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id B1E40D1C9B7 + for ; + Fri, 23 Apr 2004 15:16:05 -0300 (ADT) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4929755; Fri, 23 Apr 2004 11:17:30 -0700 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: "Chris Hoover" , + +Subject: Re: Help with performance problems +Date: Fri, 23 Apr 2004 11:15:23 -0700 +User-Agent: KMail/1.4.3 +References: <200404230931.17850.revoohc@sermonaudio.com> + <4089561B.8010001@speedfc.com> + <200404231353.17234.revoohc@sermonaudio.com> +In-Reply-To: <200404231353.17234.revoohc@sermonaudio.com> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200404231115.23198.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/411 +X-Sequence-Number: 6711 + +Chris, + +> Sorry for the confusion here. I can't run any sort of vacuum durin the day +> due to performance hits. However, I have run vacuums at night. Several +> nights a week I run a vacuumdb -f -z on all of the clusters. I can take +> serveral hours to complete, but it does complete. + +Well, here's your first problem: since your FSM pages is low, and you're only +vacuuming once a day, you've got to have some serious table and index bloat. +SO you're going to need to do VACUUM FULL on all of your databases, and then +REINDEX on all of your indexes. + +After that, raise your max_fsm_pages to something useful, like 1,000,000. Of +course, data on your real rate of updates would help more. + +If you're getting severe disk choke when you vacuum, you probably are I/O +bound. You may want to try something which allows you to vacuum one table +at a time, either pg_autovacuum or a custom script. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Fri Apr 23 15:19:19 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 11580D1BACD + for ; + Fri, 23 Apr 2004 15:19:17 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 23856-02 + for ; + Fri, 23 Apr 2004 15:19:15 -0300 (ADT) +Received: from ECCMCBH.cmc.int.ec.gc.ca (ecdor130.cmc.ec.gc.ca + [199.212.17.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 845C9D1BAD5 + for ; + Fri, 23 Apr 2004 15:19:05 -0300 (ADT) +Received: by eccmcbh.cmc.ec.gc.ca with Internet Mail Service (5.5.2653.19) + id ; Fri, 23 Apr 2004 14:19:05 -0400 +Message-ID: +From: "Shea,Dan [CIS]" +To: 'Christopher Kings-Lynne' +Cc: pgsql-performance@postgresql.org +Subject: Re: Why will vacuum not end? +Date: Fri, 23 Apr 2004 14:19:04 -0400 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2653.19) +Content-Type: text/plain +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/412 +X-Sequence-Number: 6712 + + +PWFPM_DEV=# select * from pg_locks; + relation | database | transaction | pid | mode | +granted +----------+----------+-------------+-------+--------------------------+----- +---- + 17472 | 17347 | | 2618 | ShareUpdateExclusiveLock | t + | | 10858533 | 28778 | ExclusiveLock | t + 17472 | 17347 | | 2618 | ShareUpdateExclusiveLock | t + | | 10803814 | 2618 | ExclusiveLock | t + 16759 | 17347 | | 28778 | AccessShareLock | t +(5 rows) + +PWFPM_DEV=# + +17347 is the database PWFPM_DEV iod, The pids are below + +[root@murphy root]# ps -ef |grep 28778|grep -v "grep" +postgres 28778 504 0 18:06 ? 00:00:00 postgres: scores PWFPM_DEV +[local] idle +[root@murphy root]# ps -ef |grep 2618|grep -v "grep" +postgres 2618 504 8 Apr22 ? 02:31:00 postgres: postgres PWFPM_DEV +[local] VACUUM +[root@murphy root]# +A vacuum is running now. I restarted the database, set vacuum_mem = +'196608'; and started a new vacuum. I also stopped inserting into the +database. +I hoping I will get some results. + +PWFPM_DEV=# select now();vacuum verbose analyze forecastelement;select +now(); + now +------------------------------- + 2004-04-22 13:38:02.083592+00 +(1 row) + +INFO: vacuuming "public.forecastelement" +INFO: index "forecastelement_rwv_idx" now contains 391385895 row versions +in 5051132 pages +DETAIL: 27962015 index row versions were removed. +771899 index pages have been deleted, 496872 are currently reusable. +CPU 4499.54s/385.76u sec elapsed 55780.91 sec. +INFO: "forecastelement": removed 33554117 row versions in 737471 pages +DETAIL: CPU 135.61s/83.99u sec elapsed 1101.26 sec. +-----Original Message----- +From: Christopher Kings-Lynne [mailto:chriskl@familyhealth.com.au] +Sent: Tuesday, April 20, 2004 9:26 PM +To: Shea,Dan [CIS] +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Why will vacuum not end? + + +> No, but data is constantly being inserted by userid scores. It is +postgres +> runnimg the vacuum. +> Dan. + +Well, inserts create some locks - perhaps that's the problem... + +Otherwise, check the pg_locks view to see if you can figure it out. + +Chris + + +---------------------------(end of broadcast)--------------------------- +TIP 2: you can get off all lists at once with the unregister command + (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) + +From pgsql-performance-owner@postgresql.org Fri Apr 23 15:48:47 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id F354ED1C4EB + for ; + Fri, 23 Apr 2004 15:48:45 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 36150-01 + for ; + Fri, 23 Apr 2004 15:48:43 -0300 (ADT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 7845AD1BCB9 + for ; + Fri, 23 Apr 2004 15:48:41 -0300 (ADT) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4929948; Fri, 23 Apr 2004 11:50:05 -0700 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: "Shea,Dan [CIS]" , + 'Christopher Kings-Lynne' +Subject: Re: Why will vacuum not end? +Date: Fri, 23 Apr 2004 11:47:58 -0700 +User-Agent: KMail/1.4.3 +Cc: pgsql-performance@postgresql.org +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200404231147.58279.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/413 +X-Sequence-Number: 6713 + +Guys, + +> Well, inserts create some locks - perhaps that's the problem... +> +> Otherwise, check the pg_locks view to see if you can figure it out. + +FWIW, I've had this happen a couple of times, too. Unfortunately, it's +happend in the middle of the day so that I had to cancel the processes and +get the system back to normal in too much of a hurry to consider documenting +it. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Fri Apr 23 15:56:12 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B6C9AD1B8C0 + for ; + Fri, 23 Apr 2004 15:56:10 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 27570-10 + for ; + Fri, 23 Apr 2004 15:56:09 -0300 (ADT) +Received: from silmaril.syscor.priv (h24-108-208-253.sbm.shawcable.net + [24.108.208.253]) + by svr1.postgresql.org (Postfix) with ESMTP id 189DCD1C50D + for ; + Fri, 23 Apr 2004 15:56:06 -0300 (ADT) +Received: from syscor.com (strider.syscor.priv [192.168.1.3]) + by silmaril.syscor.priv (8.12.8/8.12.8) with ESMTP id i3NIu8XR014585; + Fri, 23 Apr 2004 11:56:09 -0700 +Message-ID: <40896713.2010703@syscor.com> +Date: Fri, 23 Apr 2004 11:57:23 -0700 +From: Ron St-Pierre +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.4) Gecko/20030624 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: revoohc@sermonaudio.com, pgsql-performance@postgresql.org +Subject: Re: Help with performance problems +References: <200404230931.17850.revoohc@sermonaudio.com> + <4089561B.8010001@speedfc.com> + <200404231353.17234.revoohc@sermonaudio.com> + <200404231115.23198.josh@agliodbs.com> +In-Reply-To: <200404231115.23198.josh@agliodbs.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/414 +X-Sequence-Number: 6714 + +Josh Berkus wrote: + +>Chris, +> +> +> +>>Sorry for the confusion here. I can't run any sort of vacuum durin the day +>>due to performance hits. However, I have run vacuums at night. Several +>>nights a week I run a vacuumdb -f -z on all of the clusters. I can take +>>serveral hours to complete, but it does complete. +>> +>> +> +>Well, here's your first problem: since your FSM pages is low, and you're only +>vacuuming once a day, you've got to have some serious table and index bloat. +>SO you're going to need to do VACUUM FULL on all of your databases, and then +>REINDEX on all of your indexes. +> +>After that, raise your max_fsm_pages to something useful, like 1,000,000. Of +>course, data on your real rate of updates would help more. +> +>If you're getting severe disk choke when you vacuum, you probably are I/O +>bound. You may want to try something which allows you to vacuum one table +>at a time, either pg_autovacuum or a custom script. +> +> +> +Tom and Josh recently gave me some help about setting the fsm settings +which was quite useful. The full message is at +http://archives.postgresql.org/pgsql-performance/2004-04/msg00229.php +and the 'most interesting' posrtion was: + + Actually, since he's running 7.4, there's an even better way. Do a + "VACUUM VERBOSE" (full-database vacuum --- doesn't matter whether you + ANALYZE or not). At the end of the very voluminous output, you'll see + something like + + + INFO: free space map: 240 relations, 490 pages stored; 4080 total pages needed + DETAIL: Allocated FSM size: 1000 relations + 20000 pages = 178 kB shared memory. + + + Here, I would need max_fsm_relations = 240 and max_fsm_pages = 4080 to + exactly cover the present freespace needs of my system. I concur with + the suggestion to bump that up a good deal, of course, but that gives + you a real number to start from. + + + The DETAIL part of the message shows my current settings (which are the + defaults) and what the FSM is costing me in shared memory space. + +Good luck +Ron + + + + +From pgsql-performance-owner@postgresql.org Fri Apr 23 16:27:31 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id F03BBD1D073 + for ; + Fri, 23 Apr 2004 16:27:28 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 49811-01 + for ; + Fri, 23 Apr 2004 16:27:27 -0300 (ADT) +Received: from mail.astudios.com (unknown [66.49.77.3]) + by svr1.postgresql.org (Postfix) with ESMTP id 2414ED1C9E8 + for ; + Fri, 23 Apr 2004 16:27:25 -0300 (ADT) +thread-index: AcQpaXvsoqCzdrFlSuChyRKvDuPyjQ== +Content-Class: urn:content-classes:message +Received: from [10.4.2.155] ([66.194.26.150]) by mail.astudios.com with + Microsoft SMTPSVC(6.0.3790.0); Fri, 23 Apr 2004 15:30:49 -0400 +Importance: normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.132 +From: "Chris Hoover" +To: "Ron St-Pierre" +Subject: Re: Help with performance problems +Date: Fri, 23 Apr 2004 15:27:24 -0400 +User-Agent: KMail/1.6.1 +Cc: +References: <200404230931.17850.revoohc@sermonaudio.com> + <200404231115.23198.josh@agliodbs.com> + <40896713.2010703@syscor.com> +In-Reply-To: <40896713.2010703@syscor.com> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Message-ID: <200404231527.24230.revoohc@sermonaudio.com> +X-OriginalArrivalTime: 23 Apr 2004 19:30:49.0968 (UTC) + FILETIME=[7BDE2F00:01C42969] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/415 +X-Sequence-Number: 6715 + +On Friday 23 April 2004 14:57, Ron St-Pierre wrote: +Does this apply to 7.3.4 also? +> Actually, since he's running 7.4, there's an even better way. Do a +> "VACUUM VERBOSE" (full-database vacuum --- doesn't matter whether you +> ANALYZE or not). At the end of the very voluminous output, you'll see +> something like +> +> +> INFO: free space map: 240 relations, 490 pages stored; 4080 total pages +> needed DETAIL: Allocated FSM size: 1000 relations + 20000 pages =3D 178 = +kB +> shared memory. +> +> +> Here, I would need max_fsm_relations =3D 240 and max_fsm_pages =3D 4080 = +to +> exactly cover the present freespace needs of my system. I concur with +> the suggestion to bump that up a good deal, of course, but that gives +> you a real number to start from. +> +> +> The DETAIL part of the message shows my current settings (which are the +> defaults) and what the FSM is costing me in shared memory space. +> +> Good luck +> Ron +> +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 7: don't forget to increase your free space map settings + + +From pgsql-performance-owner@postgresql.org Fri Apr 23 17:02:48 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 38FE0D1B498 + for ; + Fri, 23 Apr 2004 17:02:46 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 56008-07 + for ; + Fri, 23 Apr 2004 17:02:46 -0300 (ADT) +Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) + by svr1.postgresql.org (Postfix) with ESMTP id A62B1D1B47D + for ; + Fri, 23 Apr 2004 17:02:42 -0300 (ADT) +Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) + by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i3NK2JIl026378; + Fri, 23 Apr 2004 14:02:19 -0600 (MDT) +Date: Fri, 23 Apr 2004 13:58:51 -0600 (MDT) +From: "scott.marlowe" +To: Chris Hoover +Cc: +Subject: Re: Help with performance problems +In-Reply-To: <200404231401.29144.revoohc@sermonaudio.com> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-IHS-MailScanner: Found to be clean +X-IHS-MailScanner-SpamCheck: +X-IHS-MailScanner-Envelope-Sender: scott.marlowe@ihs.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/416 +X-Sequence-Number: 6716 + +On Fri, 23 Apr 2004, Chris Hoover wrote: + +> On Friday 23 April 2004 13:21, scott.marlowe wrote: +> > On Fri, 23 Apr 2004, Chris Hoover wrote: +> > > DB's on Powervaults 220S using raid 5 (over 6 disks) +> > +> > What controller is this, the adaptec? We've found it to be slower than +> > the LSI megaraid based controller, but YMMV. +> > +> We are using the perc3/di controller. Believe it is using the megaraid +> driver. + +No, that's the adaptec, the PERC3/DC is the lsi megaraid. See if there +are newer drivers for the RAID card. In terms of performance, the adaptec +and lsi drivers have improved considerably in later versions. In terms of +stability they've largely gotten better with a few in between releases on +the megaraid getting poor grades. The latest / greatest from Dell is +pretty up to date. + +> > > Running RH ES 2.1 +> > +> > Are you running the latest kernel for ES 2.1? Early 2.4 kernels are +> > pretty pokey and have some odd behaviour under load that later 2.4 +> > kernels seemed to fix. +> > +> I'm not sure we are at the latest and greatest for 2.1, but I am trying to get +> there. Management won't let me do the upgrade w/o first testing/proving it +> will not cause any more issues. Due to all of the current issues, and the +> criticality of these systems to our bottom line, they are being very careful +> with any change that may impact our users further. + +Understood. It's why my production box is still running a 2.4 kernel on +rh 7.2 with pg 7.2. They just work, but for us stability AND performance +are both good with our load. + +You can install a new kernel and set up the machine to still boot off of +the old one, and test on the weekend to see how it behaves under +simulated load. Mining the logs for slow queries is a good way to build +one. + +while we don't upgrade our production server's applications to the latest +and greatest all the time (i.e. php or postgresql or openldap) we always +run the latest security patches, and I think the latest kernels had +security fixes for ES 2.1, so NOT upgrading it dangerous. Late model +linux kernels (the 2.0.x and 2.2.x where x>20) tend to be VERY stable and +very conservatively backported and upgraded, so running a new one isn't +usually a big risk. + +> > > Here is the postgresql.conf from the server with the 11GB db: +> > > +> > > max_connections = 64 +> > > shared_buffers = 32768 # 256MB=32768(buffs)*8192(bytes/buff) +> > > max_fsm_relations = 1000 # min 10, fsm is free space map, ~40 bytes +> > > max_fsm_pages = 10000 # min 1000, fsm is free space map, ~6 bytes +> > +> > IF you're doing lots of updates and such, you might want these higher. +> > Have you vacuumed full the databases since taking over? +> > +> > > sort_mem = 4096 # 256MB=4096(bytes/proc)*64(procs or conns) +> > +> > Sorry, that's wrong. sort_mem is measure in kbytes. i.e. 8192 means 8 +> > megs sort_mem. Try setting it a bit higher (you've got LOTS of ram in +> > these boxes) to something like 16 or 32 meg. +> > +> > > checkpoint_segments = 16 # in logfile segments, min 1, 16MB each +> > > checkpoint_timeout = 30 # range 30-3600, in seconds +> > > effective_cache_size = 131072 # typically 8KB each +> > +> > This still looks low. On one machine you're showing kernel cache of about +> > .7 gig, on the other it's 6 gig. 6 gigs of kernel cache would be a +> > setting of 800000. It's more of a nudge factor than an exact science, so +> > don't worry too much. +> I believe changing this requires a restart of the cluster (correct?). If so, +> I'll try bumping up the effective_cache_size over the weekend. +> +> Also, will all of the memory available to these machines, should I be running +> with larger shared_buffers? It seems like 256M is a bit small. + +No, you probably shouldn't. PostgreSQL doesn't "cache" in the classical +sense. If all backends close, the stuff they had in their buffers +disappears in a flash. So, it's generally considered better to let the +kernel do the bulk of the caching, and having the buffer area be large +enough to hold a large portion, if not all, of your working set of data. +But between the cache management which is dirt simple and works but seems +to have performance issues with large numbers of buffers, and the fact +that all the memory in it disappears when the last backend using it. + +for instance, in doing the following seq scan select: + +explain analyze select * from test; + +where test is a ~10 megabyte table, the first time I ran it it took 5 +seconds to run. The second time took it 2.5, the third 1.9, and it +levelled out around there. Starting up another backend and running the +same query got a 1.9 second response also. Shutting down both +connections, and running the query again, with only the kernel for +caching, I got 1.9. + +That's on a 2.4.2[2-4] kernel. + +> > If you've got fast I/O look at lowering random page cost to something +> > between 1 and 2. We use 1.3 to 1.4 on most of our machines with fast +> > drives under them. +> > +> > I'd use vmstat to see if you're I/O bound. +> > +> If we end up being I/O bound, should the random page cost be set higher? + +Not necessarily. Often times on a machine with a lot of memory, you are +better off using index scans where disk seek time would be expensive, but +with indexes in ram, the page cost in comparison to seq pages is almost 1, +with a slight overhead cost. So, lowering the random page cost favors +indexes, generally. If your I/O subsystem is doing a lot of seq scans, +when only part of the data set is ever really being worked on, this tends +to flush out the kernel cache, and we wind up going back to disk over and +over. On the other hand, if your data is normally going to be +sequentially accessed, then you'll have to invest in better RAID hardware +/ more drives etc... + +but with 12 gigs on one box, and an already reasonably fast I/O subsystem +in place, I'd think a lower random page cost would help, not hurt +performance. + +Have you explain analyzed your slower queries? + + + +From pgsql-performance-owner@postgresql.org Fri Apr 23 18:35:16 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7DC4CD1D2BC + for ; + Fri, 23 Apr 2004 18:35:14 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 90610-01 + for ; + Fri, 23 Apr 2004 18:35:14 -0300 (ADT) +Received: from silmaril.syscor.priv (h24-108-208-253.sbm.shawcable.net + [24.108.208.253]) + by svr1.postgresql.org (Postfix) with ESMTP id B30D3D1D26C + for ; + Fri, 23 Apr 2004 18:35:10 -0300 (ADT) +Received: from syscor.com (strider.syscor.priv [192.168.1.3]) + by silmaril.syscor.priv (8.12.8/8.12.8) with ESMTP id i3NLZGXR015000; + Fri, 23 Apr 2004 14:35:17 -0700 +Message-ID: <40898C5F.7070004@syscor.com> +Date: Fri, 23 Apr 2004 14:36:31 -0700 +From: Ron St-Pierre +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.4) Gecko/20030624 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Chris Hoover , + pgsql-performance@postgresql.org +Subject: Re: Help with performance problems +References: <200404230931.17850.revoohc@sermonaudio.com> + <200404231115.23198.josh@agliodbs.com> + <40896713.2010703@syscor.com> + <200404231527.24230.revoohc@sermonaudio.com> +In-Reply-To: <200404231527.24230.revoohc@sermonaudio.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/417 +X-Sequence-Number: 6717 + +Chris Hoover wrote: + +>On Friday 23 April 2004 14:57, Ron St-Pierre wrote: +>Does this apply to 7.3.4 also? +> +No it doesn't, I didn't look back through the thread far enough to see +what you were running. I tried it on 7.3.4 and none of the summary info +listed below was returned. FWIW one of our DBs was slowing down +considerably on an update (30+ minutes) and after I changed +max_fsm_pages from the 7.4 default of 20,000 to 50,000, it completed in +about eight minutes. + +Ron + +> +> +>> Actually, since he's running 7.4, there's an even better way. Do a +>> "VACUUM VERBOSE" (full-database vacuum --- doesn't matter whether you +>> ANALYZE or not). At the end of the very voluminous output, you'll see +>> something like +>> +>> +>> INFO: free space map: 240 relations, 490 pages stored; 4080 total pages +>>needed DETAIL: Allocated FSM size: 1000 relations + 20000 pages = 178 kB +>>shared memory. +>> +>> +>> Here, I would need max_fsm_relations = 240 and max_fsm_pages = 4080 to +>> exactly cover the present freespace needs of my system. I concur with +>> the suggestion to bump that up a good deal, of course, but that gives +>> you a real number to start from. +>> +>> +>> The DETAIL part of the message shows my current settings (which are the +>> defaults) and what the FSM is costing me in shared memory space. +>> +>>Good luck +>>Ron +>> +>> +>> +>> +>>---------------------------(end of broadcast)--------------------------- +>>TIP 7: don't forget to increase your free space map settings +>> +>> +> +> +> +> +> + + + +From pgsql-performance-owner@postgresql.org Fri Apr 23 18:42:36 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D5C7DD1D08A + for ; + Fri, 23 Apr 2004 18:42:33 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 88557-07 + for ; + Fri, 23 Apr 2004 18:42:34 -0300 (ADT) +Received: from email06.aon.at (WARSL402PIP3.highway.telekom.at [195.3.96.75]) + by svr1.postgresql.org (Postfix) with SMTP id 5256AD1D076 + for ; + Fri, 23 Apr 2004 18:42:31 -0300 (ADT) +Received: (qmail 364292 invoked from network); 23 Apr 2004 21:42:30 -0000 +Received: from m161p025.dipool.highway.telekom.at (HELO PASCAL) + ([62.46.10.25]) (envelope-sender ) + by qmail6rs.highway.telekom.at (qmail-ldap-1.03) with SMTP + for ; 23 Apr 2004 21:42:30 -0000 +From: Manfred Koizar +To: Pallav Kalva +Cc: pgsql-performance@postgresql.org +Subject: Re: Setting Shared Buffers , Effective Cache, Sort Mem Parameters +Date: Fri, 23 Apr 2004 23:44:51 +0200 +Message-ID: +References: <4088062E.2050901@deg.cc> + + <4089261A.9070700@deg.cc> +In-Reply-To: <4089261A.9070700@deg.cc> +X-Mailer: Forte Agent 1.93/32.576 English (American) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200404/418 +X-Sequence-Number: 6718 + +On Fri, 23 Apr 2004 10:20:10 -0400, Pallav Kalva wrote: +> the database sizes is around 2- 4 gig and +>there are 5 of them. this machine is +> mainly for the databases and nothing is running on them. + +Did I understand correctly that you run (or plan to run) five +postmasters? Is there a special reason that you cannot put all your +tables into one database? + +> setting shared buffers to 10000 allocates (81Mb) and effective +>cache to 400000 would be around (3gig) +> does this means that if all of the 81mb of the shared memory gets +>allocated it will use rest from the effective +> cache of (3g-81mb) ? + +Simply said, if Postgres wants to access a block, it first looks whether +this block is already in shared buffers which should be the case, if the +block is one of the last 10000 blocks accessed. Otherwise the block has +to be read in. If the OS has the block in its cache, reading it is just +a (fast) memory operation, else it involves a (slow) physical disk read. + +The number of database pages residing in the OS cache is totally out of +control of Postgres. Effective_cache_size tells the query planner how +many database pages can be *expected* to be present in the OS cache. + +>increasing the shared buffers space to 2g + +Setting shared_buffers to half your available memory is the worst thing +you can do. You would end up caching exactly the same set of blocks in +the internal buffers and in the OS cache, thus effectively making one of +the caches useless. + +Better keep shared_buffers low and let the OS do its job. + +Servus + Manfred + +From pgsql-performance-owner@postgresql.org Fri Apr 23 19:04:32 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id F03A3D1D25B + for ; + Fri, 23 Apr 2004 19:04:28 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 93235-09 + for ; + Fri, 23 Apr 2004 19:04:27 -0300 (ADT) +Received: from mta4.rcsntx.swbell.net (mta4.rcsntx.swbell.net [151.164.30.28]) + by svr1.postgresql.org (Postfix) with ESMTP id 7E113D1D08F + for ; + Fri, 23 Apr 2004 19:04:24 -0300 (ADT) +Received: from one.cheapcomplexdevices.com + (adsl-68-122-9-222.dsl.pltn13.pacbell.net [68.122.9.222]) + by mta4.rcsntx.swbell.net (8.12.10/8.12.10) with ESMTP id + i3NM3xY4004066; Fri, 23 Apr 2004 17:04:00 -0500 (CDT) +Received: from localhost (one [127.0.0.1]) + by one.cheapcomplexdevices.com (Postfix) with ESMTP + id D39AA216F7D; Fri, 23 Apr 2004 15:10:20 -0700 (PDT) +Date: Fri, 23 Apr 2004 15:10:20 -0700 (PDT) +From: Ron Mayer +X-X-Sender: mayer@one +To: Manfred Koizar +Cc: Pallav Kalva , pgsql-performance@postgresql.org +Subject: Re: Setting Shared Buffers , Effective Cache, Sort Mem +In-Reply-To: +Message-ID: +References: <4088062E.2050901@deg.cc> + + <4089261A.9070700@deg.cc> + +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200404/419 +X-Sequence-Number: 6719 + + +On Fri, 23 Apr 2004, Manfred Koizar wrote: +> +> Setting shared_buffers to half your available memory is the worst thing +> you can do. You would end up caching exactly the same set of blocks in +> the internal buffers and in the OS cache, thus effectively making one of +> the caches useless. + +One minor detail... You wouldn't really cache the _exact_ same blocks +because cache-hits in shared-buffers (on the most frequently accessed +pages) would let the OS cache some other pages in it's cache. + +But in my experience Manfred's right that there's no benefit and +some penalty to making shared_buffers so large it takes a significant +piece away from the OS's caching. + +From pgsql-performance-owner@postgresql.org Mon Apr 26 14:51:02 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 30A0CD1CCDC + for ; + Fri, 23 Apr 2004 19:21:21 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 01500-02 + for ; + Fri, 23 Apr 2004 19:21:21 -0300 (ADT) +Received: from uno.mnl.com (uno.mnl.com [63.97.246.49]) + by svr1.postgresql.org (Postfix) with SMTP id C196BD1B560 + for ; + Fri, 23 Apr 2004 19:21:18 -0300 (ADT) +Received: (qmail 12062 invoked by uid 1000); 23 Apr 2004 22:21:21 -0000 +Message-ID: <20040423222121.12061.qmail@uno.mnl.com> +From: brad-pgperf@duttonbros.com +To: pgsql-performance@postgresql.org +Subject: index usage +Date: Fri, 23 Apr 2004 15:21:21 -0700 +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="utf-8" +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME +X-Spam-Level: +X-Archive-Number: 200404/440 +X-Sequence-Number: 6740 + +Hi, + +I have a query which I think should be using an index all of the time but +postgres only uses the index part of the time. The index +(ticket_crm_map_crm_id_suppid) has the where clause column (crm_id) listed +first followed by the selected column (support_person_id). Wouldn't the +most efficient plan be to scan the index each time because the only columns +needed are in the index? Below is the table, 2 queries showing the +difference in plans, followed by the record distribution of ticket_crm_map. +I first did a 'vacuum analyze' to update the statistics. + +Thanks, +Brad + + +athenapost=> \d ticket_crm_map + Table "public.ticket_crm_map" + Column | Type | +Modifiers + ------------------------+-----------------------------+--------------------- + ----------------------- +tcrm_map_id | integer | not null +ticket_id | integer | not null +crm_id | integer | not null +support_person_id | integer | not null +escalated_to_person_id | integer | not null +status | character varying(50) | not null default +'Open'::character varying +close_date | timestamp without time zone | +updated_date | timestamp without time zone | +updated_by | character varying(255) | +created_date | timestamp without time zone | +created_by | character varying(255) | +additional_info | text | +subject | character varying(255) | +Indexes: + "ticket_crm_map_pkey" primary key, btree (tcrm_map_id) + "ticket_crm_map_crm_id_key" unique, btree (crm_id, ticket_id) + "ticket_crm_map_crm_id_suppid" btree (crm_id, support_person_id) + "ticket_crm_map_status" btree (status) + "ticket_crm_map_ticket_id" btree (ticket_id) +Foreign-key constraints: + "$1" FOREIGN KEY (ticket_id) REFERENCES ticket(ticket_id) + "$2" FOREIGN KEY (crm_id) REFERENCES company_crm(crm_id) + "$3" FOREIGN KEY (support_person_id) REFERENCES person(person_id) + "$4" FOREIGN KEY (escalated_to_person_id) REFERENCES person(person_id) + "$5" FOREIGN KEY (status) REFERENCES ticket_status(status) + +athenapost=> explain analyze select distinct support_person_id from +ticket_crm_map where crm_id = 7; + +QUERY PLAN + ---------------------------------------------------------------------------- + ---------------------------------------------------------------------------- + ---------- +Unique (cost=1262.99..1265.27 rows=1 width=4) (actual time=15.335..18.245 +rows=20 loops=1) + -> Sort (cost=1262.99..1264.13 rows=456 width=4) (actual +time=15.332..16.605 rows=2275 loops=1) + Sort Key: support_person_id + -> Index Scan using ticket_crm_map_crm_id_suppid on ticket_crm_map +(cost=0.00..1242.85 rows=456 width=4) (actual time=0.055..11.281 rows=2275 +loops=1) + Index Cond: (crm_id = 7) +Total runtime: 18.553 ms +(6 rows) + +Time: 20.598 ms +athenapost=> explain analyze select distinct support_person_id from +ticket_crm_map where crm_id = 1; + QUERY PLAN + ---------------------------------------------------------------------------- + ----------------------------------------------------- +Unique (cost=10911.12..11349.26 rows=32 width=4) (actual +time=659.102..791.517 rows=24 loops=1) + -> Sort (cost=10911.12..11130.19 rows=87628 width=4) (actual +time=659.090..713.285 rows=93889 loops=1) + Sort Key: support_person_id + -> Seq Scan on ticket_crm_map (cost=0.00..3717.25 rows=87628 +width=4) (actual time=0.027..359.299 rows=93889 loops=1) + Filter: (crm_id = 1) +Total runtime: 814.601 ms +(6 rows) + +Time: 817.095 ms +athenapost=> select count(*), crm_id from ticket_crm_map group by crm_id; +count | crm_id + -------+-------- + 2554 | 63 + 129 | 25 + 17 | 24 + 110 | 23 + 74 | 22 + 69 | 21 + 2 | 20 + 53 | 82 + 10 | 17 + 16 | 81 +46637 | 16 + 14 | 80 + 2 | 15 + 1062 | 79 + 87 | 78 + 93 | 77 + 60 | 44 + 363 | 76 + 225 | 10 + 4 | 74 + 83 | 9 + 27 | 73 + 182 | 8 + 2275 | 7 + 15 | 71 + 554 | 6 + 44 | 70 + 631 | 5 + 37 | 4 + 190 | 3 + 112 | 2 +93889 | 1 +(32 rows) + +Time: 436.697 ms + +From pgsql-performance-owner@postgresql.org Fri Apr 23 23:50:34 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id F2660D1B43A + for ; + Fri, 23 Apr 2004 23:50:29 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 72995-08 + for ; + Fri, 23 Apr 2004 23:50:31 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 98745D1BB16 + for ; + Fri, 23 Apr 2004 23:50:26 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3O2oEQD006799; + Fri, 23 Apr 2004 22:50:14 -0400 (EDT) +To: Ron Mayer +Cc: Manfred Koizar , Pallav Kalva , + pgsql-performance@postgresql.org +Subject: Re: Setting Shared Buffers , Effective Cache, Sort Mem +In-reply-to: +References: <4088062E.2050901@deg.cc> + + <4089261A.9070700@deg.cc> + + +Comments: In-reply-to Ron Mayer + message dated "Fri, 23 Apr 2004 15:10:20 -0700" +Date: Fri, 23 Apr 2004 22:50:14 -0400 +Message-ID: <6798.1082775014@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/420 +X-Sequence-Number: 6720 + +Ron Mayer writes: +> [ on setting shared_buffers = half of RAM ] + +> One minor detail... You wouldn't really cache the _exact_ same blocks +> because cache-hits in shared-buffers (on the most frequently accessed +> pages) would let the OS cache some other pages in it's cache. + +> But in my experience Manfred's right that there's no benefit and +> some penalty to making shared_buffers so large it takes a significant +> piece away from the OS's caching. + +True, it'd probably not be the *exact* worst case. But it'd be a good +approximation. In practice you should either bet on the kernel doing +most of the caching (in which case you set shared_buffers pretty low) +or bet on Postgres doing most of the caching (in which case you set +shared_buffers to eat most of RAM). + +The conventional wisdom at this point is to bet the first way; no one +has shown performance benefits from setting shared_buffers higher than +the low tens of thousands. (Most of the mail list traffic on this +predates the existence of pgsql-performance, so check the other list +archives too if you go looking for discussion.) + +It's possible that Jan's recent buffer-management improvements will +change the story as of 7.5. I kinda doubt it myself, but it'd be worth +re-running any experiments you've done when you start working with 7.5. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sat Apr 24 00:00:52 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 766A2D1DCD2 + for ; + Fri, 23 Apr 2004 23:58:22 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 85298-06 + for ; + Fri, 23 Apr 2004 23:58:25 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 73125D1DCCF + for ; + Fri, 23 Apr 2004 23:58:20 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3O2wO45006866; + Fri, 23 Apr 2004 22:58:25 -0400 (EDT) +To: "Chris Hoover" +Cc: pgsql-performance@postgresql.org +Subject: Re: Help with performance problems +In-reply-to: <200404230931.17850.revoohc@sermonaudio.com> +References: <200404230931.17850.revoohc@sermonaudio.com> +Comments: In-reply-to "Chris Hoover" + message dated "Fri, 23 Apr 2004 09:31:17 -0400" +Date: Fri, 23 Apr 2004 22:58:24 -0400 +Message-ID: <6865.1082775504@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/421 +X-Sequence-Number: 6721 + +"Chris Hoover" writes: +> Here is the postgresql.conf from the server with the 11GB db: + +> max_fsm_pages = 10000 # min 1000, fsm is free space map, ~6 bytes + +It's unlikely that that's enough for an 11Gb database, especially if +you're only vacuuming a few times a week. You should make your next run +be a "vacuum verbose" and look at the output to get an idea of what sort +of table bloat you're seeing, but I'll bet it's bad ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sat Apr 24 11:45:44 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D9FE7D1B4AE + for ; + Sat, 24 Apr 2004 11:45:43 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 06886-07 + for ; + Sat, 24 Apr 2004 11:45:46 -0300 (ADT) +Received: from ECCMCBH.cmc.int.ec.gc.ca (ecdor130.cmc.ec.gc.ca + [199.212.17.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 49E2CD1B4D0 + for ; + Sat, 24 Apr 2004 11:45:37 -0300 (ADT) +Received: by eccmcbh.cmc.ec.gc.ca with Internet Mail Service (5.5.2653.19) + id ; Sat, 24 Apr 2004 10:45:41 -0400 +Message-ID: +From: "Shea,Dan [CIS]" +To: 'Josh Berkus' +Cc: pgsql-performance@postgresql.org +Subject: Re: Why will vacuum not end? +Date: Sat, 24 Apr 2004 10:45:40 -0400 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2653.19) +Content-Type: text/plain; + charset="iso-8859-1" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/424 +X-Sequence-Number: 6724 + +Josh, how long should a vacuum take on a 87 GB table with a 39 GB index? + +I do not think that the verbose option of vacuum is verbose enough. +The vacuum keeps redoing the index, but there is no indication as to why it +is doing this. + +I see alot of activity with transaction logs being recycled (15 to 30 every +3 to 20 minutes). +Is the vacuum causing this? + + +-----Original Message----- +From: Josh Berkus [mailto:josh@agliodbs.com] +Sent: Friday, April 23, 2004 2:48 PM +To: Shea,Dan [CIS]; 'Christopher Kings-Lynne' +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Why will vacuum not end? + + +Guys, + +> Well, inserts create some locks - perhaps that's the problem... +> +> Otherwise, check the pg_locks view to see if you can figure it out. + +FWIW, I've had this happen a couple of times, too. Unfortunately, it's +happend in the middle of the day so that I had to cancel the processes and +get the system back to normal in too much of a hurry to consider documenting + +it. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Sat Apr 24 12:36:17 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A09DCD1B931 + for ; + Sat, 24 Apr 2004 12:36:15 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 40924-02 + for ; + Sat, 24 Apr 2004 12:36:14 -0300 (ADT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id B6C7AD1B927 + for ; + Sat, 24 Apr 2004 12:36:13 -0300 (ADT) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4937421; Sat, 24 Apr 2004 08:37:37 -0700 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: "Shea,Dan [CIS]" +Subject: Re: Why will vacuum not end? +Date: Sat, 24 Apr 2004 08:35:21 -0700 +User-Agent: KMail/1.4.3 +Cc: pgsql-performance@postgresql.org +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200404240835.21914.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/425 +X-Sequence-Number: 6725 + +Dan, + +> Josh, how long should a vacuum take on a 87 GB table with a 39 GB index? + +Depends: +-- What's your disk support? +-- VACUUM, VACUUM ANALYZE, or VACUUM FULL? +-- What's your vacuum_mem setting? +-- What are checkpoint and wal settings? + +> I see alot of activity with transaction logs being recycled (15 to 30 every +> 3 to 20 minutes). +> Is the vacuum causing this? + +Probably, yes. How many checkpoint_buffers do you allow? + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Sat Apr 24 12:38:37 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2BD8FD1B514 + for ; + Sat, 24 Apr 2004 12:38:36 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 40774-04 + for ; + Sat, 24 Apr 2004 12:38:34 -0300 (ADT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 52D0DD1B4F7 + for ; + Sat, 24 Apr 2004 12:38:33 -0300 (ADT) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4937428; Sat, 24 Apr 2004 08:39:58 -0700 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: Tom Lane , + Ron Mayer +Subject: Re: Setting Shared Buffers , Effective Cache, Sort Mem +Date: Sat, 24 Apr 2004 08:37:42 -0700 +User-Agent: KMail/1.4.3 +Cc: Manfred Koizar , Pallav Kalva , + pgsql-performance@postgresql.org +References: <4088062E.2050901@deg.cc> + <6798.1082775014@sss.pgh.pa.us> +In-Reply-To: <6798.1082775014@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200404240837.42398.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/426 +X-Sequence-Number: 6726 + +Tom, + +> It's possible that Jan's recent buffer-management improvements will +> change the story as of 7.5. I kinda doubt it myself, but it'd be worth +> re-running any experiments you've done when you start working with 7.5. + +Yes, Jan has indicated to me that he expects to make much heavier use of +shared buffers under ARC. But 7.5 still seems to be too unstable for me to +test this assertion on a large database. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Sat Apr 24 14:55:01 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1ABADD1B4C1 + for ; + Sat, 24 Apr 2004 14:55:00 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 72650-08 + for ; + Sat, 24 Apr 2004 14:54:59 -0300 (ADT) +Received: from email01.aon.at (WARSL402PIP8.highway.telekom.at [195.3.96.97]) + by svr1.postgresql.org (Postfix) with SMTP id CB25BD1B4D7 + for ; + Sat, 24 Apr 2004 14:54:56 -0300 (ADT) +Received: (qmail 285016 invoked from network); 24 Apr 2004 17:54:55 -0000 +Received: from m160p001.dipool.highway.telekom.at (HELO PASCAL) + ([62.46.9.225]) (envelope-sender ) + by qmail1rs.highway.telekom.at (qmail-ldap-1.03) with SMTP + for ; 24 Apr 2004 17:54:55 -0000 +From: Manfred Koizar +To: "Shea,Dan [CIS]" +Cc: 'Josh Berkus' , + pgsql-performance@postgresql.org +Subject: Re: Why will vacuum not end? +Date: Sat, 24 Apr 2004 19:57:22 +0200 +Message-ID: +References: +In-Reply-To: +X-Mailer: Forte Agent 1.93/32.576 English (American) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200404/427 +X-Sequence-Number: 6727 + +On Sat, 24 Apr 2004 10:45:40 -0400, "Shea,Dan [CIS]" +wrote: +>[...] 87 GB table with a 39 GB index? + +>The vacuum keeps redoing the index, but there is no indication as to why it +>is doing this. + +If VACUUM finds a dead tuple, if does not immediately remove index +entries pointing to that tuple. It instead collects such tuple ids and +later does a bulk delete, i.e. scans the whole index and removes all +index items pointing to one of those tuples. The number of tuple ids +that can be remembered is controlled by vacuum_mem: it is + + VacuumMem * 1024 / 6 + +Whenever this number of dead tuples has been found, VACUUM scans the +index (which takes ca. 60000 seconds, more than 16 hours), empties the +list and continues to scan the heap ... + + From the number of dead tuples you can estimate how often your index +will be scanned. If dead tuples are evenly distributed, expect there to +be 15 index scans with your current vacuum_mem setting of 196608. So +your VACUUM will run for 11 days :-( + +OTOH this would mean that there are 500 million dead tuples. Do you +think this is possible? + +Servus + Manfred + +From pgsql-performance-owner@postgresql.org Sat Apr 24 16:48:27 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 61076D1B8A9 + for ; + Sat, 24 Apr 2004 16:48:24 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 06502-07 + for ; + Sat, 24 Apr 2004 16:48:24 -0300 (ADT) +Received: from ECCMCBH.cmc.int.ec.gc.ca (ecdor130.cmc.ec.gc.ca + [199.212.17.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 39B22D1B8A0 + for ; + Sat, 24 Apr 2004 16:48:22 -0300 (ADT) +Received: by eccmcbh.cmc.ec.gc.ca with Internet Mail Service (5.5.2653.19) + id ; Sat, 24 Apr 2004 15:48:20 -0400 +Message-ID: +From: "Shea,Dan [CIS]" +To: 'Josh Berkus' +Cc: pgsql-performance@postgresql.org +Subject: Re: Why will vacuum not end? +Date: Sat, 24 Apr 2004 15:48:19 -0400 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2653.19) +Content-Type: text/plain; + charset="iso-8859-1" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/428 +X-Sequence-Number: 6728 + +Manfred is indicating the reason it is taking so long is due to the number +of dead tuples in my index and the vacuum_mem setting. +The last delete that I did before starting a vacuum had 219,177,133 +deletions. +Dan. +>Dan, + +>> Josh, how long should a vacuum take on a 87 GB table with a 39 GB index? + +>Depends: +>-- What's your disk support? + +>-- VACUUM, VACUUM ANALYZE, or VACUUM FULL? +VACUUM ANALYZE +>-- What's your vacuum_mem setting? +set vacuum_mem = '196608' +#fsync = true # turns forced synchronization on or off +#wal_sync_method = fsync +>-- What are checkpoint and wal settings? +wal_buffers = 64 +checkpoint_segments = 30 +checkpoint_timeout = 300 + +>> I see alot of activity with transaction logs being recycled (15 to 30 +every +>> 3 to 20 minutes). +>> Is the vacuum causing this? + +>Probably, yes. How many checkpoint_buffers do you allow? +I am not sure what the checkpoint_buffers are, we are running 7.4.0? +>-- +>Josh Berkus +>Aglio Database Solutions +>San Francisco + +From pgsql-performance-owner@postgresql.org Sat Apr 24 16:58:10 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C908ED1B4DF + for ; + Sat, 24 Apr 2004 16:58:09 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 06012-09 + for ; + Sat, 24 Apr 2004 16:58:09 -0300 (ADT) +Received: from ECCMCBH.cmc.int.ec.gc.ca (ecdor130.cmc.ec.gc.ca + [199.212.17.130]) + by svr1.postgresql.org (Postfix) with ESMTP id ABC45D1B4F1 + for ; + Sat, 24 Apr 2004 16:58:07 -0300 (ADT) +Received: by eccmcbh.cmc.ec.gc.ca with Internet Mail Service (5.5.2653.19) + id ; Sat, 24 Apr 2004 15:58:09 -0400 +Message-ID: +From: "Shea,Dan [CIS]" +To: 'Manfred Koizar' +Cc: 'Josh Berkus' , + pgsql-performance@postgresql.org +Subject: Re: Why will vacuum not end? +Date: Sat, 24 Apr 2004 15:58:08 -0400 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2653.19) +Content-Type: text/plain +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/429 +X-Sequence-Number: 6729 + +There were defintely 219,177,133 deletions. +The deletions are most likely from the beginning, it was based on the +reception_time of the data. +I would rather not use re-index, unless it is faster then using vacuum. +What do you think would be the best way to get around this? +Increase vacuum_mem to a higher amount 1.5 to 2 GB or try a re-index (rather +not re-index so that data can be queried without soing a seqscan). +Once the index is cleaned up, how does vacuum handle the table? +Does it take as long as the index or is it faster? + + + +-----Original Message----- +From: Manfred Koizar [mailto:mkoi-pg@aon.at] +Sent: Saturday, April 24, 2004 1:57 PM +To: Shea,Dan [CIS] +Cc: 'Josh Berkus'; pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Why will vacuum not end? + + +On Sat, 24 Apr 2004 10:45:40 -0400, "Shea,Dan [CIS]" +wrote: +>[...] 87 GB table with a 39 GB index? + +>The vacuum keeps redoing the index, but there is no indication as to why it +>is doing this. + +If VACUUM finds a dead tuple, if does not immediately remove index +entries pointing to that tuple. It instead collects such tuple ids and +later does a bulk delete, i.e. scans the whole index and removes all +index items pointing to one of those tuples. The number of tuple ids +that can be remembered is controlled by vacuum_mem: it is + + VacuumMem * 1024 / 6 + +Whenever this number of dead tuples has been found, VACUUM scans the +index (which takes ca. 60000 seconds, more than 16 hours), empties the +list and continues to scan the heap ... + + From the number of dead tuples you can estimate how often your index +will be scanned. If dead tuples are evenly distributed, expect there to +be 15 index scans with your current vacuum_mem setting of 196608. So +your VACUUM will run for 11 days :-( + +OTOH this would mean that there are 500 million dead tuples. Do you +think this is possible? + +Servus + Manfred + +From pgsql-performance-owner@postgresql.org Sat Apr 24 21:02:57 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 46177D1B553 + for ; + Sat, 24 Apr 2004 21:02:55 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 64044-08 + for ; + Sat, 24 Apr 2004 21:02:56 -0300 (ADT) +Received: from email04.aon.at (WARSL402PIP2.highway.telekom.at [195.3.96.74]) + by svr1.postgresql.org (Postfix) with SMTP id 033EAD1B53B + for ; + Sat, 24 Apr 2004 21:02:53 -0300 (ADT) +Received: (qmail 97716 invoked from network); 25 Apr 2004 00:02:55 -0000 +Received: from m160p001.dipool.highway.telekom.at (HELO PASCAL) + ([62.46.9.225]) (envelope-sender ) + by qmail7rs.highway.telekom.at (qmail-ldap-1.03) with SMTP + for ; 25 Apr 2004 00:02:55 -0000 +From: Manfred Koizar +To: "Shea,Dan [CIS]" +Cc: 'Josh Berkus' , + pgsql-performance@postgresql.org +Subject: Re: Why will vacuum not end? +Date: Sun, 25 Apr 2004 02:05:22 +0200 +Message-ID: +References: +In-Reply-To: +X-Mailer: Forte Agent 1.93/32.576 English (American) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200404/430 +X-Sequence-Number: 6730 + +On Sat, 24 Apr 2004 15:48:19 -0400, "Shea,Dan [CIS]" +wrote: +>Manfred is indicating the reason it is taking so long is due to the number +>of dead tuples in my index and the vacuum_mem setting. + + +Not dead tuples in the index, but dead tuples in the table. + + +>The last delete that I did before starting a vacuum had 219,177,133 +>deletions. + +Ok, with vacuum_mem = 196608 the bulk delete batch size is ca. 33.5 M +tuple ids. 219 M dead tuples will cause 7 index scans. The time for an +index scan is more or less constant, 60000 seconds in your case. So +yes, a larger vacuum_mem will help, but only if you really have as much +*free* memory. Forcing the machine into swapping would make things +worse. + +BTW, VACUUM frees millions of index pages, is your FSM large enough? + +Servus + Manfred + +From pgsql-performance-owner@postgresql.org Sat Apr 24 21:26:11 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 71FBFD1B520 + for ; + Sat, 24 Apr 2004 21:26:09 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 72670-03 + for ; + Sat, 24 Apr 2004 21:26:11 -0300 (ADT) +Received: from email07.aon.at (WARSL402PIP8.highway.telekom.at [195.3.96.97]) + by svr1.postgresql.org (Postfix) with SMTP id 450BAD1B514 + for ; + Sat, 24 Apr 2004 21:26:07 -0300 (ADT) +Received: (qmail 693236 invoked from network); 25 Apr 2004 00:26:10 -0000 +Received: from m160p001.dipool.highway.telekom.at (HELO PASCAL) + ([62.46.9.225]) (envelope-sender ) + by 172.18.5.236 (qmail-ldap-1.03) with SMTP + for ; 25 Apr 2004 00:26:10 -0000 +From: Manfred Koizar +To: "Shea,Dan [CIS]" +Cc: 'Josh Berkus' , + pgsql-performance@postgresql.org +Subject: Re: Why will vacuum not end? +Date: Sun, 25 Apr 2004 02:28:37 +0200 +Message-ID: +References: +In-Reply-To: +X-Mailer: Forte Agent 1.93/32.576 English (American) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200404/431 +X-Sequence-Number: 6731 + +On Sat, 24 Apr 2004 15:58:08 -0400, "Shea,Dan [CIS]" +wrote: +>There were defintely 219,177,133 deletions. +>The deletions are most likely from the beginning, it was based on the +>reception_time of the data. +>I would rather not use re-index, unless it is faster then using vacuum. + +I don't know whether it would be faster. But if you decide to reindex, +make sure sort_mem is *huge*! + +>What do you think would be the best way to get around this? +>Increase vacuum_mem to a higher amount 1.5 to 2 GB or try a re-index (rather +>not re-index so that data can be queried without soing a seqscan). + +Just out of curiosity: What kind of machine is this running on? And +how long does a seq scan take? + +>Once the index is cleaned up, how does vacuum handle the table? + +If you are lucky VACUUM frees half the index pages. And if we assume +that the most time spent scanning an index goes into random page +accesses, future VACUUMs will take "only" 30000 seconds per index scan. + +Servus + Manfred + +From pgsql-performance-owner@postgresql.org Sat Apr 24 22:50:07 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id EC113D1B436 + for ; + Sat, 24 Apr 2004 22:50:01 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 85001-07 + for ; + Sat, 24 Apr 2004 22:50:03 -0300 (ADT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id D2F89D1B432 + for ; + Sat, 24 Apr 2004 22:49:58 -0300 (ADT) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4939836; Sat, 24 Apr 2004 18:51:26 -0700 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: "Shea,Dan [CIS]" , + 'Manfred Koizar' +Subject: Re: Why will vacuum not end? +Date: Sat, 24 Apr 2004 18:49:07 -0700 +User-Agent: KMail/1.4.3 +Cc: pgsql-performance@postgresql.org +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200404241849.07896.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/432 +X-Sequence-Number: 6732 + +Dan, + +> There were defintely 219,177,133 deletions. +> The deletions are most likely from the beginning, it was based on the +> reception_time of the data. + +You need to run VACUUM more often, I think. Vacuuming out 219 million dead +tuples is going to take a long time no matter how you look at it. If you +vacuum more often, presumably there will be less for Vacuum to do each time. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Sun Apr 25 04:13:43 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 90554D1B48A + for ; + Sun, 25 Apr 2004 04:13:42 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 58789-05 + for ; + Sun, 25 Apr 2004 04:13:42 -0300 (ADT) +Received: from lamb.mcmillan.net.nz (218-101-45-219.paradise.net.nz + [218.101.45.219]) + by svr1.postgresql.org (Postfix) with ESMTP id DA14ED1B4AE + for ; + Sun, 25 Apr 2004 04:13:39 -0300 (ADT) +Received: from lamb.mcmillan.net.nz (lamb.mcmillan.net.nz [127.0.0.1]) + by lamb.mcmillan.net.nz (Postfix) with ESMTP + id 2025FAD985AC; Sun, 25 Apr 2004 19:13:36 +1200 (NZST) +Subject: Re: Wierd context-switching issue on Xeon patch for 7.4.1 +From: Andrew McMillan +To: Josh Berkus +Cc: Tom Lane , + Bruce Momjian , pg@fastcrypt.com, + Paul Tuckfield , Anjan Dave , + Neil Conway , + Dirk =?ISO-8859-1?Q?Lutzeb=E4ck?= , + pgsql-performance@postgresql.org +In-Reply-To: <200404221037.10097.josh@agliodbs.com> +References: <200404220456.i3M4uFv04710@candle.pha.pa.us> + <20171.1082610827@sss.pgh.pa.us> <200404221037.10097.josh@agliodbs.com> +Content-Type: text/plain +Message-Id: <1082877215.8041.20.camel@lamb.mcmillan.net.nz> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.5.7 +Date: Sun, 25 Apr 2004 19:13:35 +1200 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/433 +X-Sequence-Number: 6733 + +On Thu, 2004-04-22 at 10:37 -0700, Josh Berkus wrote: +> Tom, +> +> > The tricky +> > part is that a slow adaptation rate means we can't have every backend +> > figuring this out for itself --- the right value would have to be +> > maintained globally, and I'm not sure how to do that without adding a +> > lot of overhead. +> +> This may be a moot point, since you've stated that changing the loop timing +> won't solve the problem, but what about making the test part of make? I +> don't think too many systems are going to change processor architectures once +> in production, and those that do can be told to re-compile. + +Sure they do - PostgreSQL is regularly provided as a pre-compiled +distribution. I haven't compiled PostgreSQL for years, and we have it +running on dozens of machines, some SMP, some not, but most running +Debian Linux. + +Even having a compiler _installed_ on one of our client's database +servers would usually be considered against security procedures, and +would get a black mark when the auditors came through. + +Regards, + Andrew McMillan +------------------------------------------------------------------------- +Andrew @ Catalyst .Net .NZ Ltd, PO Box 11-053, Manners St, Wellington +WEB: http://catalyst.net.nz/ PHYS: Level 2, 150-154 Willis St +DDI: +64(4)916-7201 MOB: +64(21)635-694 OFFICE: +64(4)499-2267 + Planning an election? Call us! +------------------------------------------------------------------------- + + +From pgsql-performance-owner@postgresql.org Sun Apr 25 10:05:19 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 07458D1B46D + for ; + Sun, 25 Apr 2004 10:05:18 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 29541-02 + for ; + Sun, 25 Apr 2004 10:05:20 -0300 (ADT) +Received: from ECCMCBH.cmc.int.ec.gc.ca (ecdor130.cmc.ec.gc.ca + [199.212.17.130]) + by svr1.postgresql.org (Postfix) with ESMTP id C1004D1B496 + for ; + Sun, 25 Apr 2004 10:05:13 -0300 (ADT) +Received: by eccmcbh.cmc.ec.gc.ca with Internet Mail Service (5.5.2653.19) + id ; Sun, 25 Apr 2004 09:05:16 -0400 +Message-ID: +From: "Shea,Dan [CIS]" +To: 'Manfred Koizar' +Cc: pgsql-performance@postgresql.org +Subject: Re: Why will vacuum not end? +Date: Sun, 25 Apr 2004 09:05:11 -0400 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2653.19) +Content-Type: text/plain +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/434 +X-Sequence-Number: 6734 + +It is set at max_fsm_pages = 1500000 . + +We are running a +DELL PowerEdge 6650 with 4 CPU's +Mem: 3611320k av from top. +The database is on a shared device (SAN) raid5, 172 GB. +Qlogic Fibre optic cards(desc: "QLogic Corp.|QLA2312 Fibre Channel Adapter") +connected to the Dell version of an EMC SAN (FC4700 I believe). + +I have set vacuum_mem = 917504; +and started another vacuum verbose on the table in question. +Tried to set vacuum_mem to 1114112 and vacuum failed, then tried 917504 and +vacuum started. + +PWFPM_DEV=# set vacuum_mem = '1114112'; +SET +PWFPM_DEV=# show vacuum_mem; + vacuum_mem +------------ + 1114112 +(1 row) + +PWFPM_DEV=# vacuum verbose forecastelement; + +INFO: vacuuming "public.forecastelement" +ERROR: invalid memory alloc request size 1140850686 +PWFPM_DEV=# set vacuum_mem = 917504; +SET +PWFPM_DEV=# show vacuum_mem; + vacuum_mem +------------ + 917504 +(1 row) + +PWFPM_DEV=# select now();vacuum verbose forecastelement;select now(); + now +------------------------------- + 2004-04-25 01:40:23.367123+00 +(1 row) + +INFO: vacuuming "public.forecastelement" + +I performed a query that used a seqscan + +PWFPM_DEV=# explain analyze select count(*) from forecastelement; + QUERY PLAN +---------------------------------------------------------------------------- +------------------------------------------------------------------- + Aggregate (cost=16635987.60..16635987.60 rows=1 width=0) (actual +time=13111152.844..13111152.847 rows=1 loops=1) + -> Seq Scan on forecastelement (cost=0.00..15403082.88 rows=493161888 +width=0) (actual time=243.562..12692714.422 rows=264422681 loops=1) + Total runtime: 13111221.978 ms +(3 rows) + +Dan. + +-----Original Message----- +From: Manfred Koizar [mailto:mkoi-pg@aon.at] +Sent: Saturday, April 24, 2004 8:29 PM +To: Shea,Dan [CIS] +Cc: 'Josh Berkus'; pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Why will vacuum not end? + + +On Sat, 24 Apr 2004 15:58:08 -0400, "Shea,Dan [CIS]" +wrote: +>There were defintely 219,177,133 deletions. +>The deletions are most likely from the beginning, it was based on the +>reception_time of the data. +>I would rather not use re-index, unless it is faster then using vacuum. + +I don't know whether it would be faster. But if you decide to reindex, +make sure sort_mem is *huge*! + +>What do you think would be the best way to get around this? +>Increase vacuum_mem to a higher amount 1.5 to 2 GB or try a re-index +(rather +>not re-index so that data can be queried without soing a seqscan). + +Just out of curiosity: What kind of machine is this running on? And +how long does a seq scan take? + +>Once the index is cleaned up, how does vacuum handle the table? + +If you are lucky VACUUM frees half the index pages. And if we assume +that the most time spent scanning an index goes into random page +accesses, future VACUUMs will take "only" 30000 seconds per index scan. + +Servus + Manfred + +From pgsql-performance-owner@postgresql.org Sun Apr 25 17:24:32 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 414EBD1B478 + for ; + Sun, 25 Apr 2004 17:24:31 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 21904-10 + for ; + Sun, 25 Apr 2004 17:24:30 -0300 (ADT) +Received: from email03.aon.at (WARSL402PIP6.highway.telekom.at [195.3.96.93]) + by svr1.postgresql.org (Postfix) with SMTP id 38489D1B468 + for ; + Sun, 25 Apr 2004 17:24:27 -0300 (ADT) +Received: (qmail 109770 invoked from network); 25 Apr 2004 20:24:27 -0000 +Received: from m149p013.dipool.highway.telekom.at (HELO PASCAL) + ([62.46.8.141]) (envelope-sender ) + by qmail3rs.highway.telekom.at (qmail-ldap-1.03) with SMTP + for ; 25 Apr 2004 20:24:27 -0000 +From: Manfred Koizar +To: Tom Lane +Cc: Robert Treat , + pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Subject: Number of pages in a random sample (was: query slows down with more + accurate stats) +Date: Sun, 25 Apr 2004 22:26:56 +0200 +Message-ID: +References: <1081879359.25537.526.camel@camel> + <25556.1081883922@sss.pgh.pa.us> + + <22642.1082074729@sss.pgh.pa.us> + + <29060.1082126089@sss.pgh.pa.us> + + <25762.1082390410@sss.pgh.pa.us> +In-Reply-To: <25762.1082390410@sss.pgh.pa.us> +X-Mailer: Forte Agent 1.93/32.576 English (American) +MIME-Version: 1.0 +Content-Type: multipart/mixed; + boundary="--=_go7o80pp4j494vn888uhe9n4n4njhifgts.MFSBCHJLHS" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200404/435 +X-Sequence-Number: 6735 + +----=_go7o80pp4j494vn888uhe9n4n4njhifgts.MFSBCHJLHS +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit + +On Mon, 19 Apr 2004 12:00:10 -0400, Tom Lane wrote: +>A possible compromise is to limit the number of pages sampled to +>something a bit larger than n, perhaps 2n or 3n. I don't have a feeling +>for the shape of the different-pages probability function; would this +>make a significant difference, or would it just waste cycles? + +I would have replied earlier, if I had a good answer. What I have so +far contains at least one, probably two flaws. Knowing not much more +than the four basic arithmetic operations I was not able to improve my +model. So I post what I have: + +As usual we assume a constant number c of tuples per page. If we have a +table of size B pages and want to collect a sample of n tuples, the +number of possible samples is (again in OOo syntax) + + left( binom{cB}{n} right) + +If we select an arbitrary page, the number of possible samples that do +NOT contain any tuple from this page is + + left( binom {c (B-1)} {n} right) + +Let's forget about our actual implementations of sampling methods and +pretend we have a perfect random sampling method. So the probability +Pnot(c, B, n) that a certain page is not represented in a random sample +is + + left( binom {c (B-1)} {n} right) over left( binom{cB}{n} right) + +which can be transformed into the more computing-friendly form + + prod from{i=0} to{n-1} {{cB-c - i} over {cB - i}} + +Clearly the probability that a certain page *is* represented in a sample +is + + Pyes(c, B, n) = 1 - Pnot(c, B, n) + +The next step assumes that these probabilities are independent for +different pages, which in reality they are not. We simply estimate the +number of pages represented in a random sample as + + numPag(c, B, n) = B * Pyes(c, B, n) + +Here are some results for n = 3000: + + B \ c-> 10 | 100 | 200 + -------+-------+-------+------- + 100 | --- | 100 | 100 + 1000 | 972 | 953 | 951 + 2000 | 1606 | 1559 | 1556 + 3000 | 1954 | 1902 | 1899 + 6000 | 2408 | 2366 | 2363 + 9000 | 2588 | 2555 | 2553 + 20000 | 2805 | 2788 | 2787 + 30000 | 2869 | 2856 | 2856 + 100000 | 2960 | 2956 | 2956 + +This doesn't look to depend heavily on the number of tuples per page, +which sort of justifies the assumption that c is constant. + +In the next step I tried to estimate the number of pages that contain +exactly 1, 2, ... tuples of the sample. My naive procedure works as +follows (I'm not sure whether it is even valid as a rough approximation, +constructive criticism is very welcome): + +For c=100, B=3000, n=3000 we expect 1902 pages to contain at least 1 +tuple of the sample. There are 1098 more tuples than pages, these +tuples lie somewhere in those 1902 pages from the first step. +numPag(99, 1902, 1098) = 836 pages contain at least a second tuple. +So the number of pages containing exactly 1 tuple is 1902 - 836 = 1066. +Repeating these steps we get 611 pages with 2 tuples, 192 with 3, 30 +with 4, and 3 pages with 5 tuples. + +Here are some more numbers for c = 100 and n = 3000: + + B | pages with 1, 2, ... tuples + -------+-------------------------------------------------------- + 100 | 1 to 24 tuples: 0, then 1, 2, 4, 10, 18, 26, 24, 11, 4 + 1000 | 108, 201, 268, 229, 113, 29, 5 + 2000 | 616, 555, 292, 83, 12, 1 + 3000 | 1066, 611, 192, 30, 3 + 6000 | 1809, 484, 68, 5 + 9000 | 2146, 374, 32, 2 + 20000 | 2584, 196, 8 + 30000 | 2716, 138, 3 + 100000 | 2912, 44 + +A small C program to experimentally confirm or refute these calculations +is attached. Its results are fairly compatible with above numbers, +IMHO. + +Servus + Manfred + +----=_go7o80pp4j494vn888uhe9n4n4njhifgts.MFSBCHJLHS +Content-Type: text/plain; charset=us-ascii; name=samsim.c +Content-Transfer-Encoding: 7bit +Content-Disposition: attachment; filename=samsim.c + +/* +** samsim.c - sampling simulator +*/ +#include +#include +#include +#include + +typedef int bool; + + +#define MAX_RANDOM_VALUE (0x7FFFFFFF) + +static void initrandom() +{ + struct timeval tv; + + gettimeofday(&tv, NULL); + srandom(tv.tv_sec ^ tv.tv_usec); +}/*initrandom*/ + +/* Select a random value R uniformly distributed in 0 < R < 1 */ +static double +random_fract(void) +{ + long z; + + /* random() can produce endpoint values, try again if so */ + do + { + z = random(); + } while (z <= 0 || z >= MAX_RANDOM_VALUE); + return (double) z / (double) MAX_RANDOM_VALUE; +} + +/* +** data structure for (modified) Algorithm S from Knuth 3.4.2 +*/ +typedef struct +{ + long N; /* number of tuples, known in advance */ + int n; /* sample size */ + long t; /* current tuple number */ + int m; /* tuples selected so far */ +} SamplerData; +typedef SamplerData *Sampler; + +static void Sampler_Init(Sampler bs, long N, int samplesize); +static bool Sampler_HasMore(Sampler bs); +static long Sampler_Next(Sampler bs); + +/* +** Sampler_Init -- prepare for random sampling +*/ +static void +Sampler_Init(Sampler bs, long N, int samplesize) +{ + bs->N = N; /* table size */ + bs->n = samplesize; + bs->t = 0; /* tuples scanned so far */ + bs->m = 0; /* tuples selected so far */ +} + +static bool +Sampler_HasMore(Sampler bs) +{ + return (bs->t < bs->N) && (bs->m < bs->n); +} + +static long +Sampler_Next(Sampler bs) +{ + long K = bs->N - bs->t; /* remaining tuples */ + int k = bs->n - bs->m; /* tuples still to sample */ + double p; /* probability to skip the next tuple */ + double V; /* random */ + + /* Assert(Sampler_HasMore(bs)); */ + + if (k >= K) + { + /* need all the rest */ + bs->t += 1; + bs->m += 1; + return bs->t - 1; + } + + p = 1.0 - (double) k / (double) K; + V = random_fract(); + while (V < p) + { + bs->t += 1; + K -= 1; + /* + ** Assert(K > 0) + ** because we startet with K > k > 0, + ** and when K == k, the loop terminates + */ + p *= 1.0 - (double) k / (double) K; + } + + /* select */ + bs->t += 1; + bs->m += 1; + return bs->t - 1; +} + +static void usage() +{ + fprintf(stderr, "usage: samsim c B n\n" + "where c = tuples/page\n" + " B = # of pages\n" + " n = sample size\n"); +}/*usage*/ + +static void dumpstats(long *stat, long cnt) +{ + long i; + + for (i = 1; i <= cnt; ++i) { + printf("%ld%c", stat[i], (i < cnt) ? '\t' : '\n'); + }/*for*/ +}/*dumpstats*/ + +static int samsim(long c, long B, long n) +{ + SamplerData s; + long oldblock = -1; + long blockhits = 0; + long maxhits = -1; + long *stat = calloc(c + 1, sizeof(long)); + + if (stat == NULL) { + fprintf(stderr, "cannot allocate %ld numbers\n", c); + return 2; + }/*if*/ + + Sampler_Init(&s, c * B, n); + if (!Sampler_HasMore(&s)) { + fprintf(stderr, "empty sample\n"); + return 3; + }/*if*/ + + while (Sampler_HasMore(&s)) { + long t = Sampler_Next(&s); + long blocknr = t / c; + + if (blocknr == oldblock) { + ++blockhits; + } else { + if (oldblock >= 0) { + stat[blockhits] += 1; + if (blockhits > maxhits) + maxhits = blockhits; + }/*if*/ + + oldblock = blocknr; + blockhits = 1; + }/*else*/ + }/*while*/ + stat[blockhits] += 1; + + dumpstats(stat, maxhits); + free(stat); + + return 0; /* success */ +}/*samsim*/ + +int main(int argc, char* argv[]) +{ + long c, B, n; + + if (argc != 4) { + usage(); + exit(1); + }/*if*/ + + c = atol(argv[1]); + B = atol(argv[2]); + n = atol(argv[3]); + + if ((c <= 0) || (B <= 0) || (n <= 0)) { + usage(); + exit(1); + }/*if*/ + + initrandom(); + return samsim(c, B, n); +}/*main*/ + +----=_go7o80pp4j494vn888uhe9n4n4njhifgts.MFSBCHJLHS-- + +From pgsql-performance-owner@postgresql.org Sun Apr 25 17:44:28 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id F2456D1B587 + for ; + Sun, 25 Apr 2004 17:44:26 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 33483-07 + for ; + Sun, 25 Apr 2004 17:44:27 -0300 (ADT) +Received: from email06.aon.at (WARSL402PIP3.highway.telekom.at [195.3.96.75]) + by svr1.postgresql.org (Postfix) with SMTP id B43B8D1B586 + for ; + Sun, 25 Apr 2004 17:44:24 -0300 (ADT) +Received: (qmail 218026 invoked from network); 25 Apr 2004 20:44:26 -0000 +Received: from m149p013.dipool.highway.telekom.at (HELO PASCAL) + ([62.46.8.141]) (envelope-sender ) + by qmail6rs.highway.telekom.at (qmail-ldap-1.03) with SMTP + for ; 25 Apr 2004 20:44:26 -0000 +From: Manfred Koizar +To: "Shea,Dan [CIS]" +Cc: pgsql-performance@postgresql.org +Subject: Re: Why will vacuum not end? +Date: Sun, 25 Apr 2004 22:46:54 +0200 +Message-ID: <2v7o80hmttci6k5m3ht6ov760r5jbckmcc@email.aon.at> +References: +In-Reply-To: +X-Mailer: Forte Agent 1.93/32.576 English (American) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200404/436 +X-Sequence-Number: 6736 + +On Sun, 25 Apr 2004 09:05:11 -0400, "Shea,Dan [CIS]" +wrote: +>It is set at max_fsm_pages = 1500000 . + +This might be too low. Your index has ca. 5 M pages, you are going to +delete half of its entries, and what you delete is a contiguous range of +values. So up to 2.5 M index pages might be freed (minus inner nodes +and pages not completely empty). And there will be lots of free heap +pages too ... + +I wrote: +>If you are lucky VACUUM frees half the index pages. And if we assume +>that the most time spent scanning an index goes into random page +>accesses, future VACUUMs will take "only" 30000 seconds per index scan. + +After a closer look at the code and after having slept over it I'm not +so sure any more that the number of tuple ids to be removed has only +minor influence on the time spent for a bulk delete run. After the +current VACUUM has finished would you be so kind to run another VACUUM +VERBOSE with only a few dead tuples and post the results here? + +Servus + Manfred + +From pgsql-performance-owner@postgresql.org Mon Apr 26 06:02:01 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8031DD1B472 + for ; + Mon, 26 Apr 2004 06:02:00 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 38484-07 + for ; + Mon, 26 Apr 2004 06:01:59 -0300 (ADT) +Received: from mail.dsvr.co.uk (mail.dsvr.co.uk [212.69.192.8]) + by svr1.postgresql.org (Postfix) with ESMTP id 38A0CD1B46C + for ; + Mon, 26 Apr 2004 06:01:57 -0300 (ADT) +Received: from [212.69.216.20] (helo=dsvr.net) + by mail.dsvr.co.uk with esmtp (Exim 4.30) id 1BI1zy-0004CR-42 + for pgsql-performance@postgresql.org; Mon, 26 Apr 2004 10:01:58 +0100 +Message-ID: <408CD006.3090004@dsvr.net> +Date: Mon, 26 Apr 2004 10:01:58 +0100 +From: Rob Fielding +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8a) Gecko/20040418 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: OT: Help with performance problems +References: +In-Reply-To: +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/437 +X-Sequence-Number: 6737 + +scott.marlowe wrote: +> On Fri, 23 Apr 2004, Chris Hoover wrote: +> +> +>>DB's on Powervaults 220S using raid 5 (over 6 disks) +> +> +> What controller is this, the adaptec? We've found it to be slower than +> the LSI megaraid based controller, but YMMV. + +Wow, really? You got any more details of the chipset, mobo and kernel +driver ? + +I've been taken to my wits end wrestling with an LSI MegaRAID 320-1 +controller on a supermicro board all weekend. I just couldn't get +anything more than 10MB/sec out of it with megaraid driver v1 OR v2 in +Linux 2.4.26, nor the version in 2.6.6-rc2. After 2 days of humming the +Adaptec mantra I gave in and switched the array straight onto the +onboard Adaptec 160 controller (same cable and everything). Software +RAID 5 gets me over 40MB sec for a nominal cpu hit - more than 4 times +what I could get out of the MegaRAID controller :( Even the 2nd SCSI-2 +channel gets 40MB/sec max (pg_xlog :) + +And HOW LONG does it take to detect drives during POST....ohhhh never +mind ... I really just wanna rant :) There should be a free counseling +service for enraged sysops. + +-- + +Rob Fielding +rob@dsvr.net + +www.dsvr.co.uk Development Designer Servers Ltd + +From pgsql-hackers-owner@postgresql.org Mon Apr 26 12:10:34 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id A62C0D1B51A; Mon, 26 Apr 2004 12:08:27 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 82600-08; Mon, 26 Apr 2004 12:08:21 -0300 (ADT) +Received: from relay2.EECS.Berkeley.EDU (relay2.EECS.Berkeley.EDU + [169.229.60.28]) by svr1.postgresql.org (Postfix) with ESMTP + id 9057DD1B464; Mon, 26 Apr 2004 12:08:20 -0300 (ADT) +Received: from relay3.EECS.Berkeley.EDU (localhost [127.0.0.1]) + by relay2.EECS.Berkeley.EDU (8.12.10/8.9.3) with ESMTP id + i3QF8INk024799; Mon, 26 Apr 2004 08:08:19 -0700 (PDT) +Received: from datafix.CS.Berkeley.EDU (datafix.CS.Berkeley.EDU + [128.32.37.185]) + by relay3.EECS.Berkeley.EDU (8.12.10/8.9.3) with ESMTP id + i3QF8Htj015313; Mon, 26 Apr 2004 08:08:17 -0700 (PDT) +Reply-To: sailesh@cs.berkeley.edu +X-URL: http://www.cs.berkeley.edu/~sailesh +X-Attribution: Sailesh +To: Manfred Koizar +Cc: Tom Lane , Robert Treat , + pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Subject: Re: Number of pages in a random sample +References: <1081879359.25537.526.camel@camel> + <25556.1081883922@sss.pgh.pa.us> + + <22642.1082074729@sss.pgh.pa.us> + + <29060.1082126089@sss.pgh.pa.us> + + <25762.1082390410@sss.pgh.pa.us> + +From: Sailesh Krishnamurthy +Date: Mon, 26 Apr 2004 08:08:16 -0700 +In-Reply-To: (Manfred + Koizar's message of "Sun, 25 Apr 2004 22:26:56 +0200") +Message-ID: +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/839 +X-Sequence-Number: 52761 + + +I have not been following this thread carefully. Just in case you are +interested in further reading, you could check this paper: + + "A Bi-Level Bernoulli Scheme for Database Sampling" + Peter Haas, Christian Koenig (SIGMOD 2004) + +-- +Pip-pip +Sailesh +http://www.cs.berkeley.edu/~sailesh + + + +From pgsql-admin-owner@postgresql.org Mon Apr 26 17:55:51 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id DAB2ED1B432; Mon, 26 Apr 2004 13:38:04 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 21040-06; Mon, 26 Apr 2004 13:38:01 -0300 (ADT) +Received: from FE-mail03.sfg.albacom.net (FE-mail03.albacom.net + [213.217.149.83]) by svr1.postgresql.org (Postfix) with ESMTP + id 903E5D1B4E6; Mon, 26 Apr 2004 13:38:00 -0300 (ADT) +Received: from axa.it (217.221.80.72) by FE-mail03.sfg.albacom.net (7.0.009) + id 40757CA500244891; Mon, 26 Apr 2004 18:37:56 +0200 +Message-ID: <408D3AE8.5020006@axa.it> +Date: Mon, 26 Apr 2004 18:38:00 +0200 +From: Edoardo Ceccarelli +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: it, en, en-us +MIME-Version: 1.0 +To: pgsql-jdbc@postgresql.org, pgsql-performance@postgresql.org, + pgsql-admin@postgresql.org +Subject: is a good practice to create an index on the oid? +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/313 +X-Sequence-Number: 13286 + +I am using the oid of the table as the main key and I've found that is +not indexed (maybe because I have declared another primary key in the table) + +it is a good practice to create an index like this on the oid of a table? +CREATE INDEX idoid annuncio400 USING btree (oid); + + +does it work as a normal index? + +Thank you +Edoardo + +From pgsql-performance-owner@postgresql.org Mon Apr 26 17:24:00 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5FF50D1B498 + for ; + Mon, 26 Apr 2004 14:11:08 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 36409-03 + for ; + Mon, 26 Apr 2004 14:11:07 -0300 (ADT) +Received: from uno.mnl.com (uno.mnl.com [63.97.246.49]) + by svr1.postgresql.org (Postfix) with SMTP id E6E40D1B448 + for ; + Mon, 26 Apr 2004 14:11:05 -0300 (ADT) +Received: (qmail 45601 invoked by uid 1000); 26 Apr 2004 17:11:03 -0000 +Message-ID: <20040426171103.45600.qmail@uno.mnl.com> +From: brad-pgperf@duttonbros.com +To: pgsql-performance@postgresql.org +Subject: planner/optimizer question +Date: Mon, 26 Apr 2004 10:11:03 -0700 +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="utf-8" +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME +X-Spam-Level: +X-Archive-Number: 200404/446 +X-Sequence-Number: 6746 + +Hi, + +I have a query which I think should be using an index all of the time but +postgres only uses the index part of the time. The index +(ticket_crm_map_crm_id_suppid) has the where clause column (crm_id) listed +first followed by the selected column (support_person_id). Wouldn't the +most efficient plan be to scan the index regardless of crm_id because the +only columns needed are in the index? Below is the table, 2 queries showing +the difference in plans, followed by the record distribution of +ticket_crm_map. I first did a 'vacuum analyze' and am running postgres +7.4.2. + +Thanks, +Brad + + +athenapost=> \d ticket_crm_map + Table "public.ticket_crm_map" + Column | Type | +Modifiers + ------------------------+-----------------------------+--------------------- + ----------------------- +tcrm_map_id | integer | not null +ticket_id | integer | not null +crm_id | integer | not null +support_person_id | integer | not null +escalated_to_person_id | integer | not null +status | character varying(50) | not null default +'Open'::character varying +close_date | timestamp without time zone | +updated_date | timestamp without time zone | +updated_by | character varying(255) | +created_date | timestamp without time zone | +created_by | character varying(255) | +additional_info | text | +subject | character varying(255) | +Indexes: + "ticket_crm_map_pkey" primary key, btree (tcrm_map_id) + "ticket_crm_map_crm_id_key" unique, btree (crm_id, ticket_id) + "ticket_crm_map_crm_id_suppid" btree (crm_id, support_person_id) + "ticket_crm_map_status" btree (status) + "ticket_crm_map_ticket_id" btree (ticket_id) +Foreign-key constraints: + "$1" FOREIGN KEY (ticket_id) REFERENCES ticket(ticket_id) + "$2" FOREIGN KEY (crm_id) REFERENCES company_crm(crm_id) + "$3" FOREIGN KEY (support_person_id) REFERENCES person(person_id) + "$4" FOREIGN KEY (escalated_to_person_id) REFERENCES person(person_id) + "$5" FOREIGN KEY (status) REFERENCES ticket_status(status) + +athenapost=> explain analyze select distinct support_person_id from +ticket_crm_map where crm_id = 7; + +QUERY PLAN + ---------------------------------------------------------------------------- + ---------------------------------------------------------------------------- + ---------- +Unique (cost=1262.99..1265.27 rows=1 width=4) (actual time=15.335..18.245 +rows=20 loops=1) + -> Sort (cost=1262.99..1264.13 rows=456 width=4) (actual +time=15.332..16.605 rows=2275 loops=1) + Sort Key: support_person_id + -> Index Scan using ticket_crm_map_crm_id_suppid on ticket_crm_map +(cost=0.00..1242.85 rows=456 width=4) (actual time=0.055..11.281 rows=2275 +loops=1) + Index Cond: (crm_id = 7) +Total runtime: 18.553 ms +(6 rows) + +Time: 20.598 ms +athenapost=> explain analyze select distinct support_person_id from +ticket_crm_map where crm_id = 1; + QUERY PLAN + ---------------------------------------------------------------------------- + ----------------------------------------------------- +Unique (cost=10911.12..11349.26 rows=32 width=4) (actual +time=659.102..791.517 rows=24 loops=1) + -> Sort (cost=10911.12..11130.19 rows=87628 width=4) (actual +time=659.090..713.285 rows=93889 loops=1) + Sort Key: support_person_id + -> Seq Scan on ticket_crm_map (cost=0.00..3717.25 rows=87628 +width=4) (actual time=0.027..359.299 rows=93889 loops=1) + Filter: (crm_id = 1) +Total runtime: 814.601 ms +(6 rows) + +Time: 817.095 ms +athenapost=> select count(*), crm_id from ticket_crm_map group by crm_id; +count | crm_id + -------+-------- +2554 | 63 +129 | 25 + 17 | 24 +110 | 23 + 74 | 22 + 69 | 21 + 2 | 20 + 53 | 82 + 10 | 17 + 16 | 81 +46637 | 16 + 14 | 80 + 2 | 15 +1062 | 79 + 87 | 78 + 93 | 77 + 60 | 44 +363 | 76 +225 | 10 + 4 | 74 + 83 | 9 + 27 | 73 +182 | 8 +2275 | 7 + 15 | 71 +554 | 6 + 44 | 70 +631 | 5 + 37 | 4 +190 | 3 +112 | 2 +93889 | 1 +(32 rows) + +Time: 436.697 ms + + +From pgsql-performance-owner@postgresql.org Mon Apr 26 16:46:47 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id AFF98D1B55E + for ; + Mon, 26 Apr 2004 14:21:00 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 40197-10 + for ; + Mon, 26 Apr 2004 14:20:59 -0300 (ADT) +Received: from mail.astudios.com (ns1.astudios.com [66.49.77.3]) + by svr1.postgresql.org (Postfix) with ESMTP id 2457ED1B47F + for ; + Mon, 26 Apr 2004 14:20:58 -0300 (ADT) +thread-index: AcQrs1J3TY2Q3ehWSlu3D9wgKvl1cw== +Content-Class: urn:content-classes:message +Importance: normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.132 +Received: from [10.4.2.156] ([66.194.26.150]) by mail.astudios.com with + Microsoft SMTPSVC(6.0.3790.0); Mon, 26 Apr 2004 13:24:25 -0400 +From: "Chris Hoover" +To: "Tom Lane" +Subject: Re: Help with performance problems +Date: Mon, 26 Apr 2004 13:20:56 -0400 +User-Agent: KMail/1.6.1 +Cc: +References: <200404230931.17850.revoohc@sermonaudio.com> + <6865.1082775504@sss.pgh.pa.us> +In-Reply-To: <6865.1082775504@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Message-ID: <200404261320.56455.revoohc@sermonaudio.com> +X-OriginalArrivalTime: 26 Apr 2004 17:24:25.0406 (UTC) + FILETIME=[525B1DE0:01C42BB3] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/445 +X-Sequence-Number: 6745 + +Ok, I was able to run a vacuumdb -f -v on my largest db over the weekend.= +=20=20 +However, I am having trouble reading the results of the table portion. Her= +e=20 +area a couple of tables, what should I be looking at. First table is the k= +ey=20 +table to the db, and the second is the largest table in the db.=20=20 + +Thanks Chris + +INFO: --Relation public.clmhdr-- +INFO: Pages 32191: Changed 0, reaped 5357, Empty 0, New 0; Tup 339351: Vac= +=20 +48358, Keep/VTL 0/0, UnUsed 129, MinLen 560, MaxLen 696; Re-using: Free/Av +ail. Space 42011004/32546120; EndEmpty/Avail. Pages 0/5310. + CPU 0.53s/0.09u sec elapsed 0.61 sec. +INFO: Index clmhdr_pkey: Pages 1429; Tuples 339351: Deleted 48358. + CPU 0.06s/0.28u sec elapsed 4.54 sec. +INFO: Index clmhdr_hdr_user_id_idx: Pages 1711; Tuples 339351: Deleted 483= +58. + CPU 0.09s/0.31u sec elapsed 2.40 sec. +INFO: Index clmhdr_hdr_clm_status_idx: Pages 1237; Tuples 339351: Deleted= +=20 +48358. + CPU 0.03s/0.26u sec elapsed 1.66 sec. +INFO: Index clmhdr_hdr_create_dt_idx: Pages 1475; Tuples 339351: Deleted= +=20 +48358. + CPU 0.05s/0.24u sec elapsed 1.96 sec. +INFO: Index clmhdr_inv_idx: Pages 1429; Tuples 339351: Deleted 48358. + CPU 0.08s/0.22u sec elapsed 1.20 sec. +INFO: Index clmhdr_userid_status_idx: Pages 2161; Tuples 339351: Deleted= +=20 +48358. + CPU 0.05s/0.18u sec elapsed 3.02 sec. +INFO: Rel clmhdr: Pages: 32191 --> 28247; Tuple(s) moved: 8257. + CPU 0.37s/1.81u sec elapsed 16.24 sec. +INFO: Index clmhdr_pkey: Pages 1429; Tuples 339351: Deleted 8257. + CPU 0.00s/0.03u sec elapsed 0.03 sec. +INFO: Index clmhdr_hdr_user_id_idx: Pages 1743; Tuples 339351: Deleted 825= +7. + CPU 0.00s/0.05u sec elapsed 0.04 sec. +INFO: Index clmhdr_hdr_clm_status_idx: Pages 1265; Tuples 339351: Deleted= +=20 +8257. + CPU 0.00s/0.04u sec elapsed 0.03 sec. +INFO: Index clmhdr_hdr_create_dt_idx: Pages 1503; Tuples 339351: Deleted= +=20 +8257. + CPU 0.00s/0.04u sec elapsed 0.12 sec. +INFO: Index clmhdr_inv_idx: Pages 1429; Tuples 339351: Deleted 8257. + CPU 0.00s/0.04u sec elapsed 0.03 sec. +INFO: Index clmhdr_userid_status_idx: Pages 2203; Tuples 339351: Deleted= +=20 +8257. + CPU 0.01s/0.03u sec elapsed 0.04 sec. + +INFO: --Relation public.sent837-- +INFO: Pages 463552: Changed 0, reaped 6690, Empty 0, New 0; Tup 27431539: = +Vac=20 +204348, Keep/VTL 0/0, UnUsed 2801, MinLen 107, MaxLen 347; Re-using:=20 +Free/Avail. Space 54541468/34925860; EndEmpty/Avail. Pages 0/70583. + CPU 10.68s/2.18u sec elapsed 188.32 sec. +INFO: Index sent837_pkey: Pages 124424; Tuples 27431539: Deleted 204348. + CPU 4.24s/3.45u sec elapsed 144.79 sec. +INFO: Rel sent837: Pages: 463552 --> 459954; Tuple(s) moved: 91775. + CPU 1.12s/9.36u sec elapsed 20.13 sec. +INFO: Index sent837_pkey: Pages 124424; Tuples 27431539: Deleted 91775. + CPU 3.51s/2.03u sec elapsed 6.13 sec. + + +From pgsql-performance-owner@postgresql.org Mon Apr 26 19:46:42 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E71C9D1B50D + for ; + Mon, 26 Apr 2004 15:58:16 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 97239-04 + for ; + Mon, 26 Apr 2004 15:58:11 -0300 (ADT) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id E5821D1B4F6 + for ; + Mon, 26 Apr 2004 15:58:08 -0300 (ADT) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id CA06335778; Mon, 26 Apr 2004 11:58:09 -0700 (PDT) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id C862335754; Mon, 26 Apr 2004 11:58:09 -0700 (PDT) +Date: Mon, 26 Apr 2004 11:58:09 -0700 (PDT) +From: Stephan Szabo +To: brad-pgperf@duttonbros.com +Cc: pgsql-performance@postgresql.org +Subject: Re: index usage +In-Reply-To: <20040423222121.12061.qmail@uno.mnl.com> +Message-ID: <20040426115215.R11044@megazone.bigpanda.com> +References: <20040423222121.12061.qmail@uno.mnl.com> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/450 +X-Sequence-Number: 6750 + + +On Fri, 23 Apr 2004 brad-pgperf@duttonbros.com wrote: + +> I have a query which I think should be using an index all of the time but +> postgres only uses the index part of the time. The index +> (ticket_crm_map_crm_id_suppid) has the where clause column (crm_id) listed +> first followed by the selected column (support_person_id). Wouldn't the +> most efficient plan be to scan the index each time because the only columns +> needed are in the index? Below is the table, 2 queries showing the + +Not necessarily. The rows in the actual file still need to be checked to +see if they're visible to the select and if it's expected that the entire +file (or a reasonable % of the pages anyway) will need to be loaded using +the index isn't necessarily a win. + +> athenapost=> explain analyze select distinct support_person_id from +> ticket_crm_map where crm_id = 1; +> QUERY PLAN +> ---------------------------------------------------------------------------- +> ----------------------------------------------------- +> Unique (cost=10911.12..11349.26 rows=32 width=4) (actual +> time=659.102..791.517 rows=24 loops=1) +> -> Sort (cost=10911.12..11130.19 rows=87628 width=4) (actual +> time=659.090..713.285 rows=93889 loops=1) +> Sort Key: support_person_id +> -> Seq Scan on ticket_crm_map (cost=0.00..3717.25 rows=87628 +> width=4) (actual time=0.027..359.299 rows=93889 loops=1) +> Filter: (crm_id = 1) +> Total runtime: 814.601 ms + +How far off is this from the index scan version in time? Try doing +set enable_seqscan=off; and then explain analyzing again. +It's possible that you may wish to lower random_page_cost to change the +estimated effect of how much more expensive random reads are compared to +sequential ones. + +From pgsql-performance-owner@postgresql.org Mon Apr 26 19:25:12 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A0747D1B437 + for ; + Mon, 26 Apr 2004 16:16:30 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 06849-01 + for ; + Mon, 26 Apr 2004 16:16:29 -0300 (ADT) +Received: from uno.mnl.com (uno.mnl.com [63.97.246.49]) + by svr1.postgresql.org (Postfix) with SMTP id A0112D1B520 + for ; + Mon, 26 Apr 2004 16:16:27 -0300 (ADT) +Received: (qmail 47297 invoked by uid 1000); 26 Apr 2004 19:16:28 -0000 +Message-ID: <20040426191628.47296.qmail@uno.mnl.com> +References: <20040423222121.12061.qmail@uno.mnl.com> + <20040426115215.R11044@megazone.bigpanda.com> +In-Reply-To: <20040426115215.R11044@megazone.bigpanda.com> +From: brad-pgperf@duttonbros.com +To: Stephan Szabo , + pgsql-performance@postgresql.org +Subject: Re: index usage +Date: Mon, 26 Apr 2004 12:16:28 -0700 +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="utf-8" +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME +X-Spam-Level: +X-Archive-Number: 200404/449 +X-Sequence-Number: 6749 + + +When checking an index in postgres the original table has to be checked for +each result to find if the index entry is still valid? In which case you +can't blindly scan the whole index and assume the data is good. I was used +to Oracle behavior where the index is up to date so it can do the scan +without hitting the original table. + +Does this sound correct to anyone? + +Thanks, +Brad + + +Stephan Szabo writes: +> On Fri, 23 Apr 2004 brad-pgperf@duttonbros.com wrote: +> +>> I have a query which I think should be using an index all of the time but +>> postgres only uses the index part of the time. The index +>> (ticket_crm_map_crm_id_suppid) has the where clause column (crm_id) listed +>> first followed by the selected column (support_person_id). Wouldn't the +>> most efficient plan be to scan the index each time because the only columns +>> needed are in the index? Below is the table, 2 queries showing the +> +> Not necessarily. The rows in the actual file still need to be checked to +> see if they're visible to the select and if it's expected that the entire +> file (or a reasonable % of the pages anyway) will need to be loaded using +> the index isn't necessarily a win. +> + + + +From pgsql-performance-owner@postgresql.org Mon Apr 26 19:24:22 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1651AD1B7EF + for ; + Mon, 26 Apr 2004 16:20:46 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 07896-01 + for ; + Mon, 26 Apr 2004 16:20:45 -0300 (ADT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 72A0ED1B587 + for ; + Mon, 26 Apr 2004 16:20:43 -0300 (ADT) +Received: from [64.81.245.111] (HELO 192.168.1.102) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4950733; Mon, 26 Apr 2004 12:22:10 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: "Magnus Naeslund(t)" , Tom Lane +Subject: Re: Wierd context-switching issue on Xeon +Date: Mon, 26 Apr 2004 12:20:58 -0700 +User-Agent: KMail/1.5.4 +Cc: Joe Conway , "scott.marlowe" , + Bruce Momjian , lutzeb@aeccom.com, + pgsql-performance@postgresql.org, Neil Conway +References: + <1931.1082422389@sss.pgh.pa.us> <4085A895.6080403@fbab.net> +In-Reply-To: <4085A895.6080403@fbab.net> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200404261220.58257.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 + tests=RCVD_NUMERIC_HELO +X-Spam-Level: +X-Archive-Number: 200404/448 +X-Sequence-Number: 6748 + +Magus, + +> It would be interesting to see what a locking implementation ala FUTEX +> style would give on an 2.6 kernel, as i understood it that would work +> cross process with some work. + +I'mm working on testing a FUTEX patch, but am having some trouble with it. +Will let you know the results .... + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-admin-owner@postgresql.org Mon Apr 26 20:00:10 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C5263D1B478 + for ; + Mon, 26 Apr 2004 20:00:06 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 02804-07 + for ; + Mon, 26 Apr 2004 20:00:05 -0300 (ADT) +Received: from net2.micro-automation.com (net2.micro-automation.com + [64.7.141.29]) + by svr1.postgresql.org (Postfix) with SMTP id 2FE40D1B46C + for ; Mon, 26 Apr 2004 20:00:02 -0300 (ADT) +Received: (qmail 10274 invoked from network); 26 Apr 2004 23:00:00 -0000 +Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) + by net2.micro-automation.com with SMTP; 26 Apr 2004 23:00:00 -0000 +Subject: Re: [JDBC] is a good practice to create an index on the oid? +From: Dave Cramer +Reply-To: pg@fastcrypt.com +To: Edoardo Ceccarelli +Cc: "pgsql-jdbc@postgresql.org" , + pgsql-performance@postgresql.org, pgsql-admin@postgresql.org +In-Reply-To: <408D3AE8.5020006@axa.it> +References: <408D3AE8.5020006@axa.it> +Content-Type: text/plain +Organization: Cramer Consulting +Message-Id: <1083020647.13952.164.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Mon, 26 Apr 2004 19:04:07 -0400 +Content-Transfer-Encoding: 7bit +X-AntiVirus: scanned for viruses by AMaViS 0.2.1 (http://amavis.org/) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=3.0 tagged_above=0.0 required=5.0 + tests=SUSPICIOUS_RECIPS +X-Spam-Level: *** +X-Archive-Number: 200404/314 +X-Sequence-Number: 13287 + +Yes, you can create an index on the oid, but unless you are selecting on +it, it is of little use. + +you would have to do select * from foo where oid=? to get any value out +of the index. + +Dave +On Mon, 2004-04-26 at 12:38, Edoardo Ceccarelli wrote: +> I am using the oid of the table as the main key and I've found that is +> not indexed (maybe because I have declared another primary key in the table) +> +> it is a good practice to create an index like this on the oid of a table? +> CREATE INDEX idoid annuncio400 USING btree (oid); +> +> +> does it work as a normal index? +> +> Thank you +> Edoardo +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 3: if posting/reading through Usenet, please send an appropriate +> subscribe-nomail command to majordomo@postgresql.org so that your +> message can get through to the mailing list cleanly +> +> +> +> !DSPAM:408d7c38183971270217895! +> +> +-- +Dave Cramer +519 939 0336 +ICQ # 14675561 + + +From pgsql-performance-owner@postgresql.org Mon Apr 26 21:03:13 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 82C54D1B48B + for ; + Mon, 26 Apr 2004 21:03:11 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 21012-04 + for ; + Mon, 26 Apr 2004 21:03:11 -0300 (ADT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 3E0F1D1B4D7 + for ; + Mon, 26 Apr 2004 21:03:08 -0300 (ADT) +Received: from [64.81.245.111] (HELO 192.168.1.102) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4952398; Mon, 26 Apr 2004 17:04:37 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: pg@fastcrypt.com, Tom Lane +Subject: Re: Wierd context-switching issue on Xeon patch for 7.4.1 +Date: Mon, 26 Apr 2004 17:03:25 -0700 +User-Agent: KMail/1.5.4 +Cc: pgsql-performance@postgresql.org +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78509814A@vt-pe2550-001.vantage.vantage.com> + <18322.1082601330@sss.pgh.pa.us> + <1082603201.1556.272.camel@localhost.localdomain> +In-Reply-To: <1082603201.1556.272.camel@localhost.localdomain> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200404261703.25631.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 + tests=RCVD_NUMERIC_HELO +X-Spam-Level: +X-Archive-Number: 200404/452 +X-Sequence-Number: 6752 + +Dave, + +> Yeah, I did some more testing myself, and actually get better numbers +> with increasing spins per delay to 1000, but my suspicion is that it is +> highly dependent on finding the right delay for the processor you are +> on. + +Well, it certainly didn't help here: + +procs memory swap io system cpu + r b swpd free buff cache si so bi bo in cs us sy id wa + 2 0 0 14870744 123872 1129912 0 0 0 0 1027 187341 48 27 +26 0 + 2 0 0 14869912 123872 1129912 0 0 0 48 1030 126490 65 18 +16 0 + 2 0 0 14867032 123872 1129912 0 0 0 0 1021 106046 72 16 +12 0 + 2 0 0 14869912 123872 1129912 0 0 0 0 1025 90256 76 14 10 +0 + 2 0 0 14870424 123872 1129912 0 0 0 0 1022 135249 63 22 +16 0 + 2 0 0 14872664 123872 1129912 0 0 0 0 1023 131111 63 20 +17 0 + 1 0 0 14871128 123872 1129912 0 0 0 48 1024 155728 57 22 +20 0 + 2 0 0 14871128 123872 1129912 0 0 0 0 1028 189655 49 29 +22 0 + 2 0 0 14871064 123872 1129912 0 0 0 0 1018 190744 48 29 +23 0 + 2 0 0 14871064 123872 1129912 0 0 0 0 1027 186812 51 26 +23 0 + + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Mon Apr 26 21:11:57 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6E399D1B47F + for ; + Mon, 26 Apr 2004 21:11:55 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 23925-06 + for ; + Mon, 26 Apr 2004 21:11:56 -0300 (ADT) +Received: from net2.micro-automation.com (net2.micro-automation.com + [64.7.141.29]) + by svr1.postgresql.org (Postfix) with SMTP id 831C8D1B475 + for ; + Mon, 26 Apr 2004 21:11:52 -0300 (ADT) +Received: (qmail 28807 invoked from network); 27 Apr 2004 00:11:53 -0000 +Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) + by net2.micro-automation.com with SMTP; 27 Apr 2004 00:11:53 -0000 +Subject: Re: Wierd context-switching issue on Xeon patch for 7.4.1 +From: Dave Cramer +Reply-To: pg@fastcrypt.com +To: Josh Berkus +Cc: Tom Lane , pgsql-performance@postgresql.org +In-Reply-To: <200404261703.25631.josh@agliodbs.com> +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78509814A@vt-pe2550-001.vantage.vantage.com> + <18322.1082601330@sss.pgh.pa.us> + <1082603201.1556.272.camel@localhost.localdomain> + <200404261703.25631.josh@agliodbs.com> +Content-Type: text/plain +Organization: Cramer Consulting +Message-Id: <1083024960.14759.166.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Mon, 26 Apr 2004 20:16:00 -0400 +Content-Transfer-Encoding: 7bit +X-AntiVirus: scanned for viruses by AMaViS 0.2.1 (http://amavis.org/) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/453 +X-Sequence-Number: 6753 + +Are you testing this with Tom's code, you need to do a baseline +measurement with 10 and then increase it, you will still get lots of cs, +but it will be less. + +Dave +On Mon, 2004-04-26 at 20:03, Josh Berkus wrote: +> Dave, +> +> > Yeah, I did some more testing myself, and actually get better numbers +> > with increasing spins per delay to 1000, but my suspicion is that it is +> > highly dependent on finding the right delay for the processor you are +> > on. +> +> Well, it certainly didn't help here: +> +> procs memory swap io system cpu +> r b swpd free buff cache si so bi bo in cs us sy id wa +> 2 0 0 14870744 123872 1129912 0 0 0 0 1027 187341 48 27 +> 26 0 +> 2 0 0 14869912 123872 1129912 0 0 0 48 1030 126490 65 18 +> 16 0 +> 2 0 0 14867032 123872 1129912 0 0 0 0 1021 106046 72 16 +> 12 0 +> 2 0 0 14869912 123872 1129912 0 0 0 0 1025 90256 76 14 10 +> 0 +> 2 0 0 14870424 123872 1129912 0 0 0 0 1022 135249 63 22 +> 16 0 +> 2 0 0 14872664 123872 1129912 0 0 0 0 1023 131111 63 20 +> 17 0 +> 1 0 0 14871128 123872 1129912 0 0 0 48 1024 155728 57 22 +> 20 0 +> 2 0 0 14871128 123872 1129912 0 0 0 0 1028 189655 49 29 +> 22 0 +> 2 0 0 14871064 123872 1129912 0 0 0 0 1018 190744 48 29 +> 23 0 +> 2 0 0 14871064 123872 1129912 0 0 0 0 1027 186812 51 26 +> 23 0 +-- +Dave Cramer +519 939 0336 +ICQ # 14675561 + + +From pgsql-admin-owner@postgresql.org Mon Apr 26 23:43:17 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id F367FD1B47C; Mon, 26 Apr 2004 23:43:07 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 69259-02; Mon, 26 Apr 2004 23:43:10 -0300 (ADT) +Received: from houston.familyhealth.com.au (fhnet.arach.net.au + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP + id CDDC7D1B44C; Mon, 26 Apr 2004 23:43:04 -0300 (ADT) +Received: from familyhealth.com.au (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id + i3R2gtWL087170; Tue, 27 Apr 2004 10:42:59 +0800 (WST) + (envelope-from chriskl@familyhealth.com.au) +Message-ID: <408DC9E1.8020704@familyhealth.com.au> +Date: Tue, 27 Apr 2004 10:48:01 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Edoardo Ceccarelli +Cc: pgsql-jdbc@postgresql.org, pgsql-performance@postgresql.org, + pgsql-admin@postgresql.org +Subject: Re: [PERFORM] is a good practice to create an index on the oid? +References: <408D3AE8.5020006@axa.it> +In-Reply-To: <408D3AE8.5020006@axa.it> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/315 +X-Sequence-Number: 13288 + +> I am using the oid of the table as the main key and I've found that is +> not indexed (maybe because I have declared another primary key in the +> table) +> +> it is a good practice to create an index like this on the oid of a table? +> CREATE INDEX idoid annuncio400 USING btree (oid); + +Yes it is - in fact you really should add a unique index, not just a +normal index, as you want to enforce uniqueness of the oid column. It +is theoretically possible to end up with duplicate oids in wraparound +situations. + +Even better though is to not use oids at all, of course... + +Chris + + +From pgsql-admin-owner@postgresql.org Tue Apr 27 08:55:42 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 047B1D1B8BD + for ; + Tue, 27 Apr 2004 08:55:37 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 41113-09 + for ; + Tue, 27 Apr 2004 08:55:37 -0300 (ADT) +Received: from net2.micro-automation.com (net2.micro-automation.com + [64.7.141.29]) + by svr1.postgresql.org (Postfix) with SMTP id 7F492D1B554 + for ; Tue, 27 Apr 2004 08:55:33 -0300 (ADT) +Received: (qmail 12966 invoked from network); 27 Apr 2004 11:55:32 -0000 +Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) + by net2.micro-automation.com with SMTP; 27 Apr 2004 11:55:32 -0000 +Subject: Re: [JDBC] [PERFORM] is a good practice to create an index on the +From: Dave Cramer +Reply-To: pg@fastcrypt.com +To: Christopher Kings-Lynne +Cc: Edoardo Ceccarelli , + "pgsql-jdbc@postgresql.org" , + pgsql-performance@postgresql.org, pgsql-admin@postgresql.org +In-Reply-To: <408DC9E1.8020704@familyhealth.com.au> +References: <408D3AE8.5020006@axa.it> <408DC9E1.8020704@familyhealth.com.au> +Content-Type: text/plain +Organization: Cramer Consulting +Message-Id: <1083067187.14759.178.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Tue, 27 Apr 2004 07:59:47 -0400 +Content-Transfer-Encoding: 7bit +X-AntiVirus: scanned for viruses by AMaViS 0.2.1 (http://amavis.org/) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/317 +X-Sequence-Number: 13290 + +AFAIK, oids aren't used for anything internally, so duplicates don't +really matter. Besides, what would you do about duplicate oid's ? + +The best suggestion is of course his last, don't use them. + + +On Mon, 2004-04-26 at 22:48, Christopher Kings-Lynne wrote: +> > I am using the oid of the table as the main key and I've found that is +> > not indexed (maybe because I have declared another primary key in the +> > table) +> > +> > it is a good practice to create an index like this on the oid of a table? +> > CREATE INDEX idoid annuncio400 USING btree (oid); +> +> Yes it is - in fact you really should add a unique index, not just a +> normal index, as you want to enforce uniqueness of the oid column. It +> is theoretically possible to end up with duplicate oids in wraparound +> situations. +> +> Even better though is to not use oids at all, of course... +> +> Chris +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 5: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faqs/FAQ.html +> +> +> +> !DSPAM:408dcc51235334924183622! +> +> +-- +Dave Cramer +519 939 0336 +ICQ # 14675561 + + +From pgsql-performance-owner@postgresql.org Tue Apr 27 09:09:51 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id AF00FD1B590 + for ; + Tue, 27 Apr 2004 09:09:50 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 49620-10 + for ; + Tue, 27 Apr 2004 09:09:50 -0300 (ADT) +Received: from email03.aon.at (WARSL402PIP6.highway.telekom.at [195.3.96.93]) + by svr1.postgresql.org (Postfix) with SMTP id E6175D1B570 + for ; + Tue, 27 Apr 2004 09:09:46 -0300 (ADT) +Received: (qmail 175214 invoked from network); 27 Apr 2004 12:09:48 -0000 +Received: from m168p020.dipool.highway.telekom.at (HELO PASCAL) + ([62.46.10.244]) (envelope-sender ) + by qmail3rs.highway.telekom.at (qmail-ldap-1.03) with SMTP + for ; 27 Apr 2004 12:09:48 -0000 +From: Manfred Koizar +To: Qing Zhao +Cc: =?ISO-8859-1?Q?Fr=E9d=E9ric_Robinet?= , + +Subject: Re: Shared buffers, Sort memory, Effective Cache Size +Date: Tue, 27 Apr 2004 14:12:20 +0200 +Message-ID: +References: <009901c427bd$c4752410$c601a8c0@MIMS> + <8937BC90-93B5-11D8-AC12-000A95AB8896@supplyfx.com> +In-Reply-To: <8937BC90-93B5-11D8-AC12-000A95AB8896@supplyfx.com> +X-Mailer: Forte Agent 1.93/32.576 English (American) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200404/456 +X-Sequence-Number: 6756 + +On Wed, 21 Apr 2004 10:01:30 -0700, Qing Zhao +wrote: +>I have recently configured my PG7.3 on a G5 (8GB RAM) with +>shmmax set to 512MB and shared_buffer=50000, sort_mem=4096 +>and effective cache size = 10000. It seems working great so far but +>I am wondering if I should make effctive cache size larger myself. + +Yes, much larger! And while you are at it make shared_buffers smaller. + +Servus + Manfred + +From pgsql-performance-owner@postgresql.org Tue Apr 27 09:54:19 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1B9E2D1B503 + for ; + Tue, 27 Apr 2004 09:54:17 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 72453-02 + for ; + Tue, 27 Apr 2004 09:54:17 -0300 (ADT) +Received: from 192.168.0.11 (fw.i-trade.hu [212.92.1.62]) + by svr1.postgresql.org (Postfix) with SMTP id 98C48D1B4E6 + for ; + Tue, 27 Apr 2004 09:54:12 -0300 (ADT) +Received: (qmail 22728 invoked from network); 27 Apr 2004 12:34:16 -0000 +Received: from unknown (HELO atesz) (212.92.7.130) + by 0 with SMTP; 27 Apr 2004 12:34:15 -0000 +From: "Atesz" +To: +Subject: Re: planner/optimizer question +Date: Tue, 27 Apr 2004 14:54:27 +0200 +Message-ID: <002901c42c56$c8e077a0$0b02010a@atesz> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.2627 +Importance: Normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 +In-Reply-To: <20040426171103.45600.qmail@uno.mnl.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/457 +X-Sequence-Number: 6757 + +Hi, + +You should try the next queries: + +select support_person_id from ticket_crm_map where crm_id = 7 GROUP BY +support_person_id; +select support_person_id from ticket_crm_map where crm_id = 1 GROUP BY +support_person_id; + +It can use the 'ticket_crm_map_crm_id_suppid' index. + +Generally the Postgres use an k-column index if columns of your +conditions are prefix of the index column. +For example: +CREATE INDEX test_idx on test(col1,col2,col3,col4); +SELECT * FROM test WHERE col1=3 AND col2=13; -- This can use the index. + +But the next queries cannot use the index: +SELECT * FROM test WHERE col1=3 AND col3=13;. +SELECT * FROM test WHERE col2=3; + +If you have problem with seq_scan or sort, you can disable globally and +locally: +SET enable_seqscan=0; +SET enable_sort = 0; + +Regards, Antal Attila + + + +From pgsql-admin-owner@postgresql.org Tue Apr 27 12:01:29 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 20B36D1B4DF; Tue, 27 Apr 2004 12:01:27 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 27869-02; Tue, 27 Apr 2004 12:01:23 -0300 (ADT) +Received: from vscan02.westnet.com.au (vscan02.westnet.com.au [203.10.1.132]) + by svr1.postgresql.org (Postfix) with ESMTP + id BD55AD1B4B3; Tue, 27 Apr 2004 12:01:22 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by localhost (Postfix) with ESMTP id 1F05C100F39; + Tue, 27 Apr 2004 23:01:18 +0800 (WST) +Received: from familyhealth.com.au (dsl-202-72-133-22.wa.westnet.com.au + [202.72.133.22]) + by vscan02.westnet.com.au (Postfix) with ESMTP id 90034100DE2; + Tue, 27 Apr 2004 23:01:17 +0800 (WST) +Message-ID: <408E75C2.5060703@familyhealth.com.au> +Date: Tue, 27 Apr 2004 23:01:22 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.6b) Gecko/20031205 Thunderbird/0.4 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pg@fastcrypt.com +Cc: Edoardo Ceccarelli , + "pgsql-jdbc@postgresql.org" , + pgsql-performance@postgresql.org, pgsql-admin@postgresql.org +Subject: Re: [JDBC] [PERFORM] is a good practice to create an index on the +References: <408D3AE8.5020006@axa.it> <408DC9E1.8020704@familyhealth.com.au> + <1083067187.14759.178.camel@localhost.localdomain> +In-Reply-To: <1083067187.14759.178.camel@localhost.localdomain> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=3.0 tagged_above=0.0 required=5.0 + tests=SUSPICIOUS_RECIPS +X-Spam-Level: *** +X-Archive-Number: 200404/320 +X-Sequence-Number: 13293 + +> AFAIK, oids aren't used for anything internally, so duplicates don't +> really matter. Besides, what would you do about duplicate oid's ? + +If he's using them _externally_, then he does have to worry about +duplicates. + +Chris + + +From pgsql-admin-owner@postgresql.org Tue Apr 27 12:14:28 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6A042D1B4FD + for ; + Tue, 27 Apr 2004 12:14:26 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 32819-04 + for ; + Tue, 27 Apr 2004 12:14:23 -0300 (ADT) +Received: from net2.micro-automation.com (net2.micro-automation.com + [64.7.141.29]) + by svr1.postgresql.org (Postfix) with SMTP id 50717D1B475 + for ; Tue, 27 Apr 2004 12:14:23 -0300 (ADT) +Received: (qmail 17086 invoked from network); 27 Apr 2004 15:14:18 -0000 +Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) + by net2.micro-automation.com with SMTP; 27 Apr 2004 15:14:18 -0000 +Subject: Re: [JDBC] [PERFORM] is a good practice to create an index on the +From: Dave Cramer +Reply-To: pg@fastcrypt.com +To: Christopher Kings-Lynne +Cc: Edoardo Ceccarelli , + "pgsql-jdbc@postgresql.org" , + pgsql-performance@postgresql.org, pgsql-admin@postgresql.org +In-Reply-To: <408E75C2.5060703@familyhealth.com.au> +References: <408D3AE8.5020006@axa.it> <408DC9E1.8020704@familyhealth.com.au> + <1083067187.14759.178.camel@localhost.localdomain> + <408E75C2.5060703@familyhealth.com.au> +Content-Type: text/plain +Organization: Cramer Consulting +Message-Id: <1083079114.14759.204.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Tue, 27 Apr 2004 11:18:34 -0400 +Content-Transfer-Encoding: 7bit +X-AntiVirus: scanned for viruses by AMaViS 0.2.1 (http://amavis.org/) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/321 +X-Sequence-Number: 13294 + +Edoardo, + +Are you using them for referential integrity? If so you would be wise to +use sequences instead. + +Christopher: yes you are correct, I wasn't sure if that is what he was +doing. + +Dave +On Tue, 2004-04-27 at 11:01, Christopher Kings-Lynne wrote: +> > AFAIK, oids aren't used for anything internally, so duplicates don't +> > really matter. Besides, what would you do about duplicate oid's ? +> +> If he's using them _externally_, then he does have to worry about +> duplicates. +> +> Chris +> +> +> +> !DSPAM:408e75e0137721921318500! +> +> +-- +Dave Cramer +519 939 0336 +ICQ # 14675561 + + +From pgsql-performance-owner@postgresql.org Tue Apr 27 14:32:49 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3C6C8D1B577 + for ; + Tue, 27 Apr 2004 14:32:41 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 92717-06 + for ; + Tue, 27 Apr 2004 14:32:39 -0300 (ADT) +Received: from mail.informatik.hu-berlin.de (mail.informatik.hu-berlin.de + [141.20.20.50]) + by svr1.postgresql.org (Postfix) with ESMTP id 5438FD1B570 + for ; + Tue, 27 Apr 2004 14:32:37 -0300 (ADT) +Received: from informatik.hu-berlin.de (karotte [141.20.27.143]) + (authenticated bits=0) by mail.informatik.hu-berlin.de + (8.12.10/8.12.10/INF-2.0-MA-SOLARIS-2.8) with ESMTP id i3RHWaID026870 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) + for ; + Tue, 27 Apr 2004 19:32:37 +0200 (MEST) +Message-ID: <408E9934.8060509@informatik.hu-berlin.de> +Date: Tue, 27 Apr 2004 19:32:36 +0200 +From: Silke Trissl +User-Agent: Mozilla/5.0 (X11; U; Linux i686; de-AT; rv:1.4) Gecko/20030624 +X-Accept-Language: de-at, de, en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Join problem +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/460 +X-Sequence-Number: 6760 + +Hi, + +I came across a very intriguing thing: + +I had to join two tables and in both tables I wanted to restrict the +result set by some (text/varchar) attributes. + +Here is an example: + +Table "item" # 147 000 entries + + Column | Type | Modifiers +---------------+-----------------------+------------ + id | integer | not null + description | text | + comment | text | not null + order_id | integer | + + +Table "orders" # 210 000 entries + Column | Type | Modifiers +-----------------+------------------------+----------- + order_id | integer | + order_name | character varying(255) | + + +The tables have 147 000 and 210 000 entries, respectively. + +First I tried the following query, which took ages: + +(Query 1) +EXPLAIN ANALYZE +SELECT item.id +FROM item, orders +WHERE orders.order_name ~* 'Smit' + AND item.description ~* 'CD' + and orders.order_id = item.order_id; + + + +I found out, that the change of the operator from '~*' to '=' for the +item.description brought a great boost in performance (425 secs to 1 +sec!), but not in cost (Query plans at the end). + +(Query 2) + EXPLAIN ANALYZE +SELECT item.id +FROM item, orders +WHERE orders.order_name ~* 'Smit' + AND item.description = 'CD' + and orders.order_id = item.order_id; + + +The main difference was that Query 2 used the Hash join instead of the +Nested Loop, so I disabled the option 'NESTED LOOP' and got for Query 1 +a similar time as for Query 2. + + +Can anyone tell me, why in one case the Hash join and in the other the +much worse Nested Loop is prefered? +And my second question is, is there any possibility to execute the first +query without disabling the Nested Loop first, but get the good +performance of the Hash join? + + +Many thanks in advance for your help or suggestions + +Silke + + +QUERY PLANS: + +##################################### + +Query 1: + QUERY PLAN +------------------------------------------------------------------------------------------------------------------ + + Nested Loop (cost=0.00..28836.75 rows=1 width=4) (actual +time=65350.780..452130.702 rows=6 loops=1) + Join Filter: ("inner".order_id = "outer".order_id) + -> Seq Scan on item (cost=0.00..28814.24 rows=1 width=8) (actual +time=33.180..1365.190 rows=716 loops=1) + Filter: (description ~* 'CD'::text) + -> Seq Scan on orders (cost=0.00..22.50 rows=1 width=4) (actual +time=21.644..629.500 rows=18 loops=716) + Filter: ((order_name)::text ~* 'Smith'::text) + Total runtime: 452130.782 ms +########################################################################### + +Query 2: + QUERY PLAN +------------------------------------------------------------------------------------------------------------------ + + Hash Join (cost=22.50..28840.44 rows=4 width=4) (actual +time=1187.798..1187.798 rows=0 loops=1) + Hash Cond: ("outer".order_id = "inner".order_id) + -> Seq Scan on item (cost=0.00..28814.24 rows=733 width=8) (actual +time=542.737..542.737 rows=0 loops=1) + Filter: (description = 'CD'::text) + -> Hash (cost=22.50..22.50 rows=1 width=4) (actual +time=645.042..645.042 rows=0 loops=1) + -> Seq Scan on orders (cost=0.00..22.50 rows=1 width=4) +(actual time=22.373..644.996 rows=18 loops=1) + Filter: ((order_name)::text ~* 'Smith'::text) + Total runtime: 1187.865 ms +############################################################################ + + +Query 1 with 'set enable_nestloop to false' + + QUERY PLAN +----------------------------------------------------------------------------------------------------------------------- + Hash Join (cost=22.50..28836.75 rows=1 width=4) (actual +time=1068.593..2003.330 rows=6 loops=1) + Hash Cond: ("outer".item_id = "inner".item_id) + -> Seq Scan on item (cost=0.00..28814.24 rows=1 width=8) (actual +time=33.347..1357.073 rows=716 loops=1) + Filter: (description ~* 'CD'::text) + -> Hash (cost=22.50..22.50 rows=1 width=4) (actual +time=645.287..645.287 rows=0 loops=1) + -> Seq Scan on orders (cost=0.00..22.50 rows=1 width=4) +(actual time=22.212..645.239 rows=18 loops=1) + Filter: ((order_name)::text ~* 'CD'::text) + Total runtime: 2003.409 ms + + +From pgsql-performance-owner@postgresql.org Tue Apr 27 15:03:10 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9315CD1B432 + for ; + Tue, 27 Apr 2004 15:03:09 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 08121-04 + for ; + Tue, 27 Apr 2004 15:03:07 -0300 (ADT) +Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) + by svr1.postgresql.org (Postfix) with ESMTP id 1FAABD1B553 + for ; + Tue, 27 Apr 2004 15:03:06 -0300 (ADT) +Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) + by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i3RI2gBh007433; + Tue, 27 Apr 2004 12:02:42 -0600 (MDT) +Date: Tue, 27 Apr 2004 12:02:45 -0600 (MDT) +From: "scott.marlowe" +To: Rob Fielding +Cc: +Subject: Re: OT: Help with performance problems +In-Reply-To: <408CD006.3090004@dsvr.net> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-IHS-MailScanner: Found to be clean +X-IHS-MailScanner-SpamCheck: +X-IHS-MailScanner-Envelope-Sender: scott.marlowe@ihs.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/461 +X-Sequence-Number: 6761 + +On Mon, 26 Apr 2004, Rob Fielding wrote: + +> scott.marlowe wrote: +> > On Fri, 23 Apr 2004, Chris Hoover wrote: +> > +> > +> >>DB's on Powervaults 220S using raid 5 (over 6 disks) +> > +> > +> > What controller is this, the adaptec? We've found it to be slower than +> > the LSI megaraid based controller, but YMMV. +> +> Wow, really? You got any more details of the chipset, mobo and kernel +> driver ? + +We're running on a Dell 2650, the controller is the U320 LSI megaraid 2 +channel (they only make the one that I know of right now). Don't know my +mobo chipset offhand, but might be able to find out what one dell includes +on the 2650. The kernel driver is the latest megaraid2 driver as of about +Feb this year. + +> I've been taken to my wits end wrestling with an LSI MegaRAID 320-1 +> controller on a supermicro board all weekend. I just couldn't get +> anything more than 10MB/sec out of it with megaraid driver v1 OR v2 in +> Linux 2.4.26, nor the version in 2.6.6-rc2. After 2 days of humming the +> Adaptec mantra I gave in and switched the array straight onto the +> onboard Adaptec 160 controller (same cable and everything). Software +> RAID 5 gets me over 40MB sec for a nominal cpu hit - more than 4 times +> what I could get out of the MegaRAID controller :( Even the 2nd SCSI-2 +> channel gets 40MB/sec max (pg_xlog :) +> +> And HOW LONG does it take to detect drives during POST....ohhhh never +> mind ... I really just wanna rant :) There should be a free counseling +> service for enraged sysops. + +I wonder if your controller is broken or something? Or maybe on a PCI +slow that has to share IRQs or something. I've had great luck with +SuperMicro mobos in the past (we're talking dual PPro 200 mobos, so +seriously, IN THE PAST here... ) Hell, my Dual PPro 200 with an old +MegaRAID 428 got 18 Megs a second cfer rate no problem. + +Have you tried that lsi card in another machine / mobo combo? Can you +disable the onboard adaptec? We have on our Dell 2650s, the only active +controllers are the onboard IDE and the add in LSI-320-2 controller. + +We're running ours with 128 Meg cache (I think could be 64) set to write +back. I think our throughput on a RAID-1 pair was somewhere around 40+ +megs a second reads with bonnie++ With RAID-5 it was not really much +faster at reads (something like 60 megs a second) but was much more +scalable under heavy parellel read/write access for PostgreSQL. + +Have you updated the BIOS on the mobo to see if that helps? I'm just +throwing darts at the wall here. + + +From pgsql-performance-owner@postgresql.org Tue Apr 27 15:05:23 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A81EBD1B44C + for ; + Tue, 27 Apr 2004 15:05:20 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 03257-10 + for ; + Tue, 27 Apr 2004 15:05:19 -0300 (ADT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id A650ED1B432 + for ; + Tue, 27 Apr 2004 15:05:17 -0300 (ADT) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4957685; Tue, 27 Apr 2004 11:06:43 -0700 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: pg@fastcrypt.com +Subject: Re: Wierd context-switching issue on Xeon patch for 7.4.1 +Date: Tue, 27 Apr 2004 11:05:00 -0700 +User-Agent: KMail/1.4.3 +Cc: Tom Lane , pgsql-performance@postgresql.org +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78509814A@vt-pe2550-001.vantage.vantage.com> + <200404261703.25631.josh@agliodbs.com> + <1083024960.14759.166.camel@localhost.localdomain> +In-Reply-To: <1083024960.14759.166.camel@localhost.localdomain> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200404271105.00395.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/462 +X-Sequence-Number: 6762 + +Dave, + +> Are you testing this with Tom's code, you need to do a baseline +> measurement with 10 and then increase it, you will still get lots of cs, +> but it will be less. + +No, that was just a test of 1000 straight up. Tom outlined a method, but I +didn't see any code that would help me find a better level, other than just +trying each +100 increase one at a time. This would take days of testing +... +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Tue Apr 27 15:24:11 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D5E7DD1B4B3 + for ; + Tue, 27 Apr 2004 15:23:27 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 17850-02 + for ; + Tue, 27 Apr 2004 15:23:20 -0300 (ADT) +Received: from net2.micro-automation.com (net2.micro-automation.com + [64.7.141.29]) + by svr1.postgresql.org (Postfix) with SMTP id 6C4C8D1B575 + for ; + Tue, 27 Apr 2004 15:23:17 -0300 (ADT) +Received: (qmail 21878 invoked from network); 27 Apr 2004 18:23:15 -0000 +Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) + by net2.micro-automation.com with SMTP; 27 Apr 2004 18:23:15 -0000 +Subject: Re: Wierd context-switching issue on Xeon patch for 7.4.1 +From: Dave Cramer +Reply-To: pg@fastcrypt.com +To: Josh Berkus +Cc: Tom Lane , pgsql-performance@postgresql.org +In-Reply-To: <200404271105.00395.josh@agliodbs.com> +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78509814A@vt-pe2550-001.vantage.vantage.com> + <200404261703.25631.josh@agliodbs.com> + <1083024960.14759.166.camel@localhost.localdomain> + <200404271105.00395.josh@agliodbs.com> +Content-Type: text/plain +Organization: Cramer Consulting +Message-Id: <1083090452.14759.224.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Tue, 27 Apr 2004 14:27:33 -0400 +Content-Transfer-Encoding: 7bit +X-AntiVirus: scanned for viruses by AMaViS 0.2.1 (http://amavis.org/) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/463 +X-Sequence-Number: 6763 + +Josh, + +I think you can safely increase by orders of magnitude here, instead of +by +100, my wild ass guess is that the sweet spot is the spin time +should be approximately the time it takes to consume the resource. So if +you have a really fast machine then the spin count should be higher. + +Also you have to take into consideration your memory bus speed, with the +pause instruction inserted in the loop the timing is now dependent on +memory speed. + +But... you need a baseline first. + +Dave +On Tue, 2004-04-27 at 14:05, Josh Berkus wrote: +> Dave, +> +> > Are you testing this with Tom's code, you need to do a baseline +> > measurement with 10 and then increase it, you will still get lots of cs, +> > but it will be less. +> +> No, that was just a test of 1000 straight up. Tom outlined a method, but I +> didn't see any code that would help me find a better level, other than just +> trying each +100 increase one at a time. This would take days of testing +> ... +-- +Dave Cramer +519 939 0336 +ICQ # 14675561 + + +From pgsql-performance-owner@postgresql.org Tue Apr 27 18:02:55 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 06FC2D1B454 + for ; + Tue, 27 Apr 2004 18:02:54 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 28052-03 + for ; + Tue, 27 Apr 2004 18:02:54 -0300 (ADT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 8BB9DD1B45E + for ; + Tue, 27 Apr 2004 18:02:51 -0300 (ADT) +Received: from [64.81.245.111] (HELO 192.168.1.102) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4958932; Tue, 27 Apr 2004 14:04:18 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: pg@fastcrypt.com +Subject: Re: Wierd context-switching issue on Xeon patch for 7.4.1 +Date: Tue, 27 Apr 2004 14:03:13 -0700 +User-Agent: KMail/1.5.4 +Cc: pgsql-performance@postgresql.org +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78509814A@vt-pe2550-001.vantage.vantage.com> + <200404271105.00395.josh@agliodbs.com> + <1083090452.14759.224.camel@localhost.localdomain> +In-Reply-To: <1083090452.14759.224.camel@localhost.localdomain> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200404271403.13543.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 + tests=RCVD_NUMERIC_HELO +X-Spam-Level: +X-Archive-Number: 200404/464 +X-Sequence-Number: 6764 + +Dave, + +> But... you need a baseline first. + +A baseline on CS? I have that .... + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Tue Apr 27 18:27:28 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 19887D1B4A3 + for ; + Tue, 27 Apr 2004 18:27:28 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 31555-10 + for ; + Tue, 27 Apr 2004 18:27:27 -0300 (ADT) +Received: from fep4.012.net.il (fep4.012.net.il [212.117.129.203]) + by svr1.postgresql.org (Postfix) with ESMTP id 49DC4D1B48A + for ; + Tue, 27 Apr 2004 18:27:24 -0300 (ADT) +Received: from 80.178.84.42.forward.012.net.il ([80.178.84.42]) + by fep4.012.net.il with ESMTP + id <20040427212718.QOXC29794.fep4@80.178.84.42.forward.012.net.il> + for ; + Wed, 28 Apr 2004 00:27:18 +0300 +Date: Wed, 28 Apr 2004 00:27:40 +0300 +From: Vitaly Belman +Reply-To: Vitaly Belman +X-Priority: 3 (Normal) +Message-ID: <282909734.20040428002740@012.net.il> +To: pgsql-performance@postgresql.org +Subject: Simply join in PostrgeSQL takes too long +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.8 tagged_above=0.0 required=5.0 + tests=PRIORITY_NO_NAME +X-Spam-Level: +X-Archive-Number: 200404/465 +X-Sequence-Number: 6765 + +Hello pgsql-performance, + + I discussed the whole subject for some time in DevShed and didn't + achieve much (as for results). I wonder if any of you guys can help + out: + + http://forums.devshed.com/t136202/s.html + +Regards, + Vitaly Belman + + ICQ: 1912453 + AIM: VitalyB1984 + MSN: tmdagent@hotmail.com + Yahoo!: VitalyBe + + +From pgsql-admin-owner@postgresql.org Tue Apr 27 18:43:40 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 6A64FD1B50C; Tue, 27 Apr 2004 18:43:38 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 36987-10; Tue, 27 Apr 2004 18:43:38 -0300 (ADT) +Received: from FE-mail04.sfg.albacom.net (FE-mail04.albacom.net + [213.217.149.84]) by svr1.postgresql.org (Postfix) with ESMTP + id 641CFD1B4F6; Tue, 27 Apr 2004 18:43:35 -0300 (ADT) +Received: from axa.it (217.221.80.72) by FE-mail04.sfg.albacom.net (7.0.009) + id 408E270C00015408; Tue, 27 Apr 2004 23:42:57 +0200 +Message-ID: <408ED3E2.802@axa.it> +Date: Tue, 27 Apr 2004 23:42:58 +0200 +From: Edoardo Ceccarelli +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: it, en, en-us +MIME-Version: 1.0 +To: pg@fastcrypt.com +Cc: Christopher Kings-Lynne , + "pgsql-jdbc@postgresql.org" , + pgsql-performance@postgresql.org, pgsql-admin@postgresql.org +Subject: Re: [JDBC] [PERFORM] is a good practice to create an index on the +References: <408D3AE8.5020006@axa.it> <408DC9E1.8020704@familyhealth.com.au> + <1083067187.14759.178.camel@localhost.localdomain> + <408E75C2.5060703@familyhealth.com.au> + <1083079114.14759.204.camel@localhost.localdomain> +In-Reply-To: <1083079114.14759.204.camel@localhost.localdomain> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=3.0 tagged_above=0.0 required=5.0 + tests=SUSPICIOUS_RECIPS +X-Spam-Level: *** +X-Archive-Number: 200404/327 +X-Sequence-Number: 13300 + +I am going to use them as primary key of the table, so I'll surely need +them unique :) +thank you for you help +Edoardo + +Dave Cramer ha scritto: + +>Edoardo, +> +>Are you using them for referential integrity? If so you would be wise to +>use sequences instead. +> +>Christopher: yes you are correct, I wasn't sure if that is what he was +>doing. +> +>Dave +>On Tue, 2004-04-27 at 11:01, Christopher Kings-Lynne wrote: +> +> +>>>AFAIK, oids aren't used for anything internally, so duplicates don't +>>>really matter. Besides, what would you do about duplicate oid's ? +>>> +>>> +>>If he's using them _externally_, then he does have to worry about +>>duplicates. +>> +>>Chris +>> +>> +>> +>>!DSPAM:408e75e0137721921318500! +>> +>> +>> +>> + +From pgsql-performance-owner@postgresql.org Tue Apr 27 18:56:00 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6097CD1B8B7 + for ; + Tue, 27 Apr 2004 18:55:58 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 47269-02 + for ; + Tue, 27 Apr 2004 18:55:58 -0300 (ADT) +Received: from 192.168.0.11 (fw.i-trade.hu [212.92.1.62]) + by svr1.postgresql.org (Postfix) with SMTP id EB9D3D1B8A5 + for ; + Tue, 27 Apr 2004 18:55:54 -0300 (ADT) +Received: (qmail 32297 invoked from network); 27 Apr 2004 21:35:54 -0000 +Received: from unknown (HELO atesz) (212.92.7.130) + by 0 with SMTP; 27 Apr 2004 21:35:54 -0000 +From: "Atesz" +To: "'Vitaly Belman'" , +Subject: Re: Simply join in PostrgeSQL takes too long +Date: Tue, 27 Apr 2004 23:56:07 +0200 +Message-ID: <002a01c42ca2$7492ac30$0b02010a@atesz> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.2627 +Importance: Normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 +In-Reply-To: <282909734.20040428002740@012.net.il> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/467 +X-Sequence-Number: 6767 + +Hi, + +You can try some variation: + +SELECT + book_id +FROM + bookgenres, genre_children +WHERE + bookgenres.genre_id = genre_children.genre_child_id AND + genre_children.genre_id = 1 +GROUP BY book_id +LIMIT 10 + +The next works if the 'genre_child_id' is UNIQUE on the 'genre_children' +table. + +SELECT + book_id +FROM + bookgenres +WHERE + bookgenres.genre_id = (SELECT genre_child_id FROM genre_children +WHERE genre_id = 1) +GROUP BY book_id +LIMIT 10 + +You may need some index. Try these with EXPLAIN! +CREATE INDEX bookgenres_genre_id_book_id ON bookgenres(genre_id, +book_id); or +CREATE INDEX bookgenres_book_id_genre_id ON bookgenres(book_id, +genre_id); +CREATE INDEX genre_children_genre_id ON genre_children(genre_id); + +Regards, Antal Attila + + + +From pgsql-performance-owner@postgresql.org Tue Apr 27 19:00:15 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id EE54AD1BCA7 + for ; + Tue, 27 Apr 2004 19:00:13 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 49648-02 + for ; + Tue, 27 Apr 2004 19:00:08 -0300 (ADT) +Received: from obie.mrkdns.com (obie.mrkdns.com [69.93.72.82]) + by svr1.postgresql.org (Postfix) with ESMTP id 278A4D1BC54 + for ; + Tue, 27 Apr 2004 19:00:05 -0300 (ADT) +Received: from 82-33-1-22.cable.ubr13.newt.blueyonder.co.uk ([82.33.1.22] + helo=chuckie.co.uk) by obie.mrkdns.com with asmtp (Exim 4.30) + id 1BIacd-0002my-H7; Tue, 27 Apr 2004 23:00:11 +0100 +Message-ID: <408ED7FC.2010705@chuckie.co.uk> +Date: Tue, 27 Apr 2004 23:00:28 +0100 +From: Nick Barr +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Vitaly Belman +Cc: pgsql-performance@postgresql.org +Subject: Re: Simply join in PostrgeSQL takes too long +References: <282909734.20040428002740@012.net.il> +In-Reply-To: <282909734.20040428002740@012.net.il> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-AntiAbuse: This header was added to track abuse, + please include it with any abuse report +X-AntiAbuse: Primary Hostname - obie.mrkdns.com +X-AntiAbuse: Original Domain - postgresql.org +X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] +X-AntiAbuse: Sender Address Domain - chuckie.co.uk +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200404/468 +X-Sequence-Number: 6768 + +Vitaly Belman wrote: +> Hello pgsql-performance, +> +> I discussed the whole subject for some time in DevShed and didn't +> achieve much (as for results). I wonder if any of you guys can help +> out: +> +> http://forums.devshed.com/t136202/s.html +> + +So cutting and pasting: + +----- SCHEMA ----- +CREATE TABLE bv_bookgenres ( + book_id INT NOT NULL, + genre_id INT NOT NULL +); +CREATE TABLE bv_genre_children ( + genre_id INT, + genre_child_id INT +); +------------------- + +----- QUERY ----- +select DISTINCT + book_id +from + bookgenres, + genre_children +WHERE + bookgenres.genre_id = genre_children.genre_child_id AND + genre_children.genre_id = 1 +LIMIT 10 +----------------- + +----- EXPLAIN ANALYZE ----- +QUERY PLAN +Limit (cost=6503.51..6503.70 rows=10 width=4) (actual +time=703.000..703.000 rows=10 loops=1) + -> Unique (cost=6503.51..6738.20 rows=12210 width=4) (actual +time=703.000..703.000 rows=10 loops=1) + -> Sort (cost=6503.51..6620.85 rows=46937 width=4) (actual +time=703.000..703.000 rows=24 loops=1) + Sort Key: bv_bookgenres.book_id + -> Merge Join (cost=582.45..2861.57 rows=46937 width=4) +(actual time=46.000..501.000 rows=45082 loops=1) + Merge Cond: ("outer".genre_id = "inner".genre_child_id) + -> Index Scan using genre_id on bv_bookgenres +(cost=0.00..1462.84 rows=45082 width=8) (actual time=0.000..158.000 +rows=45082 loops=1) + -> Sort (cost=582.45..598.09 rows=6256 width=2) +(actual time=46.000..77.000 rows=49815 loops=1) + Sort Key: bv_genre_children.genre_child_id + -> Index Scan using genre_id2 on +bv_genre_children (cost=0.00..187.98 rows=6256 width=2) (actual +time=0.000..31.000 rows=6379 loops=1) + Index Cond: (genre_id = 1) +Total runtime: 703.000 ms +------------------------------- + +----- CONF SETTINGS ----- +shared_buffers = 1000 # min 16, at least max_connections*2, 8KB each +sort_mem = 10000 +#work_mem = 1024 # min 64, size in KB +#maintenance_work_mem = 16384 # min 1024, size in KB +#max_stack_depth = 2048 # min 100, size in KB +------------------------- + +Have you VACUUM ANALYZED recently. If not do that then rerun the EXPLAIN +ANALYZE. + +You might wanna bump shared_buffers. You have 512MB RAM right? You +probably want to bump shared_buffers to 10000, restart PG then run a +VACUUM ANALYZE. Then rerun the EXPLAIN ANALYZE. + +If that doesnt help try doing a + +ALTER TABLE bv_genre_children ALTER COLUMN genre_child_id SET STATISTICS +100; + +followed by a: + +VACUUM ANALYZE bv_genre_children; + +You might also want to be tweaking the effective_cache_size parameter in + postgresql.conf, but I am unsure how this would work on Windows. Does +Windows have a kernel disk cache anyone? + + + + +HTH + +Nick + + + + + + +From pgsql-performance-owner@postgresql.org Tue Apr 27 19:01:55 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C2DDAD1B4DF + for ; + Tue, 27 Apr 2004 19:01:53 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 48376-05 + for ; + Tue, 27 Apr 2004 19:01:47 -0300 (ADT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9FB2AD1BC54 + for ; + Tue, 27 Apr 2004 19:01:43 -0300 (ADT) +Received: from [134.22.68.249] (dyn-68-249.tor.dsl.tht.net [134.22.68.249]) + by tht.net (Postfix) with ESMTP + id 99FD276A7A; Tue, 27 Apr 2004 18:01:50 -0400 (EDT) +Subject: Re: Simply join in PostrgeSQL takes too long +From: Rod Taylor +To: Vitaly Belman +Cc: Postgresql Performance +In-Reply-To: <282909734.20040428002740@012.net.il> +References: <282909734.20040428002740@012.net.il> +Content-Type: text/plain +Message-Id: <1083103293.30065.100.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Tue, 27 Apr 2004 18:01:34 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/469 +X-Sequence-Number: 6769 + +On Tue, 2004-04-27 at 17:27, Vitaly Belman wrote: +> Hello pgsql-performance, +> +> I discussed the whole subject for some time in DevShed and didn't +> achieve much (as for results). I wonder if any of you guys can help +> out: +> +> http://forums.devshed.com/t136202/s.html + +You're taking the wrong approach. Rather than using a select query to +ensure that the book_id is distinct, add a constraint to the table so +that is guaranteed. + + CREATE UNIQUE INDEX bv_bookgeneres_unq ON bv_bookgenres(book_id, + genre_id); + +Now you can do a simple join (Drop the DISTINCT keyword) and achieve the +same results. + +The point is that a book cannot be of a certain genre more than once. + +Without the distinct, this should take a matter of a few milliseconds to +execute. + + + +From pgsql-performance-owner@postgresql.org Tue Apr 27 19:36:58 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id F2742D1BB4C + for ; + Tue, 27 Apr 2004 19:36:55 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 60874-02 + for ; + Tue, 27 Apr 2004 19:36:55 -0300 (ADT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id B8C45D1BB45 + for ; + Tue, 27 Apr 2004 19:36:52 -0300 (ADT) +Received: from [64.81.245.111] (HELO 192.168.1.102) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4959495; Tue, 27 Apr 2004 15:38:21 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Vitaly Belman , + pgsql-performance@postgresql.org +Subject: Re: Simply join in PostrgeSQL takes too long +Date: Tue, 27 Apr 2004 15:37:09 -0700 +User-Agent: KMail/1.5.4 +References: <282909734.20040428002740@012.net.il> +In-Reply-To: <282909734.20040428002740@012.net.il> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200404271537.09547.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 + tests=RCVD_NUMERIC_HELO +X-Spam-Level: +X-Archive-Number: 200404/470 +X-Sequence-Number: 6770 + +Vitaly, + +I'm afraid that your helper on DevShed is right; 7.5 for Windows is still in +development, we've not even *started* to check it for performance yet. + +Since the Merge Join is taking 90% of your query time, I might suggest +increasing shared_buffers and sort_mem to see if that helps. + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-admin-owner@postgresql.org Tue Apr 27 22:25:23 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 17793D1B498; Tue, 27 Apr 2004 22:25:13 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 06476-06; Tue, 27 Apr 2004 22:25:13 -0300 (ADT) +Received: from houston.familyhealth.com.au (fhnet.arach.net.au + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP + id 005F4D1C942; Tue, 27 Apr 2004 22:25:08 -0300 (ADT) +Received: from familyhealth.com.au (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id + i3S1OxWL006768; Wed, 28 Apr 2004 09:24:59 +0800 (WST) + (envelope-from chriskl@familyhealth.com.au) +Message-ID: <408F0944.5060608@familyhealth.com.au> +Date: Wed, 28 Apr 2004 09:30:44 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Edoardo Ceccarelli +Cc: pg@fastcrypt.com, "pgsql-jdbc@postgresql.org" , + pgsql-performance@postgresql.org, pgsql-admin@postgresql.org +Subject: Re: [JDBC] [PERFORM] is a good practice to create an index on the +References: <408D3AE8.5020006@axa.it> <408DC9E1.8020704@familyhealth.com.au> + <1083067187.14759.178.camel@localhost.localdomain> + <408E75C2.5060703@familyhealth.com.au> + <1083079114.14759.204.camel@localhost.localdomain> + <408ED3E2.802@axa.it> +In-Reply-To: <408ED3E2.802@axa.it> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=3.0 tagged_above=0.0 required=5.0 + tests=SUSPICIOUS_RECIPS +X-Spam-Level: *** +X-Archive-Number: 200404/329 +X-Sequence-Number: 13302 + +> I am going to use them as primary key of the table, so I'll surely need +> them unique :) + +Eduoardo, I REALLY suggest you don't use them at all. You should make a +primary key like this: + +CREATE TABLE blah ( + id SERIAL PRIMARY KEY, + ... +); + +Also note that by default, OIDs are NOT dumped by pg_dump. You will +need to add extra switches to your pg_dump backup to ensure that they are. + +Chris + + +From pgsql-performance-owner@postgresql.org Wed Apr 28 01:28:19 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 76797D1B8B6 + for ; + Wed, 28 Apr 2004 01:28:18 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 65937-01 + for ; + Wed, 28 Apr 2004 01:28:17 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 43616D1B582 + for ; + Wed, 28 Apr 2004 01:28:16 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3S4RxpG023033; + Wed, 28 Apr 2004 00:28:00 -0400 (EDT) +To: brad-pgperf@duttonbros.com +Cc: pgsql-performance@postgresql.org +Subject: Re: planner/optimizer question +In-reply-to: <20040426171103.45600.qmail@uno.mnl.com> +References: <20040426171103.45600.qmail@uno.mnl.com> +Comments: In-reply-to brad-pgperf@duttonbros.com + message dated "Mon, 26 Apr 2004 10:11:03 -0700" +Date: Wed, 28 Apr 2004 00:27:59 -0400 +Message-ID: <23032.1083126479@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/472 +X-Sequence-Number: 6772 + +brad-pgperf@duttonbros.com writes: +> ... Wouldn't the most efficient plan be to scan the index regardless +> of crm_id because the only columns needed are in the index? + +No. People coming from other databases often have the misconception +that queries can be answered by looking only at an index. That is never +true in Postgres because row validity info is only stored in the table; +so we must always visit the table entry to make sure the row is still +valid/visible for the current query. + +Accordingly, columns added to the index that aren't constrained by the +WHERE clause are not very useful ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Apr 28 03:35:30 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 51047D1B455 + for ; + Wed, 28 Apr 2004 03:35:29 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 03735-04 + for ; + Wed, 28 Apr 2004 03:35:26 -0300 (ADT) +Received: from gpdnet.co.uk (gpdnet.plus.com [212.56.100.243]) + by svr1.postgresql.org (Postfix) with ESMTP id 6B51AD1B454 + for ; + Wed, 28 Apr 2004 03:35:24 -0300 (ADT) +Received: from gary (unverified [192.168.1.2]) + by gpdnet.co.uk (SurgeMail 1.8g3) with ESMTP id 72 + for ; Wed, 28 Apr 2004 07:34:44 +0100 +From: "Gary Doades" +To: pgsql-performance@postgresql.org +Date: Wed, 28 Apr 2004 07:35:41 +0100 +MIME-Version: 1.0 +Subject: Re: planner/optimizer question +Message-ID: <408F5ECD.29849.CA91084@localhost> +In-reply-to: <23032.1083126479@sss.pgh.pa.us> +References: <20040426171103.45600.qmail@uno.mnl.com> +X-mailer: Pegasus Mail for Windows (v4.12a) +Content-type: text/plain; charset=US-ASCII +Content-transfer-encoding: 7BIT +Content-description: Mail message body +X-Server: High Performance Mail Server - http://surgemail.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/473 +X-Sequence-Number: 6773 + +I know you will shoot me down, but... + +Why is there an entry in the index for a row if the row is not valid? +Wouldn't it be better for the index entry validity to track the row validity. +If a particular data value for a query (join, where etc.) can be satisfied +by the index entry itself this would be a big performance gain. + +Cheers, +Gary. + +On 28 Apr 2004 at 0:27, Tom Lane wrote: + +> brad-pgperf@duttonbros.com writes: +> > ... Wouldn't the most efficient plan be to scan the index regardless +> > of crm_id because the only columns needed are in the index? +> +> No. People coming from other databases often have the misconception +> that queries can be answered by looking only at an index. That is never +> true in Postgres because row validity info is only stored in the table; +> so we must always visit the table entry to make sure the row is still +> valid/visible for the current query. +> +> Accordingly, columns added to the index that aren't constrained by the +> WHERE clause are not very useful ... +> +> regards, tom lane +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 8: explain analyze is your friend + + + +From pgsql-performance-owner@postgresql.org Wed Apr 28 03:58:33 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 37846D1B454 + for ; + Wed, 28 Apr 2004 03:58:32 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 13158-01 + for ; + Wed, 28 Apr 2004 03:58:30 -0300 (ADT) +Received: from houston.familyhealth.com.au (fhnet.arach.net.au + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id B051FD1B453 + for ; + Wed, 28 Apr 2004 03:58:27 -0300 (ADT) +Received: from familyhealth.com.au (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id + i3S6wLWL037650; Wed, 28 Apr 2004 14:58:22 +0800 (WST) + (envelope-from chriskl@familyhealth.com.au) +Message-ID: <408F576E.1080504@familyhealth.com.au> +Date: Wed, 28 Apr 2004 15:04:14 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Gary Doades +Cc: pgsql-performance@postgresql.org +Subject: Re: planner/optimizer question +References: <20040426171103.45600.qmail@uno.mnl.com> + <408F5ECD.29849.CA91084@localhost> +In-Reply-To: <408F5ECD.29849.CA91084@localhost> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/474 +X-Sequence-Number: 6774 + +> Why is there an entry in the index for a row if the row is not valid? +> Wouldn't it be better for the index entry validity to track the row validity. +> If a particular data value for a query (join, where etc.) can be satisfied +> by the index entry itself this would be a big performance gain. + +For SELECTs, yes - but for INSERT, UPDATE and DELETE it would be a big +performance loss. + +Chris + + +From pgsql-performance-owner@postgresql.org Wed Apr 28 04:07:45 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A2D41D1B8E4 + for ; + Wed, 28 Apr 2004 04:07:43 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 07145-10 + for ; + Wed, 28 Apr 2004 04:07:44 -0300 (ADT) +Received: from gpdnet.co.uk (gpdnet.plus.com [212.56.100.243]) + by svr1.postgresql.org (Postfix) with ESMTP id B4D51D1B8D1 + for ; + Wed, 28 Apr 2004 04:07:41 -0300 (ADT) +Received: from gary (unverified [192.168.1.2]) + by gpdnet.co.uk (SurgeMail 1.8g3) with ESMTP id 80 + for ; Wed, 28 Apr 2004 08:07:05 +0100 +From: "Gary Doades" +To: pgsql-performance@postgresql.org +Date: Wed, 28 Apr 2004 08:08:03 +0100 +MIME-Version: 1.0 +Subject: Re: planner/optimizer question +Message-ID: <408F6663.22977.CC6AF7D@localhost> +In-reply-to: <408F576E.1080504@familyhealth.com.au> +References: <408F5ECD.29849.CA91084@localhost> +X-mailer: Pegasus Mail for Windows (v4.12a) +Content-type: text/plain; charset=US-ASCII +Content-transfer-encoding: 7BIT +Content-description: Mail message body +X-Server: High Performance Mail Server - http://surgemail.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/475 +X-Sequence-Number: 6775 + +I can understand the performance loss on non-selects for keeping the +index validity state tracking the row validity, but would that outweigh the +performance gains on selects? Depends on your mix of selects to non +selects I guess, but other database systems seem to imply that keeping +the index on track is worth it overall. + +Cheers, +Gary. + +On 28 Apr 2004 at 15:04, Christopher Kings-Lynne wrote: + +> > Why is there an entry in the index for a row if the row is not valid? +> > Wouldn't it be better for the index entry validity to track the row validity. +> > If a particular data value for a query (join, where etc.) can be satisfied +> > by the index entry itself this would be a big performance gain. +> +> For SELECTs, yes - but for INSERT, UPDATE and DELETE it would be a big +> performance loss. +> +> Chris +> + + + +From pgsql-performance-owner@postgresql.org Wed Apr 28 04:18:32 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id BBB88D1B454 + for ; + Wed, 28 Apr 2004 04:17:59 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 20161-07 + for ; + Wed, 28 Apr 2004 04:17:59 -0300 (ADT) +Received: from houston.familyhealth.com.au (fhnet.arach.net.au + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id C8722D1B4E0 + for ; + Wed, 28 Apr 2004 04:17:56 -0300 (ADT) +Received: from familyhealth.com.au (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id + i3S7HrWL039443; Wed, 28 Apr 2004 15:17:53 +0800 (WST) + (envelope-from chriskl@familyhealth.com.au) +Message-ID: <408F5C04.7020101@familyhealth.com.au> +Date: Wed, 28 Apr 2004 15:23:48 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Gary Doades +Cc: pgsql-performance@postgresql.org +Subject: Re: planner/optimizer question +References: <408F5ECD.29849.CA91084@localhost> + <408F6663.22977.CC6AF7D@localhost> +In-Reply-To: <408F6663.22977.CC6AF7D@localhost> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/476 +X-Sequence-Number: 6776 + +> I can understand the performance loss on non-selects for keeping the +> index validity state tracking the row validity, but would that outweigh the +> performance gains on selects? Depends on your mix of selects to non +> selects I guess, but other database systems seem to imply that keeping +> the index on track is worth it overall. + +Yes, some sort of flag on index creation would be sweet :) + +Chris + + +From pgsql-performance-owner@postgresql.org Wed Apr 28 04:32:33 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1D7F1D1B445 + for ; + Wed, 28 Apr 2004 04:32:31 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 22187-07 + for ; + Wed, 28 Apr 2004 04:32:29 -0300 (ADT) +Received: from email05.aon.at (WARSL402PIP4.highway.telekom.at [195.3.96.79]) + by svr1.postgresql.org (Postfix) with SMTP id E2126D1B4E0 + for ; + Wed, 28 Apr 2004 04:32:26 -0300 (ADT) +Received: (qmail 556408 invoked from network); 28 Apr 2004 07:32:27 -0000 +Received: from m150p026.dipool.highway.telekom.at (HELO PASCAL) + ([62.46.8.186]) (envelope-sender ) + by qmail5rs.highway.telekom.at (qmail-ldap-1.03) with SMTP + for ; 28 Apr 2004 07:32:27 -0000 +From: Manfred Koizar +To: "Gary Doades" +Cc: pgsql-performance@postgresql.org +Subject: Re: planner/optimizer question +Date: Wed, 28 Apr 2004 09:34:59 +0200 +Message-ID: +References: <20040426171103.45600.qmail@uno.mnl.com> + <23032.1083126479@sss.pgh.pa.us> <408F5ECD.29849.CA91084@localhost> +In-Reply-To: <408F5ECD.29849.CA91084@localhost> +X-Mailer: Forte Agent 1.93/32.576 English (American) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200404/477 +X-Sequence-Number: 6777 + +On Wed, 28 Apr 2004 07:35:41 +0100, "Gary Doades" +wrote: +>Why is there an entry in the index for a row if the row is not valid? + +Because whether a row is seen as valid or not lies in the eye of the +transaction looking at it. Full visibility information is stored in the +heap tuple header. The developers' consensus is that this overhead +should not be in every index tuple. + +Servus + Manfred + +From pgsql-admin-owner@postgresql.org Wed Apr 28 05:13:59 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id ABBFCD1B8D1; Wed, 28 Apr 2004 05:13:51 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 40407-07; Wed, 28 Apr 2004 05:13:49 -0300 (ADT) +Received: from FE-mail04.sfg.albacom.net (FE-mail04.albacom.net + [213.217.149.84]) by svr1.postgresql.org (Postfix) with ESMTP + id CC622D1B8EF; Wed, 28 Apr 2004 05:13:47 -0300 (ADT) +Received: from axa.it (217.221.80.72) by FE-mail04.sfg.albacom.net (7.0.009) + id 408E270C0002A496; Wed, 28 Apr 2004 10:13:12 +0200 +Message-ID: <408F679A.9030608@axa.it> +Date: Wed, 28 Apr 2004 10:13:14 +0200 +From: Edoardo Ceccarelli +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: it, en, en-us +MIME-Version: 1.0 +To: Christopher Kings-Lynne +Cc: pg@fastcrypt.com, "pgsql-jdbc@postgresql.org" , + pgsql-performance@postgresql.org, pgsql-admin@postgresql.org +Subject: Re: [JDBC] [PERFORM] is a good practice to create an index on the +References: <408D3AE8.5020006@axa.it> <408DC9E1.8020704@familyhealth.com.au> + <1083067187.14759.178.camel@localhost.localdomain> + <408E75C2.5060703@familyhealth.com.au> + <1083079114.14759.204.camel@localhost.localdomain> + <408ED3E2.802@axa.it> <408F0944.5060608@familyhealth.com.au> +In-Reply-To: <408F0944.5060608@familyhealth.com.au> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=3.0 tagged_above=0.0 required=5.0 + tests=SUSPICIOUS_RECIPS +X-Spam-Level: *** +X-Archive-Number: 200404/330 +X-Sequence-Number: 13303 + +do you mean that, declaring an index serial, I'd never have to deal with +incrementing its primary key? good to know! +anyway in this particular situation I don't need such accurate +behaviour: this table is filled up with a lot of data twice per week and +it's used only to answer queries. +I could drop it whenever I want :) + +Thanks again, +eddy + +Christopher Kings-Lynne ha scritto: + +>> I am going to use them as primary key of the table, so I'll surely +>> need them unique :) +> +> +> Eduoardo, I REALLY suggest you don't use them at all. You should make +> a primary key like this: +> +> CREATE TABLE blah ( +> id SERIAL PRIMARY KEY, +> ... +> ); +> +> Also note that by default, OIDs are NOT dumped by pg_dump. You will +> need to add extra switches to your pg_dump backup to ensure that they +> are. +> +> Chris +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 4: Don't 'kill -9' the postmaster +> +> +> + +From pgsql-performance-owner@postgresql.org Wed Apr 28 05:12:38 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9670BD1B432 + for ; + Wed, 28 Apr 2004 05:12:37 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 37012-07 + for ; + Wed, 28 Apr 2004 05:12:36 -0300 (ADT) +Received: from 192.168.0.11 (fw.i-trade.hu [212.92.1.62]) + by svr1.postgresql.org (Postfix) with SMTP id 96F6DD1B8E4 + for ; + Wed, 28 Apr 2004 05:12:33 -0300 (ADT) +Received: (qmail 27852 invoked from network); 28 Apr 2004 07:52:31 -0000 +Received: from unknown (HELO freemail.hu) (212.92.7.130) + by 0 with SMTP; 28 Apr 2004 07:52:31 -0000 +Message-ID: <408F6817.1060708@freemail.hu> +Date: Wed, 28 Apr 2004 10:15:19 +0200 +From: =?ISO-8859-2?Q?Suller_Andr=E1s?= +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: hu, en-us +MIME-Version: 1.0 +To: Silke Trissl +Cc: pgsql-performance@postgresql.org +Subject: Re: Join problem +References: <408E9934.8060509@informatik.hu-berlin.de> +In-Reply-To: <408E9934.8060509@informatik.hu-berlin.de> +Content-Type: text/plain; charset=ISO-8859-2; format=flowed +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/478 +X-Sequence-Number: 6778 + +these two queries are not equal. Query1 returns 6 rows, query2 returns 0 +rows, because '~*' and '=' operators are not same. BTW when you use '=', +it could use index on "item.description". +On query1, "Seq Scan on item" estimates 1 row, on query2 it estimates +733 rows. IMHO that's why query1 uses nested loop, query2 uses hash join. + +bye, +Suller Andras + +Silke Trissl �rta: + +> Hi, +> +> Query 1: +> QUERY PLAN +> ------------------------------------------------------------------------------------------------------------------ +> +> Nested Loop (cost=0.00..28836.75 rows=1 width=4) (actual +> time=65350.780..452130.702 rows=6 loops=1) +> Join Filter: ("inner".order_id = "outer".order_id) +> -> Seq Scan on item (cost=0.00..28814.24 rows=1 width=8) (actual +> time=33.180..1365.190 rows=716 loops=1) +> Filter: (description ~* 'CD'::text) +> -> Seq Scan on orders (cost=0.00..22.50 rows=1 width=4) (actual +> time=21.644..629.500 rows=18 loops=716) +> Filter: ((order_name)::text ~* 'Smith'::text) +> Total runtime: 452130.782 ms +> ########################################################################### +> +> +> Query 2: +> QUERY PLAN +> ------------------------------------------------------------------------------------------------------------------ +> +> Hash Join (cost=22.50..28840.44 rows=4 width=4) (actual +> time=1187.798..1187.798 rows=0 loops=1) +> Hash Cond: ("outer".order_id = "inner".order_id) +> -> Seq Scan on item (cost=0.00..28814.24 rows=733 width=8) +> (actual time=542.737..542.737 rows=0 loops=1) +> Filter: (description = 'CD'::text) +> -> Hash (cost=22.50..22.50 rows=1 width=4) (actual +> time=645.042..645.042 rows=0 loops=1) +> -> Seq Scan on orders (cost=0.00..22.50 rows=1 width=4) +> (actual time=22.373..644.996 rows=18 loops=1) +> Filter: ((order_name)::text ~* 'Smith'::text) +> Total runtime: 1187.865 ms +> ############################################################################ +> +> +> +> Query 1 with 'set enable_nestloop to false' +> +> QUERY PLAN +> ----------------------------------------------------------------------------------------------------------------------- +> +> Hash Join (cost=22.50..28836.75 rows=1 width=4) (actual +> time=1068.593..2003.330 rows=6 loops=1) +> Hash Cond: ("outer".item_id = "inner".item_id) +> -> Seq Scan on item (cost=0.00..28814.24 rows=1 width=8) (actual +> time=33.347..1357.073 rows=716 loops=1) +> Filter: (description ~* 'CD'::text) +> -> Hash (cost=22.50..22.50 rows=1 width=4) (actual +> time=645.287..645.287 rows=0 loops=1) +> -> Seq Scan on orders (cost=0.00..22.50 rows=1 width=4) +> (actual time=22.212..645.239 rows=18 loops=1) +> Filter: ((order_name)::text ~* 'CD'::text) +> Total runtime: 2003.409 ms + + + + +From pgsql-performance-owner@postgresql.org Wed Apr 28 05:24:04 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6832FD1B560 + for ; + Wed, 28 Apr 2004 05:22:11 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 36576-08 + for ; + Wed, 28 Apr 2004 05:22:11 -0300 (ADT) +Received: from email07.aon.at (WARSL402PIP8.highway.telekom.at [195.3.96.97]) + by svr1.postgresql.org (Postfix) with SMTP id A7EC9D1B4E0 + for ; + Wed, 28 Apr 2004 05:22:08 -0300 (ADT) +Received: (qmail 633540 invoked from network); 28 Apr 2004 08:22:09 -0000 +Received: from m150p026.dipool.highway.telekom.at (HELO PASCAL) + ([62.46.8.186]) (envelope-sender ) + by 172.18.5.236 (qmail-ldap-1.03) with SMTP + for ; 28 Apr 2004 08:22:09 -0000 +From: Manfred Koizar +To: Rod Taylor +Cc: Vitaly Belman , + Postgresql Performance +Subject: Re: Simply join in PostrgeSQL takes too long +Date: Wed, 28 Apr 2004 10:24:41 +0200 +Message-ID: +References: <282909734.20040428002740@012.net.il> + <1083103293.30065.100.camel@jester> +In-Reply-To: <1083103293.30065.100.camel@jester> +X-Mailer: Forte Agent 1.93/32.576 English (American) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200404/480 +X-Sequence-Number: 6780 + +On Tue, 27 Apr 2004 18:01:34 -0400, Rod Taylor wrote: +>On Tue, 2004-04-27 at 17:27, Vitaly Belman wrote: +>> Hello pgsql-performance, +>> +>> I discussed the whole subject for some time in DevShed and didn't +>> achieve much (as for results). I wonder if any of you guys can help +>> out: +>> +>> http://forums.devshed.com/t136202/s.html + +>The point is that a book cannot be of a certain genre more than once. + +Rod, he has a hierarchy of genres. Genre 1 has 6379 child genres and a +book can be in more than one of these. + +Vitaly, though LIMIT makes this look like a small query, DISTINCT +requires the whole result set to be retrieved. 0.7 seconds doesn't look +so bad for several thousand rows. Did you try with other genre_ids? + +Maybe a merge join is not the best choice. Set enable_mergejoin to +false and see whether you get a (hopefully faster) hash join, assuming +that sort_mem is large enough to keep the hash table in memory. + +If you send me your table contents I'll try it on Linux. + +Servus + Manfred + +From pgsql-admin-owner@postgresql.org Wed Apr 28 05:27:27 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id B3898D1B445; Wed, 28 Apr 2004 05:19:44 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 43428-01; Wed, 28 Apr 2004 05:19:43 -0300 (ADT) +Received: from houston.familyhealth.com.au (fhnet.arach.net.au + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP + id 59FEBD1B478; Wed, 28 Apr 2004 05:19:40 -0300 (ADT) +Received: from familyhealth.com.au (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id + i3S8JTWL045110; Wed, 28 Apr 2004 16:19:29 +0800 (WST) + (envelope-from chriskl@familyhealth.com.au) +Message-ID: <408F6A76.9070908@familyhealth.com.au> +Date: Wed, 28 Apr 2004 16:25:26 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Edoardo Ceccarelli +Cc: pg@fastcrypt.com, "pgsql-jdbc@postgresql.org" , + pgsql-performance@postgresql.org, pgsql-admin@postgresql.org +Subject: Re: [JDBC] [PERFORM] is a good practice to create an index on the +References: <408D3AE8.5020006@axa.it> <408DC9E1.8020704@familyhealth.com.au> + <1083067187.14759.178.camel@localhost.localdomain> + <408E75C2.5060703@familyhealth.com.au> + <1083079114.14759.204.camel@localhost.localdomain> + <408ED3E2.802@axa.it> <408F0944.5060608@familyhealth.com.au> + <408F679A.9030608@axa.it> +In-Reply-To: <408F679A.9030608@axa.it> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=3.0 tagged_above=0.0 required=5.0 + tests=SUSPICIOUS_RECIPS +X-Spam-Level: *** +X-Archive-Number: 200404/331 +X-Sequence-Number: 13304 + +> do you mean that, declaring an index serial, I'd never have to deal with +> incrementing its primary key? good to know! + +Yep. You can use 'DEFAULT' as the value, eg: + +INSERT INTO blah (DEFAULT, ...); + +> anyway in this particular situation I don't need such accurate +> behaviour: this table is filled up with a lot of data twice per week and +> it's used only to answer queries. +> I could drop it whenever I want :) + +Sure. + +Chris + + +From pgsql-admin-owner@postgresql.org Wed Apr 28 05:38:59 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B55F5D1B8BD + for ; + Wed, 28 Apr 2004 05:28:08 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 43467-06 + for ; + Wed, 28 Apr 2004 05:28:08 -0300 (ADT) +Received: from wolff.to (wolff.to [66.93.249.74]) + by svr1.postgresql.org (Postfix) with SMTP id 79120D1B8B1 + for ; Wed, 28 Apr 2004 05:28:06 -0300 (ADT) +Received: (qmail 8577 invoked by uid 500); 28 Apr 2004 08:32:23 -0000 +Date: Wed, 28 Apr 2004 03:32:23 -0500 +From: Bruno Wolff III +To: Edoardo Ceccarelli +Cc: Christopher Kings-Lynne , pg@fastcrypt.com, + "pgsql-jdbc@postgresql.org" , + pgsql-performance@postgresql.org, pgsql-admin@postgresql.org +Subject: Re: [JDBC] [PERFORM] is a good practice to create an index on the +Message-ID: <20040428083223.GA8384@wolff.to> +Mail-Followup-To: Edoardo Ceccarelli , + Christopher Kings-Lynne , + pg@fastcrypt.com, + "pgsql-jdbc@postgresql.org" , + pgsql-performance@postgresql.org, pgsql-admin@postgresql.org +References: <408D3AE8.5020006@axa.it> <408DC9E1.8020704@familyhealth.com.au> + <1083067187.14759.178.camel@localhost.localdomain> + <408E75C2.5060703@familyhealth.com.au> + <1083079114.14759.204.camel@localhost.localdomain> + <408ED3E2.802@axa.it> <408F0944.5060608@familyhealth.com.au> + <408F679A.9030608@axa.it> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <408F679A.9030608@axa.it> +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/332 +X-Sequence-Number: 13305 + +On Wed, Apr 28, 2004 at 10:13:14 +0200, + Edoardo Ceccarelli wrote: +> do you mean that, declaring an index serial, I'd never have to deal with +> incrementing its primary key? good to know! + +That isn't what is happening. Serial is a special type. It is int plus +a default rule linked to a sequence. No index is created by default +for the serial type. Declaring a column as a primary key will however +create a unique index on that column. + +Also note that you should only assume that the serial values are unique. +(This assumes that you don't use setval and that you don't roll a sequence +over.) Within a single session you can assume the sequence values will +be monotonicly increasing. The values that end up in your table can have +gaps. Typically this happens when a transaction rolls back after obtaining +a new value from a sequence. It can also happen if you grab sequence +values in larger blocks (which might be more efficient if a session normally +acquires mulitple values from a particular sequence) than the default 1. + +> anyway in this particular situation I don't need such accurate +> behaviour: this table is filled up with a lot of data twice per week and +> it's used only to answer queries. +> I could drop it whenever I want :) + +You really don't want to use oids. + +From pgsql-performance-owner@postgresql.org Wed Apr 28 09:24:01 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id F0034D1B8A5 + for ; + Wed, 28 Apr 2004 09:23:54 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 29669-02 + for ; + Wed, 28 Apr 2004 09:23:56 -0300 (ADT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 22076D1B58D + for ; + Wed, 28 Apr 2004 09:23:52 -0300 (ADT) +Received: from [134.22.68.249] (dyn-68-249.tor.dsl.tht.net [134.22.68.249]) + by tht.net (Postfix) with ESMTP + id B276B76A96; Wed, 28 Apr 2004 08:23:55 -0400 (EDT) +Subject: Re: Simply join in PostrgeSQL takes too long +From: Rod Taylor +To: Manfred Koizar +Cc: Vitaly Belman , + Postgresql Performance +In-Reply-To: +References: <282909734.20040428002740@012.net.il> + <1083103293.30065.100.camel@jester> + +Content-Type: text/plain +Message-Id: <1083155014.30065.189.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Wed, 28 Apr 2004 08:23:35 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/483 +X-Sequence-Number: 6783 + +> Rod, he has a hierarchy of genres. Genre 1 has 6379 child genres and a +> book can be in more than one of these. + + bookgenres.genre_id = genre_children.genre_child_id AND + genre_children.genre_id = 1 + +I see, sorry. I didn't notice the genre_child_id in the where clause. +First glance had them all as genre_id. + +When I run into this I usually create a 3rd table managed by triggers +that would relate the book to all genre entries. Insert takes a little +longer, but the selects can still be very quick. + +The below plpgsql forces the kind of algorithm we wish the planner could +choose. It should be fairly quick irregardless of dataset. + + +CREATE OR REPLACE FUNCTION book_results(numeric) RETURNS SETOF numeric +AS +' +DECLARE + v_genre ALIAS FOR $1; + v_limit integer = 10; + t_rows RECORD; + v_transmitted integer = 0; + + v_transmitted_values numeric[] = ARRAY[1]; + +BEGIN + FOR t_rows IN SELECT book_id + FROM bv_bookgenres AS b + JOIN bv_genre_children AS g ON (b.genre_id = +g.genre_child_id) + WHERE g.genre_id = v_genre + LOOP + + -- If this is a new value, transmit it to the end user + IF NOT t_rows.book_id = ANY(v_transmitted_values) THEN + v_transmitted_values := array_append(v_transmitted_values, +t_rows.book_id); + v_transmitted := v_transmitted + 1; + RETURN NEXT t_rows.book_id; + END IF; + + EXIT WHEN v_transmitted >= v_limit; + END LOOP; + + RETURN; +END; +' LANGUAGE plpgsql; + +EXPLAIN ANALYZE SELECT * FROM book_results(1); +SELECT * FROM book_results(1); + + +From pgsql-performance-owner@postgresql.org Wed Apr 28 09:52:24 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id BB399D1B519 + for ; + Wed, 28 Apr 2004 09:52:21 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 39914-05 + for ; + Wed, 28 Apr 2004 09:52:23 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 8D9D5D1B503 + for ; + Wed, 28 Apr 2004 09:52:19 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3SCqLDj027628; + Wed, 28 Apr 2004 08:52:21 -0400 (EDT) +To: Silke Trissl +Cc: pgsql-performance@postgresql.org +Subject: Re: Join problem +In-reply-to: <408E9934.8060509@informatik.hu-berlin.de> +References: <408E9934.8060509@informatik.hu-berlin.de> +Comments: In-reply-to Silke Trissl + message dated "Tue, 27 Apr 2004 19:32:36 +0200" +Date: Wed, 28 Apr 2004 08:52:20 -0400 +Message-ID: <27627.1083156740@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/484 +X-Sequence-Number: 6784 + +Silke Trissl writes: +> I found out, that the change of the operator from '~*' to '=' for the +> item.description brought a great boost in performance (425 secs to 1 +> sec!), but not in cost (Query plans at the end). + +The main problem seems to be bad estimation of the number of rows +extracted from the item table. Have you ANALYZEd that table lately? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Apr 28 10:05:18 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 21FF7D1B8AA + for ; + Wed, 28 Apr 2004 10:05:06 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 42082-07 + for ; + Wed, 28 Apr 2004 10:05:08 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 1EA39D1B893 + for ; + Wed, 28 Apr 2004 10:05:04 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3SD54l0027807; + Wed, 28 Apr 2004 09:05:04 -0400 (EDT) +To: Manfred Koizar +Cc: "Gary Doades" , + pgsql-performance@postgresql.org +Subject: Re: planner/optimizer question +In-reply-to: +References: <20040426171103.45600.qmail@uno.mnl.com> + <23032.1083126479@sss.pgh.pa.us> <408F5ECD.29849.CA91084@localhost> + +Comments: In-reply-to Manfred Koizar + message dated "Wed, 28 Apr 2004 09:34:59 +0200" +Date: Wed, 28 Apr 2004 09:05:04 -0400 +Message-ID: <27806.1083157504@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/485 +X-Sequence-Number: 6785 + +Manfred Koizar writes: +> On Wed, 28 Apr 2004 07:35:41 +0100, "Gary Doades" +> wrote: +>> Why is there an entry in the index for a row if the row is not valid? + +> Because whether a row is seen as valid or not lies in the eye of the +> transaction looking at it. Full visibility information is stored in the +> heap tuple header. The developers' consensus is that this overhead +> should not be in every index tuple. + +Storing that information would at least double the overhead space used +for each index tuple. The resulting index bloat would significantly +slow index operations by requiring more I/O. So it's far from clear +that this would be a win, even for those who care only about select +speed. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed May 5 13:52:35 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6FB57D1B50F + for ; + Wed, 28 Apr 2004 10:29:20 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 51147-10 + for ; + Wed, 28 Apr 2004 10:29:21 -0300 (ADT) +Received: from mail.socialserve.com (office.socialserve.com [208.60.89.34]) + by svr1.postgresql.org (Postfix) with ESMTP id 07786D1B892 + for ; + Wed, 28 Apr 2004 10:29:18 -0300 (ADT) +Received: from localhost (localhost [127.0.0.1]) + by mail.socialserve.com (Postfix) with ESMTP + id A629F975F; Wed, 28 Apr 2004 09:29:23 -0400 (EDT) +Received: from mail.socialserve.com ([127.0.0.1]) + by localhost (ms2 [127.0.0.1]) (amavisd-new, port 10024) with ESMTP + id 04220-08; Wed, 28 Apr 2004 09:29:19 -0400 (EDT) +Received: from [10.1.1.94] (dynamic-94.socialserve.com [10.1.1.94]) + (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by mail.socialserve.com (Postfix) with ESMTP + id B8479975E; Wed, 28 Apr 2004 09:29:19 -0400 (EDT) +Mime-Version: 1.0 (Apple Message framework v613) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <0B7369F9-9918-11D8-A107-000A9566A412@socialserve.com> +Content-Transfer-Encoding: 7bit +Cc: pgsql-performance@postgresql.org +From: James Robinson +Subject: History of oids in postgres? +Date: Wed, 28 Apr 2004 09:29:15 -0400 +To: bruno@wolff.to +X-Mailer: Apple Mail (2.613) +X-Virus-Scanned: by amavisd-new at socialserve.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200405/33 +X-Sequence-Number: 6864 + +Bruno et al, + + Any self-repsecting lurker would know that oids as row identifiers are +depreciated in postgres. Can anyone provide a brief history regarding +the reasoning behind using them as row identifiers in the first place? +I see a discussion of their use as various primary keys in he system +catalog in the oid-datatype doc page, but not regarding their history +as 'user-space' row ids. + +Thanks, +James + +---- +James Robinson +Socialserve.com + + +From pgsql-performance-owner@postgresql.org Wed Apr 28 12:41:27 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B6566D1BB45 + for ; + Wed, 28 Apr 2004 12:41:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 10653-07 + for ; + Wed, 28 Apr 2004 12:41:24 -0300 (ADT) +Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) + by svr1.postgresql.org (Postfix) with ESMTP id 80FABD1B91B + for ; + Wed, 28 Apr 2004 12:41:23 -0300 (ADT) +Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) + by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i3SFeBBh025640; + Wed, 28 Apr 2004 09:40:11 -0600 (MDT) +Date: Wed, 28 Apr 2004 09:40:08 -0600 (MDT) +From: "scott.marlowe" +To: Stephan Szabo +Cc: , +Subject: Re: index usage +In-Reply-To: <20040426115215.R11044@megazone.bigpanda.com> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-IHS-MailScanner: Found to be clean +X-IHS-MailScanner-SpamCheck: +X-IHS-MailScanner-Envelope-Sender: scott.marlowe@ihs.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/486 +X-Sequence-Number: 6786 + +On Mon, 26 Apr 2004, Stephan Szabo wrote: + +> +> On Fri, 23 Apr 2004 brad-pgperf@duttonbros.com wrote: +> +> > I have a query which I think should be using an index all of the time but +> > postgres only uses the index part of the time. The index +> > (ticket_crm_map_crm_id_suppid) has the where clause column (crm_id) listed +> > first followed by the selected column (support_person_id). Wouldn't the +> > most efficient plan be to scan the index each time because the only columns +> > needed are in the index? Below is the table, 2 queries showing the +> +> Not necessarily. The rows in the actual file still need to be checked to +> see if they're visible to the select and if it's expected that the entire +> file (or a reasonable % of the pages anyway) will need to be loaded using +> the index isn't necessarily a win. + +While those of us familiar with PostgreSQL are well aware of the fact that +indexes can't be used directly to garner information, but only as a lookup +to a tuple in the table, it seems this misconception is quite common among +those coming to postgreSQL from other databases. + +Is there any information that directly reflects this issue in the docs? +There are tons of hints that it works this way in how they're written, but +nothing that just comes out and says that with pgsql's mvcc +implementation, an index scan still has to hit the pages that contain the +tuples, so often in pgsql a seq scan is a win where in other databases and +index scan would have been a win? + +If not, where would I add it if I were going to write something up for the +docs? Just wondering... + + +From pgsql-performance-owner@postgresql.org Wed Apr 28 13:42:08 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id EE9B7D1B4D7 + for ; + Wed, 28 Apr 2004 13:42:06 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 25269-10 + for ; + Wed, 28 Apr 2004 13:42:05 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id AE70CD1B4A3 + for ; + Wed, 28 Apr 2004 13:42:04 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3SGfeNQ000425; + Wed, 28 Apr 2004 12:41:41 -0400 (EDT) +To: "scott.marlowe" +Cc: Stephan Szabo , + brad-pgperf@duttonbros.com, pgsql-performance@postgresql.org +Subject: Re: index usage +In-reply-to: +References: +Comments: In-reply-to "scott.marlowe" + message dated "Wed, 28 Apr 2004 09:40:08 -0600" +Date: Wed, 28 Apr 2004 12:41:40 -0400 +Message-ID: <424.1083170500@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/487 +X-Sequence-Number: 6787 + +"scott.marlowe" writes: +> There are tons of hints that it works this way in how they're written, but +> nothing that just comes out and says that with pgsql's mvcc +> implementation, an index scan still has to hit the pages that contain the +> tuples, so often in pgsql a seq scan is a win where in other databases and +> index scan would have been a win? + +> If not, where would I add it if I were going to write something up for the +> docs? Just wondering... + +AFAIR the only place in the docs that mentions seqscan or indexscan at +all is the discussion of EXPLAIN in "Performance Tips". Perhaps a +suitably-enlarged version of that section could cover this. + + regards, tom lane + +From pgsql-admin-owner@postgresql.org Wed Apr 28 15:12:26 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 4041ED1B8EE; Wed, 28 Apr 2004 15:12:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 65938-10; Wed, 28 Apr 2004 15:12:24 -0300 (ADT) +Received: from mail01.stbernard.com (mail01.stbernard.com [199.245.188.4]) + by svr1.postgresql.org (Postfix) with ESMTP + id 70446D1B8E3; Wed, 28 Apr 2004 15:12:22 -0300 (ADT) +X-MimeOLE: Produced By Microsoft Exchange V6.0.6375.0 +Content-Class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Subject: 7.4.2 out of memory +Date: Wed, 28 Apr 2004 11:12:17 -0700 +Message-ID: +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [ADMIN] [JDBC] [PERFORM] is a good practice to create an index + on the +Thread-Index: AcQs/Igo8CGZODf/T/GyXkvW/iN6swATt3PQ +From: "Jie Liang" +To: +Cc: , +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/335 +X-Sequence-Number: 13308 + +All, +After I upgraded postgres from 7.3.4 to 7.4.2, one of my program got follow= +ing error: +DRROR: out of memory +DETAIL: Fail on request of size 92. + +any idea?? +does memory management have big difference between 7.3.4 and 7.4.2??? +this program using a chunk of share memory and a lot of temp tables. + + +Thanks. + + + +Jie Liang + +From pgsql-performance-owner@postgresql.org Wed Apr 28 16:57:44 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 42940D1B8E1 + for ; + Wed, 28 Apr 2004 16:57:42 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 44732-07 + for ; + Wed, 28 Apr 2004 16:57:40 -0300 (ADT) +Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) + by svr1.postgresql.org (Postfix) with ESMTP id F2034D1B8D2 + for ; + Wed, 28 Apr 2004 16:57:37 -0300 (ADT) +Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) + by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i3SJvOBh024619; + Wed, 28 Apr 2004 13:57:25 -0600 (MDT) +Date: Wed, 28 Apr 2004 13:57:21 -0600 (MDT) +From: "scott.marlowe" +To: Jie Liang +Cc: +Subject: Re: [ADMIN] 7.4.2 out of memory +In-Reply-To: +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-IHS-MailScanner: Found to be clean +X-IHS-MailScanner-SpamCheck: +X-IHS-MailScanner-Envelope-Sender: scott.marlowe@ihs.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/488 +X-Sequence-Number: 6788 + +On Wed, 28 Apr 2004, Jie Liang wrote: + +> All, +> After I upgraded postgres from 7.3.4 to 7.4.2, one of my program got following error: +> DRROR: out of memory +> DETAIL: Fail on request of size 92. +> +> any idea?? +> does memory management have big difference between 7.3.4 and 7.4.2??? +> this program using a chunk of share memory and a lot of temp tables. + +More than likely this is a hash aggregate problem (or can they spill to +disk in 7.4.2 yet? I don't think they can, but maybe we should ask Tom. + +Try setting this before running the query and see what happens: + +set enable_hashagg = false; + + + + +From pgsql-performance-owner@postgresql.org Wed May 5 13:54:21 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2C1BED1DF65 + for ; + Wed, 28 Apr 2004 17:41:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 61532-08 + for ; + Wed, 28 Apr 2004 17:41:24 -0300 (ADT) +Received: from mail01.stbernard.com (mail01.stbernard.com [199.245.188.4]) + by svr1.postgresql.org (Postfix) with ESMTP id 028B5D1BC54 + for ; + Wed, 28 Apr 2004 17:41:22 -0300 (ADT) +X-MimeOLE: Produced By Microsoft Exchange V6.0.6375.0 +Content-Class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Subject: Re: [ADMIN] 7.4.2 out of memory +Date: Wed, 28 Apr 2004 13:41:21 -0700 +Message-ID: +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [ADMIN] 7.4.2 out of memory +Thread-Index: AcQtWxiGD9sHnFvTSvup5/T5vwgEyAABdS4g +From: "Jie Liang" +To: "scott.marlowe" +Cc: +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200405/34 +X-Sequence-Number: 6865 + +Sccot, + +Thank you very much, I think taht you are right about this. +I tested a single query, there is no problem. I'll do a full test with my p= +rogram. + +Jie Liang + +-----Original Message----- +From: scott.marlowe [mailto:scott.marlowe@ihs.com] +Sent: Wednesday, April 28, 2004 12:57 PM +To: Jie Liang +Cc: pgsql-performance@postgresql.org +Subject: Re: [ADMIN] 7.4.2 out of memory + + +On Wed, 28 Apr 2004, Jie Liang wrote: + +> All, +> After I upgraded postgres from 7.3.4 to 7.4.2, one of my program got foll= +owing error: +> DRROR: out of memory +> DETAIL: Fail on request of size 92. +>=20 +> any idea?? +> does memory management have big difference between 7.3.4 and 7.4.2??? +> this program using a chunk of share memory and a lot of temp tables. + +More than likely this is a hash aggregate problem (or can they spill to=20 +disk in 7.4.2 yet? I don't think they can, but maybe we should ask Tom. + +Try setting this before running the query and see what happens: + +set enable_hashagg =3D false; + + + + +From pgsql-performance-owner@postgresql.org Wed May 5 13:59:26 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 27EBCD1B8BD; Wed, 28 Apr 2004 19:02:04 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 91649-09; Wed, 28 Apr 2004 19:02:04 -0300 (ADT) +Received: from mail01.stbernard.com (mail01.stbernard.com [199.245.188.4]) + by svr1.postgresql.org (Postfix) with ESMTP + id 66F42D1B8B5; Wed, 28 Apr 2004 19:02:01 -0300 (ADT) +X-MimeOLE: Produced By Microsoft Exchange V6.0.6375.0 +Content-Class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Subject: LIKE and INDEX +Date: Wed, 28 Apr 2004 15:02:04 -0700 +Message-ID: +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [ADMIN] 7.4.2 out of memory +Thread-Index: AcQtWxiGD9sHnFvTSvup5/T5vwgEyAAD7HNA +From: "Jie Liang" +To: +Cc: +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200405/37 +X-Sequence-Number: 6868 + +All, +This is old topic, when I use: +select url from urlinfo where url like 'http://www.lycos.de%'; +it uses the index, good! + +but if I use: +select url from urlinfo where url like 'http://%.lycos.de'; +it won't use index at all, NOT good! +is there any way I can force secon query use index??? + +Thanks. + +Jie Liang + + QUERY PLAN=20=20=20=20=20=20=20= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= +=20=20=20=20=20=20=20=20=20=20=20 +---------------------------------------------------------------------------= +--------------------- + Index Scan using urlinfo_ukey on urlinfo (cost=3D0.00..6.01 rows=3D1 widt= +h=3D33) + Index Cond: ((url >=3D 'http://www.lycos.de/'::text) AND (url < 'http://= +www.lycos.de0'::text)) + Filter: (url ~ '^http://www\\.lycos\\.de/.*$'::text) +(3 rows) + + QUERY PLAN=20=20=20=20=20=20=20=20=20=20=20=20=20= +=20=20=20=20=20=20=20=20=20=20=20=20=20 +------------------------------------------------------------- + Seq Scan on urlinfo (cost=3D0.00..100440.48 rows=3D4 width=3D33) + Filter: (url ~ '^http://.*\\.lycos\\.de$'::text) +(2 rows) + +From pgsql-performance-owner@postgresql.org Wed Apr 28 23:41:52 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 76E21D1DF5C + for ; + Wed, 28 Apr 2004 23:41:48 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 36471-09 + for ; + Wed, 28 Apr 2004 23:41:27 -0300 (ADT) +Received: from srvr3.iniquinet.com (srvr2.iniquinet.com [64.240.87.12]) + by svr1.postgresql.org (Postfix) with SMTP id 4FC30D1EF8B + for ; + Wed, 28 Apr 2004 21:59:28 -0300 (ADT) +Received: (qmail 28632 invoked by uid 104); 29 Apr 2004 00:59:31 -0000 +Received: from Robert_Creager@LogicalChaos.org by srvr3.iniquinet.com by uid + 101 with qmail-scanner-1.15 + (clamscan: 0.65. spamassassin: 2.55. Clear:SA:0(-6.5/6.0):. + Processed in 32.720762 secs); 29 Apr 2004 00:59:31 -0000 +Received: from unknown (HELO thunder.mshome.net) (216.58.165.126) + by srvr3.iniquinet.com with SMTP; 29 Apr 2004 00:58:58 -0000 +Received: from localhost.localdomain (thunder.mshome.net [192.168.0.250]) + by thunder.mshome.net (Postfix) with ESMTP id EBB3CE805E; + Wed, 28 Apr 2004 18:58:57 -0600 (MDT) +Received: from logicalchaos.org (thunder.mshome.net [192.168.0.250]) + by thunder.mshome.net (Postfix) with SMTP id 20001E805E; + Wed, 28 Apr 2004 18:58:55 -0600 (MDT) +Date: Wed, 28 Apr 2004 18:57:53 -0600 +From: Robert Creager +To: Josh Berkus +Cc: pg@fastcrypt.com, =?ISO-8859-1?Q?Dirk=5FLutzeb=E4ck?= , + ohp@pyrenet.fr, Tom Lane , + Joe Conway , "scott.marlowe" , + Bruce Momjian , + pgsql-performance@postgresql.org, Neil Conway +Subject: Re: Wierd context-switching issue on Xeon +Message-Id: <20040428185753.56614b2c@thunder.mshome.net> +In-Reply-To: <200404211029.43675.josh@agliodbs.com> +References: + <408664CF.9040507@aeccom.com> + <1082559931.1557.235.camel@localhost.localdomain> + <200404211029.43675.josh@agliodbs.com> +Organization: Starlight Vision, LLC. +X-Mailer: Sylpheed version 0.9.9claws (GTK+ 1.2.10; i586-mandrake-linux-gnu) +Mime-Version: 1.0 +Content-Type: multipart/signed; protocol="application/pgp-signature"; + micalg="pgp-sha1"; + boundary="Signature=_Wed__28_Apr_2004_18_57_53_-0600_NKZvs8lnAAF58pWn" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, + hits=2.0 tagged_above=0.0 required=5.0 tests=DRASTIC_REDUCED +X-Spam-Level: * +X-Archive-Number: 200404/489 +X-Sequence-Number: 6789 + +--Signature=_Wed__28_Apr_2004_18_57_53_-0600_NKZvs8lnAAF58pWn +Content-Type: text/plain; charset=US-ASCII +Content-Disposition: inline +Content-Transfer-Encoding: 7bit + +When grilled further on (Wed, 21 Apr 2004 10:29:43 -0700), +Josh Berkus confessed: + +> Dave, +> +> > After some testing if you use the current head code for s_lock.c which +> > has some mods in it to alleviate this situation, and change +> > SPINS_PER_DELAY to 10 you can drastically reduce the cs with tom's test. +> > I am seeing a slight degradation in throughput using pgbench -c 10 -t +> > 1000 but it might be liveable, considering the alternative is unbearable +> > in some situations. +> > +> > Can anyone else replicate my results? +> +> Can you produce a patch against 7.4.1? I'd like to test your fix against a +> real-world database. + +I would like to see the same, as I have a system that exhibits the same behavior +on a production db that's running 7.4.1. + +Cheers, +Rob + + +-- + 18:55:22 up 1:40, 4 users, load average: 2.00, 2.04, 2.00 +Linux 2.6.5-01 #7 SMP Fri Apr 16 22:45:31 MDT 2004 + +--Signature=_Wed__28_Apr_2004_18_57_53_-0600_NKZvs8lnAAF58pWn +Content-Type: application/pgp-signature + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.4 (GNU/Linux) + +iEYEARECAAYFAkCQUxEACgkQLQ/DKuwDYzkGIACfVeE6q/BGr/ZwShuQ8pM0ch2F +YlcAoIQSiwr7bp0G1OuazNm2OkqES15D +=XbD0 +-----END PGP SIGNATURE----- + +--Signature=_Wed__28_Apr_2004_18_57_53_-0600_NKZvs8lnAAF58pWn-- + + +From pgsql-performance-owner@postgresql.org Thu Apr 29 10:20:43 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 80E25D1E3E5 + for ; + Thu, 29 Apr 2004 10:20:39 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 71725-01 + for ; + Thu, 29 Apr 2004 10:20:21 -0300 (ADT) +Received: from server.pyrenet.fr (server.pyrenet.fr [194.250.190.1]) + by svr1.postgresql.org (Postfix) with ESMTP id B193CD1E28E + for ; + Thu, 29 Apr 2004 10:20:17 -0300 (ADT) +Received: from localhost (localhost [127.0.0.1]) + by localhost.pyrenet.fr (Postfix) with ESMTP + id 6612D2B8CA; Thu, 29 Apr 2004 15:20:21 +0200 (MET DST) +Received: from server.pyrenet.fr ([127.0.0.1]) + by localhost (server [127.0.0.1]) (amavisd-new, port 10024) with ESMTP + id 11398-01; Thu, 29 Apr 2004 15:20:18 +0200 (MET DST) +Received: from server.pyrenet.fr (server.pyrenet.fr [194.250.190.1]) + by server.pyrenet.fr (Postfix) with ESMTP + id 24CE12B8A2; Thu, 29 Apr 2004 15:20:18 +0200 (MET DST) +Date: Thu, 29 Apr 2004 15:20:18 +0200 (MET DST) +From: ohp@pyrenet.fr +Reply-To: ohp@pyrenet.fr +To: Robert Creager +Cc: Josh Berkus , pg@fastcrypt.com, + =?ISO-8859-1?Q?Dirk=5FLutzeb=E4ck?= , + Tom Lane , Joe Conway , + "scott.marlowe" , + Bruce Momjian , + pgsql-performance@postgresql.org, Neil Conway +Subject: Re: Wierd context-switching issue on Xeon +In-Reply-To: <20040428185753.56614b2c@thunder.mshome.net> +Message-ID: +References: + <408664CF.9040507@aeccom.com> + <1082559931.1557.235.camel@localhost.localdomain> + <200404211029.43675.josh@agliodbs.com> + <20040428185753.56614b2c@thunder.mshome.net> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=iso-8859-1 +Content-Transfer-Encoding: 8BIT +X-Virus-Scanned: by amavisd-new at pyrenet.fr +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=2.3 tagged_above=0.0 required=5.0 + tests=DRASTIC_REDUCED, NO_REAL_NAME +X-Spam-Level: ** +X-Archive-Number: 200404/490 +X-Sequence-Number: 6790 + +Hi + +I'd LOVE to contribute on this but I don't have vmstat and I'm not running +linux. + +How can I help? +Regards +On Wed, 28 Apr 2004, Robert Creager wrote: + +> Date: Wed, 28 Apr 2004 18:57:53 -0600 +> From: Robert Creager +> To: Josh Berkus +> Cc: pg@fastcrypt.com, Dirk_Lutzeb�ck , ohp@pyrenet.fr, +> Tom Lane , Joe Conway , +> scott.marlowe , +> Bruce Momjian , pgsql-performance@postgresql.org, +> Neil Conway +> Subject: Re: [PERFORM] Wierd context-switching issue on Xeon +> +> When grilled further on (Wed, 21 Apr 2004 10:29:43 -0700), +> Josh Berkus confessed: +> +> > Dave, +> > +> > > After some testing if you use the current head code for s_lock.c which +> > > has some mods in it to alleviate this situation, and change +> > > SPINS_PER_DELAY to 10 you can drastically reduce the cs with tom's test. +> > > I am seeing a slight degradation in throughput using pgbench -c 10 -t +> > > 1000 but it might be liveable, considering the alternative is unbearable +> > > in some situations. +> > > +> > > Can anyone else replicate my results? +> > +> > Can you produce a patch against 7.4.1? I'd like to test your fix against a +> > real-world database. +> +> I would like to see the same, as I have a system that exhibits the same behavior +> on a production db that's running 7.4.1. +> +> Cheers, +> Rob +> +> +> + +-- +Olivier PRENANT Tel: +33-5-61-50-97-00 (Work) +6, Chemin d'Harraud Turrou +33-5-61-50-97-01 (Fax) +31190 AUTERIVE +33-6-07-63-80-64 (GSM) +FRANCE Email: ohp@pyrenet.fr +------------------------------------------------------------------------------ +Make your life a dream, make your dream a reality. (St Exupery) + +From pgsql-performance-owner@postgresql.org Thu Apr 29 13:41:30 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id BF58CD1E410 + for ; + Thu, 29 Apr 2004 13:41:27 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 62612-09 + for ; + Thu, 29 Apr 2004 13:41:07 -0300 (ADT) +Received: from lin-mgregory11.caset.buffalo.edu + (lin-mgregory11.caset.buffalo.edu [128.205.152.74]) + by svr1.postgresql.org (Postfix) with ESMTP id 4CDAAD1CAA7 + for ; + Thu, 29 Apr 2004 13:41:06 -0300 (ADT) +Received: by lin-mgregory11.caset.buffalo.edu (Postfix, from userid 129391) + id 4C7F21D499; Thu, 29 Apr 2004 12:41:06 -0400 (EDT) +Date: Thu, 29 Apr 2004 12:41:06 -0400 +From: Roelant Ossewaarde +To: pgsql-performance@postgresql.org +Subject: Use arrays or not? +Message-ID: <20040429164059.GC24558@belboek.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +User-Agent: Mutt/1.4i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/491 +X-Sequence-Number: 6791 + +Hi, + +I am building an application using postgresql to store XML-records. There is a +debate within the group of developers about the best way to store our data. I +hope you can help us make a decision. + +The data consists of XML-records, with a lot of XML-fields. I want to store +the XML as it is, so taking the information from the XML-records and then +storing it in a different-from-XML-format is not an option. + +Each XML-record describes data about one book. If an update of bookdata comes, +the XML itself is not changed, but a new XML-record is stored with the updated +data. Via a complex scheme of combining a base record and its updates, the +final dataset is produced that is used in the application. + +There are different XML-formats that need to be combined. Right now, we can +handle three different XML-formats, each with its own structure (but all +describing book-data). + +Searching is done via a simple table lookup on three different fields: title, +author and subject. The data for these fields is extracted from the +database. Each book has a unique identifier (EAN13, derivative of ISBN). + +Here is one way to organize the database: +table title: +TITLE | EAN13, indexing on TITLE + +table author: +AUTHOR | EAN13, indexing on AUTHOR + +table subject: +SUBJECT | EAN13, indexing on SUBJECT. + +Finally: +table record: +EAN13 | ARRAY OF XML-records. + +It's the last table that I am most curious (and worried) about, the question +being mainly what the optimal way of structuring that table is. Option 1 is +the given option: adding/deleting an XML-record for the same book requires +adding/deleting it to/from the array of XML-records. + +Option 2 would be something like this: +EAN13 | XML-record +where, if a book has several records describing it, there are multiple entries +of the EAN13|XML-record - pair. Adding an XML-record for the same book, +requires adding a new entry to the table as a whole. + +So, option 1-tables look like this: +EAN13 | ARRAY OF XML-records +0001 | {..., ..., ...} +0002 | {..., ..., ...} + +Option-2 tables look like this: +EAN13 | ARRAY OF XML-records +0001 | ... +0001 | ... +0002 | ... +0002 | ... + +We can't decide which one is best. These are some issues we can think of: + +Indexing: For option 1, the EAN13-index remains unique, even if you have +multiple XML-records; for option 2 it does not, since multiple XML-records are +stored as multiple tuples. On the other hand, an additional internal index can +be used to link the several tuples of option 2 to the information in the +`lookup'-tables (author, title, keyword). Does any of these two options +increase query efficiency, ie. speed? + +Database growth: On average, the information about a book is updated three +times per year. In option 1, this means that the length of the table does not +increase, but the width does. If we choose option 2, if we have three updates +per book each year, the length of the table triples, but the width does +not. What is more costly to store for postgres, long arrays or long tables? + +Integrity: Option 1 means that our software needs to keep track of all the +bookkeeping for arrays, since such support is quite rudimentary in +postgres. For example, it is hard to take out a record from the middle of an +array. Also, a multidimensional array, which contains for each record the +record itself and its type, is even harder to maintain. Option 2 has a simpler +datatype, so integrity can be easier inforced using the standard +postgres-machinery of variable-types etc. + +Arrays are non-standard SQL, and I hear that PHP-support for postgres & arrays +is rudimentary. So that might be an argument to avoid using them, and go for +option 2. From the standpoint of performance (or wisdom), can you help me +decide what I should choose? Or is there maybe an even better way to structure +my data? + +Thanks for any contribution! + +Roelant. + +From pgsql-performance-owner@postgresql.org Thu Apr 29 13:54:26 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8BFBED1CA32 + for ; + Thu, 29 Apr 2004 13:54:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 67275-10 + for ; + Thu, 29 Apr 2004 13:54:04 -0300 (ADT) +Received: from email10.aon.at (WARSL402PIP8.highway.telekom.at [195.3.96.97]) + by svr1.postgresql.org (Postfix) with SMTP id C7E44D1E3DD + for ; + Thu, 29 Apr 2004 13:54:02 -0300 (ADT) +Received: (qmail 229764 invoked from network); 29 Apr 2004 16:54:02 -0000 +Received: from m148p023.dipool.highway.telekom.at (HELO PASCAL) + ([62.46.8.119]) (envelope-sender ) + by qmail1rs.highway.telekom.at (qmail-ldap-1.03) with SMTP + for ; 29 Apr 2004 16:54:02 -0000 +From: Manfred Koizar +To: sailesh@cs.berkeley.edu +Cc: Tom Lane , Robert Treat , + pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Subject: Re: [HACKERS] Number of pages in a random sample +Date: Thu, 29 Apr 2004 18:56:36 +0200 +Message-ID: <0nc290hvvr6tcv45enh93afcgbg8vuk6j9@email.aon.at> +References: <1081879359.25537.526.camel@camel> + <25556.1081883922@sss.pgh.pa.us> + + <22642.1082074729@sss.pgh.pa.us> + + <29060.1082126089@sss.pgh.pa.us> + + <25762.1082390410@sss.pgh.pa.us> + + +In-Reply-To: +X-Mailer: Forte Agent 1.93/32.576 English (American) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200404/492 +X-Sequence-Number: 6792 + +On Mon, 26 Apr 2004 08:08:16 -0700, Sailesh Krishnamurthy + wrote: +> "A Bi-Level Bernoulli Scheme for Database Sampling" +> Peter Haas, Christian Koenig (SIGMOD 2004) + +Does this apply to our problem? AFAIK with Bernoulli sampling you don't +know the sample size in advance. + +Anyway, thanks for the hint. Unfortunately I couldn't find the +document. Do you have a link? + +Servus + Manfred + +From pgsql-performance-owner@postgresql.org Thu Apr 29 14:01:00 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 45001D1CA32 + for ; + Thu, 29 Apr 2004 14:00:55 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 76003-06 + for ; + Thu, 29 Apr 2004 14:00:30 -0300 (ADT) +Received: from email07.aon.at (WARSL402PIP8.highway.telekom.at [195.3.96.97]) + by svr1.postgresql.org (Postfix) with SMTP id E924FD1E3DD + for ; + Thu, 29 Apr 2004 14:00:28 -0300 (ADT) +Received: (qmail 250966 invoked from network); 29 Apr 2004 17:00:28 -0000 +Received: from m148p023.dipool.highway.telekom.at (HELO PASCAL) + ([62.46.8.119]) (envelope-sender ) + by 172.18.5.236 (qmail-ldap-1.03) with SMTP + for ; 29 Apr 2004 17:00:28 -0000 +From: Manfred Koizar +To: Tom Lane +Cc: "Gary Doades" , + pgsql-performance@postgresql.org +Subject: Re: planner/optimizer question +Date: Thu, 29 Apr 2004 19:03:03 +0200 +Message-ID: +References: <20040426171103.45600.qmail@uno.mnl.com> + <23032.1083126479@sss.pgh.pa.us> <408F5ECD.29849.CA91084@localhost> + + <27806.1083157504@sss.pgh.pa.us> +In-Reply-To: <27806.1083157504@sss.pgh.pa.us> +X-Mailer: Forte Agent 1.93/32.576 English (American) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200404/493 +X-Sequence-Number: 6793 + +On Wed, 28 Apr 2004 09:05:04 -0400, Tom Lane wrote: +>> [ ... visibility information in index tuples ... ] + +>Storing that information would at least double the overhead space used +>for each index tuple. The resulting index bloat would significantly +>slow index operations by requiring more I/O. So it's far from clear +>that this would be a win, even for those who care only about select +>speed. + +While the storage overhead could be reduced to 1 bit (not a joke) we'd +still have the I/O overhead of locating and updating index tuples for +every heap tuple deleted/updated. + +Servus + Manfred + +From pgsql-performance-owner@postgresql.org Thu Apr 29 14:11:38 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4C4EBD1DF5D + for ; + Thu, 29 Apr 2004 14:11:36 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 81803-04 + for ; + Thu, 29 Apr 2004 14:11:16 -0300 (ADT) +Received: from email06.aon.at (WARSL402PIP3.highway.telekom.at [195.3.96.75]) + by svr1.postgresql.org (Postfix) with SMTP id C584FD1E5E9 + for ; + Thu, 29 Apr 2004 14:11:14 -0300 (ADT) +Received: (qmail 525140 invoked from network); 29 Apr 2004 17:11:14 -0000 +Received: from m148p023.dipool.highway.telekom.at (HELO PASCAL) + ([62.46.8.119]) (envelope-sender ) + by qmail6rs.highway.telekom.at (qmail-ldap-1.03) with SMTP + for ; 29 Apr 2004 17:11:14 -0000 +From: Manfred Koizar +To: Rod Taylor +Cc: Vitaly Belman , + Postgresql Performance +Subject: Re: Simply join in PostrgeSQL takes too long +Date: Thu, 29 Apr 2004 19:13:49 +0200 +Message-ID: +References: <282909734.20040428002740@012.net.il> + <1083103293.30065.100.camel@jester> + + <1083155014.30065.189.camel@jester> +In-Reply-To: <1083155014.30065.189.camel@jester> +X-Mailer: Forte Agent 1.93/32.576 English (American) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200404/494 +X-Sequence-Number: 6794 + +On Wed, 28 Apr 2004 08:23:35 -0400, Rod Taylor wrote: +>The below plpgsql forces the kind of algorithm we wish the planner could +>choose. It should be fairly quick irregardless of dataset. + +That reminds me of hash aggregation. So here's another idea for Vitaly: + + SELECT book_id + FROM ... + WHERE ... + GROUP BY book_id + LIMIT ... + +Servus + Manfred + +From pgsql-sql-owner@postgresql.org Thu Apr 29 14:24:55 2004 +X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0B7A4D1DF5D + for ; + Thu, 29 Apr 2004 14:24:54 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 83223-06 + for ; + Thu, 29 Apr 2004 14:24:33 -0300 (ADT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id B4301D1E181 + for ; Thu, 29 Apr 2004 14:24:31 -0300 (ADT) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4973814; Thu, 29 Apr 2004 10:25:57 -0700 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: Roelant Ossewaarde +Subject: Re: Use arrays or not? +Date: Thu, 29 Apr 2004 10:23:58 -0700 +User-Agent: KMail/1.4.3 +References: <20040429164059.GC24558@belboek.com> +In-Reply-To: <20040429164059.GC24558@belboek.com> +Cc: pgsql-sql@postgresql.org +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200404291023.58712.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/318 +X-Sequence-Number: 17693 + +Roelant, + +Yours is not a performance question, so I'm crossing it over to SQL for advice +on database design. + +> I am building an application using postgresql to store XML-records. There +> is a debate within the group of developers about the best way to store our +> data. I hope you can help us make a decision. +> +> The data consists of XML-records, with a lot of XML-fields. I want to store +> the XML as it is, so taking the information from the XML-records and then +> storing it in a different-from-XML-format is not an option. +> +> Each XML-record describes data about one book. If an update of bookdata +> comes, the XML itself is not changed, but a new XML-record is stored with +> the updated data. Via a complex scheme of combining a base record and its +> updates, the final dataset is produced that is used in the application. +> +> There are different XML-formats that need to be combined. Right now, we can +> handle three different XML-formats, each with its own structure (but all +> describing book-data). +> +> Searching is done via a simple table lookup on three different fields: +> title, author and subject. The data for these fields is extracted from the +> database. Each book has a unique identifier (EAN13, derivative of ISBN). +> +> Here is one way to organize the database: +> table title: +> TITLE | EAN13, indexing on TITLE +> +> table author: +> AUTHOR | EAN13, indexing on AUTHOR +> +> table subject: +> SUBJECT | EAN13, indexing on SUBJECT. + +This is a *very* strange way of setting up your database. Are you new to +Relational Databases and SQL? If so, I'd recommend starting with a book on +relational database design. + +Either that, or you're a victim of UML design. + +If only one author, title and subject are allowed per book, you should have: + +table books + EAN13 | TITLE | AUTHOR | SUBJECT + +> Finally: +> table record: +> EAN13 | ARRAY OF XML-records. +> +> It's the last table that I am most curious (and worried) about, the +> question being mainly what the optimal way of structuring that table is. +> Option 1 is the given option: adding/deleting an XML-record for the same +> book requires adding/deleting it to/from the array of XML-records. +> +> Option 2 would be something like this: +> EAN13 | XML-record +> where, if a book has several records describing it, there are multiple +> entries of the EAN13|XML-record - pair. Adding an XML-record for the same +> book, requires adding a new entry to the table as a whole. + +In my mind, there is no question that this is the best way to do things. It +is a normalized data structure, as opposed to the arrays, which are now. + +> +> So, option 1-tables look like this: +> EAN13 | ARRAY OF XML-records +> 0001 | {..., ..., ...} +> 0002 | {..., ..., ...} +> +> Option-2 tables look like this: +> EAN13 | ARRAY OF XML-records +> 0001 | ... +> 0001 | ... +> 0002 | ... +> 0002 | ... +> +> We can't decide which one is best. These are some issues we can think of: +> +> Indexing: For option 1, the EAN13-index remains unique, even if you have +> multiple XML-records; for option 2 it does not, since multiple XML-records +> are stored as multiple tuples. On the other hand, an additional internal +> index can be used to link the several tuples of option 2 to the information +> in the `lookup'-tables (author, title, keyword). Does any of these two +> options increase query efficiency, ie. speed? +> +> Database growth: On average, the information about a book is updated three +> times per year. In option 1, this means that the length of the table does +> not increase, but the width does. If we choose option 2, if we have three +> updates per book each year, the length of the table triples, but the width +> does not. What is more costly to store for postgres, long arrays or long +> tables? +> +> Integrity: Option 1 means that our software needs to keep track of all the +> bookkeeping for arrays, since such support is quite rudimentary in +> postgres. For example, it is hard to take out a record from the middle of +> an array. Also, a multidimensional array, which contains for each record +> the record itself and its type, is even harder to maintain. Option 2 has a +> simpler datatype, so integrity can be easier inforced using the standard +> postgres-machinery of variable-types etc. +> +> Arrays are non-standard SQL, and I hear that PHP-support for postgres & +> arrays is rudimentary. So that might be an argument to avoid using them, +> and go for option 2. From the standpoint of performance (or wisdom), can +> you help me decide what I should choose? Or is there maybe an even better +> way to structure my data? +> +> Thanks for any contribution! +> +> Roelant. + + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Thu Apr 29 14:37:49 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 15C70D1E60F + for ; + Thu, 29 Apr 2004 14:37:46 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 89915-06 + for ; + Thu, 29 Apr 2004 14:37:25 -0300 (ADT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9C508D1E616 + for ; + Thu, 29 Apr 2004 14:37:24 -0300 (ADT) +Received: from [134.22.68.249] (dyn-68-249.tor.dsl.tht.net [134.22.68.249]) + by tht.net (Postfix) with ESMTP + id C252276AF3; Thu, 29 Apr 2004 13:37:27 -0400 (EDT) +Subject: Re: Simply join in PostrgeSQL takes too long +From: Rod Taylor +To: Manfred Koizar +Cc: Vitaly Belman , + Postgresql Performance +In-Reply-To: +References: <282909734.20040428002740@012.net.il> + <1083103293.30065.100.camel@jester> + + <1083155014.30065.189.camel@jester> + +Content-Type: text/plain +Message-Id: <1083260206.30065.300.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Thu, 29 Apr 2004 13:36:47 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/495 +X-Sequence-Number: 6795 + +On Thu, 2004-04-29 at 13:13, Manfred Koizar wrote: +> On Wed, 28 Apr 2004 08:23:35 -0400, Rod Taylor wrote: +> >The below plpgsql forces the kind of algorithm we wish the planner could +> >choose. It should be fairly quick irregardless of dataset. +> +> That reminds me of hash aggregation. So here's another idea for Vitaly: + +The reason for the function is that the sort routines (hash aggregation +included) will not stop in mid-sort, although I believe that feature is +on the TODO list. + +I believe Vitaly will achieve 10ms or less query times using that +function. + + + +From pgsql-performance-owner@postgresql.org Thu Apr 29 14:57:04 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2B9B6D1E60F + for ; + Thu, 29 Apr 2004 14:57:03 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 96471-08 + for ; + Thu, 29 Apr 2004 14:56:42 -0300 (ADT) +Received: from email08.aon.at (WARSL402PIP7.highway.telekom.at [195.3.96.94]) + by svr1.postgresql.org (Postfix) with SMTP id 34706D1E6B3 + for ; + Thu, 29 Apr 2004 14:56:41 -0300 (ADT) +Received: (qmail 357716 invoked from network); 29 Apr 2004 17:56:38 -0000 +Received: from m148p023.dipool.highway.telekom.at (HELO PASCAL) + ([62.46.8.119]) (envelope-sender ) + by 172.18.5.237 (qmail-ldap-1.03) with SMTP + for ; 29 Apr 2004 17:56:38 -0000 +From: Manfred Koizar +To: Rod Taylor +Cc: Vitaly Belman , + Postgresql Performance +Subject: Re: Simply join in PostrgeSQL takes too long +Date: Thu, 29 Apr 2004 19:59:13 +0200 +Message-ID: +References: <282909734.20040428002740@012.net.il> + <1083103293.30065.100.camel@jester> + + <1083155014.30065.189.camel@jester> + + <1083260206.30065.300.camel@jester> +In-Reply-To: <1083260206.30065.300.camel@jester> +X-Mailer: Forte Agent 1.93/32.576 English (American) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200404/496 +X-Sequence-Number: 6796 + +On Thu, 29 Apr 2004 13:36:47 -0400, Rod Taylor wrote: +>The reason for the function is that the sort routines (hash aggregation +>included) will not stop in mid-sort + +Good point. + +Servus + Manfred + +From pgsql-performance-owner@postgresql.org Thu Apr 29 15:13:53 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 76078D1E752 + for ; + Thu, 29 Apr 2004 15:13:49 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 10306-01 + for ; + Thu, 29 Apr 2004 15:13:25 -0300 (ADT) +Received: from gpdnet.co.uk (gpdnet.plus.com [212.56.100.243]) + by svr1.postgresql.org (Postfix) with ESMTP id E1FC2D1CA40 + for ; + Thu, 29 Apr 2004 15:13:22 -0300 (ADT) +Received: from gary (unverified [192.168.1.2]) + by gpdnet.co.uk (SurgeMail 1.8g3) with ESMTP id 211 + for ; Thu, 29 Apr 2004 19:12:49 +0100 +From: "Gary Doades" +To: pgsql-performance@postgresql.org +Date: Thu, 29 Apr 2004 19:13:51 +0100 +MIME-Version: 1.0 +Subject: Re: planner/optimizer question +Message-ID: <409153EF.24647.144E9BF7@localhost> +In-reply-to: +References: <27806.1083157504@sss.pgh.pa.us> +X-mailer: Pegasus Mail for Windows (v4.12a) +Content-type: text/plain; charset=US-ASCII +Content-transfer-encoding: 7BIT +Content-description: Mail message body +X-Server: High Performance Mail Server - http://surgemail.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/497 +X-Sequence-Number: 6797 + +On 29 Apr 2004 at 19:03, Manfred Koizar wrote: + +> While the storage overhead could be reduced to 1 bit (not a joke) we'd +> still have the I/O overhead of locating and updating index tuples for +> every heap tuple deleted/updated. + +But this is what a lot of DBMSs do and seem to do well enough. I can see that the +MVCC system gives additional problems, but maybe it shouldn't be dismissed so lightly. + +Coming from a MS SQLServer platform I have spent a lot of time optimising SQL in +PostgreSQL to be comparable to SQLServer. For the most part I have done this, but +some things are just slower in PostgreSQL. + +Recently I have been looking at raw performance (CPU, IO) rather than the plans. I +have some test queries that (as far as I can determine) use the same access plans on +PostgreSQL and SQLServer. Getting to the detail, an index scan of an index on a +integer column (222512 rows) takes 60ms on SQLServer and 540ms on PostgreSQL. +A full seq table scan on the same table without the index on the other hand takes 370ms +in SQLServer and 420ms in PostgreSQL. + +I know that the platforms are different (windows 2000 vs Linux 2.6.3), but the statement +was executed several times to make sure the index and data was in cache (no disk io) +on both systems. Same data, Same CPU, Same disks, Same memory, Same +motherboards. + +The only thing I can think of is the way that the index scan is performed on each +platform, SQLServer can use the data directly from the index. This makes the biggest +difference in multi join statements where several of the intermediate tables do not need +to be accessed at all, the data is contained in the join indexes. This results in almost an +order of magnitude performance difference for the same data. + +I would be nice to get a feel for how much performance loss would be incurred in +maintaining the index flags against possible performance gains for getting the data back +out again. + +Regards, +Gary. + + +From pgsql-performance-owner@postgresql.org Thu Apr 29 15:21:57 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E18E3D1CA43 + for ; + Thu, 29 Apr 2004 15:21:54 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 05967-06 + for ; + Thu, 29 Apr 2004 15:21:34 -0300 (ADT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id ECC56D1E600 + for ; + Thu, 29 Apr 2004 15:21:32 -0300 (ADT) +Received: from [64.81.245.111] (HELO 192.168.1.102) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4974375; Thu, 29 Apr 2004 11:22:58 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Robert Creager +Subject: Re: Wierd context-switching issue on Xeon +Date: Thu, 29 Apr 2004 11:21:51 -0700 +User-Agent: KMail/1.5.4 +Cc: pg@fastcrypt.com, =?iso-8859-1?q?Dirk=5FLutzeb=E4ck?= , + ohp@pyrenet.fr, Tom Lane , + Joe Conway , "scott.marlowe" , + Bruce Momjian , + pgsql-performance@postgresql.org, Neil Conway +References: + <200404211029.43675.josh@agliodbs.com> + <20040428185753.56614b2c@thunder.mshome.net> +In-Reply-To: <20040428185753.56614b2c@thunder.mshome.net> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200404291121.51247.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 + tests=RCVD_NUMERIC_HELO +X-Spam-Level: +X-Archive-Number: 200404/498 +X-Sequence-Number: 6798 + +Rob, + +> I would like to see the same, as I have a system that exhibits the same +behavior +> on a production db that's running 7.4.1. + +If you checked the thread follow-ups, you'd see that *decreasing* +spins_per_delay was not beneficial. Instead, try increasing them, one step +at a time: + +(take baseline measurement at 100) +250 +500 +1000 +1500 +2000 +3000 +5000 + +... until you find an optimal level. Then report the results to us! + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Thu Apr 29 16:13:14 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id AEF33D1E930 + for ; + Thu, 29 Apr 2004 16:13:12 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 26966-08 + for ; + Thu, 29 Apr 2004 16:12:53 -0300 (ADT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 212B7D1E5F7 + for ; + Thu, 29 Apr 2004 16:12:52 -0300 (ADT) +Received: from [134.22.68.249] (dyn-68-249.tor.dsl.tht.net [134.22.68.249]) + by tht.net (Postfix) with ESMTP + id E5F9276B03; Thu, 29 Apr 2004 15:12:56 -0400 (EDT) +Subject: Re: planner/optimizer question +From: Rod Taylor +To: Gary Doades +Cc: Postgresql Performance +In-Reply-To: <409153EF.24647.144E9BF7@localhost> +References: <27806.1083157504@sss.pgh.pa.us> + <409153EF.24647.144E9BF7@localhost> +Content-Type: text/plain +Message-Id: <1083265934.30065.359.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Thu, 29 Apr 2004 15:12:15 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/499 +X-Sequence-Number: 6799 + +> I would be nice to get a feel for how much performance loss would be incurred in +> maintaining the index flags against possible performance gains for getting the data back +> out again. + +I guess the real question is, why maintain index flags and not simply +drop the index entry altogether? + +A more interesting case would be to have the backend process record +index tuples that it would invalidate (if committed), then on commit +send that list to a garbage collection process. + +It's still vacuum -- just the reaction time for it would be much +quicker. + + + +From pgsql-performance-owner@postgresql.org Thu Apr 29 16:23:11 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D368ED1E9A7 + for ; + Thu, 29 Apr 2004 16:23:10 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 27231-09 + for ; + Thu, 29 Apr 2004 16:22:51 -0300 (ADT) +Received: from gpdnet.co.uk (gpdnet.plus.com [212.56.100.243]) + by svr1.postgresql.org (Postfix) with ESMTP id 92DEED1E5DC + for ; + Thu, 29 Apr 2004 16:22:48 -0300 (ADT) +Received: from gary (unverified [192.168.1.2]) + by gpdnet.co.uk (SurgeMail 1.8g3) with ESMTP id 226 + for ; Thu, 29 Apr 2004 20:22:17 +0100 +From: "Gary Doades" +To: pgsql-performance@postgresql.org +Date: Thu, 29 Apr 2004 20:23:19 +0100 +MIME-Version: 1.0 +Subject: Re: planner/optimizer question +Message-ID: <40916437.19555.148E3602@localhost> +In-reply-to: <1083265934.30065.359.camel@jester> +References: <409153EF.24647.144E9BF7@localhost> +X-mailer: Pegasus Mail for Windows (v4.12a) +Content-type: text/plain; charset=US-ASCII +Content-transfer-encoding: 7BIT +Content-description: Mail message body +X-Server: High Performance Mail Server - http://surgemail.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/500 +X-Sequence-Number: 6800 + +> +> I guess the real question is, why maintain index flags and not simply +> drop the index entry altogether? +> +> A more interesting case would be to have the backend process record +> index tuples that it would invalidate (if committed), then on commit +> send that list to a garbage collection process. +> +> It's still vacuum -- just the reaction time for it would be much +> quicker. +> +This was my original question. + +I guess the problem is with MVCC. The row may have gone from your +current view of the table but not from someone elses. I don't (yet) +understand the way it works to say for sure, but I still think it is worth +pursuing further for someone who does know the deep stuff. They seem +to have concluded that it is not worth it however. + +Cheers, +Gary. + + + + +From pgsql-performance-owner@postgresql.org Thu Apr 29 17:14:42 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 17971D1EB6B + for ; + Thu, 29 Apr 2004 17:12:54 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 60864-02 + for ; + Thu, 29 Apr 2004 17:12:33 -0300 (ADT) +Received: from www.totalcardinc.com (unknown [64.33.232.186]) + by svr1.postgresql.org (Postfix) with ESMTP id 0F569D1EB30 + for ; + Thu, 29 Apr 2004 17:12:31 -0300 (ADT) +Received: from RSCHWARZW2K ([10.250.0.37]) (authenticated bits=0) + by www.totalcardinc.com (8.12.8/8.12.8) with ESMTP id i3TKCTiK000820; + Thu, 29 Apr 2004 15:12:29 -0500 +From: "Rosser Schwarz" +To: "'Gary Doades'" , + +Subject: Re: planner/optimizer question +Date: Thu, 29 Apr 2004 15:12:29 -0500 +Message-ID: <003101c42e26$4c384e90$2500fa0a@CardServices.TCI.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.4510 +In-Reply-To: <409153EF.24647.144E9BF7@localhost> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +Importance: Normal +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200404/501 +X-Sequence-Number: 6801 + +while you weren't looking, Gary Doades wrote: + +> Recently I have been looking at raw performance (CPU, IO) +> rather than the plans. I have some test queries that (as far +> as I can determine) use the same access plans on PostgreSQL +> and SQLServer. Getting to the detail, an index scan of an +> index on a integer column (222512 rows) takes 60ms on +> SQLServer and 540ms on PostgreSQL. + +After a recent power outage, I had the opportunity to watch both +PostgreSQL and MS SQL come back from forced shutdowns (clean, +though there were active connections, in one case a bulk insert). +PostgreSQL was available and responsive as soon as the postmaster +had started. MS SQL, on the other hand, took the better part of +an hour to become remotely usable again -- on a radically faster +machine (Dell 6650, versus the 6450 we run PostgreSQL on). + +Digging a bit, I noted that once MS SQL was up again, it was +using nearly 2GB main memory even when more or less idle. From +this, and having observed the performance differences between +the two, I'm left with little alternative but to surmise that +part of MS SQL's noted performance advantage [1] is due to its +forcibly storing its indices in main memory. Its startup lag +(during which it was utterly unusable; even SELECTs blocked) +could be accounted for by reindexing the tables. [2] + +Granted, this is only a hypothesis, is rather unverifyable, and +probably belongs more on ADVOCACY than it does PERFORM, but it +seemed relevant. + +It's also entirely possible your indices are using inaccurate +statistical information. Have you ANALYZEd recently? + +/rls + +[1] Again, at least in our case, the comparison is entirely + invalid, as MS SQL gets a hell of a lot more machine than + PostgreSQL. Even so, for day-to-day work and queries, even + our DBA, an until-recently fervent MS SQL advocate can't + fault PostgreSQL's SELECT, INSERT or DELETE performance. + We still can't get UPDATEs (at least bulk such) to pass + muster. + +[2] This is further supported by having observed MS SQL run a + "recovery process" on databases that were entirely unused, + even for SELECT queries, at the time of the outage. The + only thing it might conceivably need to recover on them + is in-memory indices that were lost when power was lost. + +-- +Rosser Schwarz +Total Card, Inc. + + +From pgsql-performance-owner@postgresql.org Thu Apr 29 17:26:15 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3524CD1E959 + for ; + Thu, 29 Apr 2004 17:26:14 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 64003-05 + for ; + Thu, 29 Apr 2004 17:25:54 -0300 (ADT) +Received: from gpdnet.co.uk (gpdnet.plus.com [212.56.100.243]) + by svr1.postgresql.org (Postfix) with ESMTP id 2F97BD1E968 + for ; + Thu, 29 Apr 2004 17:25:52 -0300 (ADT) +Received: from gary (unverified [192.168.1.2]) + by gpdnet.co.uk (SurgeMail 1.8g3) with ESMTP id 236 + for ; Thu, 29 Apr 2004 21:25:16 +0100 +From: "Gary Doades" +To: pgsql-performance@postgresql.org +Date: Thu, 29 Apr 2004 21:26:18 +0100 +MIME-Version: 1.0 +Subject: Re: planner/optimizer question +Message-ID: <409172FA.1509.14C7E00E@localhost> +In-reply-to: <003101c42e26$4c384e90$2500fa0a@CardServices.TCI.com> +References: <409153EF.24647.144E9BF7@localhost> +X-mailer: Pegasus Mail for Windows (v4.12a) +Content-type: text/plain; charset=US-ASCII +Content-transfer-encoding: 7BIT +Content-description: Mail message body +X-Server: High Performance Mail Server - http://surgemail.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/502 +X-Sequence-Number: 6802 + + +> It's also entirely possible your indices are using inaccurate +> statistical information. Have you ANALYZEd recently? +> + +In this example the statistics don't matter. The plans used were the same for +MSSQL and Postgres. I was trying to eliminate the difference in plans +between the two, which obviously does make a difference, sometimes in +MSSQL favour and sometimes the other way round. Both systems, having +decided to do the same index scan, took noticably different times. The +Postgres database was fully vacuumed and analysed anyway. + +I agree about MSSQL recovery time. it sucks. This is why they are making a +big point about the improved recovery time in "yukon". Although the recovery +time is important, I see this as an exception, whereas at the moment I am +interested in the everyday. + +Cheers, +Gary. + + +From pgsql-sql-owner@postgresql.org Tue May 4 09:55:29 2004 +X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 83E85D1E785 + for ; + Thu, 29 Apr 2004 17:27:00 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 61085-09 + for ; + Thu, 29 Apr 2004 17:26:41 -0300 (ADT) +Received: from lin-mgregory11.caset.buffalo.edu + (lin-mgregory11.caset.buffalo.edu [128.205.152.74]) + by svr1.postgresql.org (Postfix) with ESMTP id 1C6D3D1ED90 + for ; Thu, 29 Apr 2004 17:26:39 -0300 (ADT) +Received: by lin-mgregory11.caset.buffalo.edu (Postfix, from userid 129391) + id CF44F1D49B; Thu, 29 Apr 2004 16:26:40 -0400 (EDT) +Date: Thu, 29 Apr 2004 16:26:40 -0400 +From: Roelant Ossewaarde +To: Richard Huxton +Cc: Josh Berkus , + Roelant Ossewaarde , pgsql-sql@postgresql.org +Subject: Re: Use arrays or not? +Message-ID: <20040429202631.GB25328@belboek.com> +References: <20040429164059.GC24558@belboek.com> + <200404291023.58712.josh@agliodbs.com> <40914CC2.6050909@archonet> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <40914CC2.6050909@archonet> +User-Agent: Mutt/1.4i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200405/23 +X-Sequence-Number: 17737 + +Hi, + +Thanks for your fast response. But I'm afraid I stated some things unclear. + +> >>The data consists of XML-records, with a lot of XML-fields. I want to +> >>store +> >>the XML as it is, so taking the information from the XML-records and then +> >>storing it in a different-from-XML-format is not an option. +> +> Actually, your data consists of data. The XML is just scaffolding to +> enable you to locate and understand your data. Since you are storing it +> in a relational database, that will use relational scaffolding for its +> organisation instead. At least partially, you will *have* to parse the +> values out and organise them differently. +I do, and I know. But I want to store the XML-records as they are. So given an +author, title and an XML-record that are related to that author and title, how +to store that. That's the question. I have good reasons to store the +XML-records as they are, without further parsing them. + +> >>Each XML-record describes data about one book. If an update of bookdata +> >>comes, the XML itself is not changed, but a new XML-record is stored with +> >>the updated data. Via a complex scheme of combining a base record and its +> >>updates, the final dataset is produced that is used in the application. +> >> +> >>Searching is done via a simple table lookup on three different fields: +> >>title, author and subject. The data for these fields is extracted from the +> >>database. Each book has a unique identifier (EAN13, derivative of ISBN). +> >> +> >>Here is one way to organize the database: +> >>table title: +> >>TITLE | EAN13, indexing on TITLE +> >> +> >>table author: +> >>AUTHOR | EAN13, indexing on AUTHOR +> >> +> >>table subject: +> >>SUBJECT | EAN13, indexing on SUBJECT. +> > +> > +> >This is a *very* strange way of setting up your database. Are you new to +> >Relational Databases and SQL? If so, I'd recommend starting with a book +> >on relational database design. +> I agree with Josh - think about a book. + +Thank your for the recommendations. But the above thing is just background +information, it will not be stored as such. The important question for me is +the question whether to use arrays or not. With index in the above examples I +do not mean the actual postgres-index, I mean that those are the fields that +are used in searching. One never searches on an EAN13-number, only on author, +title and subject. And one never, by the way, searches for a specific +XML-record, only the total of the stored XML-records per book should be retrieved. + +> +> >If only one author, title and subject are allowed per book, you should +> >have: +> > +> >table books +> > EAN13 | TITLE | AUTHOR | SUBJECT +> +> If, on the other hand you can have multiple authors (likely) you'll want +> something like: +> +> CREATE TABLE author ( +> ean13 varchar(13), -- Guessing ean13 format +> author_num int4, +> author_name text, +> PRIMARY KEY (ean13, author_num) +> ); +> +> Then you can have rows like: +> +> ('my-ean-number-here', 1, 'Aaron Aardvark') +> ('my-ean-number-here', 2, 'Betty Bee') +> etc. + +Yes, I have such a thing. There can be multiple titles, multiple authors and +multiple keywords per book. + +> +> +> >>Finally: +> >>table record: +> >>EAN13 | ARRAY OF XML-records. +> >> +> >>It's the last table that I am most curious (and worried) about, the +> >>question being mainly what the optimal way of structuring that table is. +> >>Option 1 is the given option: adding/deleting an XML-record for the same +> >>book requires adding/deleting it to/from the array of XML-records. +> >> +> >>Option 2 would be something like this: +> >>EAN13 | XML-record +> >>where, if a book has several records describing it, there are multiple +> >>entries of the EAN13|XML-record - pair. Adding an XML-record for the same +> >>book, requires adding a new entry to the table as a whole. +> > +> > +> >In my mind, there is no question that this is the best way to do things. +> >It is a normalized data structure, as opposed to the arrays, which are now. +> +> Although your option 2 doesn't go quite far enough. You'll also want to +> know what order these come in. So, assuming you can't have two updates +> at the same time: +> +> CREATE TABLE book_history ( +> ean13 varchar(13), -- Guessing ean13 format +> ts timestamp with time zone, +> xml text, +> PRIMARY KEY (ean13, ts) +> ); + +The order is not important; the interpretation of the XML-records is done by +an external module. The order is determined upon the content of the +XML-records, because they can come from different sources and can be combined +in different ways, depending on the application processing the +XML-records. Order is not determined at the moment that the records are +stored, but at the moment the records are interpreted. + +> As for your other concerns: +> >>Indexing: +> >>Database growth: +> >>Integrity: +> Just worry about the integrity - if you keep the design simple, +> PostgreSQL will manage quite large growth on quite small hardware. + +What would be a situation in which one should use arrays then? + + +> Now... I don't think you want to do what you're trying to do. Don't take +> this personally, but unless you're extremely pushed for time and +> resources this is almost certainly a bad design choice. + +> 1. Wrong tool for the job +> Basically you're taking a relational database and treating it like a +> filesystem. All you need for what you're doing is a directory-tree to +> represent the ean13 structure and one file per xml-record. Index the +> author/title fields with dbm/SQLite. You could write the whole thing in +> a day - simple, efficient, leverages existing unix tools. + +That is correct. I think nothing would beat a dbm-style solution qua +performance, and I'm still considering using that. The added value of a system +like postgresql is the client/server-interface and the omnipresent support of +programming languages, and not in the least the familiarity of most people +with mysql/postgresql in comparison to dbm. + +> 2. Wrong job for the tool +> How do I find out which publisher produced the most books in 2003 (I'm +> assuming this is in your XML somewhere)? Which book is available in the +> most languages? +> How many updates were applied last month? How many different books did +> they affect? Why do the numbers not match - which books had multiple +> changes? +> The first set of questions need you to write code, the second set don't. +> Why? Because the second set rely on information stored simply and +> explicitly in the database (book_history as it happens). + +We know what set of questions will be asked: we only need to access through +author, title and subject keywords. Another reason maybe to choose a +non-relational model. + +> 3. The medium isn't the message +> You don't want to open up your XML records to store them in the +> database, but I assume you have to in your PHP code, or you can't +> process individual values. As it stands you're having to extract certain +> information when an XML update arrives anyway. If the title of a book is +> amended, then you'll need to remember to update the book_title table. If +> it's simple to extract more, why not do so? If some of it is fiddly to +> represent in an SQL database then at least extract everything that is +> convenient. + +There are good reasons for that. The XMLs not necessarily contain the input to +author/title/subject-tables (or columns). I just want to store the XML, +interpret it later. (really, it makes sense!) + +> Oh - and I would probably store a "current snapshot" of the book's +> record separately too. Saves your application having to recalculate it +> every time it's needed. + +I *want* to recalculate it every time it's needed. Because the different +XML-records can be combined in several ways, depending on the application that +is accessing the database-client. + +So, let me rephrase my questions: +1. When and why would anyone use arrays? +2. When designing the database, is it really true that there is no performance +difference between a table of which the number of tuples grow by a factor of, +say 10, and a table of which the size of the tuples grow by a factor of, say +10? + +Thanks, + +Roelant. + +From pgsql-sql-owner@postgresql.org Thu Apr 29 17:52:22 2004 +X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DBFA2D1ED9A + for ; + Thu, 29 Apr 2004 17:47:31 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 69735-09 + for ; + Thu, 29 Apr 2004 17:47:12 -0300 (ADT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 169C8D1E964 + for ; Thu, 29 Apr 2004 17:47:10 -0300 (ADT) +Received: from [64.81.245.111] (HELO 192.168.1.102) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4975391; Thu, 29 Apr 2004 13:48:24 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Roelant Ossewaarde , + Richard Huxton +Subject: Re: Use arrays or not? +Date: Thu, 29 Apr 2004 13:47:16 -0700 +User-Agent: KMail/1.5.4 +Cc: pgsql-sql@postgresql.org +References: <20040429164059.GC24558@belboek.com> <40914CC2.6050909@archonet> + <20040429202631.GB25328@belboek.com> +In-Reply-To: <20040429202631.GB25328@belboek.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200404291347.16488.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 + tests=RCVD_NUMERIC_HELO +X-Spam-Level: +X-Archive-Number: 200404/324 +X-Sequence-Number: 17699 + +Roelant, + +> So, let me rephrase my questions: +> 1. When and why would anyone use arrays? + +When the data itself is an ordered set of items which is indivisible and lacks +meaning outside the ordered set. For example, a set of ordered pairs of +molecules in a gene snippet. Or a mathematical matrix. + +> 2. When designing the database, is it really true that there is no +performance +> difference between a table of which the number of tuples grow by a factor +of, +> say 10, and a table of which the size of the tuples grow by a factor of, say +> 10? + +Nobody's tested anything. I would *tend* to think that PostgreSQL would +handle more-of-less-wide-rows somewhat better, but that's just a guess. + +Hmmm ... not completely a guess. Postgres, by default, compresses fields +over 8K in size (see TOAST in the docs). This makes those fields somewhat +slower to update. So if 1 XML rec < 8k but 4 XML rec > 8k, there could be a +small-but-noticeable performance loss from going to "broad" rows. + +If I had your application, I would not go for the array approach, jjust to +avoid maintainence headaches. For example, what happens when the books +start having a variable number of XML records? Normalized designs are +almost always easier to deal with from a perspective of long-term +maintainence. + +The arrays, as far as I can tell, gain you nothing in ethier performance or +convenience. + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Thu Apr 29 18:07:14 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 45002D1EE8E + for ; + Thu, 29 Apr 2004 17:54:40 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 74407-06 + for ; + Thu, 29 Apr 2004 17:54:20 -0300 (ADT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 11CE4D1EDB9 + for ; + Thu, 29 Apr 2004 17:54:18 -0300 (ADT) +Received: from [64.81.245.111] (HELO 192.168.1.102) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4975456; Thu, 29 Apr 2004 13:55:47 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: "Gary Doades" , + pgsql-performance@postgresql.org +Subject: Re: planner/optimizer question +Date: Thu, 29 Apr 2004 13:54:33 -0700 +User-Agent: KMail/1.5.4 +References: <409153EF.24647.144E9BF7@localhost> + <409172FA.1509.14C7E00E@localhost> +In-Reply-To: <409172FA.1509.14C7E00E@localhost> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200404291354.33304.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 + tests=RCVD_NUMERIC_HELO +X-Spam-Level: +X-Archive-Number: 200404/503 +X-Sequence-Number: 6803 + +Gary, + +> In this example the statistics don't matter. The plans used were the same +for +> MSSQL and Postgres. I was trying to eliminate the difference in plans +> between the two, which obviously does make a difference, sometimes in +> MSSQL favour and sometimes the other way round. Both systems, having +> decided to do the same index scan, took noticably different times. The +> Postgres database was fully vacuumed and analysed anyway. + +It's also quite possble the MSSQL simply has more efficient index scanning +implementation that we do. They've certainly had incentive; their storage +system sucks big time for random lookups and they need those fast indexes. +(just try to build a 1GB adjacency list tree on SQL Server. I dare ya). + +Certainly the fact that MSSQL is essentially a single-user database makes +things easier for them. They don't have to maintain multiple copies of the +index tuples in memory. I think that may be our main performance loss. + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Thu Apr 29 18:08:54 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E9C41D1EE95 + for ; + Thu, 29 Apr 2004 18:08:52 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 79425-06 + for ; + Thu, 29 Apr 2004 18:08:34 -0300 (ADT) +Received: from gpdnet.co.uk (gpdnet.plus.com [212.56.100.243]) + by svr1.postgresql.org (Postfix) with ESMTP id E9EB7D1EDA0 + for ; + Thu, 29 Apr 2004 18:08:30 -0300 (ADT) +Received: from gary (unverified [192.168.1.2]) + by gpdnet.co.uk (SurgeMail 1.8g3) with ESMTP id 243 + for ; Thu, 29 Apr 2004 22:08:01 +0100 +From: "Gary Doades" +To: pgsql-performance@postgresql.org +Date: Thu, 29 Apr 2004 22:08:28 +0100 +MIME-Version: 1.0 +Subject: Re: planner/optimizer question +Message-ID: <40917CDC.3078.14EE7897@localhost> +In-reply-to: <20040429203519.GI26634@it.is.rice.edu> +References: <409172FA.1509.14C7E00E@localhost> +X-mailer: Pegasus Mail for Windows (v4.12a) +Content-type: text/plain; charset=US-ASCII +Content-transfer-encoding: 7BIT +Content-description: Mail message body +X-Server: High Performance Mail Server - http://surgemail.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/504 +X-Sequence-Number: 6804 + +On 29 Apr 2004 at 15:35, Kenneth Marshall wrote: + +> Did you try to cluster based on the index? +> +> --Ken + +Yes, This speeds up the index scan a little (12%). This to me just +reinforces the overhead that subsequently having to go and fetch the +data tuple actually has on the performance. + +Cheers, +Gary. + + +From pgsql-performance-owner@postgresql.org Thu Apr 29 18:09:26 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 36EE5D1EEAC + for ; + Thu, 29 Apr 2004 18:09:24 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 84785-01 + for ; + Thu, 29 Apr 2004 18:09:04 -0300 (ADT) +Received: from fep12.012.net.il (fep12.012.net.il [212.117.129.243]) + by svr1.postgresql.org (Postfix) with ESMTP id 56FC9D1EDB9 + for ; + Thu, 29 Apr 2004 18:09:01 -0300 (ADT) +Received: from 80.178.84.42.forward.012.net.il ([80.178.84.42]) + by fep12.012.net.il with ESMTP + id <20040429210945.DJKT26710.fep12@80.178.84.42.forward.012.net.il>; + Fri, 30 Apr 2004 00:09:45 +0300 +Date: Fri, 30 Apr 2004 00:09:36 +0300 +From: Vitaly Belman +Reply-To: Vitaly Belman +X-Priority: 3 (Normal) +Message-ID: <147254626500.20040430000936@012.net.il> +To: Manfred Koizar +Cc: Rod Taylor , + Postgresql Performance +Subject: Re: Simply join in PostrgeSQL takes too long +In-Reply-To: +References: <282909734.20040428002740@012.net.il> + <1083103293.30065.100.camel@jester> + +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.9 tagged_above=0.0 required=5.0 + tests=PRIORITY_NO_NAME, RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200404/505 +X-Sequence-Number: 6805 + +Hello Manfred, + +I thank everyone for helping me on this - So many tips. + +I am in the middle of going through them all, till now disabling the +enable_mergejoin really helped. + +Also, I agree that the design might be flawed (I could use triggers +and stuff like that) but for now I am just comparing how my project +will run on PostgreSQL (Considering migration from MySQL). + +I'll be reporting back on how the other stuff helped. + +Regards, + Vitaly Belman + + ICQ: 1912453 + AIM: VitalyB1984 + MSN: tmdagent@hotmail.com + Yahoo!: VitalyBe + +Wednesday, April 28, 2004, 11:24:41 AM, you wrote: + +MK> On Tue, 27 Apr 2004 18:01:34 -0400, Rod Taylor wrote: +>>On Tue, 2004-04-27 at 17:27, Vitaly Belman wrote: +>>> Hello pgsql-performance, +>>> +>>> I discussed the whole subject for some time in DevShed and didn't +>>> achieve much (as for results). I wonder if any of you guys can help +>>> out: +>>> +>>> http://forums.devshed.com/t136202/s.html + +>>The point is that a book cannot be of a certain genre more than once. + +MK> Rod, he has a hierarchy of genres. Genre 1 has 6379 child genres and a +MK> book can be in more than one of these. + +MK> Vitaly, though LIMIT makes this look like a small query, DISTINCT +MK> requires the whole result set to be retrieved. 0.7 seconds doesn't look +MK> so bad for several thousand rows. Did you try with other genre_ids? + +MK> Maybe a merge join is not the best choice. Set enable_mergejoin to +MK> false and see whether you get a (hopefully faster) hash join, assuming +MK> that sort_mem is large enough to keep the hash table in memory. + +MK> If you send me your table contents I'll try it on Linux. + +MK> Servus +MK> Manfred + + +From pgsql-performance-owner@postgresql.org Thu Apr 29 18:27:08 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1E45AD1EF10 + for ; + Thu, 29 Apr 2004 18:15:02 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 84879-02 + for ; + Thu, 29 Apr 2004 18:14:42 -0300 (ADT) +Received: from gpdnet.co.uk (gpdnet.plus.com [212.56.100.243]) + by svr1.postgresql.org (Postfix) with ESMTP id D9B4AD1EEC5 + for ; + Thu, 29 Apr 2004 18:14:39 -0300 (ADT) +Received: from gary (unverified [192.168.1.2]) + by gpdnet.co.uk (SurgeMail 1.8g3) with ESMTP id 247 + for ; Thu, 29 Apr 2004 22:14:10 +0100 +From: "Gary Doades" +To: pgsql-performance@postgresql.org +Date: Thu, 29 Apr 2004 22:15:12 +0100 +MIME-Version: 1.0 +Subject: Re: planner/optimizer question +Message-ID: <40917E70.21362.14F4A330@localhost> +In-reply-to: <200404291354.33304.josh@agliodbs.com> +References: <409172FA.1509.14C7E00E@localhost> +X-mailer: Pegasus Mail for Windows (v4.12a) +Content-type: text/plain; charset=US-ASCII +Content-transfer-encoding: 7BIT +Content-description: Mail message body +X-Server: High Performance Mail Server - http://surgemail.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/506 +X-Sequence-Number: 6806 + +On 29 Apr 2004 at 13:54, Josh Berkus wrote: + +> Gary, +> +> +> It's also quite possble the MSSQL simply has more efficient index scanning +> implementation that we do. They've certainly had incentive; their storage +> system sucks big time for random lookups and they need those fast indexes. +> (just try to build a 1GB adjacency list tree on SQL Server. I dare ya). +> +> Certainly the fact that MSSQL is essentially a single-user database makes +> things easier for them. They don't have to maintain multiple copies of the +> index tuples in memory. I think that may be our main performance loss. +> + +Possibly, but MSSQL certainly uses data from indexes and cuts out the +subsequent (possibly random seek) data fetch. This is also why the +"Index Tuning Wizard" often recommends multi column compound +indexes in some cases. I've tried these recommendations on occasions +and they certainly speed up the selects significantly. If anyhing the index +scan on the new compound index must be slower then the original single +column index and yet it still gets the data faster. + +This indicates to me that it is not the scan (or IO) performance that is +making the difference, but not having to go get the data row. + +Cheers, +Gary. + + +From pgsql-performance-owner@postgresql.org Thu Apr 29 18:55:06 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A2CFFD1EB57 + for ; + Thu, 29 Apr 2004 18:54:52 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 95162-09 + for ; + Thu, 29 Apr 2004 18:54:34 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 9EA52D1B582 + for ; + Thu, 29 Apr 2004 18:54:31 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3TLsWkY017176; + Thu, 29 Apr 2004 17:54:32 -0400 (EDT) +To: "Gary Doades" +Cc: pgsql-performance@postgresql.org +Subject: Re: planner/optimizer question +In-reply-to: <409172FA.1509.14C7E00E@localhost> +References: <409153EF.24647.144E9BF7@localhost> + <409172FA.1509.14C7E00E@localhost> +Comments: In-reply-to "Gary Doades" + message dated "Thu, 29 Apr 2004 21:26:18 +0100" +Date: Thu, 29 Apr 2004 17:54:31 -0400 +Message-ID: <17175.1083275671@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/507 +X-Sequence-Number: 6807 + +"Gary Doades" writes: +> In this example the statistics don't matter. + +Don't they? + +A prior poster mentioned that he thought MSSQL tries to keep all its +indexes in memory. I wonder whether you are giving Postgres a fair +chance to do the same. What postgresql.conf settings are you using? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Apr 29 19:13:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6D64CD1EB2E + for ; + Thu, 29 Apr 2004 19:10:14 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 07043-01 + for ; + Thu, 29 Apr 2004 19:09:51 -0300 (ADT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 5D9A8D1EB33 + for ; + Thu, 29 Apr 2004 19:09:48 -0300 (ADT) +Received: from [64.81.245.111] (HELO 192.168.1.102) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4976073; Thu, 29 Apr 2004 15:11:18 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Vitaly Belman , + Manfred Koizar +Subject: Re: Simply join in PostrgeSQL takes too long +Date: Thu, 29 Apr 2004 15:10:08 -0700 +User-Agent: KMail/1.5.4 +Cc: Rod Taylor , + Postgresql Performance +References: <282909734.20040428002740@012.net.il> + + <147254626500.20040430000936@012.net.il> +In-Reply-To: <147254626500.20040430000936@012.net.il> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200404291510.08757.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 + tests=RCVD_NUMERIC_HELO +X-Spam-Level: +X-Archive-Number: 200404/508 +X-Sequence-Number: 6808 + +Vitaly, + +> I am in the middle of going through them all, till now disabling the +> enable_mergejoin really helped. + +In that case, your random_page_cost is probably too low. Check the ratio of +per-tuple times on index vs. seqscan seeks. + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Thu Apr 29 19:32:36 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1C650D1EDA2 + for ; + Thu, 29 Apr 2004 19:30:51 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 14173-02 + for ; + Thu, 29 Apr 2004 19:30:31 -0300 (ADT) +Received: from gpdnet.co.uk (gpdnet.plus.com [212.56.100.243]) + by svr1.postgresql.org (Postfix) with ESMTP id AE3B2D1EDC0 + for ; + Thu, 29 Apr 2004 19:30:27 -0300 (ADT) +Received: from gary (unverified [192.168.1.2]) + by gpdnet.co.uk (SurgeMail 1.8g3) with ESMTP id 264 + for ; Thu, 29 Apr 2004 23:29:58 +0100 +From: "Gary Doades" +To: pgsql-performance@postgresql.org +Date: Thu, 29 Apr 2004 23:31:00 +0100 +MIME-Version: 1.0 +Subject: Re: planner/optimizer question +Message-ID: <40919034.20317.153A0B6F@localhost> +In-reply-to: <17175.1083275671@sss.pgh.pa.us> +References: <409172FA.1509.14C7E00E@localhost> +X-mailer: Pegasus Mail for Windows (v4.12a) +Content-type: Multipart/Alternative; boundary="Alt-Boundary-23407.356125551" +X-Server: High Performance Mail Server - http://surgemail.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=1.3 tagged_above=0.0 required=5.0 tests=HTML_40_50, + HTML_FONTCOLOR_RED, HTML_FONTCOLOR_UNSAFE, HTML_MESSAGE, + HTML_TITLE_EMPTY, LINES_OF_YELLING, LINES_OF_YELLING_2 +X-Spam-Level: * +X-Archive-Number: 200404/509 +X-Sequence-Number: 6809 + +--Alt-Boundary-23407.356125551 +Content-type: text/plain; charset=US-ASCII +Content-transfer-encoding: 7BIT +Content-description: Mail message body + +On 29 Apr 2004 at 17:54, Tom Lane wrote: + +> "Gary Doades" writes: +> > In this example the statistics don't matter. +> +> Don't they? +> +> A prior poster mentioned that he thought MSSQL tries to keep all its +> indexes in memory. I wonder whether you are giving Postgres a fair +> chance to do the same. What postgresql.conf settings are you using? +> +> regards, tom lane + +As far as I understand it the statistics only contribute to determining the query plan. +Once the access methods are determined, the stats don't matter during the running of +the query. + +I believe I have given Postgres exactly the same chance. The data is small enough to fit +into RAM (all the tables in the query add up to around 50meg) and I executed the query +several times to get a consistent figure for the explain analyze. + +Having picked out an index scan as being the highest time user I concentrated on that in +this case and compared the same index scan on MSSQL. At least MSSQL reported it as +an index scan on the same index for the same number of rows. + +There was nothing wrong with the query plan that Postgres used. As far as I could see it +was probably the best one to use, it just physically took longer than the same access +plan on MSSQL. + +The query and plan are included below, the main thing I was looking at was the index +scan on staff_booking_pkey being 676ms long. + +The only postgresql.conf parameters changed from the default are: + +shared_buffers = 3000 +sort_mem = 4096 +effective_cache_size = 15000 +default_statistics_target = 100 + +There was no disk IO (above the small background IO) during the final run of the query +as reported by vmstat (Task Mangler on Windows). + +SELECT B.CONTRACT_ID,SUM(R.DURATION+1)/60.0 AS SUMDUR FROM +SEARCH_REQT_RESULT TSR +JOIN STAFF_BOOKING B ON (B.STAFF_ID = TSR.STAFF_ID) +JOIN ORDER_REQT R ON (R.REQT_ID = B.REQT_ID) +JOIN BOOKING_PLAN BP ON (BP.BOOKING_ID = B.BOOKING_ID) AND +BP.BOOKING_DATE BETWEEN '2004-04-12' AND '2004-04-18' AND +TSR.SEARCH_ID = 8 GROUP BY B.CONTRACT_ID + +QUERY PLAN +HashAggregate (cost=11205.80..11209.81 rows=401 width=6) (actual +time=1179.729..1179.980 rows=50 loops=1) + -> Nested Loop (cost=326.47..11203.79 rows=401 width=6) (actual +time=39.700..1177.149 rows=652 loops=1) + -> Hash Join (cost=326.47..9990.37 rows=401 width=8) (actual +time=39.537..1154.807 rows=652 loops=1) + Hash Cond: ("outer".staff_id = "inner".staff_id) + -> Merge Join (cost=320.39..9885.06 rows=3809 width=12) (actual +time=38.316..1143.953 rows=4079 loops=1) + Merge Cond: ("outer".booking_id = "inner".booking_id) + -> Index Scan using staff_booking_pkey on staff_booking b +(cost=0.00..8951.94 rows=222612 width=16) (actual time=0.218..676.219 rows=222609 +loops=1) + -> Sort (cost=320.39..329.91 rows=3808 width=4) (actual +time=26.225..32.754 rows=4079 loops=1) + Sort Key: bp.booking_id + -> Index Scan using booking_plan_idx2 on booking_plan bp +(cost=0.00..93.92 rows=3808 width=4) (actual time=0.223..14.186 rows=4079 loops=1) + Index Cond: ((booking_date >= '2004-04-12'::date) AND +(booking_date <= '2004-04-18'::date)) + -> Hash (cost=5.59..5.59 rows=193 width=4) (actual time=1.139..1.139 +rows=0 loops=1) + -> Index Scan using fk_idx_search_reqt_result on search_reqt_result tsr +(cost=0.00..5.59 rows=193 width=4) (actual time=0.213..0.764 rows=192 loops=1) + Index Cond: (search_id = 8) + -> Index Scan using order_reqt_pkey on order_reqt r (cost=0.00..3.01 rows=1 +width=6) (actual time=0.023..0.025 rows=1 loops=652) + Index Cond: (r.reqt_id = "outer".reqt_id) +Total runtime: 1181.239 ms + + +Cheers, +Gary. + +--Alt-Boundary-23407.356125551 +Content-type: text/html; charset=US-ASCII +Content-transfer-encoding: 7BIT +Content-description: Mail message body + + + + + + +
On 29 Apr 2004 at 17:54, Tom Lane wrote:
+

+
+
> "Gary Doades" <gpd@gpdnet.co.uk> writes:
+
> > In this example the statistics don't matter.
+
>
+
> Don't they?
+
>
+
> A prior poster mentioned that he thought MSSQL tries to keep all its
+
> indexes in memory.  I wonder whether you are giving Postgres a fair
+
> chance to do the same.  What postgresql.conf settings are you using?
+
>
+
>                                  regards, +tom lane
+

+
As far as I understand it the statistics only contribute to determining the query plan. +Once the access methods are determined, the stats don't matter during the running of +the query.
+

+
I believe I have given Postgres exactly the same chance. The data is small enough to fit +into RAM (all the tables in the query add up to around 50meg) and I executed the query +several times to get a consistent figure for the explain analyze.
+

+
+
Having picked out an index scan as being the highest time user I concentrated on that in +this case and compared the same index scan on MSSQL. At least MSSQL reported it as +an index scan on the same index for the same number of rows.
+

+
+
There was nothing wrong with the query plan that Postgres used. As far as I could see it +was probably the best one to use, it just physically took longer than the same access +plan on MSSQL.
+

+
The query and plan are included below, the main thing I was looking at was the index +scan on staff_booking_pkey being 676ms long.
+

+
The only postgresql.conf parameters changed from the default are:
+

+
shared_buffers = 3000   
+
sort_mem = 4096
+
effective_cache_size = 15000
+
default_statistics_target = 100
+

+
There was no disk IO (above the small background IO) during the final run of the query +as reported by vmstat (Task Mangler on Windows).
+

+
+
SELECT B.CONTRACT_ID,SUM(R.DURATION+1)/60.0 AS SUMDUR FROM +SEARCH_REQT_RESULT TSR
+
JOIN STAFF_BOOKING B ON (B.STAFF_ID = TSR.STAFF_ID)
+
JOIN ORDER_REQT R ON (R.REQT_ID = B.REQT_ID)
+
JOIN BOOKING_PLAN BP ON (BP.BOOKING_ID = B.BOOKING_ID) AND +BP.BOOKING_DATE BETWEEN '2004-04-12' AND '2004-04-18' AND +TSR.SEARCH_ID = 8 GROUP BY B.CONTRACT_ID
+

+
+
QUERY PLAN
+
HashAggregate  (cost=11205.80..11209.81 rows=401 width=6) (actual +time=1179.729..1179.980 rows=50 loops=1)
+
  ->  Nested Loop  (cost=326.47..11203.79 rows=401 width=6) (actual +time=39.700..1177.149 rows=652 loops=1)
+
        ->  Hash Join  (cost=326.47..9990.37 rows=401 width=8) +(actual +time=39.537..1154.807 rows=652 loops=1)
+
              Hash Cond: ("outer".staff_id += "inner".staff_id)
+
              ->  Merge Join  +(cost=320.39..9885.06 rows=3809 width=12) (actual +time=38.316..1143.953 rows=4079 loops=1)
+
                    +Merge Cond: ("outer".booking_id = "inner".booking_id)
+
                    +->  Index Scan using staff_booking_pkey on staff_booking b +(cost=0.00..8951.94 rows=222612 width=16) (actual time=0.218..676.219 rows=222609 +loops=1)
+
                    +->  Sort  (cost=320.39..329.91 rows=3808 width=4) (actual +time=26.225..32.754 rows=4079 loops=1)
+
                          +Sort Key: bp.booking_id
+
                          +->  Index Scan using booking_plan_idx2 on booking_plan bp +(cost=0.00..93.92 rows=3808 width=4) (actual time=0.223..14.186 rows=4079 loops=1)
+
                                +Index Cond: ((booking_date >= '2004-04-12'::date) AND +(booking_date <= '2004-04-18'::date))
+
              ->  Hash  (cost=5.59..5.59 +rows=193 width=4) (actual time=1.139..1.139 +rows=0 loops=1)
+
                    +->  Index Scan using fk_idx_search_reqt_result on search_reqt_result tsr +(cost=0.00..5.59 rows=193 width=4) (actual time=0.213..0.764 rows=192 loops=1)
+
                          +Index Cond: (search_id = 8)
+
        ->  Index Scan using order_reqt_pkey on order_reqt r  +(cost=0.00..3.01 rows=1 +width=6) (actual time=0.023..0.025 rows=1 loops=652)
+
              Index Cond: (r.reqt_id = "outer".reqt_id)
+
Total runtime: 1181.239 ms
+

+
+

+
+
Cheers,
+
Gary.
+ + + +--Alt-Boundary-23407.356125551-- + +From pgsql-performance-owner@postgresql.org Thu Apr 29 20:01:02 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2A5E1D1E7C0 + for ; + Thu, 29 Apr 2004 20:01:00 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 17063-10 + for ; + Thu, 29 Apr 2004 20:00:42 -0300 (ADT) +Received: from gpdnet.co.uk (gpdnet.plus.com [212.56.100.243]) + by svr1.postgresql.org (Postfix) with ESMTP id 351EAD1E321 + for ; + Thu, 29 Apr 2004 20:00:38 -0300 (ADT) +Received: from gary (unverified [192.168.1.2]) + by gpdnet.co.uk (SurgeMail 1.8g3) with ESMTP id 268 + for ; Fri, 30 Apr 2004 00:00:08 +0100 +From: "Gary Doades" +To: pgsql-performance@postgresql.org +Date: Fri, 30 Apr 2004 00:01:10 +0100 +MIME-Version: 1.0 +Subject: Re: planner/optimizer question +Message-ID: <40919746.25550.1555A9CC@localhost> +X-mailer: Pegasus Mail for Windows (v4.12a) +Content-type: text/plain; charset=US-ASCII +Content-transfer-encoding: 7BIT +Content-description: Mail message body +X-Server: High Performance Mail Server - http://surgemail.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/510 +X-Sequence-Number: 6810 + +> +> Having picked out an index scan as being the highest time user I +> concentrated on that in this case and compared the same index scan on +> MSSQL. At least MSSQL reported it as an index scan on the same index +> for the same number of rows. +> + +I should have also pointed out that MSSQL reported that same index scan as taking 65% of the overall query time. +It was just "faster". The overall query took 103ms in MSSQL. + +Gary. + + +From pgsql-performance-owner@postgresql.org Thu Apr 29 20:15:31 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 51058D1E155 + for ; + Thu, 29 Apr 2004 20:15:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 26790-05 + for ; + Thu, 29 Apr 2004 20:15:07 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id DD98ED1E607 + for ; + Thu, 29 Apr 2004 20:15:04 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i3TNF3T3050408 + for ; Thu, 29 Apr 2004 23:15:04 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i3TN8MwP045235 + for pgsql-performance@postgresql.org; Thu, 29 Apr 2004 23:08:22 GMT +From: Joseph Shraibman +X-Newsgroups: comp.databases.postgresql.performance +Subject: Insert only tables and vacuum performance +Date: Thu, 29 Apr 2004 19:08:23 -0400 +Organization: Hub.Org Networking Services +Lines: 7 +Message-ID: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7b) Gecko/20040421 +X-Accept-Language: en-us, en +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/512 +X-Sequence-Number: 6812 + +I have a table that is never updated, only INSERTED into. Is there a way +I can prevent vacuum wasting time on this table besides vacuuming each +table in the db by itself and omitting this table? + +How feasable would it be to have a marker somewhere in pg that is +"updated since last vacuum" that would be cleared when vacuum runs, and +if set vacuum will ignore that table? + +From pgsql-performance-owner@postgresql.org Thu Apr 29 20:15:29 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4C982D1C50D + for ; + Thu, 29 Apr 2004 20:15:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 29982-01 + for ; + Thu, 29 Apr 2004 20:15:07 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id B0AFDD1E5FC + for ; + Thu, 29 Apr 2004 20:15:04 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i3TNF3T1050408 + for ; Thu, 29 Apr 2004 23:15:04 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i3TN954J045921 + for pgsql-performance@postgresql.org; Thu, 29 Apr 2004 23:09:05 GMT +From: Joseph Shraibman +X-Newsgroups: comp.databases.postgresql.performance +Subject: analyzer/planner and clustered rows +Date: Thu, 29 Apr 2004 19:09:09 -0400 +Organization: Hub.Org Networking Services +Lines: 4 +Message-ID: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7b) Gecko/20040421 +X-Accept-Language: en-us, en +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/511 +X-Sequence-Number: 6811 + +How does the analyzer/planner deal with rows clustered together? Does +it just assume that if this col is clustered on then the actual data +will be clustered? What if the data in the table happens to be close +together because it was inserted together originally? + +From pgsql-performance-owner@postgresql.org Thu Apr 29 20:18:15 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5D5F9D1E73F + for ; + Thu, 29 Apr 2004 20:18:11 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 29982-02 + for ; + Thu, 29 Apr 2004 20:17:53 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 5FE8AD1B43A + for ; + Thu, 29 Apr 2004 20:17:50 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3TNHoSJ017899; + Thu, 29 Apr 2004 19:17:50 -0400 (EDT) +To: josh@agliodbs.com +Cc: "Gary Doades" , + pgsql-performance@postgresql.org +Subject: Re: planner/optimizer question +In-reply-to: <200404291354.33304.josh@agliodbs.com> +References: <409153EF.24647.144E9BF7@localhost> + <409172FA.1509.14C7E00E@localhost> + <200404291354.33304.josh@agliodbs.com> +Comments: In-reply-to Josh Berkus + message dated "Thu, 29 Apr 2004 13:54:33 -0700" +Date: Thu, 29 Apr 2004 19:17:49 -0400 +Message-ID: <17898.1083280669@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/513 +X-Sequence-Number: 6813 + +Josh Berkus writes: +> Certainly the fact that MSSQL is essentially a single-user database makes +> things easier for them. + +Our recent testing (cf the "Xeon" thread) says that the interlocking we +do to make the world safe for multiple backends has a fairly high cost +(at least on some hardware) compared to the rest of the work in +scenarios where you are doing zero-I/O scans of data already in memory. +Especially so for index scans. I'm not sure this completely explains +the differential that Gary is complaining about, but it could be part of +it. Is it really true that MSSQL doesn't support concurrent operations? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Apr 29 20:45:28 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 10706D1E2A0 + for ; + Thu, 29 Apr 2004 20:45:24 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 33783-10 + for ; + Thu, 29 Apr 2004 20:45:05 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id D449BD1E31C + for ; + Thu, 29 Apr 2004 20:45:02 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i3TNj2Sx097842 + for ; Thu, 29 Apr 2004 23:45:02 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i3TNJ7rt054355 + for pgsql-performance@postgresql.org; Thu, 29 Apr 2004 23:19:07 GMT +From: Joseph Shraibman +X-Newsgroups: comp.databases.postgresql.performance +Subject: why can't 2 indexes be used at once? +Date: Thu, 29 Apr 2004 19:19:09 -0400 +Organization: Hub.Org Networking Services +Lines: 12 +Message-ID: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7b) Gecko/20040421 +X-Accept-Language: en-us, en +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/515 +X-Sequence-Number: 6815 + +Lets say I have two columns, A and B. They are each indexed seperately. + If I do a query like: +SELECT * FROM table WHERE A = 1 AND B = 2; +postgres can only use one index. + +I assume that postgres uses the index data to narrow down pages in the +table to visit when doing its search. Then it goes through and filters +on the second condition. + +My question: why can't it go through the first index, get a list of +pages in the table, then go through the second index, union the result +with the results from first index, and then go into the table? + +From pgsql-performance-owner@postgresql.org Thu Apr 29 20:45:26 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E325AD1CAA7 + for ; + Thu, 29 Apr 2004 20:45:23 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 39487-02 + for ; + Thu, 29 Apr 2004 20:45:05 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id D4F8DD1E350 + for ; + Thu, 29 Apr 2004 20:45:02 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i3TNj2T1097842 + for ; Thu, 29 Apr 2004 23:45:02 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i3TNObQK063246 + for pgsql-performance@postgresql.org; Thu, 29 Apr 2004 23:24:37 GMT +From: Joseph Shraibman +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Insert only tables and vacuum performance +Date: Thu, 29 Apr 2004 19:24:40 -0400 +Organization: Hub.Org Networking Services +Lines: 13 +Message-ID: +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7b) Gecko/20040421 +X-Accept-Language: en-us, en +In-Reply-To: +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/514 +X-Sequence-Number: 6814 + +Joseph Shraibman wrote: +> I have a table that is never updated, only INSERTED into. Is there a way +> I can prevent vacuum wasting time on this table besides vacuuming each +> table in the db by itself and omitting this table? +> +> How feasable would it be to have a marker somewhere in pg that is +> "updated since last vacuum" that would be cleared when vacuum runs, and +> if set vacuum will ignore that table? + +Or even better an offset into the datatable for the earliest deleted +row, so if you have a table where you update the row shortly after +insert and then never touch it vacuum can skip most of the table +(inserts are done at the end of the table, right?) + +From pgsql-performance-owner@postgresql.org Thu Apr 29 21:45:23 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 17F9ED1DF83 + for ; + Thu, 29 Apr 2004 21:45:21 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 54734-07 + for ; + Thu, 29 Apr 2004 21:45:02 -0300 (ADT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 59532D1B4E0 + for ; + Thu, 29 Apr 2004 21:44:58 -0300 (ADT) +Received: from [134.22.68.249] (dyn-68-249.tor.dsl.tht.net [134.22.68.249]) + by tht.net (Postfix) with ESMTP + id DB30276A69; Thu, 29 Apr 2004 20:45:03 -0400 (EDT) +Subject: Re: Insert only tables and vacuum performance +From: Rod Taylor +To: Joseph Shraibman +Cc: Postgresql Performance +In-Reply-To: +References: +Content-Type: text/plain +Message-Id: <1083285855.30065.462.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Thu, 29 Apr 2004 20:44:16 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/516 +X-Sequence-Number: 6816 + +> Or even better an offset into the datatable for the earliest deleted +> row, so if you have a table where you update the row shortly after +> insert and then never touch it vacuum can skip most of the table +> (inserts are done at the end of the table, right?) + +Inserts are done at the end of the table as a last resort. But anyway, +how do you handle a rolled back insert? + + + +From pgsql-performance-owner@postgresql.org Thu Apr 29 21:53:46 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 94F36D1DF83 + for ; + Thu, 29 Apr 2004 21:53:44 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 57460-07 + for ; + Thu, 29 Apr 2004 21:53:22 -0300 (ADT) +Received: from tupari.net (node-40242ac2.lga.onnet.us.uu.net [64.36.42.194]) + by svr1.postgresql.org (Postfix) with ESMTP id A7AA0D1CAA9 + for ; + Thu, 29 Apr 2004 21:53:18 -0300 (ADT) +Received: from selectacast.net ([192.168.0.2]) + by tupari.net (8.12.8/8.12.8) with ESMTP id i3U0rLCE028271; + Thu, 29 Apr 2004 20:53:22 -0400 +Message-ID: <4091A381.3020307@selectacast.net> +Date: Thu, 29 Apr 2004 20:53:21 -0400 +From: Joseph Shraibman +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7b) Gecko/20040421 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Rod Taylor +Cc: Postgresql Performance +Subject: Re: Insert only tables and vacuum performance +References: + <1083285855.30065.462.camel@jester> +In-Reply-To: <1083285855.30065.462.camel@jester> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/517 +X-Sequence-Number: 6817 + +Rod Taylor wrote: +>>Or even better an offset into the datatable for the earliest deleted +>>row, so if you have a table where you update the row shortly after +>>insert and then never touch it vacuum can skip most of the table +>>(inserts are done at the end of the table, right?) +> +> +> Inserts are done at the end of the table as a last resort. + +But if most of the table is never updated then the inserts would tend to +be at the end, right? + +> But anyway, +> how do you handle a rolled back insert? +> +It is considered like a deleted row to be vacuumed. + +From pgsql-performance-owner@postgresql.org Fri Apr 30 00:58:12 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E1396D1CA4D + for ; + Fri, 30 Apr 2004 00:58:10 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 14374-03 + for ; + Fri, 30 Apr 2004 00:57:50 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 2C5A6D1E5F1 + for ; + Fri, 30 Apr 2004 00:57:50 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3U3vni0020260; + Thu, 29 Apr 2004 23:57:50 -0400 (EDT) +To: Joseph Shraibman +Cc: pgsql-performance@postgresql.org +Subject: Re: why can't 2 indexes be used at once? +In-reply-to: +References: +Comments: In-reply-to Joseph Shraibman + message dated "Thu, 29 Apr 2004 19:19:09 -0400" +Date: Thu, 29 Apr 2004 23:57:49 -0400 +Message-ID: <20259.1083297469@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/518 +X-Sequence-Number: 6818 + +Joseph Shraibman writes: +> My question: why can't it go through the first index, get a list of +> pages in the table, then go through the second index, union the result +> with the results from first index, and then go into the table? + +See TODO list ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Apr 30 01:30:49 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1E662D1E5EE + for ; + Fri, 30 Apr 2004 01:30:48 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 21470-07 + for ; + Fri, 30 Apr 2004 01:30:28 -0300 (ADT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 2B52ED1DC9D + for ; + Fri, 30 Apr 2004 01:30:27 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3U4URcg020620; + Fri, 30 Apr 2004 00:30:27 -0400 (EDT) +To: Joseph Shraibman +Cc: pgsql-performance@postgresql.org +Subject: Re: Insert only tables and vacuum performance +In-reply-to: +References: +Comments: In-reply-to Joseph Shraibman + message dated "Thu, 29 Apr 2004 19:08:23 -0400" +Date: Fri, 30 Apr 2004 00:30:26 -0400 +Message-ID: <20619.1083299426@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/519 +X-Sequence-Number: 6819 + +Joseph Shraibman writes: +> I have a table that is never updated, only INSERTED into. Is there a way +> I can prevent vacuum wasting time on this table + +What makes you think vacuum is wasting much time on this table? AFAICS +it will only update any unfixed hint bits ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Apr 30 02:27:21 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D9C6DD1DAC4 + for ; + Fri, 30 Apr 2004 02:27:20 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 38484-07 + for ; + Fri, 30 Apr 2004 02:27:01 -0300 (ADT) +Received: from zigo.dhs.org (as2-4-3.an.g.bonet.se [194.236.34.191]) + by svr1.postgresql.org (Postfix) with ESMTP id F0DDFD1DF8B + for ; + Fri, 30 Apr 2004 02:26:59 -0300 (ADT) +Received: from zigo.zigo.dhs.org (zigo.zigo.dhs.org [192.168.0.1]) + by zigo.dhs.org (Postfix) with ESMTP + id 6CCB780DB; Fri, 30 Apr 2004 07:26:59 +0200 (CEST) +Date: Fri, 30 Apr 2004 07:26:59 +0200 (CEST) +From: Dennis Bjorklund +To: Gary Doades +Cc: pgsql-performance@postgresql.org +Subject: Re: planner/optimizer question +In-Reply-To: <40919746.25550.1555A9CC@localhost> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=ISO-8859-1 +Content-Transfer-Encoding: 8BIT +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/520 +X-Sequence-Number: 6820 + +On Fri, 30 Apr 2004, Gary Doades wrote: + +> I should have also pointed out that MSSQL reported that same index scan +> as taking 65% of the overall query time. It was just "faster". The +> overall query took 103ms in MSSQL. + +Are your results based on a single client accessing the database and no +concurrent updates? + +Would adding more clients, and maybe having some client that +updates/inserts into the tables, still make mssql faster then pg? Maybe +it's so simple as pg being optimized for more concurrent users then mssql? + +I'm just asking, I don't know much about the inner workings of +mssql. + +-- +/Dennis Bj�rklund + + +From pgsql-sql-owner@postgresql.org Fri Apr 30 03:45:58 2004 +X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A57FED1DAC4 + for ; + Fri, 30 Apr 2004 03:45:57 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 57814-09 + for ; + Fri, 30 Apr 2004 03:45:37 -0300 (ADT) +Received: from matrix.gatewaynet.com (matrix.gatewaynet.com [217.19.69.50]) + by svr1.postgresql.org (Postfix) with ESMTP id CCCE6D1CA39 + for ; Fri, 30 Apr 2004 03:45:34 -0300 (ADT) +Received: from matrix.gatewaynet.com (localhost.localdomain [127.0.0.1]) + by matrix.gatewaynet.com (8.12.8/8.12.8) with ESMTP id i3U5ngFr002040; + Fri, 30 Apr 2004 08:49:42 +0300 +Received: from localhost (achill@localhost) + by matrix.gatewaynet.com (8.12.8/8.12.8/Submit) with ESMTP id + i3U5nfJV002036; Fri, 30 Apr 2004 08:49:41 +0300 +Date: Fri, 30 Apr 2004 08:49:41 +0300 (EEST) +From: Achilleus Mantzios +To: Josh Berkus +Cc: Roelant Ossewaarde , +Subject: Re: Use arrays or not? +In-Reply-To: <200404291023.58712.josh@agliodbs.com> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/331 +X-Sequence-Number: 17706 + + +Just some comments from my experience: + +PgSQL Arrays are mainly for modeling arrays not relations. +Arrays can be very useful if they are not ever gonna be treated +as relations and if performance is an issue (e.g. dynamic graphs, on the +fly statistics etc..). + +Also (besides other solutions) int[] arrays is a handy way of implementing +tree structures in a database. + +For your case as you set it the XML arrays will make your life difficult. + +O kyrios Josh Berkus egrapse stis Apr 29, 2004 : + +> Roelant, +> +> Yours is not a performance question, so I'm crossing it over to SQL for advice +> on database design. +> +> > I am building an application using postgresql to store XML-records. There +> > is a debate within the group of developers about the best way to store our +> > data. I hope you can help us make a decision. +> > +> > The data consists of XML-records, with a lot of XML-fields. I want to store +> > the XML as it is, so taking the information from the XML-records and then +> > storing it in a different-from-XML-format is not an option. +> > +> > Each XML-record describes data about one book. If an update of bookdata +> > comes, the XML itself is not changed, but a new XML-record is stored with +> > the updated data. Via a complex scheme of combining a base record and its +> > updates, the final dataset is produced that is used in the application. +> > +> > There are different XML-formats that need to be combined. Right now, we can +> > handle three different XML-formats, each with its own structure (but all +> > describing book-data). +> > +> > Searching is done via a simple table lookup on three different fields: +> > title, author and subject. The data for these fields is extracted from the +> > database. Each book has a unique identifier (EAN13, derivative of ISBN). +> > +> > Here is one way to organize the database: +> > table title: +> > TITLE | EAN13, indexing on TITLE +> > +> > table author: +> > AUTHOR | EAN13, indexing on AUTHOR +> > +> > table subject: +> > SUBJECT | EAN13, indexing on SUBJECT. +> +> This is a *very* strange way of setting up your database. Are you new to +> Relational Databases and SQL? If so, I'd recommend starting with a book on +> relational database design. +> +> Either that, or you're a victim of UML design. +> +> If only one author, title and subject are allowed per book, you should have: +> +> table books +> EAN13 | TITLE | AUTHOR | SUBJECT +> +> > Finally: +> > table record: +> > EAN13 | ARRAY OF XML-records. +> > +> > It's the last table that I am most curious (and worried) about, the +> > question being mainly what the optimal way of structuring that table is. +> > Option 1 is the given option: adding/deleting an XML-record for the same +> > book requires adding/deleting it to/from the array of XML-records. +> > +> > Option 2 would be something like this: +> > EAN13 | XML-record +> > where, if a book has several records describing it, there are multiple +> > entries of the EAN13|XML-record - pair. Adding an XML-record for the same +> > book, requires adding a new entry to the table as a whole. +> +> In my mind, there is no question that this is the best way to do things. It +> is a normalized data structure, as opposed to the arrays, which are now. +> +> > +> > So, option 1-tables look like this: +> > EAN13 | ARRAY OF XML-records +> > 0001 | {..., ..., ...} +> > 0002 | {..., ..., ...} +> > +> > Option-2 tables look like this: +> > EAN13 | ARRAY OF XML-records +> > 0001 | ... +> > 0001 | ... +> > 0002 | ... +> > 0002 | ... +> > +> > We can't decide which one is best. These are some issues we can think of: +> > +> > Indexing: For option 1, the EAN13-index remains unique, even if you have +> > multiple XML-records; for option 2 it does not, since multiple XML-records +> > are stored as multiple tuples. On the other hand, an additional internal +> > index can be used to link the several tuples of option 2 to the information +> > in the `lookup'-tables (author, title, keyword). Does any of these two +> > options increase query efficiency, ie. speed? +> > +> > Database growth: On average, the information about a book is updated three +> > times per year. In option 1, this means that the length of the table does +> > not increase, but the width does. If we choose option 2, if we have three +> > updates per book each year, the length of the table triples, but the width +> > does not. What is more costly to store for postgres, long arrays or long +> > tables? +> > +> > Integrity: Option 1 means that our software needs to keep track of all the +> > bookkeeping for arrays, since such support is quite rudimentary in +> > postgres. For example, it is hard to take out a record from the middle of +> > an array. Also, a multidimensional array, which contains for each record +> > the record itself and its type, is even harder to maintain. Option 2 has a +> > simpler datatype, so integrity can be easier inforced using the standard +> > postgres-machinery of variable-types etc. +> > +> > Arrays are non-standard SQL, and I hear that PHP-support for postgres & +> > arrays is rudimentary. So that might be an argument to avoid using them, +> > and go for option 2. From the standpoint of performance (or wisdom), can +> > you help me decide what I should choose? Or is there maybe an even better +> > way to structure my data? +> > +> > Thanks for any contribution! +> > +> > Roelant. +> +> +> + +-- +-Achilleus + + +From pgsql-performance-owner@postgresql.org Fri Apr 30 02:58:08 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 79E21D1DC64 + for ; + Fri, 30 Apr 2004 02:58:07 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 50644-01 + for ; + Fri, 30 Apr 2004 02:57:46 -0300 (ADT) +Received: from tupari.net (node-40242ac2.lga.onnet.us.uu.net [64.36.42.194]) + by svr1.postgresql.org (Postfix) with ESMTP id 3C839D1E60E + for ; + Fri, 30 Apr 2004 02:57:45 -0300 (ADT) +Received: from selectacast.net ([192.168.0.2]) + by tupari.net (8.12.8/8.12.8) with ESMTP id i3U5viCE028467; + Fri, 30 Apr 2004 01:57:45 -0400 +Message-ID: <4091EAD8.4020503@selectacast.net> +Date: Fri, 30 Apr 2004 01:57:44 -0400 +From: Joseph Shraibman +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7b) Gecko/20040421 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane , pgsql-performance@postgresql.org +Subject: Re: Insert only tables and vacuum performance +References: <20619.1083299426@sss.pgh.pa.us> +In-Reply-To: <20619.1083299426@sss.pgh.pa.us> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/521 +X-Sequence-Number: 6821 + +Tom Lane wrote: +> Joseph Shraibman writes: +> +>>I have a table that is never updated, only INSERTED into. Is there a way +>>I can prevent vacuum wasting time on this table +> +> +> What makes you think vacuum is wasting much time on this table? AFAICS +> it will only update any unfixed hint bits ... +> +> regards, tom lane + +INFO: "elog": found 0 removable, 12869411 nonremovable row versions in +196195 pages +DETAIL: 0 dead row versions cannot be removed yet. +There were 5 unused item pointers. +0 pages are entirely empty. +CPU 31.61s/4.53u sec elapsed 1096.83 sec. + +It took 1096.83 seconds, and what did it accomplish? And what are hint +bits? + +From pgsql-performance-owner@postgresql.org Fri Apr 30 03:34:47 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D79ABD1CAB1 + for ; + Fri, 30 Apr 2004 03:34:45 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 55501-06 + for ; + Fri, 30 Apr 2004 03:34:26 -0300 (ADT) +Received: from gpdnet.co.uk (gpdnet.plus.com [212.56.100.243]) + by svr1.postgresql.org (Postfix) with ESMTP id EBC7DD1CA4F + for ; + Fri, 30 Apr 2004 03:34:23 -0300 (ADT) +Received: from gary (unverified [192.168.1.2]) + by gpdnet.co.uk (SurgeMail 1.8g3) with ESMTP id 326 + for ; Fri, 30 Apr 2004 07:33:52 +0100 +From: "Gary Doades" +To: pgsql-performance@postgresql.org +Date: Fri, 30 Apr 2004 07:33:11 +0100 +MIME-Version: 1.0 +Subject: Re: planner/optimizer question +Message-ID: <40920137.13806.16F37CC5@localhost> +In-reply-to: <17898.1083280669@sss.pgh.pa.us> +References: <200404291354.33304.josh@agliodbs.com> +X-mailer: Pegasus Mail for Windows (v4.12a) +Content-type: text/plain; charset=US-ASCII +Content-transfer-encoding: 7BIT +Content-description: Mail message body +X-Server: High Performance Mail Server - http://surgemail.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/522 +X-Sequence-Number: 6822 + +On 29 Apr 2004 at 19:17, Tom Lane wrote: + +> Josh Berkus writes: +> > Certainly the fact that MSSQL is essentially a single-user database makes +> > things easier for them. +> +> Our recent testing (cf the "Xeon" thread) says that the interlocking we +> do to make the world safe for multiple backends has a fairly high cost +> (at least on some hardware) compared to the rest of the work in +> scenarios where you are doing zero-I/O scans of data already in memory. +> Especially so for index scans. I'm not sure this completely explains +> the differential that Gary is complaining about, but it could be part of +> it. Is it really true that MSSQL doesn't support concurrent operations? +> +> regards, tom lane + +As far as I am aware SQLSever supports concurrent operations. It +certainly creates more threads for each connection. None of my +observations of the system under load (50 ish concurrent users, 150 ish +connections) suggest that it is serializing queries. + +These tests are currentl on single processor Athlon XP 2000+ systems. + +Regards, +Gary. + +From pgsql-performance-owner@postgresql.org Fri Apr 30 04:01:15 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4E382D1E5C5 + for ; + Fri, 30 Apr 2004 04:01:14 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 66568-02 + for ; + Fri, 30 Apr 2004 04:00:55 -0300 (ADT) +Received: from gpdnet.co.uk (gpdnet.plus.com [212.56.100.243]) + by svr1.postgresql.org (Postfix) with ESMTP id 964D7D1E3DF + for ; + Fri, 30 Apr 2004 04:00:52 -0300 (ADT) +Received: from gary (unverified [192.168.1.2]) + by gpdnet.co.uk (SurgeMail 1.8g3) with ESMTP id 330 + for ; Fri, 30 Apr 2004 08:00:22 +0100 +From: "Gary Doades" +To: pgsql-performance@postgresql.org +Date: Fri, 30 Apr 2004 08:01:26 +0100 +MIME-Version: 1.0 +Subject: Re: planner/optimizer question +Message-ID: <409207D6.17204.170D5A52@localhost> +In-reply-to: +References: <40919746.25550.1555A9CC@localhost> +X-mailer: Pegasus Mail for Windows (v4.12a) +Content-type: text/plain; charset=ISO-8859-1 +Content-transfer-encoding: Quoted-printable +Content-description: Mail message body +X-Server: High Performance Mail Server - http://surgemail.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/523 +X-Sequence-Number: 6823 + +On 30 Apr 2004 at 7:26, Dennis Bjorklund wrote: + +> On Fri, 30 Apr 2004, Gary Doades wrote: +> +> > I should have also pointed out that MSSQL reported that same index scan +> > as taking 65% of the overall query time. It was just "faster". The +> > overall query took 103ms in MSSQL. +> +> Are your results based on a single client accessing the database and no +> concurrent updates? +> +> Would adding more clients, and maybe having some client that +> updates/inserts into the tables, still make mssql faster then pg? Maybe +> it's so simple as pg being optimized for more concurrent users then mssql? +> +> I'm just asking, I don't know much about the inner workings of +> mssql. +> +> -- +> /Dennis Bj=F6rklund +> + +At the moment it is difficult to set up many clients for testing concurrent +stuff. In the past I have had several SQLServer clients under test, +mainly select queries. MSSQL can certainly execute queries while other +queries are still running in the background. + +Our production app is fairly well biased towards selects. Currently it is +about 70% selects, 20% inserts, 6% deletes and 4% updates. Very few +updates are more than one row based on the primary key. Over 90% of +the time spend running SQL is in select queries. + +My limited concurrent testing on Postgres gives very good performance +on updates, inserts, deletes, but it is suffering on the selects in certain +areas which why I have been concentrating my efforts on that area. + +Having got similar (or the same) access plans in both Postgres and +MSSQL I was getting down to the next level of checking what was going +on when executing the already planned query. + +I do have another database system I could try. Sybase SQLAnywhere. +This is not the original Sybase Entrerprise which has the same roots as +MSSQL. In the past my testing suggested that SQLAnywhere +performance was as godd or better than MSSQL. I mey try to set it up +with the same data in these tests for a more detailed comparison. + +Regards, +Gary. + + +From pgsql-performance-owner@postgresql.org Fri Apr 30 04:31:00 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C4345D1E6B4 + for ; + Fri, 30 Apr 2004 04:30:59 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 74171-05 + for ; + Fri, 30 Apr 2004 04:30:39 -0300 (ADT) +Received: from email10.aon.at (WARSL402PIP8.highway.telekom.at [195.3.96.97]) + by svr1.postgresql.org (Postfix) with SMTP id 9A8E9D1E5D3 + for ; + Fri, 30 Apr 2004 04:30:37 -0300 (ADT) +Received: (qmail 227216 invoked from network); 30 Apr 2004 07:30:38 -0000 +Received: from m154p027.dipool.highway.telekom.at (HELO PASCAL) ([62.46.9.59]) + (envelope-sender ) + by qmail1rs.highway.telekom.at (qmail-ldap-1.03) with SMTP + for ; 30 Apr 2004 07:30:38 -0000 +From: Manfred Koizar +To: Joseph Shraibman +Cc: pgsql-performance@postgresql.org +Subject: Re: analyzer/planner and clustered rows +Date: Fri, 30 Apr 2004 09:33:13 +0200 +Message-ID: +References: +In-Reply-To: +X-Mailer: Forte Agent 2.0/32.652 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=4.5 tagged_above=0.0 required=5.0 tests=RCVD_IN_DSBL, + RCVD_IN_SORBS, RCVD_IN_SORBS_HTTP, RCVD_IN_SORBS_MISC, + RCVD_IN_SORBS_SOCKS +X-Spam-Level: **** +X-Archive-Number: 200404/524 +X-Sequence-Number: 6824 + +On Thu, 29 Apr 2004 19:09:09 -0400, Joseph Shraibman + wrote: +>How does the analyzer/planner deal with rows clustered together? + +There's a correlation value per column. Just try + + SELECT attname, correlation + FROM pg_stats + WHERE tablename = '...'; + +if you are interested. It indicates how well the hypothetical order of +tuples if sorted by that column corresponds to the physical order. +1.0 +is perfect correlation, 0.0 is totally chaotic, -1.0 means reverse +order. The optimizer is more willing to choose an index scan if +correlation for the first index column is near +/-1. + +> What if the data in the table happens to be close +>together because it was inserted together originally? + +Having equal values close to each other is not enough, the values should +be increasing, too. Compare + + 5 5 5 4 4 4 7 7 7 2 2 2 6 6 6 3 3 3 8 8 8 low correlation +and + 2 2 2 3 3 3 4 4 4 5 5 5 6 6 6 7 7 7 8 8 8 correlation = 1.0 + + +From pgsql-performance-owner@postgresql.org Fri Apr 30 09:32:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DBD13D1E74F + for ; + Fri, 30 Apr 2004 09:32:48 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 65805-10 + for ; + Fri, 30 Apr 2004 09:32:30 -0300 (ADT) +Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com + [24.128.241.68]) + by svr1.postgresql.org (Postfix) with SMTP id 6BEBED1D070 + for ; + Fri, 30 Apr 2004 09:32:26 -0300 (ADT) +Received: (qmail 35520 invoked from network); 30 Apr 2004 12:32:19 -0000 +Received: from localhost (HELO ?10.124.7.125?) (threshar@127.0.0.1) + by localhost with SMTP; 30 Apr 2004 12:32:19 -0000 +In-Reply-To: <409207D6.17204.170D5A52@localhost> +References: <40919746.25550.1555A9CC@localhost> + <409207D6.17204.170D5A52@localhost> +Mime-Version: 1.0 (Apple Message framework v613) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <69EF9EF2-9AA2-11D8-A4E1-000D9366F0C4@torgo.978.org> +Content-Transfer-Encoding: 7bit +Cc: pgsql-performance@postgresql.org +From: Jeff +Subject: Re: planner/optimizer question +Date: Fri, 30 Apr 2004 08:32:16 -0400 +To: "Gary Doades" +X-Mailer: Apple Mail (2.613) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=2.6 tagged_above=0.0 required=5.0 + tests=RCVD_IN_DYNABLOCK, RCVD_IN_SORBS +X-Spam-Level: ** +X-Archive-Number: 200404/525 +X-Sequence-Number: 6825 + + +On Apr 30, 2004, at 3:01 AM, Gary Doades wrote: + +[ pg query plan, etc ] + +I wonder if other parts of the plan are affecting the speed. + +I've recently run into a case where a merge join plan was chosen for +this query, which took 11 seconds to execute. Forcing it to pick a +nested loop join dropped it to 3. (Updating my +default_statistics_target to 500 caused the planner to choose nested +loop join) + +So, is the plan really the same? + + A better comparision query may be a simple "select a from mytable +where a between foo and bar" to get an index scan. In that case its a +straight up, vanilla index scan. Nothing else getting in the way. + +-- +Jeff Trout +http://www.jefftrout.com/ +http://www.stuarthamm.net/ + + +From pgsql-performance-owner@postgresql.org Tue May 4 01:24:48 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8D10CD1E153 + for ; + Fri, 30 Apr 2004 09:46:21 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 73309-05 + for ; + Fri, 30 Apr 2004 09:46:03 -0300 (ADT) +Received: from mwinf0102.wanadoo.fr (smtp1.wanadoo.fr [193.252.22.30]) + by svr1.postgresql.org (Postfix) with ESMTP id CEFDCD1E74D + for ; + Fri, 30 Apr 2004 09:45:58 -0300 (ADT) +Received: from [192.168.0.2] (AMontsouris-108-1-33-27.w81-49.abo.wanadoo.fr + [81.49.55.27]) + by mwinf0102.wanadoo.fr (SMTP Server) with ESMTP id 8E8DC1BE7A1E + for ; + Fri, 30 Apr 2004 14:45:58 +0200 (CEST) +Mime-Version: 1.0 (Apple Message framework v613) +In-Reply-To: <40615443.4030003@paradise.net.nz> +References: <200403231248.34425.darcy@wavefire.com> + <40615443.4030003@paradise.net.nz> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Message-Id: <52623D23-9AA4-11D8-9268-000A95DE2550@gdr-isis.enst.fr> +Content-Transfer-Encoding: quoted-printable +From: =?ISO-8859-1?Q?Pailloncy_Jean-G=E9rard?= +Subject: Re: Fwd: FreeBSD, PostgreSQL, semwait and sbwait! +Date: Fri, 30 Apr 2004 14:45:55 +0200 +To: pgsql-performance@postgresql.org +X-Mailer: Apple Mail (2.613) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200405/19 +X-Sequence-Number: 6850 + +Hello, + +>> We're having a substantial problem with our FreeBSD 5.2 database=20 +>> server +>> running PostgreSQL - it's getting a lot of traffic (figure about 3,000 +>> queries per second), but queries are slow, and it's seemingly waiting=20 +>> on +>> other things than CPU time +>> +> Could this be a 5.2 performance issue ? +> +> In spite of certain areas where the 5.x series performance is known to=20 +> be much better than 4.x (e.g networking), this may not be manifested=20 +> in practice for a complete application. +> (e.g. I am still running 4.9 as it outperformed 5.1 vastly for a ~100=20 +> database sessions running queries - note that I have not tried out=20 +> 5.2, so am happy to be corrected on this) +I found the same problem. + +I use OpenBSD 3.3, +On Pentium 2,4 GHz with 1 Gb RAM, RAID 10. +With PostgreSQL 7.4.1 with 32 Kb bock's size (to match ffs and raid=20 +block's size) +With pg_autovacuum daemon from Pg 7.5. + +I run a web indexer. +sd0 raid-1 with system pg-log and indexer-log +sd1 raid-10 with pg-data and indexer-data +The sd1 disk achives between 10 and 40 Mb/s on normal operation. + +When I get semwait in top, system waits ;-) +Not much disk activity. +Not much log in pg or indexer. +Just wait.... + +What can I do ? + + > sudo top -s1 -S -I +load averages: 4.45, 4.45, 3.86=20=20=20=20=20=20=20=20=20=20=20=20=20= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 + 11:25:52 +97 processes: 1 running, 96 idle +CPU states: 2.3% user, 0.0% nice, 3.8% system, 0.8% interrupt,=20 +93.1% idle +Memory: Real: 473M/803M act/tot Free: 201M Swap: 0K/3953M used/tot + + PID USERNAME PRI NICE SIZE RES STATE WAIT TIME CPU COMMAND + 2143 postgres -5 0 4008K 37M sleep biowai 1:02 1.81% postgres +28662 postgres 14 0 4060K 37M sleep semwai 0:59 1.17% postgres +25794 postgres 14 0 4072K 37M sleep semwai 1:30 0.93% postgres +23271 postgres -5 0 4060K 37M sleep biowai 1:13 0.29% postgres +14619 root 28 0 276K 844K run - 0:01 0.00% top + + > vmstat -w1 sd0 sd1 + r b w avm fre flt re pi po fr sr sd0 sd1 in sy cs=20 +us sy id + 0 4 0 527412 36288 1850 0 0 0 0 0 26 72 368 8190 588=20= +=20 +0 4 96 + 0 4 0 527420 36288 1856 0 0 0 0 0 0 86 356 8653 620=20= +=20 +2 2 97 + 0 4 0 527432 36280 1853 0 0 0 0 0 0 54 321 8318 458=20= +=20 +1 3 96 + 0 4 0 527436 36248 1864 0 0 0 0 0 0 77 358 8417 539=20= +=20 +1 2 97 + 0 4 0 522828 40932 2133 0 0 0 0 0 7 70 412 15665 724=20= +=20 +2 3 95 + 0 4 0 522896 40872 1891 0 0 0 0 0 15 72 340 9656 727=20= +=20 +3 5 92 + 0 4 0 522900 40872 1841 0 0 0 0 0 0 69 322 8308 536=20= +=20 +1 2 98 + 0 4 0 522920 40860 1846 0 0 0 0 0 1 69 327 8023 520=20= +=20 +2 2 97 + 0 4 0 522944 40848 1849 0 0 0 0 0 4 76 336 8035 567=20= +=20 +1 2 97 + 0 4 0 522960 40848 1843 0 0 0 0 0 0 77 331 14669 587=20= +=20 +3 2 95 + 0 4 0 522976 40836 1848 0 0 0 0 0 4 81 339 8384 581=20= +=20 +1 2 97 + 0 4 0 522980 40836 1841 0 0 0 0 0 3 65 320 8068 502=20= +=20 +1 4 95 + 0 4 0 523000 40824 1848 0 0 0 0 0 14 74 341 8226 564=20= +=20 +3 2 95 + 0 4 0 523020 40812 1844 0 0 0 0 0 0 67 317 7606 530=20= +=20 +2 1 97 + 1 4 0 523052 40796 1661 0 0 0 0 0 0 68 315 11603 493=20= +=20 +2 2 97 + 1 4 0 523056 40800 233 0 0 0 0 0 12 87 341 12550 609=20= +=20 +2 2 96 + 0 4 0 523076 40788 1845 0 0 0 0 0 0 82 334 12457 626=20= +=20 +2 2 96 + 0 4 0 523100 40776 1851 0 0 0 0 0 0 91 345 10914 623=20= +=20 +2 3 95 + 0 4 0 523120 40764 1845 0 0 0 0 0 0 92 343 19213 596=20= +=20 +1 5 95 + 0 4 0 523136 40752 1845 0 0 0 0 0 0 97 349 8659 605=20= +=20 +2 2 96 + 0 4 0 523144 40748 4501 0 0 0 0 0 32 78 385 15632 934=20 +25 12 64 + 0 4 0 523168 40728 1853 0 0 0 0 0 3 74 335 3965 531=20= +=20 +0 2 98 + + > ps -Upostgresql -Ostart | grep -v idle + PID STARTED TT STAT TIME COMMAND + 8267 10:53AM ?? Is 0:00.28 /usr/local/bin/pg_autovacuum -D -L=20 +/var/pgsql/autovacuum +23271 10:54AM ?? I 1:13.56 postmaster: dps dps 127.0.0.1 SELECT=20 +(postgres) +28662 10:55AM ?? I 0:59.98 postmaster: dps dps 127.0.0.1 SELECT=20 +(postgres) +25794 10:56AM ?? D 1:30.48 postmaster: dps dps 127.0.0.1 SELECT=20 +(postgres) + 2143 11:02AM ?? D 1:02.06 postmaster: dps dps 127.0.0.1 DELETE=20 +(postgres) +25904 10:52AM C0- I 0:00.07 /usr/local/bin/postmaster -D=20 +/var/pgsql (postgres) +10908 10:52AM C0- I 0:05.96 postmaster: stats collector process=20= +=20 + (postgres) + 7045 10:52AM C0- I 0:05.19 postmaster: stats buffer process=20=20= +=20=20 +(postgres) + + > grep -v -E '^#' /var/pgsql/postgresql.conf +tcpip_socket =3D true +max_connections =3D 100 +shared_buffers =3D 1024 # 32KB +max_fsm_pages =3D 1000000 # min max_fsm_relations*16, 6 bytes each +max_fsm_relations =3D 200 # min 100, ~50 bytes each +wal_buffers =3D 32 # min 4, 8KB each +checkpoint_segments =3D 16 # in logfile segments, min 1, 16MB each +commit_delay =3D 100 # range 0-100000, in microseconds +effective_cache_size =3D 4096 # 32KB each +random_page_cost =3D 3 +default_statistics_target =3D 200 # range 1-1000 +client_min_messages =3D notice # Values, in order of decreasing detail: +log_min_messages =3D log # Values, in order of decreasing detail: +log_min_duration_statement =3D 20000 # Log all statements whose +log_timestamp =3D true +stats_start_collector =3D true +stats_command_string =3D true +stats_block_level =3D true +stats_row_level =3D true +stats_reset_on_server_start =3D true +lc_messages =3D 'C' # locale for system error message=20 +strings +lc_monetary =3D 'C' # locale for monetary formatting +lc_numeric =3D 'C' # locale for number formatting +lc_time =3D 'C' # locale for time formatting +explain_pretty_print =3D true + + > sysctl -a | grep seminfo +kern.seminfo.semmni =3D 256 +kern.seminfo.semmns =3D 2048 +kern.seminfo.semmnu =3D 30 +kern.seminfo.semmsl =3D 60 +kern.seminfo.semopm =3D 100 +kern.seminfo.semume =3D 10 +kern.seminfo.semusz =3D 100 +kern.seminfo.semvmx =3D 32767 +kern.seminfo.semaem =3D 16384 + + > systat +vmstat + 7 users Load 3.48 3.64 3.56 Fri Apr 30=20 +14:42:18 2004 + + memory totals (in KB) PAGING SWAPPING=20=20=20=20= +=20 +Interrupts + real virtual free in out in out 361=20 +total +Active 514768 527436 36280 ops 100=20 +clock +All 992496 1005164 4071736 pages 128=20 +rtc + 45=20 +fxp0 +Proc:r d s w Csw Trp Sys Int Sof Flt 6 forks 88=20 +twe0 + 4 26 580 1848 8395 361 249 1856 6 fkppw + fksvm + 3.0% Sys 1.1% User 0.0% Nice 95.9% Idle pwait +| | | | | | | | | | | relck +=3D> rlkok + noram +Namei Sys-cache Proc-cache No-cache 80 ndcpy + Calls hits % hits % miss % 54 fltcp + 812 806 99 5 1 1 0 208 zfod + 95 cow +Discs cd0 sd0 sd1 sd2 fd0 128 fmin +seeks 6 82 170 ftarg +xfers 6 82 60208 itarg +Kbyte 47 2554 226 wired + sec 1.0 pdfre + + > tail -f /var/pgsql/log +2004-04-30 11:35:03 LOG: recycled transaction log file=20 +"000000C8000000CA" +2004-04-30 11:35:03 LOG: recycled transaction log file=20 +"000000C8000000CB" +2004-04-30 11:35:03 LOG: recycled transaction log file=20 +"000000C8000000CC" +2004-04-30 11:35:03 LOG: recycled transaction log file=20 +"000000C8000000BF" +2004-04-30 11:35:03 LOG: recycled transaction log file=20 +"000000C8000000C0" +2004-04-30 11:35:03 LOG: recycled transaction log file=20 +"000000C8000000C1" +2004-04-30 11:35:03 LOG: recycled transaction log file=20 +"000000C8000000C2" +2004-04-30 11:36:46 LOG: duration: 28284.360 ms statement: SELECT=20 +rec_id,url FROM url WHERE status > 300 AND status<>304 AND=20 +(referrer=3D'28615' OR referrer=3D'0') AND bad_since_time<1083317778 +2004-04-30 11:36:46 LOG: duration: 24918.201 ms statement: SELECT=20 +rec_id,url FROM url WHERE status > 300 AND status<>304 AND=20 +(referrer=3D'122879' OR referrer=3D'0') AND bad_since_time<1083317781 +2004-04-30 11:36:46 LOG: duration: 21173.427 ms statement: SELECT=20 +rec_id,url FROM url WHERE status > 300 AND status<>304 AND=20 +(referrer=3D'586182' OR referrer=3D'0') AND bad_since_time<1083317785 + + From PhpPgAdmin: Table url: Info +Row Performance +Sequential Index Rows +Scan Read Scan Fetch Insert Udate Delete +1 414173 85711 10963854 20431 8707 594 + +I/O Performance +Heap Index TOAST TOAST Index +Disk Cache % Disk Cache % Disk Cache % Disk Cache % +3298907 7790769 (70%) 200782 1274898 (86%) 0 0 (0%) 0 0=20=20=20= +=20=20 +(0%) + +Index Row Performance +Index Scan Read Fetch +url_bad_since_time 0 0 0 +url_crc 2924 131566 131566 +url_hops 0 0 0 +url_last_mod_time 0 0 0 +url_next_index_time 5 5120 5120 +url_pkey 9187 8980 8980 +url_referrer 4431 10753641 10753641 +url_seed 0 0 0 +url_serverid 0 0 0 +url_siteid 0 0 0 +url_status 0 0 0 +url_url 69164 64547 64547 + +Index I/O Performance +Index Disk Cache % +url_bad_since_time 7169 80280 (92%) +url_crc 9106 19200 (68%) +url_hops 9071 109864 (92%) +url_last_mod_time 5836 27887 (83%) +url_next_index_time 12004 109887 (90%) +url_pkey 7501 52825 (88%) +url_referrer 58765 97634 (62%) +url_seed 30293 88712 (75%) +url_serverid 8647 110078 (93%) +url_siteid 8888 109864 (93%) +url_status 7448 111250 (94%) +url_url 36054 357417 (91%) + + +Cordialement, +Jean-G=E9rard Pailloncy + + +From pgsql-performance-owner@postgresql.org Fri Apr 30 14:46:48 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id CA57ED1E8CB + for ; + Fri, 30 Apr 2004 14:46:45 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 85733-05 + for ; + Fri, 30 Apr 2004 14:46:24 -0300 (ADT) +Received: from mailhost2.tudelft.nl (mailhost2.tudelft.nl [130.161.180.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A0534D1BABD + for ; + Fri, 30 Apr 2004 14:46:22 -0300 (ADT) +Received: from localhost (localhost [127.0.0.1]) + by rav.antivirus (Postfix) with ESMTP id C640D17D93 + for ; + Fri, 30 Apr 2004 19:46:22 +0200 (MEST) +Received: from listserv.tudelft.nl (listserv.tudelft.nl [130.161.180.33]) + by mailhost2.tudelft.nl (Postfix) with ESMTP id A8C7017D8F + for ; + Fri, 30 Apr 2004 19:46:22 +0200 (MEST) +Received: from oli.tudelft.nl (jochemd.tnw-s.tudelft.nl [145.94.90.156]) + by listserv.tudelft.nl (8.12.10/8.12.8) with ESMTP id i3UHkMF7011958 + for ; + Fri, 30 Apr 2004 19:46:22 +0200 (MEST) +Message-ID: <409290F0.10509@oli.tudelft.nl> +Date: Fri, 30 Apr 2004 19:46:24 +0200 +From: Jochem van Dieten +Organization: OnLine Internet +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: planner/optimizer question +References: +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at tudelft.nl +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/526 +X-Sequence-Number: 6826 + +Manfred Koizar wrote: +> On Wed, 28 Apr 2004 09:05:04 -0400, Tom Lane wrote: +>>> [ ... visibility information in index tuples ... ] +>> +>> Storing that information would at least double the overhead space used +>> for each index tuple. The resulting index bloat would significantly +>> slow index operations by requiring more I/O. So it's far from clear +>> that this would be a win, even for those who care only about select +>> speed. +> +> While the storage overhead could be reduced to 1 bit (not a joke) + +You mean adding an isLossy bit and only where it is set the head +tuple has to be checked for visibility, if it is not set the head +tuple does not have to be checked? + + +> we'd +> still have the I/O overhead of locating and updating index tuples for +> every heap tuple deleted/updated. + +Would there be additional I/O for the additional bit in the index +tuple (I am unable to find the layout of index tuple headers in +the docs)? + +Jochem + +-- +I don't get it +immigrants don't work +and steal our jobs + - Loesje + + + +From pgsql-performance-owner@postgresql.org Fri Apr 30 15:29:32 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7583ED1E6C8 + for ; + Fri, 30 Apr 2004 15:29:31 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 99270-09 + for ; + Fri, 30 Apr 2004 15:29:12 -0300 (ADT) +Received: from gpdnet.co.uk (gpdnet.plus.com [212.56.100.243]) + by svr1.postgresql.org (Postfix) with ESMTP id A13C5D1E796 + for ; + Fri, 30 Apr 2004 15:29:09 -0300 (ADT) +Received: from gary (unverified [192.168.1.2]) + by gpdnet.co.uk (SurgeMail 1.8g3) with ESMTP id 422 + for ; Fri, 30 Apr 2004 19:28:39 +0100 +From: "Gary Doades" +To: pgsql-performance@postgresql.org +Date: Fri, 30 Apr 2004 19:29:44 +0100 +MIME-Version: 1.0 +Subject: Re: planner/optimizer question +Message-ID: <4092A928.27720.19838422@localhost> +In-reply-to: <69EF9EF2-9AA2-11D8-A4E1-000D9366F0C4@torgo.978.org> +References: <409207D6.17204.170D5A52@localhost> +X-mailer: Pegasus Mail for Windows (v4.12a) +Content-type: text/plain; charset=US-ASCII +Content-transfer-encoding: 7BIT +Content-description: Mail message body +X-Server: High Performance Mail Server - http://surgemail.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/527 +X-Sequence-Number: 6827 + +On 30 Apr 2004 at 8:32, Jeff wrote: +> +> A better comparision query may be a simple "select a from mytable +> where a between foo and bar" to get an index scan. In that case its a +> straight up, vanilla index scan. Nothing else getting in the way. +> + +Yes, you're right and I have done this just to prove to myself that it is the index scan that +is the bottleneck. I have some complex SQL that executes very quickly with Postgres, +similar to MSSQL, but the index scans in most of those only touch a few rows for a few +loops. It seems to be a problem when the index scan is scanning very many rows and +for each of these it has to go to the table just to find out if the index it just looked at is +still valid. + +Gary. + + +From pgsql-performance-owner@postgresql.org Fri Apr 30 15:59:26 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 38A4DD1CAA2 + for ; + Fri, 30 Apr 2004 15:59:23 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 17934-01 + for ; + Fri, 30 Apr 2004 15:59:03 -0300 (ADT) +Received: from gpdnet.co.uk (gpdnet.plus.com [212.56.100.243]) + by svr1.postgresql.org (Postfix) with ESMTP id 9BEB3D1E728 + for ; + Fri, 30 Apr 2004 15:59:01 -0300 (ADT) +Received: from gary (unverified [192.168.1.2]) + by gpdnet.co.uk (SurgeMail 1.8g3) with ESMTP id 424 + for ; Fri, 30 Apr 2004 19:58:33 +0100 +From: "Gary Doades" +To: pgsql-performance@postgresql.org +Date: Fri, 30 Apr 2004 19:59:38 +0100 +MIME-Version: 1.0 +Subject: Re: planner/optimizer question +Message-ID: <4092B02A.15469.199EE3DE@localhost> +In-reply-to: <409264C4.8060506@speedfc.com> +References: <40920137.13806.16F37CC5@localhost> +X-mailer: Pegasus Mail for Windows (v4.12a) +Content-type: text/plain; charset=US-ASCII +Content-transfer-encoding: 7BIT +Content-description: Mail message body +X-Server: High Performance Mail Server - http://surgemail.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/528 +X-Sequence-Number: 6828 + +On 30 Apr 2004 at 9:37, Kevin Barnard wrote: + +> +> I was always under the impression that MSSQL used leaf and row level locking and therefore +> was not a concurrent, in the same sense that postgres is, database. It would still allow for +> concurrent connections and such but updates will get blocked/ delayed. I might be wrong. +> + +Ultimately you may be right. I don't know enough about SQLServer +internals to say either way. Anyway, most of our system is in selects for +70% of the time. I could try and set up a test for this when I get a bit +more time. + +Unfortunately I suspect that this topic won't get taken much further. In +order to test this it would mean modifying quite a bit of code. Whether +putting additional info in the index header and not visiting the data row +if all the required data is in the index would be beneficial would require +quite a bit of work by someone who knows more than I do. I reckon that +no-one has the time to do this at the moment. + +Regards, +Gary. + + +From pgsql-performance-owner@postgresql.org Fri Apr 30 16:49:03 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6BEFFD1E796 + for ; + Fri, 30 Apr 2004 16:49:00 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 24604-09 + for ; + Fri, 30 Apr 2004 16:48:41 -0300 (ADT) +Received: from mail63.csoft.net (unknown [63.111.22.74]) + by svr1.postgresql.org (Postfix) with SMTP id 39478D1E835 + for ; + Fri, 30 Apr 2004 16:48:39 -0300 (ADT) +Received: (qmail 2506 invoked by uid 1112); 30 Apr 2004 19:48:32 -0000 +Date: Fri, 30 Apr 2004 14:48:32 -0500 (EST) +From: Kris Jurka +X-X-Sender: books@leary.csoft.net +To: Gary Doades +Cc: pgsql-performance@postgresql.org +Subject: Re: planner/optimizer question +In-Reply-To: <4092A928.27720.19838422@localhost> +Message-ID: +References: <409207D6.17204.170D5A52@localhost> + <4092A928.27720.19838422@localhost> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200404/529 +X-Sequence-Number: 6829 + + + +On Fri, 30 Apr 2004, Gary Doades wrote: + +> Yes, you're right and I have done this just to prove to myself that it +> is the index scan that is the bottleneck. I have some complex SQL that +> executes very quickly with Postgres, similar to MSSQL, but the index +> scans in most of those only touch a few rows for a few loops. It seems +> to be a problem when the index scan is scanning very many rows and for +> each of these it has to go to the table just to find out if the index it +> just looked at is still valid. +> + +Another way to speed this up is the TODO item: "Use bitmaps to fetch +heap pages in sequential order" For an indexscan that fetches a number +of rows those rows may be anywhere in the base table so as each index +entry is found it fetches the corresponding table row from the heap. This +is not ideal because you can be jumping around in the heap and end up +fetching the same page multiple times because table rows are in the same +page, but were found in different places in the index. + +Kris Jurka + +From pgsql-performance-owner@postgresql.org Fri Apr 30 18:34:52 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 199E6D1E70E + for ; + Fri, 30 Apr 2004 18:34:51 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 64926-08 + for ; + Fri, 30 Apr 2004 18:34:27 -0300 (ADT) +Received: from email05.aon.at (WARSL402PIP4.highway.telekom.at [195.3.96.79]) + by svr1.postgresql.org (Postfix) with SMTP id 2229CD1B4F7 + for ; + Fri, 30 Apr 2004 18:34:23 -0300 (ADT) +Received: (qmail 561446 invoked from network); 30 Apr 2004 21:34:22 -0000 +Received: from m161p030.dipool.highway.telekom.at (HELO PASCAL) + ([62.46.10.30]) (envelope-sender ) + by qmail5rs.highway.telekom.at (qmail-ldap-1.03) with SMTP + for ; 30 Apr 2004 21:34:22 -0000 +From: Manfred Koizar +To: Jochem van Dieten +Cc: pgsql-performance@postgresql.org +Subject: Re: planner/optimizer question +Date: Fri, 30 Apr 2004 23:36:58 +0200 +Message-ID: +References: + <409290F0.10509@oli.tudelft.nl> +In-Reply-To: <409290F0.10509@oli.tudelft.nl> +X-Mailer: Forte Agent 2.0/32.652 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200404/530 +X-Sequence-Number: 6830 + +On Fri, 30 Apr 2004 19:46:24 +0200, Jochem van Dieten + wrote: +>> While the storage overhead could be reduced to 1 bit (not a joke) +> +>You mean adding an isLossy bit and only where it is set the head +>tuple has to be checked for visibility, if it is not set the head +>tuple does not have to be checked? + +Yes, something like this. Actually I imagined it the other way round: a +visible-to-all flag similar to the existing dead-to-all flag (search for +LP_DELETE and ItemIdDeleted in nbtree.c). + +>> we'd +>> still have the I/O overhead of locating and updating index tuples for +>> every heap tuple deleted/updated. +> +>Would there be additional I/O for the additional bit in the index +>tuple (I am unable to find the layout of index tuple headers in +>the docs)? + +Yes, the visible-to-all flag would be set as a by-product of an index +scan, if the heap tuple is found to be visible to all active +transactions. This update is non-critical and, I think, not very +expensive. + +Deleting (and hence updating) a tuple is more critical, regarding both +consistency and performance. We'd have to locate all index entries +pointing to the heap tuple and set their visible-to-all flags to false. + +